From c35fc435950437d3d046b17d06593873d7b82011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 3 Aug 2017 12:07:11 +0200 Subject: macOS: Make alpha-based click-trough work again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/plugins') 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; } -- cgit v1.2.3