From 207f204e798a19702d28c945aeb447d59e49bbc3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 28 May 2002 19:24:11 +0000 Subject: [PATCH] Date: Fri, 24 May 2002 10:32:00 -0700 From: David Hedbor 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 | 5 ++-- src/video/qtopia/Makefile.am | 2 -- src/video/qtopia/SDL_QWin.cc | 44 ++++++++++++++++++++----------- src/video/qtopia/SDL_QWin.h | 3 +-- src/video/qtopia/SDL_sysvideo.cc | 20 +++++++------- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/main/linux/SDL_Qtopia_main.cc b/src/main/linux/SDL_Qtopia_main.cc index 6dfdbb743..16cd40aea 100644 --- a/src/main/linux/SDL_Qtopia_main.cc +++ b/src/main/linux/SDL_Qtopia_main.cc @@ -6,7 +6,6 @@ #endif #ifdef QWS #include -#include #endif extern int SDL_main(int argc, char *argv[]); @@ -16,9 +15,9 @@ int main(int argc, char *argv[]) #ifdef QWS // This initializes the Qtopia application. It needs to be done here // because it parses command line options. - QPEApplication *app = new QPEApplication(argc, argv); + QPEApplication app(argc, argv); QWidget dummy; - app->showMainWidget(&dummy); + app.showMainWidget(&dummy); #endif return(SDL_main(argc, argv)); } diff --git a/src/video/qtopia/Makefile.am b/src/video/qtopia/Makefile.am index f1cb8ca16..09b0fb338 100644 --- a/src/video/qtopia/Makefile.am +++ b/src/video/qtopia/Makefile.am @@ -8,8 +8,6 @@ libvideo_qtopia_la_SOURCES = $(QTOPIA_SRCS) QTOPIA_SRCS = \ SDL_QWin.h \ SDL_QWin.cc \ - SDL_QPEApp.h \ - SDL_QPEApp.cc \ SDL_lowvideo.h \ SDL_sysmouse.cc \ SDL_sysmouse_c.h \ diff --git a/src/video/qtopia/SDL_QWin.cc b/src/video/qtopia/SDL_QWin.cc index 5b343f97a..adf3b5cdb 100644 --- a/src/video/qtopia/SDL_QWin.cc +++ b/src/video/qtopia/SDL_QWin.cc @@ -80,6 +80,14 @@ void SDL_QWin::closeEvent(QCloseEvent *e) { 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 @@ void SDL_QWin::mouseMoveEvent(QMouseEvent *e) { 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 @@ void SDL_QWin::repaintRect(const QRect& rect) { // 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 { diff --git a/src/video/qtopia/SDL_QWin.h b/src/video/qtopia/SDL_QWin.h index 2d0058889..97c49389f 100644 --- a/src/video/qtopia/SDL_QWin.h +++ b/src/video/qtopia/SDL_QWin.h @@ -36,7 +36,6 @@ static char rcsid = #include #include "SDL_events.h" -//#include "SDL_BView.h" extern "C" { #include "SDL_events_c.h" @@ -77,7 +76,7 @@ class SDL_QWin : public QWidget my_flags = flags; } const QPoint& mousePos() const { return my_mouse_pos; } - void setMousePos(const QPoint& newpos) { my_mouse_pos = newpos; } + void setMousePos(const QPoint& newpos); void setFullscreen(bool); void lockScreen() { diff --git a/src/video/qtopia/SDL_sysvideo.cc b/src/video/qtopia/SDL_sysvideo.cc index 837952ca2..1d0ad6416 100644 --- a/src/video/qtopia/SDL_sysvideo.cc +++ b/src/video/qtopia/SDL_sysvideo.cc @@ -34,12 +34,12 @@ static char rcsid = #include #include +#include #include "SDL.h" #include "SDL_timer.h" #include "SDL_QWin.h" -#include "SDL_QPEApp.h" extern "C" { @@ -213,10 +213,6 @@ extern "C" { int QT_VideoInit(_THIS, SDL_PixelFormat *vformat) { /* Initialize the QPE Application */ - if(SDL_InitQPEApp() == -1) { - return -1; - } - /* Determine the screen depth */ vformat->BitsPerPixel = QPixmap::defaultDepth(); @@ -231,7 +227,7 @@ extern "C" { /* Create the window / widget */ SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); - qApp->setMainWidget(SDL_Win); + ((QPEApplication*)qApp)->showMainWidget(SDL_Win); /* Fill in some window manager capabilities */ _this->info.wm_available = 0; @@ -274,7 +270,7 @@ extern "C" { SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { - Qt::WFlags wflags = Qt::WType_TopLevel|Qt::WStyle_Customize; + QImage *qimage; QSize desktop_size = qApp->desktop()->size(); @@ -367,9 +363,13 @@ extern "C" { void QT_VideoQuit(_THIS) { - qApp->setMainWidget(0); - delete SDL_Win; - SDL_QuitQPEApp(); + // This is dumb, but if I free this, the app doesn't exit correctly. + // Of course, this will leak memory if init video is done more than once. + // Sucks but such is life. + + // -- David Hedbor + // delete SDL_Win; + // SDL_Win = 0; _this->screen->pixels = NULL; }