macOS: Don't ask for a NSWindow background unless we need one

This allow halfway transparent windows, even with a border, which is
a bit of a weird use-case, but matches what we do on other platforms.

We don't need the explicit call to NSDrawWindowBackground in the
QNSWindowBackingStore implementation, as the NSThemeFrame will draw
this background on our behalf.

Fixes: QTBUG-77637
Change-Id: I012d845fa957c40aa713adaecbb1601a848e3534
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-08-21 16:37:16 +02:00
parent c4aa90cb56
commit ee82f86615
2 changed files with 2 additions and 15 deletions

View File

@ -212,9 +212,6 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const
CGRect viewRect = viewLocalRect.toCGRect();
if (windowHasUnifiedToolbar())
NSDrawWindowBackground(viewRect);
[backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect()
operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil];

View File

@ -253,20 +253,10 @@ static bool isMouseEvent(NSEvent *ev)
return m_platformWindow ? m_platformWindow->isOpaque() : [super isOpaque];
}
/*!
Borderless windows need a transparent background
Technically windows with NSWindowStyleMaskTexturedBackground
(such as windows with unified toolbars) need to draw the textured
background of the NSWindow, and can't have a transparent
background, but as NSWindowStyleMaskBorderless is 0, you can't
have a window with NSWindowStyleMaskTexturedBackground that is
also borderless.
*/
- (NSColor *)backgroundColor
{
return self.styleMask == NSWindowStyleMaskBorderless
? [NSColor clearColor] : [super backgroundColor];
return self.styleMask & NSWindowStyleMaskTexturedBackground ?
[super backgroundColor] : [NSColor clearColor];
}
- (void)sendEvent:(NSEvent*)theEvent