diff options
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 33 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 46 |
2 files changed, 17 insertions, 62 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 85af8ee1d2..e1ccc3f086 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2022,6 +2022,19 @@ void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, con QWindowSystemInterface::handleMouseEvent(window(), time, local, global, connection()->buttons(), modifiers); } +static bool ignoreLeaveEvent(const xcb_leave_notify_event_t *event) +{ + return event->detail == XCB_NOTIFY_DETAIL_VIRTUAL + || event->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL; +} + +static bool ignoreEnterEvent(const xcb_enter_notify_event_t *event) +{ + return ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB) + || event->detail == XCB_NOTIFY_DETAIL_VIRTUAL + || event->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL); +} + class EnterEventChecker { public: @@ -2033,13 +2046,8 @@ public: return false; xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)event; - - if ((enter->mode != XCB_NOTIFY_MODE_NORMAL && enter->mode != XCB_NOTIFY_MODE_UNGRAB) - || enter->detail == XCB_NOTIFY_DETAIL_VIRTUAL - || enter->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) - { + if (ignoreEnterEvent(enter)) return false; - } return true; } @@ -2052,12 +2060,9 @@ void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) connection()->handleEnterEvent(event); #endif - if ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB) - || event->detail == XCB_NOTIFY_DETAIL_VIRTUAL - || event->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) - { + if (ignoreEnterEvent(event)) return; - } + const int dpr = int(devicePixelRatio()); const QPoint local(event->event_x/dpr, event->event_y/dpr); const QPoint global(event->root_x/dpr, event->root_y/dpr); @@ -2068,12 +2073,8 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) { connection()->setTime(event->time); - if ((event->mode != XCB_NOTIFY_MODE_NORMAL && event->mode != XCB_NOTIFY_MODE_UNGRAB) - || event->detail == XCB_NOTIFY_DETAIL_VIRTUAL - || event->detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) - { + if (ignoreLeaveEvent(event)) return; - } EnterEventChecker checker; xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)connection()->checkEvent(checker); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 44d7671ca3..756b22073e 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -206,7 +206,6 @@ private slots: void enabledPropagation(); void ignoreKeyEventsWhenDisabled_QTBUG27417(); void properTabHandlingWhenDisabled_QTBUG27417(); - void popupEnterLeave(); #ifndef QT_NO_DRAGANDDROP void acceptDropsPropagation(); #endif @@ -5001,51 +5000,6 @@ bool verifyColor(QWidget &child, const QRegion ®ion, const QColor &color, uns return true; } -void tst_QWidget::popupEnterLeave() -{ - QWidget parent; - parent.setWindowFlags(Qt::FramelessWindowHint); - parent.setGeometry(10, 10, 200, 100); - - ColorWidget alien(&parent, Qt::Widget, Qt::black); - alien.setGeometry(0, 0, 10, 10); - alien.show(); - - parent.show(); - - QVERIFY(QTest::qWaitForWindowExposed(&parent)); - - QWindowSystemInterface::handleMouseEvent(parent.windowHandle(), QPointF(5, 5), QPointF(), Qt::LeftButton, Qt::NoModifier); - QTest::qWait(100); - QWindowSystemInterface::handleMouseEvent(parent.windowHandle(), QPointF(5, 5), QPointF(), Qt::NoButton, Qt::NoModifier); - QTest::qWait(100); - - QStringList wordList; - wordList << "alpha" << "omega" << "omicron" << "zeta"; - - QLineEdit popup(&parent); - - QCompleter completer(wordList); - completer.setCaseSensitivity(Qt::CaseInsensitive); - popup.setCompleter(&completer); - popup.setWindowFlags(Qt::Popup); - popup.setGeometry(20, 20, 80, 20); - - popup.show(); - - QVERIFY(QTest::qWaitForWindowExposed(&popup)); - - QTest::qWait(100); - - QWindowSystemInterface::handleMouseEvent(popup.windowHandle(), QPointF(-5, -5), QPointF(), Qt::LeftButton, Qt::NoModifier); - QTest::qWait(100); - QWindowSystemInterface::handleMouseEvent(popup.windowHandle(), QPointF(-5, -5), QPointF(), Qt::NoButton, Qt::NoModifier); - QTest::qWait(100); - - QTest::qWait(1000); - QVERIFY(!popup.underMouse()); -} - void tst_QWidget::moveChild_data() { QTest::addColumn<QPoint>("offset"); |