diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2017-08-03 12:07:11 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2017-08-09 11:31:52 +0000 |
commit | c35fc435950437d3d046b17d06593873d7b82011 (patch) | |
tree | c5c1a6aa7730cd229c08c8111ae4ba7ad1311aa1 /src/plugins/platforms/cocoa | |
parent | 37f3ed96eb6f41d2b9fc34f64725dd754bb627a8 (diff) |
macOS: Make alpha-based click-trough work again
Commit 3ea04c7d made it so that we always set the
ignoresMouseEvent property on the NSWindow, based
on the WindowTransparentForInput flag.
However, this overwrites the magical secret initial
state where click-trough is determined based on window
content transparency - setting the property to false
makes the window capture all events.
Restore 5.6 behavior by not modifying ignoresMouseEvent
if we can. Toggling WindowTransparentForInput on and
off again is still broken.
Task-number: QTBUG-54830
Change-Id: I5f44ce14d9a7dc1713f9efb1ef929e2969838d90
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 59b76370ae..6ef459566a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1088,8 +1088,18 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) setWindowZoomButton(flags); } - if (m_nsWindow) - m_nsWindow.ignoresMouseEvents = flags & Qt::WindowTransparentForInput; + // Make window ignore mouse events if WindowTransparentForInput is set. + // Note that ignoresMouseEvents has a special initial state where events + // are ignored (passed through) based on window transparency, and that + // setting the property to false does not return us to that state. Instead, + // this makes the window capture all mouse events. Take care to only + // set the property if needed. FIXME: recreate window if needed or find + // some other way to implement WindowTransparentForInput. + if (m_nsWindow) { + bool ignoreMouse = flags & Qt::WindowTransparentForInput; + if (m_nsWindow.ignoresMouseEvents != ignoreMouse) + m_nsWindow.ignoresMouseEvents = ignoreMouse; + } m_windowFlags = flags; } |