summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-12-19 19:08:39 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-01-03 19:06:17 +0100
commit3b60534ab9a2f467cd44ee23a1429ed46d6d5a23 (patch)
tree104d180f9435a09407dee863308288a0b043fbff /src/plugins/platforms
parenta080fc9f89d0e1efa41841219dbb38454a2ff375 (diff)
macOS: Limit cursor update workaround to Monterey and below
The AppKit issue has been fixed in Ventura. Change-Id: Ic2c0a0ed4ad52ef2d52410ec2c8ba061907cbe8e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index af5afab00d..7a0bf5a4cb 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1807,22 +1807,24 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor)
[m_view.window invalidateCursorRectsForView:m_view];
- // 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.
- // 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];
- 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
- eventNumber:0 trackingNumber:0 userData:0]];
+ if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::MacOSMonterey) {
+ // 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.
+ // 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];
+ 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
+ eventNumber:0 trackingNumber:0 userData:0]];
+ }
}
}