diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-24 14:01:13 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-30 17:57:01 +0000 |
commit | fefbed5eae9e1b2761da6a506874b0ccd42fd6a0 (patch) | |
tree | 94f657576f0bc607a3305a85bde30e6dda87453b /src/plugins/platforms/cocoa/qnswindow.mm | |
parent | 2a131b94db2af663f3d35a97c5e2224c3ba50c5d (diff) |
macOS: Determine opaqueness and backgroundColor of NSWindow declaratively
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ø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qnswindow.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindow.mm | 22 |
1 files changed, 22 insertions, 0 deletions
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 |