From fefbed5eae9e1b2761da6a506874b0ccd42fd6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Aug 2017 14:01:13 +0200 Subject: macOS: Determine opaqueness and backgroundColor of NSWindow declaratively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of imperatively trying to keep the logic consistent in many different call sites. Task-number: QTBUG-61909 Change-Id: I8d647690c47656f34673555a8a8aa3ec6ffc73d1 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnswindow.mm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/plugins/platforms/cocoa/qnswindow.mm') diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index e5ddd3ca0f..513c7f22b5 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -153,6 +153,28 @@ static bool isMouseEvent(NSEvent *ev) return canBecomeMain; } +- (BOOL)isOpaque +{ + return self.platformWindow ? + self.platformWindow->isOpaque() : qt_objcDynamicSuper(); +} + +/*! + Borderless windows need a transparent background + + Technically windows with NSTexturedBackgroundWindowMask (such + as windows with unified toolbars) need to draw the textured + background of the NSWindow, and can't have a transparent + background, but as NSBorderlessWindowMask is 0, you can't + have a window with NSTexturedBackgroundWindowMask that is + also borderless. +*/ +- (NSColor *)backgroundColor +{ + return self.styleMask == NSBorderlessWindowMask + ? [NSColor clearColor] : qt_objcDynamicSuper(); +} + - (void)sendEvent:(NSEvent*)theEvent { // We might get events for a NSWindow after the corresponding platform -- cgit v1.2.3