diff options
-rw-r--r-- | src/gui/kernel/qapplication_lite.cpp | 29 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 32 | ||||
-rw-r--r-- | src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 18 | ||||
-rw-r--r-- | src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp | 8 |
4 files changed, 51 insertions, 36 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); } diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 8e288ba..6229b46 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -137,13 +137,14 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) IDirectFBWindow *window; layer->GetWindow(layer,event.window.window_id,&window); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; + if (event.window.type == DWET_BUTTONDOWN) { static long prevTime = 0; static QWidget *prevWindow; static int prevX = -999; static int prevY = -999; - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - timestamp /= 1000; if (tlw == prevWindow && timestamp - prevTime < QApplication::doubleClickInterval() && qAbs(event.window.cx - prevX) < 5 && qAbs(event.window.cy - prevY) < 5) { @@ -161,7 +162,7 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) window->UngrabPointer(window); } - QApplicationPrivate::handleMouseEvent(tlw, p, globalPos, buttons); + QApplicationPrivate::handleMouseEvent(event.window.window_id, timestamp, p, globalPos, buttons); } void QDirectFbInput::applicationEnd() @@ -174,9 +175,10 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event) { QPoint p(event.window.cx, event.window.cy); QPoint globalPos = globalPoint(event); - QWidget *tlw = tlwMap.value(event.window.window_id); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; - QApplicationPrivate::handleWheelEvent(tlw, p, globalPos, + QApplicationPrivate::handleWheelEvent(event.window.window_id, timestamp, p, globalPos, event.window.step*120, Qt::Vertical); } @@ -187,8 +189,10 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - QWidget *tlw = tlwMap.value(event.window.window_id); - QApplicationPrivate::handleKeyEvent(tlw, type, key, modifiers, QChar(event.window.key_symbol)); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; + + QApplicationPrivate::handleKeyEvent(event.window.window_id, timestamp, type, key, modifiers, QChar(event.window.key_symbol)); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 65407fd..0d277b8 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -243,7 +243,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) bool hor = (((e->button == Button4 || e->button == Button5) && (modifiers & Qt::AltModifier)) || (e->button == 6 || e->button == 7)); - QApplicationPrivate::handleWheelEvent(window(), + QApplicationPrivate::handleWheelEvent(winId(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, hor ? Qt::Horizontal : Qt::Vertical); @@ -256,7 +256,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) buttons ^= button; // X event uses state *before*, Qt uses state *after* - QApplicationPrivate::handleMouseEvent(window(), QPoint(e->x, e->y), + QApplicationPrivate::handleMouseEvent(winId(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), buttons); @@ -590,12 +590,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) modifiers ^= modifierFromKeyCode(qtcode); if (qtcode) { - QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers); + QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers, QString::fromLatin1(chars)); + QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } |