Skip to content

Commit

Permalink
Date: Fri, 24 May 2002 10:32:00 -0700
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed May 28, 2002
1 parent f87faef commit 207f204
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 32 deletions.
5 changes: 2 additions & 3 deletions src/main/linux/SDL_Qtopia_main.cc
Expand Up @@ -6,7 +6,6 @@
#endif
#ifdef QWS
#include <qpe/qpeapplication.h>
#include <qapplication.h>
#endif

extern int SDL_main(int argc, char *argv[]);
Expand All @@ -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));
}
2 changes: 0 additions & 2 deletions src/video/qtopia/Makefile.am
Expand Up @@ -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 \
Expand Down
44 changes: 29 additions & 15 deletions src/video/qtopia/SDL_QWin.cc
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/video/qtopia/SDL_QWin.h
Expand Up @@ -36,7 +36,6 @@ static char rcsid =
#include <qdirectpainter_qws.h>

#include "SDL_events.h"
//#include "SDL_BView.h"

extern "C" {
#include "SDL_events_c.h"
Expand Down Expand Up @@ -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() {
Expand Down
20 changes: 10 additions & 10 deletions src/video/qtopia/SDL_sysvideo.cc
Expand Up @@ -34,12 +34,12 @@ static char rcsid =
#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" {

Expand Down Expand Up @@ -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();

Expand All @@ -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;

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 207f204

Please sign in to comment.