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.
--- a/src/main/linux/SDL_Qtopia_main.cc Mon May 20 18:36:48 2002 +0000
+++ b/src/main/linux/SDL_Qtopia_main.cc Tue May 28 19:24:11 2002 +0000
@@ -6,7 +6,6 @@
#endif
#ifdef QWS
#include <qpe/qpeapplication.h>
-#include <qapplication.h>
#endif
extern int SDL_main(int argc, char *argv[]);
@@ -16,9 +15,9 @@
#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));
}
--- a/src/video/qtopia/Makefile.am Mon May 20 18:36:48 2002 +0000
+++ b/src/video/qtopia/Makefile.am Tue May 28 19:24:11 2002 +0000
@@ -8,8 +8,6 @@
QTOPIA_SRCS = \
SDL_QWin.h \
SDL_QWin.cc \
- SDL_QPEApp.h \
- SDL_QPEApp.cc \
SDL_lowvideo.h \
SDL_sysmouse.cc \
SDL_sysmouse_c.h \
--- 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 {
--- a/src/video/qtopia/SDL_QWin.h Mon May 20 18:36:48 2002 +0000
+++ b/src/video/qtopia/SDL_QWin.h Tue May 28 19:24:11 2002 +0000
@@ -36,7 +36,6 @@
#include <qdirectpainter_qws.h>
#include "SDL_events.h"
-//#include "SDL_BView.h"
extern "C" {
#include "SDL_events_c.h"
@@ -77,7 +76,7 @@
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() {
--- a/src/video/qtopia/SDL_sysvideo.cc Mon May 20 18:36:48 2002 +0000
+++ b/src/video/qtopia/SDL_sysvideo.cc Tue May 28 19:24:11 2002 +0000
@@ -34,12 +34,12 @@
#include <unistd.h>
#include <qapplication.h>
+#include <qpe/qpeapplication.h>
#include "SDL.h"
#include "SDL_timer.h"
#include "SDL_QWin.h"
-#include "SDL_QPEApp.h"
extern "C" {
@@ -213,10 +213,6 @@
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 @@
/* 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 @@
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 @@
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;
}