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>bb10
parent
a080fc9f89
commit
3b60534ab9
|
|
@ -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]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue