Add a QEnterEvent containing the mouse position.
Enter handling requires knowledge of the mouse position. Extend the enter handling of QWindowSystemInterface to receive the position (implemented for Windows, XCB and Mac), passing it on to QEnterEvent. Dispatch QEnterEvent from widgets code. Change-Id: I49c07d2b1f46310c877017dd55d4cd7d636bdbce Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
parent
1fe0c2c25d
commit
2d07d3b4e3
@ -121,7 +121,7 @@ QT_BEGIN_NAMESPACE
|
||||
\value Drop A drag and drop operation is completed (QDropEvent).
|
||||
\value DynamicPropertyChange A dynamic property was added, changed, or removed from the object.
|
||||
\value EnabledChange Widget's enabled state has changed.
|
||||
\value Enter Mouse enters widget's boundaries.
|
||||
\value Enter Mouse enters widget's boundaries (QEnterEvent).
|
||||
\value EnterEditFocus An editor widget gains focus for editing. QT_KEYPAD_NAVIGATION must be defined.
|
||||
\value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode.
|
||||
\value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store.
|
||||
|
@ -55,6 +55,40 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QEnterEvent
|
||||
\ingroup events
|
||||
|
||||
\brief The QEnterEvent class contains parameters that describe an enter event.
|
||||
|
||||
Enter events occur when the mouse cursor enters a window or a widget.
|
||||
|
||||
\since 5.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an enter event object.
|
||||
|
||||
The points \a localPos, \a windowPos and \a screenPos specify the
|
||||
mouse cursor's position relative to the receiving widget or item,
|
||||
window, and screen, respectively.
|
||||
*/
|
||||
|
||||
QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos)
|
||||
: QEvent(QEvent::Enter)
|
||||
, l(localPos)
|
||||
, w(windowPos)
|
||||
, s(screenPos)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QEnterEvent::~QEnterEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QInputEvent
|
||||
\ingroup events
|
||||
|
@ -83,6 +83,28 @@ protected:
|
||||
ulong ts;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QEnterEvent : public QEvent
|
||||
{
|
||||
public:
|
||||
QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos);
|
||||
~QEnterEvent();
|
||||
|
||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||
inline QPoint pos() const { return l.toPoint(); }
|
||||
inline QPoint globalPos() const { return s.toPoint(); }
|
||||
inline int x() const { return qRound(l.x()); }
|
||||
inline int y() const { return qRound(l.y()); }
|
||||
inline int globalX() const { return qRound(s.x()); }
|
||||
inline int globalY() const { return qRound(s.y()); }
|
||||
#endif
|
||||
const QPointF &localPos() const { return l; }
|
||||
const QPointF &windowPos() const { return w; }
|
||||
const QPointF &screenPos() const { return s; }
|
||||
|
||||
protected:
|
||||
QPointF l, w, s;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QMouseEvent : public QInputEvent
|
||||
{
|
||||
public:
|
||||
|
@ -1424,7 +1424,7 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En
|
||||
|
||||
currentMouseWindow = e->enter;
|
||||
|
||||
QEvent event(QEvent::Enter);
|
||||
QEnterEvent event(e->localPos, e->localPos, e->globalPos);
|
||||
QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
|
||||
}
|
||||
|
||||
|
@ -75,10 +75,10 @@ extern QPointer<QWindow> qt_last_mouse_receiver;
|
||||
until sendWindowSystemEvents() is called by the event dispatcher.
|
||||
*/
|
||||
|
||||
void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
|
||||
void QWindowSystemInterface::handleEnterEvent(QWindow *tlw, const QPointF &local, const QPointF &global)
|
||||
{
|
||||
if (tlw) {
|
||||
QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
|
||||
QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw, local, global);
|
||||
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
|
||||
}
|
||||
}
|
||||
@ -96,13 +96,13 @@ void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
|
||||
determine where mouse went and act accordingly. E.g. QWidgetWindow needs to know if mouse
|
||||
cursor moves between windows in same window hierarchy.
|
||||
*/
|
||||
void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave)
|
||||
void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local, const QPointF& global)
|
||||
{
|
||||
bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents;
|
||||
if (wasSynchronous)
|
||||
setSynchronousWindowsSystemEvents(false);
|
||||
handleLeaveEvent(leave);
|
||||
handleEnterEvent(enter);
|
||||
handleEnterEvent(enter, local, global);
|
||||
if (wasSynchronous) {
|
||||
flushWindowSystemEvents();
|
||||
setSynchronousWindowsSystemEvents(true);
|
||||
|
@ -134,9 +134,9 @@ public:
|
||||
|
||||
static void handleGeometryChange(QWindow *w, const QRect &newRect);
|
||||
static void handleCloseEvent(QWindow *w);
|
||||
static void handleEnterEvent(QWindow *w);
|
||||
static void handleEnterEvent(QWindow *w, const QPointF &local = QPointF(), const QPointF& global = QPointF());
|
||||
static void handleLeaveEvent(QWindow *w);
|
||||
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave);
|
||||
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
|
||||
static void handleWindowActivated(QWindow *w);
|
||||
static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
|
||||
|
||||
|
@ -119,10 +119,12 @@ public:
|
||||
|
||||
class EnterEvent : public WindowSystemEvent {
|
||||
public:
|
||||
explicit EnterEvent(QWindow *enter)
|
||||
: WindowSystemEvent(Enter), enter(enter)
|
||||
explicit EnterEvent(QWindow *enter, const QPointF &local, const QPointF &global)
|
||||
: WindowSystemEvent(Enter), enter(enter), localPos(local), globalPos(global)
|
||||
{ }
|
||||
QPointer<QWindow> enter;
|
||||
const QPointF localPos;
|
||||
const QPointF globalPos;
|
||||
};
|
||||
|
||||
class LeaveEvent : public WindowSystemEvent {
|
||||
|
@ -340,7 +340,7 @@ static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)handleMouseEvent:(NSEvent *)theEvent
|
||||
- (void)convertFromEvent:(NSEvent *)event toWindowPoint:(QPoint *)qtWindowPoint andScreenPoint:(QPoint *)qtScreenPoint
|
||||
{
|
||||
// Calculate the mouse position in the QWindow and Qt screen coordinate system,
|
||||
// starting from coordinates in the NSWindow coordinate system.
|
||||
@ -360,25 +360,29 @@ static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy
|
||||
// NSView and QWindow are equal coordinate systems: the QWindow covers the
|
||||
// entire NSView, and we've set the NSView's isFlipped property to true.
|
||||
|
||||
NSPoint nsWindowPoint = [theEvent locationInWindow]; // NSWindow coordinates
|
||||
NSPoint nsWindowPoint = [event locationInWindow]; // NSWindow coordinates
|
||||
|
||||
NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates
|
||||
QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
|
||||
|
||||
QPoint qtScreenPoint;
|
||||
*qtWindowPoint = QPoint(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
|
||||
|
||||
NSWindow *window = [self window];
|
||||
// Use convertRectToScreen if available (added in 10.7).
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if ([window respondsToSelector:@selector(convertRectToScreen:)]) {
|
||||
NSRect screenRect = [window convertRectToScreen : NSMakeRect(nsWindowPoint.x, nsWindowPoint.y, 0, 0)]; // OS X screen coordinates
|
||||
qtScreenPoint = QPoint(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates
|
||||
*qtScreenPoint = QPoint(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
NSPoint screenPoint = [window convertBaseToScreen : NSMakePoint(nsWindowPoint.x, nsWindowPoint.y)];
|
||||
qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
|
||||
*qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleMouseEvent:(NSEvent *)theEvent
|
||||
{
|
||||
QPoint qtWindowPoint, qtScreenPoint;
|
||||
[self convertFromEvent:theEvent toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
|
||||
ulong timestamp = [theEvent timestamp] * 1000;
|
||||
|
||||
QCocoaDrag* nativeDrag = static_cast<QCocoaDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
|
||||
@ -463,8 +467,9 @@ static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)theEvent
|
||||
{
|
||||
Q_UNUSED(theEvent);
|
||||
QWindowSystemInterface::handleEnterEvent(m_window);
|
||||
QPoint windowPoint, screenPoint;
|
||||
[self convertFromEvent:theEvent toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
|
||||
QWindowSystemInterface::handleEnterEvent(m_window, windowPoint, screenPoint);
|
||||
}
|
||||
|
||||
- (void)mouseExited:(NSEvent *)theEvent
|
||||
|
@ -291,7 +291,9 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
|
||||
if (QWindowsContext::verboseEvents)
|
||||
qDebug() << "Entering " << currentWindowUnderMouse;
|
||||
QWindowsWindow::baseWindowOf(currentWindowUnderMouse)->applyCursor();
|
||||
QWindowSystemInterface::handleEnterEvent(currentWindowUnderMouse);
|
||||
QWindowSystemInterface::handleEnterEvent(currentWindowUnderMouse,
|
||||
currentWindowUnderMouse->mapFromGlobal(globalPosition),
|
||||
globalPosition);
|
||||
}
|
||||
}
|
||||
m_windowUnderMouse = currentWindowUnderMouse;
|
||||
|
@ -1529,7 +1529,9 @@ void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event)
|
||||
return;
|
||||
}
|
||||
|
||||
QWindowSystemInterface::handleEnterEvent(window());
|
||||
const QPoint local(event->event_x, event->event_y);
|
||||
const QPoint global(event->root_x, event->root_y);
|
||||
QWindowSystemInterface::handleEnterEvent(window(), local, global);
|
||||
}
|
||||
|
||||
void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
|
||||
|
@ -267,7 +267,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
|
||||
}
|
||||
|
||||
if (!lastWidgetUnderMouse) {
|
||||
QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0);
|
||||
QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
|
||||
lastWidgetUnderMouse = receiver;
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
|
||||
else // released on the frame our outside the item, or doesn't accept hover events.
|
||||
lastWidgetUnderMouse = 0;
|
||||
|
||||
QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber);
|
||||
QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
|
||||
embeddedMouseGrabber = 0;
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
@ -1142,7 +1142,7 @@ void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
Q_D(QGraphicsProxyWidget);
|
||||
// If hoverMove was compressed away, make sure we update properly here.
|
||||
if (d->lastWidgetUnderMouse) {
|
||||
QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
|
||||
QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
|
||||
d->lastWidgetUnderMouse = 0;
|
||||
}
|
||||
}
|
||||
@ -1159,7 +1159,7 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
// Ignore events on the window frame.
|
||||
if (!d->widget || !rect().contains(event->pos())) {
|
||||
if (d->lastWidgetUnderMouse) {
|
||||
QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
|
||||
QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
|
||||
d->lastWidgetUnderMouse = 0;
|
||||
}
|
||||
return;
|
||||
|
@ -2114,20 +2114,23 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
|
||||
\fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
|
||||
\internal
|
||||
|
||||
Creates the proper Enter/Leave event when widget \a enter is entered and
|
||||
widget \a leave is left.
|
||||
*/
|
||||
void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
|
||||
void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
|
||||
{
|
||||
const QPoint globalPos = globalPosF.toPoint();
|
||||
#if 0
|
||||
if (leave) {
|
||||
QEvent e(QEvent::Leave);
|
||||
QApplication::sendEvent(leave, & e);
|
||||
}
|
||||
if (enter) {
|
||||
QEvent e(QEvent::Enter);
|
||||
const QPoint windowPos = enter->window()->mapFromGlobal(globalPos);
|
||||
QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos);
|
||||
QApplication::sendEvent(enter, & e);
|
||||
}
|
||||
return;
|
||||
@ -2205,17 +2208,20 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
|
||||
}
|
||||
}
|
||||
}
|
||||
QPoint posEnter = QCursor::pos();
|
||||
QEvent enterEvent(QEvent::Enter);
|
||||
for (int i = 0; i < enterList.size(); ++i) {
|
||||
w = enterList.at(i);
|
||||
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
|
||||
QApplication::sendEvent(w, &enterEvent);
|
||||
if (w->testAttribute(Qt::WA_Hover) &&
|
||||
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
|
||||
QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1),
|
||||
QApplication::keyboardModifiers());
|
||||
qApp->d_func()->notify_helper(w, &he);
|
||||
if (!enterList.isEmpty()) {
|
||||
const QPoint windowPos = enterList.front()->window()->mapFromGlobal(globalPos);
|
||||
for (int i = 0; i < enterList.size(); ++i) {
|
||||
w = enterList.at(i);
|
||||
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
|
||||
const QPointF localPos = w->mapFromGlobal(globalPos);
|
||||
QEnterEvent enterEvent(localPos, windowPos, globalPosF);
|
||||
QApplication::sendEvent(w, &enterEvent);
|
||||
if (w->testAttribute(Qt::WA_Hover) &&
|
||||
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
|
||||
QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1),
|
||||
QApplication::keyboardModifiers());
|
||||
qApp->d_func()->notify_helper(w, &he);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2506,9 +2512,9 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
|
||||
|| (isAlien(lastMouseReceiver) && !alienWidget)) {
|
||||
if (activePopupWidget) {
|
||||
if (!QWidget::mouseGrabber())
|
||||
dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver);
|
||||
dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->screenPos());
|
||||
} else {
|
||||
dispatchEnterLeave(receiver, lastMouseReceiver);
|
||||
dispatchEnterLeave(receiver, lastMouseReceiver, event->screenPos());
|
||||
}
|
||||
|
||||
}
|
||||
@ -2540,7 +2546,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
|
||||
enter = alienGuard ? alienWidget : nativeWidget;
|
||||
else // The receiver is typically deleted on mouse release with drag'n'drop.
|
||||
enter = QApplication::widgetAt(event->globalPos());
|
||||
dispatchEnterLeave(enter, leaveAfterRelease);
|
||||
dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos());
|
||||
leaveAfterRelease = 0;
|
||||
lastMouseReceiver = enter;
|
||||
} else if (!wasLeaveAfterRelease) {
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
|
||||
|
||||
void createEventDispatcher();
|
||||
static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
|
||||
static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF);
|
||||
|
||||
//modality
|
||||
bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const Q_DECL_OVERRIDE;
|
||||
|
@ -253,7 +253,8 @@ void QApplicationPrivate::openPopup(QWidget *popup)
|
||||
|
||||
// Dispatch leave for last mouse receiver to update undermouse states
|
||||
if (qt_last_mouse_receiver && !QWidget::mouseGrabber()) {
|
||||
QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver.data());
|
||||
QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver.data(),
|
||||
QGuiApplicationPrivate::lastCursorPosition);
|
||||
qt_last_mouse_receiver = 0;
|
||||
}
|
||||
}
|
||||
|
@ -8563,6 +8563,8 @@ void QWidget::enterEvent(QEvent *)
|
||||
{
|
||||
}
|
||||
|
||||
// ### Qt 6: void QWidget::enterEvent(QEnterEvent *).
|
||||
|
||||
/*!
|
||||
\fn void QWidget::leaveEvent(QEvent *event)
|
||||
|
||||
|
@ -230,6 +230,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
|
||||
QWindowSystemInterfacePrivate::EnterEvent *systemEvent =
|
||||
static_cast<QWindowSystemInterfacePrivate::EnterEvent *>
|
||||
(QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter));
|
||||
const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition;
|
||||
if (systemEvent) {
|
||||
if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter))
|
||||
{
|
||||
@ -255,11 +256,12 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
|
||||
QWidget *leave = m_widget;
|
||||
if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
|
||||
leave = qt_last_mouse_receiver.data();
|
||||
QApplicationPrivate::dispatchEnterLeave(enter, leave);
|
||||
QApplicationPrivate::dispatchEnterLeave(enter, leave, globalPosF);
|
||||
qt_last_mouse_receiver = enter;
|
||||
}
|
||||
} else {
|
||||
QApplicationPrivate::dispatchEnterLeave(m_widget, 0);
|
||||
const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
|
||||
QApplicationPrivate::dispatchEnterLeave(m_widget, 0, ee->screenPos());
|
||||
qt_last_mouse_receiver = m_widget;
|
||||
}
|
||||
}
|
||||
|
@ -5407,6 +5407,7 @@ void tst_QWidget::setToolTip()
|
||||
// Mouse over doesn't work on Windows mobile, so skip the rest of the test for that platform.
|
||||
#ifndef Q_OS_WINCE_WM
|
||||
for (int pass = 0; pass < 2; ++pass) {
|
||||
QCursor::setPos(0, 0);
|
||||
QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup));
|
||||
popup->setObjectName(QString::fromLatin1("tst_qwidget setToolTip #%1").arg(pass));
|
||||
popup->setWindowTitle(popup->objectName());
|
||||
@ -5421,17 +5422,16 @@ void tst_QWidget::setToolTip()
|
||||
popup->setToolTip(QLatin1String("TOOLTIP POPUP"));
|
||||
popup->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(popup.data()));
|
||||
QWindow *popupWindow = popup->windowHandle();
|
||||
QTest::qWait(10);
|
||||
QTest::mouseMove(frame);
|
||||
QTest::mouseMove(popupWindow, QPoint(25, 25));
|
||||
QTest::qWait(900); // delay is 700
|
||||
|
||||
if (m_platform == QStringLiteral("xcb"))
|
||||
QSKIP("QTBUG-26424");
|
||||
QCOMPARE(spy1.count(), 1);
|
||||
QCOMPARE(spy2.count(), 0);
|
||||
if (pass == 0)
|
||||
QTest::qWait(2200); // delay is 2000
|
||||
QTest::mouseMove(popup.data());
|
||||
QTest::mouseMove(popupWindow);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -9635,7 +9635,7 @@ void tst_QWidget::underMouse()
|
||||
|
||||
// Enter window, outside children
|
||||
// Note: QTest::mouseMove will not generate enter events for windows, so send one explicitly
|
||||
QWindowSystemInterface::handleEnterEvent(window);
|
||||
QWindowSystemInterface::handleEnterEvent(window, inWindowPoint, window->mapToGlobal(inWindowPoint));
|
||||
QTest::mouseMove(window, inWindowPoint);
|
||||
QVERIFY(topLevelWidget.underMouse());
|
||||
QVERIFY(!childWidget1.underMouse());
|
||||
@ -9754,7 +9754,7 @@ void tst_QWidget::underMouse()
|
||||
childWidget1.resetCounts();
|
||||
|
||||
// Mouse enters back in, should cause enter to topLevelWidget
|
||||
QWindowSystemInterface::handleEnterEvent(window);
|
||||
QWindowSystemInterface::handleEnterEvent(window, inWindowPoint, window->mapToGlobal(inWindowPoint));
|
||||
QApplication::processEvents();
|
||||
QVERIFY(!topLevelWidget.underMouse());
|
||||
QVERIFY(!childWidget1.underMouse());
|
||||
@ -9788,7 +9788,8 @@ void tst_QWidget::underMouse()
|
||||
|
||||
// Mouse enters popup, should cause enter to popup and leave to current widgets under mouse
|
||||
QWindowSystemInterface::handleLeaveEvent(window);
|
||||
QWindowSystemInterface::handleEnterEvent(popupWindow);
|
||||
const QPoint popupCenter = popupWindow->geometry().center();
|
||||
QWindowSystemInterface::handleEnterEvent(popupWindow, popupWindow->mapFromGlobal(popupCenter), popupCenter);
|
||||
QApplication::processEvents();
|
||||
QVERIFY(!topLevelWidget.underMouse());
|
||||
QVERIFY(!childWidget1.underMouse());
|
||||
@ -9823,7 +9824,7 @@ void tst_QWidget::underMouse()
|
||||
|
||||
// Mouse leaves popup and enters topLevelWidget, should cause enter to topLevelWidget and leave for popup
|
||||
QWindowSystemInterface::handleLeaveEvent(popupWindow);
|
||||
QWindowSystemInterface::handleEnterEvent(window);
|
||||
QWindowSystemInterface::handleEnterEvent(window, inWindowPoint, window->mapToGlobal(inWindowPoint));
|
||||
QApplication::processEvents();
|
||||
QVERIFY(!topLevelWidget.underMouse());
|
||||
QVERIFY(!childWidget1.underMouse());
|
||||
@ -9876,7 +9877,7 @@ public slots:
|
||||
QPoint point2(15, 20);
|
||||
QPoint point3(20, 20);
|
||||
QWindow *window = modal->windowHandle();
|
||||
QWindowSystemInterface::handleEnterEvent(window);
|
||||
QWindowSystemInterface::handleEnterEvent(window, point1, window->mapToGlobal(point1));
|
||||
QTest::mouseMove(window, point1);
|
||||
QTest::mouseMove(window, point2);
|
||||
QTest::mouseMove(window, point3);
|
||||
@ -9922,7 +9923,7 @@ void tst_QWidget::taskQTBUG_27643_enterEvents()
|
||||
QWindow *window = dialog.windowHandle();
|
||||
QPoint overButton(25, 25);
|
||||
|
||||
QWindowSystemInterface::handleEnterEvent(window);
|
||||
QWindowSystemInterface::handleEnterEvent(window, overButton, window->mapToGlobal(overButton));
|
||||
QTest::mouseMove(window, overButton);
|
||||
QTest::mouseClick(window, Qt::LeftButton, 0, overButton, 0);
|
||||
|
||||
|
@ -233,9 +233,11 @@ bool MainWindow::eventFilter(QObject *o, QEvent *e)
|
||||
if (o->isWidgetType()) {
|
||||
switch (e->type()) {
|
||||
case QEvent::Enter: {
|
||||
const QEnterEvent *ee = static_cast<QEnterEvent *>(e);
|
||||
QString message;
|
||||
QDebug debug(&message);
|
||||
debug.nospace() << '#' << m_enterLeaveEventCount++ << " Enter for " << o->objectName();
|
||||
debug.nospace() << '#' << m_enterLeaveEventCount++ << " Enter for " << o->objectName()
|
||||
<< " at " << ee->localPos() << " global: " << ee->globalPos();
|
||||
m_logEdit->appendPlainText(message);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user