summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-12-19 19:03:44 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-01-03 19:06:16 +0100
commita080fc9f89d0e1efa41841219dbb38454a2ff375 (patch)
treed2bcbb93683f3e5b400e5b292e13a87d8e4bf171 /src/plugins/platforms
parent49a8311ae5f2fb467d43c8e68ab9490efd2e064e (diff)
macOS: Send synthetic cursorUpdate events for utility windows
In faffaa729282b435fb330e1c92523fc0df3fc051 we limited our cursor update workaround to key windows, but macOS also sends cursorUpdate events to non-key windows with the NSWindowStyleMaskUtilityWindow style mask, so we include this in our workaround logic from ae8e96d4c2fc43. We include NSWindowStyleMaskTitled in this check, as macOS seems to require a window to be titled to treat it as a utility window. Task-number: QTBUG-96374 Change-Id: I1c54da181acbe472c2f598fec37aeadada3956bb Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index d7d82a9a7d..af5afab00d 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1797,6 +1797,8 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor)
if (isForeignWindow())
return;
+ qCInfo(lcQpaMouse) << "Setting" << this << "cursor to" << cursor;
+
QNSView *view = qnsview_cast(m_view);
if (cursor == view.cursor)
return;
@@ -1808,11 +1810,15 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor)
// There's a bug in AppKit where calling invalidateCursorRectsForView when
// there's an override cursor active (for example when hovering over the
// window frame), will not result in a cursorUpdate: callback. To work around
- // this we synthesize a cursor update event and call the callback ourselves,
- // if we detect that the mouse is currently over the view, and the window key.
+ // this we synthesize a cursor update event and call the callback ourselves.
+ // We only do this is if the window would normally receive cursor updates.
auto locationInWindow = m_view.window.mouseLocationOutsideOfEventStream;
auto locationInSuperview = [m_view.superview convertPoint:locationInWindow fromView:nil];
- if (m_view.window.keyWindow && [m_view hitTest:locationInSuperview] == m_view) {
+ bool mouseIsOverView = [m_view hitTest:locationInSuperview] == m_view;
+ auto utilityMask = NSWindowStyleMaskUtilityWindow | NSWindowStyleMaskTitled;
+ bool isUtilityWindow = (m_view.window.styleMask & utilityMask) == utilityMask;
+ if (mouseIsOverView && (m_view.window.keyWindow || isUtilityWindow)) {
+ qCDebug(lcQpaMouse) << "Synthesizing cursor update";
[m_view cursorUpdate:[NSEvent enterExitEventWithType:NSEventTypeCursorUpdate
location:locationInWindow modifierFlags:0 timestamp:0
windowNumber:m_view.window.windowNumber context:nil