diff 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
line wrap: on
line diff
--- a/src/video/qtopia/SDL_QWin.cc	Mon May 20 18:36:48 2002 +0000
+++ b/src/video/qtopia/SDL_QWin.cc	Tue May 28 19:24:11 2002 +0000
@@ -80,6 +80,14 @@
   e->ignore();
 }
 
+void SDL_QWin::setMousePos(const QPoint &pos) {
+  if(my_image->width() == height()) {
+    my_mouse_pos = QPoint(height()-pos.y(), pos.x());
+  } else {
+    my_mouse_pos = pos;
+  }
+}
+
 void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
   Qt::ButtonState button = e->button();
   int sdlstate = 0;
@@ -92,25 +100,27 @@
   if( (button & Qt::MidButton)) {
     sdlstate |= SDL_BUTTON_MMASK;
   }
-  SDL_PrivateMouseMotion(sdlstate, 0, e->pos().x(), e->pos().y());
+  setMousePos(e->pos());
+  SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y());
 }
 
 void SDL_QWin::mousePressEvent(QMouseEvent *e) {
-  my_mouse_pos = e->pos();
+  setMousePos(e->pos());
   Qt::ButtonState button = e->button();
   SDL_PrivateMouseButton(SDL_PRESSED,
 			 (button & Qt::LeftButton) ? 1 :
 			 ((button & Qt::RightButton) ? 2 : 3),
-			 e->x(), e->y());
+			 my_mouse_pos.x(), my_mouse_pos.y());
 }
 
 void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
-  my_mouse_pos = QPoint(-1, -1);
+  setMousePos(e->pos());
   Qt::ButtonState button = e->button();
   SDL_PrivateMouseButton(SDL_RELEASED,
 			 (button & Qt::LeftButton) ? 1 :
 			 ((button & Qt::RightButton) ? 2 : 3),
-			 e->x(), e->y());
+			 my_mouse_pos.x(), my_mouse_pos.y());
+  my_mouse_pos = QPoint(-1, -1);
 }
 
 #define USE_DIRECTPAINTER
@@ -190,16 +200,20 @@
       // landscape mode
       uchar *fb = (uchar*)my_painter->frameBuffer();
       uchar *buf = (uchar*)my_image->bits();
-      int h = rect.height();
-      int wd = rect.width()<<1;
-      int fblineadd = my_painter->lineStep();
-      int buflineadd = my_image->bytesPerLine();
-      fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
-      buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
-      while(h--) {
-	memcpy(fb, buf, wd);
-	fb += fblineadd;
-	buf += buflineadd;
+      if(rect == my_image->rect()) {
+	memcpy(fb, buf, width()*height()*2);
+      } else {
+	int h = rect.height();
+	int wd = rect.width()<<1;
+	int fblineadd = my_painter->lineStep();
+	int buflineadd = my_image->bytesPerLine();
+	fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
+	buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
+	while(h--) {
+	  memcpy(fb, buf, wd);
+	  fb += fblineadd;
+	  buf += buflineadd;
+	}
       }
     }
   } else {