comparison src/video/qtopia/SDL_QWin.cc @ 379:11c8a7684f74

Date: Fri, 24 May 2002 10:32:00 -0700 From: David Hedbor <david@hedbor.org> Subject: more patches Ok, another thing I discovered when porting prboom to the Zaurus - mouse events weren't rotated when the screen was (i.e you got incorrect events there). This is now fixed. Also noticed that SDL_WarpMouse isn't handled correctly, but I haven't looked at fixing that yes.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 28 May 2002 19:24:11 +0000
parents db0cc6034336
children c96e2137f9eb
comparison
equal deleted inserted replaced
378:6089cd59e3ca 379:11c8a7684f74
78 void SDL_QWin::closeEvent(QCloseEvent *e) { 78 void SDL_QWin::closeEvent(QCloseEvent *e) {
79 SDL_PrivateQuit(); 79 SDL_PrivateQuit();
80 e->ignore(); 80 e->ignore();
81 } 81 }
82 82
83 void SDL_QWin::setMousePos(const QPoint &pos) {
84 if(my_image->width() == height()) {
85 my_mouse_pos = QPoint(height()-pos.y(), pos.x());
86 } else {
87 my_mouse_pos = pos;
88 }
89 }
90
83 void SDL_QWin::mouseMoveEvent(QMouseEvent *e) { 91 void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
84 Qt::ButtonState button = e->button(); 92 Qt::ButtonState button = e->button();
85 int sdlstate = 0; 93 int sdlstate = 0;
86 if( (button & Qt::LeftButton)) { 94 if( (button & Qt::LeftButton)) {
87 sdlstate |= SDL_BUTTON_LMASK; 95 sdlstate |= SDL_BUTTON_LMASK;
90 sdlstate |= SDL_BUTTON_RMASK; 98 sdlstate |= SDL_BUTTON_RMASK;
91 } 99 }
92 if( (button & Qt::MidButton)) { 100 if( (button & Qt::MidButton)) {
93 sdlstate |= SDL_BUTTON_MMASK; 101 sdlstate |= SDL_BUTTON_MMASK;
94 } 102 }
95 SDL_PrivateMouseMotion(sdlstate, 0, e->pos().x(), e->pos().y()); 103 setMousePos(e->pos());
104 SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y());
96 } 105 }
97 106
98 void SDL_QWin::mousePressEvent(QMouseEvent *e) { 107 void SDL_QWin::mousePressEvent(QMouseEvent *e) {
99 my_mouse_pos = e->pos(); 108 setMousePos(e->pos());
100 Qt::ButtonState button = e->button(); 109 Qt::ButtonState button = e->button();
101 SDL_PrivateMouseButton(SDL_PRESSED, 110 SDL_PrivateMouseButton(SDL_PRESSED,
102 (button & Qt::LeftButton) ? 1 : 111 (button & Qt::LeftButton) ? 1 :
103 ((button & Qt::RightButton) ? 2 : 3), 112 ((button & Qt::RightButton) ? 2 : 3),
104 e->x(), e->y()); 113 my_mouse_pos.x(), my_mouse_pos.y());
105 } 114 }
106 115
107 void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) { 116 void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
108 my_mouse_pos = QPoint(-1, -1); 117 setMousePos(e->pos());
109 Qt::ButtonState button = e->button(); 118 Qt::ButtonState button = e->button();
110 SDL_PrivateMouseButton(SDL_RELEASED, 119 SDL_PrivateMouseButton(SDL_RELEASED,
111 (button & Qt::LeftButton) ? 1 : 120 (button & Qt::LeftButton) ? 1 :
112 ((button & Qt::RightButton) ? 2 : 3), 121 ((button & Qt::RightButton) ? 2 : 3),
113 e->x(), e->y()); 122 my_mouse_pos.x(), my_mouse_pos.y());
123 my_mouse_pos = QPoint(-1, -1);
114 } 124 }
115 125
116 #define USE_DIRECTPAINTER 126 #define USE_DIRECTPAINTER
117 127
118 128
188 gs_fastRotateBlit_3(fb, buf, rect); 198 gs_fastRotateBlit_3(fb, buf, rect);
189 } else { 199 } else {
190 // landscape mode 200 // landscape mode
191 uchar *fb = (uchar*)my_painter->frameBuffer(); 201 uchar *fb = (uchar*)my_painter->frameBuffer();
192 uchar *buf = (uchar*)my_image->bits(); 202 uchar *buf = (uchar*)my_image->bits();
193 int h = rect.height(); 203 if(rect == my_image->rect()) {
194 int wd = rect.width()<<1; 204 memcpy(fb, buf, width()*height()*2);
195 int fblineadd = my_painter->lineStep(); 205 } else {
196 int buflineadd = my_image->bytesPerLine(); 206 int h = rect.height();
197 fb += (rect.left()<<1) + rect.top() * my_painter->lineStep(); 207 int wd = rect.width()<<1;
198 buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine(); 208 int fblineadd = my_painter->lineStep();
199 while(h--) { 209 int buflineadd = my_image->bytesPerLine();
200 memcpy(fb, buf, wd); 210 fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
201 fb += fblineadd; 211 buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
202 buf += buflineadd; 212 while(h--) {
213 memcpy(fb, buf, wd);
214 fb += fblineadd;
215 buf += buflineadd;
216 }
203 } 217 }
204 } 218 }
205 } else { 219 } else {
206 #endif 220 #endif
207 QPainter pp(this); 221 QPainter pp(this);