summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-04-13 12:57:00 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-04-14 08:27:51 (GMT)
commitd3e91e4124b96869b8c4e2c8492b4d4cec913ebc (patch)
treeb0886255256015520e0ceb5ef09473cbc000aea2
parent7e1e691d0ae3c665ecb213ce7fd0e27d9838e5a9 (diff)
downloadQt-d3e91e4124b96869b8c4e2c8492b4d4cec913ebc.zip
Qt-d3e91e4124b96869b8c4e2c8492b4d4cec913ebc.tar.gz
Qt-d3e91e4124b96869b8c4e2c8492b4d4cec913ebc.tar.bz2
Cocoa: qwidget autotest fails on setToolTip
The reason turns out to be that we: 1. Half-way fake mouse events from QCursor::setPos 2. Don't fake mouse move upon mouse enter unless traking is on The test failed when mouse trackin was on, so that we ended up faking the same mouse move event twize (in QCursor::setPos and mouseEnter). We now do a different implementation for setPos on cocoa (so that native events will be generated), and always fake a mouse move event from mouse enter to make tooltips (and other event filters) work Reviewed-by: MortenS
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm15
-rw-r--r--src/gui/kernel/qcursor_mac.mm10
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp3
3 files changed, 18 insertions, 10 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 9c5380b..dd12f65 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -673,13 +673,14 @@ static int qCocoaViewCount = 0;
// Send mouse move and hover events as well:
if (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window()) {
- if (qwidget->testAttribute(Qt::WA_MouseTracking)) {
- NSEvent *mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved
- location:windowPoint modifierFlags:[event modifierFlags] timestamp:[event timestamp]
- windowNumber:[event windowNumber] context:[event context] eventNumber:[event eventNumber]
- clickCount:0 pressure:0];
- qt_mac_handleMouseEvent(self, mouseEvent, QEvent::MouseMove, Qt::NoButton);
- }
+ // This mouse move event should be sendt, even when mouse
+ // tracking is switched off (to trigger tooltips):
+ NSEvent *mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved
+ location:windowPoint modifierFlags:[event modifierFlags] timestamp:[event timestamp]
+ windowNumber:[event windowNumber] context:[event context] eventNumber:[event eventNumber]
+ clickCount:0 pressure:0];
+ qt_mac_handleMouseEvent(self, mouseEvent, QEvent::MouseMove, Qt::NoButton);
+
if (qwidget->testAttribute(Qt::WA_Hover)) {
QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1));
QApplicationPrivate::instance()->notify_helper(qwidget, &he);
diff --git a/src/gui/kernel/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm
index 03e38b0..c3d6c54 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/gui/kernel/qcursor_mac.mm
@@ -224,6 +224,15 @@ QPoint QCursor::pos()
void QCursor::setPos(int x, int y)
{
+#ifdef QT_MAC_USE_COCOA
+ CGPoint pos;
+ pos.x = x;
+ pos.y = y;
+
+ CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0);
+ CGEventPost(kCGHIDEventTap, e);
+ CFRelease(e);
+#else
CGWarpMouseCursorPosition(CGPointMake(x, y));
/* I'm not too keen on doing this, but this makes it a lot easier, so I just
@@ -240,6 +249,7 @@ void QCursor::setPos(int x, int y)
QApplication::mouseButtons(), QApplication::keyboardModifiers());
qt_sendSpontaneousEvent(widget, &me);
}
+#endif
}
void QCursorData::initCursorFromBitmap()
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 1b2944e..76e20b9 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -6056,9 +6056,6 @@ void tst_QWidget::setToolTip()
#ifdef Q_OS_WINCE_WM
QSKIP("Mouse over doesn't work on Windows mobile.", SkipAll);
#endif
-#ifdef QT_MAC_USE_COCOA
- QSKIP("Temporarily disable the rest on cocoa due to QCursor::setPos problems.", SkipAll);
-#endif
for (int pass = 0; pass < 2; ++pass) {
QWidget *popup = new QWidget(0, Qt::Popup);