summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJeremy Katz <jeremy.katz@nokia.com>2010-02-01 12:42:56 (GMT)
committerJeremy Katz <jeremy.katz@nokia.com>2010-02-01 12:42:56 (GMT)
commitf4588871d38d244c83e50354da66d145ae40be8f (patch)
tree0cc6c21c87edfe35ebb50cc0dc9a115aa7782656 /src/gui/kernel
parent6fe259f696b5cc302bda6befcefe0a94e2676325 (diff)
downloadQt-f4588871d38d244c83e50354da66d145ae40be8f.zip
Qt-f4588871d38d244c83e50354da66d145ae40be8f.tar.gz
Qt-f4588871d38d244c83e50354da66d145ae40be8f.tar.bz2
Change mouse, key, and wheel events to use a window id instead of a pointer to a QWidget
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication_lite.cpp29
-rw-r--r--src/gui/kernel/qapplication_p.h32
2 files changed, 36 insertions, 25 deletions
diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp
index 8bbc756..39cc29f 100644
--- a/src/gui/kernel/qapplication_lite.cpp
+++ b/src/gui/kernel/qapplication_lite.cpp
@@ -561,14 +561,20 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e)
// move first
Qt::MouseButtons stateChange = e->buttons ^ buttons;
if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
- MouseEvent * newMouseEvent = new MouseEvent(e->tlw, e->timestamp, e->localPos, e->globalPos, e->buttons);
+ MouseEvent * newMouseEvent = new MouseEvent(e->id, e->timestamp, e->localPos, e->globalPos, e->buttons);
userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
stateChange = Qt::NoButton;
}
+ QWidget * tlw;
+ if (e->id)
+ tlw = QWidget::find(e->id);
+ else
+ tlw = 0;
+
QPoint localPoint = e->localPos;
QPoint globalPoint = e->globalPos;
- QWidget *mouseWindow = e->tlw;
+ QWidget *mouseWindow = tlw;
Qt::MouseButton button = Qt::NoButton;
@@ -619,11 +625,11 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e)
implicit_mouse_grabber.clear();
//### how should popup mode and implicit mouse grab interact?
- } else if (e->tlw && app_do_modal && !qt_try_modal(e->tlw, e->type) ) {
+ } else if (tlw && app_do_modal && !qt_try_modal(tlw, e->type) ) {
//even if we're blocked by modality, we should deliver the mouse release event..
//### this code is not completely correct: multiple buttons can be pressed simultaneously
if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) {
- qDebug() << "modal blocked mouse event to" << e->tlw;
+ qDebug() << "modal blocked mouse event to" << tlw;
return;
}
}
@@ -636,7 +642,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e)
if (!mouseWindow && !implicit_mouse_grabber)
mouseWindow = QApplication::desktop();
- if (mouseWindow && mouseWindow != e->tlw) {
+ if (mouseWindow && mouseWindow != tlw) {
//we did not get a sensible localPoint from the window system, so let's calculate it
localPoint = mouseWindow->mapFromGlobal(globalPoint);
}
@@ -659,7 +665,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e)
} else if (implicit_mouse_grabber) {
mouseWidget = implicit_mouse_grabber.data();
mouseWindow = mouseWidget->window();
- if (mouseWindow != e->tlw)
+ if (mouseWindow != tlw)
localPoint = mouseWindow->mapFromGlobal(globalPoint);
}
@@ -705,7 +711,11 @@ void QApplicationPrivate::processWheelEvent(WheelEvent *e)
qt_last_x = globalPoint.x();
qt_last_y = globalPoint.y();
- QWidget *mouseWindow = e->tlw;
+ QWidget *mouseWindow;
+ if (e->id)
+ mouseWindow = QWidget::find(e->id);
+ else
+ mouseWindow = 0;
// find the tlw if we didn't get it from the plugin
if (!mouseWindow) {
@@ -746,8 +756,9 @@ void QApplicationPrivate::processKeyEvent(KeyEvent *e)
}
if (!focusW)
focusW = QApplication::focusWidget();
- if (!focusW)
- focusW = e->tlw;
+ if (!focusW && e->id) {
+ focusW = QWidget::find(e->id);
+ }
if (!focusW)
focusW = QApplication::activeWindow();
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 75bc5bd..d07b83b 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -570,16 +570,16 @@ public:
class UserEvent {
public:
- UserEvent(QWidget *w, QEvent::Type t, ulong time) { tlw = w; type = t; timestamp = time; }
- QWidget * tlw;
+ UserEvent(WId w, ulong time, QEvent::Type t) { id = w; type = t; timestamp = time; }
+ WId id;
QEvent::Type type;
unsigned long timestamp;
};
class MouseEvent : public UserEvent {
public:
- MouseEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
- : UserEvent(w, QEvent::MouseMove, time){ localPos = local; globalPos = global; buttons = b; }
+ MouseEvent(WId w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+ : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; }
QPoint localPos;
QPoint globalPos;
Qt::MouseButtons buttons;
@@ -587,8 +587,8 @@ public:
class WheelEvent : public UserEvent {
public:
- WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
- : UserEvent(w, QEvent::Wheel, time) { localPos = local; globalPos = global; delta = d; orient = o; }
+ WheelEvent(WId w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+ : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; }
int delta;
QPoint localPos;
QPoint globalPos;
@@ -597,8 +597,8 @@ public:
class KeyEvent : public UserEvent {
public:
- KeyEvent(QWidget *w, QEvent::Type t, ulong time, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
- :UserEvent(w, t, time){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; }
+ KeyEvent(WId w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; }
int key;
QString unicode;
bool repeat;
@@ -606,29 +606,29 @@ public:
Qt::KeyboardModifiers modifiers;
};
- static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
+ static void handleMouseEvent(WId w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
handleMouseEvent(w, time.elapsed(), local, global, b);
}
- static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
+ static void handleMouseEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
MouseEvent * e = new MouseEvent(w, timestamp, local, global, b);
queueUserEvent(e);
}
- static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
- handleKeyEvent(w, t, time.elapsed(), k, mods, text, autorep, count);
+ static void handleKeyEvent(WId w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
+ handleKeyEvent(w, time.elapsed(), t, k, mods, text, autorep, count);
}
- static void handleKeyEvent(QWidget *w, QEvent::Type t, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
- KeyEvent * e = new KeyEvent(w, t, timestamp, k, mods, text, autorep, count);
+ static void handleKeyEvent(WId w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) {
+ KeyEvent * e = new KeyEvent(w, timestamp, t, k, mods, text, autorep, count);
queueUserEvent(e);
}
- static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
+ static void handleWheelEvent(WId w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
handleWheelEvent(w, time.elapsed(), local, global, d, o);
}
- static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
+ static void handleWheelEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
WheelEvent *e = new WheelEvent(w, timestamp, local, global, d, o);
queueUserEvent(e);
}