Date: Fri, 24 May 2002 10:32:00 -0700
authorSam Lantinga <slouken@libsdl.org>
Tue, 28 May 2002 19:24:11 +0000
changeset 37911c8a7684f74
parent 378 6089cd59e3ca
child 380 bce7171e7a85
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.
src/main/linux/SDL_Qtopia_main.cc
src/video/qtopia/Makefile.am
src/video/qtopia/SDL_QWin.cc
src/video/qtopia/SDL_QWin.h
src/video/qtopia/SDL_sysvideo.cc
     1.1 --- a/src/main/linux/SDL_Qtopia_main.cc	Mon May 20 18:36:48 2002 +0000
     1.2 +++ b/src/main/linux/SDL_Qtopia_main.cc	Tue May 28 19:24:11 2002 +0000
     1.3 @@ -6,7 +6,6 @@
     1.4  #endif
     1.5  #ifdef QWS
     1.6  #include <qpe/qpeapplication.h>
     1.7 -#include <qapplication.h>
     1.8  #endif
     1.9  
    1.10  extern int SDL_main(int argc, char *argv[]);
    1.11 @@ -16,9 +15,9 @@
    1.12  #ifdef QWS
    1.13    // This initializes the Qtopia application. It needs to be done here
    1.14    // because it parses command line options.
    1.15 -  QPEApplication *app = new QPEApplication(argc, argv);
    1.16 +  QPEApplication app(argc, argv);
    1.17    QWidget dummy;
    1.18 -  app->showMainWidget(&dummy);
    1.19 +  app.showMainWidget(&dummy);
    1.20  #endif
    1.21    return(SDL_main(argc, argv));
    1.22  }
     2.1 --- a/src/video/qtopia/Makefile.am	Mon May 20 18:36:48 2002 +0000
     2.2 +++ b/src/video/qtopia/Makefile.am	Tue May 28 19:24:11 2002 +0000
     2.3 @@ -8,8 +8,6 @@
     2.4  QTOPIA_SRCS = 			\
     2.5  	SDL_QWin.h		\
     2.6  	SDL_QWin.cc		\
     2.7 -	SDL_QPEApp.h		\
     2.8 -	SDL_QPEApp.cc		\
     2.9  	SDL_lowvideo.h		\
    2.10  	SDL_sysmouse.cc		\
    2.11  	SDL_sysmouse_c.h	\
     3.1 --- a/src/video/qtopia/SDL_QWin.cc	Mon May 20 18:36:48 2002 +0000
     3.2 +++ b/src/video/qtopia/SDL_QWin.cc	Tue May 28 19:24:11 2002 +0000
     3.3 @@ -80,6 +80,14 @@
     3.4    e->ignore();
     3.5  }
     3.6  
     3.7 +void SDL_QWin::setMousePos(const QPoint &pos) {
     3.8 +  if(my_image->width() == height()) {
     3.9 +    my_mouse_pos = QPoint(height()-pos.y(), pos.x());
    3.10 +  } else {
    3.11 +    my_mouse_pos = pos;
    3.12 +  }
    3.13 +}
    3.14 +
    3.15  void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
    3.16    Qt::ButtonState button = e->button();
    3.17    int sdlstate = 0;
    3.18 @@ -92,25 +100,27 @@
    3.19    if( (button & Qt::MidButton)) {
    3.20      sdlstate |= SDL_BUTTON_MMASK;
    3.21    }
    3.22 -  SDL_PrivateMouseMotion(sdlstate, 0, e->pos().x(), e->pos().y());
    3.23 +  setMousePos(e->pos());
    3.24 +  SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y());
    3.25  }
    3.26  
    3.27  void SDL_QWin::mousePressEvent(QMouseEvent *e) {
    3.28 -  my_mouse_pos = e->pos();
    3.29 +  setMousePos(e->pos());
    3.30    Qt::ButtonState button = e->button();
    3.31    SDL_PrivateMouseButton(SDL_PRESSED,
    3.32  			 (button & Qt::LeftButton) ? 1 :
    3.33  			 ((button & Qt::RightButton) ? 2 : 3),
    3.34 -			 e->x(), e->y());
    3.35 +			 my_mouse_pos.x(), my_mouse_pos.y());
    3.36  }
    3.37  
    3.38  void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
    3.39 -  my_mouse_pos = QPoint(-1, -1);
    3.40 +  setMousePos(e->pos());
    3.41    Qt::ButtonState button = e->button();
    3.42    SDL_PrivateMouseButton(SDL_RELEASED,
    3.43  			 (button & Qt::LeftButton) ? 1 :
    3.44  			 ((button & Qt::RightButton) ? 2 : 3),
    3.45 -			 e->x(), e->y());
    3.46 +			 my_mouse_pos.x(), my_mouse_pos.y());
    3.47 +  my_mouse_pos = QPoint(-1, -1);
    3.48  }
    3.49  
    3.50  #define USE_DIRECTPAINTER
    3.51 @@ -190,16 +200,20 @@
    3.52        // landscape mode
    3.53        uchar *fb = (uchar*)my_painter->frameBuffer();
    3.54        uchar *buf = (uchar*)my_image->bits();
    3.55 -      int h = rect.height();
    3.56 -      int wd = rect.width()<<1;
    3.57 -      int fblineadd = my_painter->lineStep();
    3.58 -      int buflineadd = my_image->bytesPerLine();
    3.59 -      fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
    3.60 -      buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
    3.61 -      while(h--) {
    3.62 -	memcpy(fb, buf, wd);
    3.63 -	fb += fblineadd;
    3.64 -	buf += buflineadd;
    3.65 +      if(rect == my_image->rect()) {
    3.66 +	memcpy(fb, buf, width()*height()*2);
    3.67 +      } else {
    3.68 +	int h = rect.height();
    3.69 +	int wd = rect.width()<<1;
    3.70 +	int fblineadd = my_painter->lineStep();
    3.71 +	int buflineadd = my_image->bytesPerLine();
    3.72 +	fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
    3.73 +	buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
    3.74 +	while(h--) {
    3.75 +	  memcpy(fb, buf, wd);
    3.76 +	  fb += fblineadd;
    3.77 +	  buf += buflineadd;
    3.78 +	}
    3.79        }
    3.80      }
    3.81    } else {
     4.1 --- a/src/video/qtopia/SDL_QWin.h	Mon May 20 18:36:48 2002 +0000
     4.2 +++ b/src/video/qtopia/SDL_QWin.h	Tue May 28 19:24:11 2002 +0000
     4.3 @@ -36,7 +36,6 @@
     4.4  #include <qdirectpainter_qws.h>
     4.5  
     4.6  #include "SDL_events.h"
     4.7 -//#include "SDL_BView.h"
     4.8  
     4.9  extern "C" {
    4.10  #include "SDL_events_c.h"
    4.11 @@ -77,7 +76,7 @@
    4.12      my_flags = flags;
    4.13    }
    4.14    const QPoint& mousePos() const { return my_mouse_pos; }
    4.15 -  void setMousePos(const QPoint& newpos) { my_mouse_pos = newpos; }
    4.16 +  void setMousePos(const QPoint& newpos);
    4.17    void setFullscreen(bool);
    4.18  
    4.19    void lockScreen() {
     5.1 --- a/src/video/qtopia/SDL_sysvideo.cc	Mon May 20 18:36:48 2002 +0000
     5.2 +++ b/src/video/qtopia/SDL_sysvideo.cc	Tue May 28 19:24:11 2002 +0000
     5.3 @@ -34,12 +34,12 @@
     5.4  #include <unistd.h>
     5.5  
     5.6  #include <qapplication.h>
     5.7 +#include <qpe/qpeapplication.h>
     5.8  
     5.9  #include "SDL.h"
    5.10  #include "SDL_timer.h"
    5.11  
    5.12  #include "SDL_QWin.h"
    5.13 -#include "SDL_QPEApp.h"
    5.14  
    5.15  extern "C" {
    5.16  
    5.17 @@ -213,10 +213,6 @@
    5.18    int QT_VideoInit(_THIS, SDL_PixelFormat *vformat)
    5.19    {
    5.20      /* Initialize the QPE Application  */
    5.21 -    if(SDL_InitQPEApp() == -1) {
    5.22 -      return -1;
    5.23 -    }
    5.24 -
    5.25       /* Determine the screen depth */
    5.26      vformat->BitsPerPixel = QPixmap::defaultDepth();
    5.27  
    5.28 @@ -231,7 +227,7 @@
    5.29  
    5.30      /* Create the window / widget */
    5.31      SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
    5.32 -    qApp->setMainWidget(SDL_Win);
    5.33 +    ((QPEApplication*)qApp)->showMainWidget(SDL_Win);
    5.34      /* Fill in some window manager capabilities */
    5.35      _this->info.wm_available = 0;
    5.36  
    5.37 @@ -274,7 +270,7 @@
    5.38    SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current,
    5.39  			       int width, int height, int bpp, Uint32 flags)
    5.40    {
    5.41 -    Qt::WFlags wflags = Qt::WType_TopLevel|Qt::WStyle_Customize;
    5.42 +
    5.43      QImage *qimage;
    5.44      QSize desktop_size = qApp->desktop()->size();
    5.45  
    5.46 @@ -367,9 +363,13 @@
    5.47  
    5.48    void QT_VideoQuit(_THIS)
    5.49    {
    5.50 -    qApp->setMainWidget(0);
    5.51 -    delete SDL_Win;
    5.52 -    SDL_QuitQPEApp();
    5.53 +    // This is dumb, but if I free this, the app doesn't exit correctly.
    5.54 +    // Of course, this will leak memory if init video is done more than once.
    5.55 +    // Sucks but such is life.
    5.56 +    
    5.57 +    //    -- David Hedbor
    5.58 +    //    delete SDL_Win; 
    5.59 +    //    SDL_Win = 0;
    5.60      _this->screen->pixels = NULL;
    5.61    }
    5.62