Commit 5e5d89d8 authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40380
parent f90540a2
......@@ -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 @@ 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));
}
......@@ -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 \
......
......@@ -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 {
......
......@@ -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"
......@@ -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() {
......
......@@ -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" {
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment