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-12-15 08:35:46 +0000 |
commit | 2164209224cd275906728e8e9e315a8b25e355fa (patch) | |
tree | ae9585f03d9191a1268c9112133366c6346b79ac | |
parent | f8b5a1f4b9da32a8599d1f4e545ae32476de9b78 (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.5 behavior by not modifying ignoresMouseEvent
if we can. Toggling WindowTransparentForInput on and
off again is still broken.
Task-number: QTBUG-54830
Change-Id: I5f44ce14d9a7dc1713f9efb1ef929e2969838d90
(cherry picked from commit c35fc435950437d3d046b17d06593873d7b82011)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-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 0e5655fe58..a6c0da50ec 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1456,8 +1456,18 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) [m_contentView setHidden: YES]; } - m_nsWindow.ignoresMouseEvents = - (window()->flags() & Qt::WindowTransparentForInput) == 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 = window()->flags() & Qt::WindowTransparentForInput; + if (m_nsWindow.ignoresMouseEvents != ignoreMouse) + m_nsWindow.ignoresMouseEvents = ignoreMouse; + } const qreal opacity = qt_window_private(window())->opacity; if (!qFuzzyCompare(opacity, qreal(1.0))) |