From 04dcc902eb64d94653a12005f3aedf32be1011c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 19 Sep 2019 18:09:52 +0200 Subject: macOS: Handle backing property changes in a single place Change-Id: I70d57632a1756f74249f64d4d4c405cb3120a179 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 - src/plugins/platforms/cocoa/qcocoawindow.mm | 11 ----------- src/plugins/platforms/cocoa/qnsview_drawing.mm | 20 ++++++++++++-------- 3 files changed, 12 insertions(+), 20 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index c6ce6e6819..fef72bc496 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -161,7 +161,6 @@ public: Q_NOTIFICATION_HANDLER(NSWindowDidOrderOffScreenNotification) void windowDidOrderOffScreen(); Q_NOTIFICATION_HANDLER(NSWindowDidChangeOcclusionStateNotification) void windowDidChangeOcclusionState(); Q_NOTIFICATION_HANDLER(NSWindowDidChangeScreenNotification) void windowDidChangeScreen(); - Q_NOTIFICATION_HANDLER(NSWindowDidChangeBackingPropertiesNotification) void windowDidChangeBackingProperties(); Q_NOTIFICATION_HANDLER(NSWindowWillCloseNotification) void windowWillClose(); bool windowShouldClose(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index db4bc12210..35b7162346 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1262,17 +1262,6 @@ void QCocoaWindow::windowDidChangeScreen() currentScreen->requestUpdate(); } } -/* - The window's backing scale factor or color space has changed. -*/ -void QCocoaWindow::windowDidChangeBackingProperties() -{ - // Ideally we would plumb this thought QPA in a way that lets clients - // invalidate their own caches, and recreate QBackingStore. For now we - // trigger an expose, and let QCocoaBackingStore deal with its own - // buffer invalidation. - [m_view setNeedsDisplay:YES]; -} void QCocoaWindow::windowWillClose() { diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm index d2e6f848a0..de93e03685 100644 --- a/src/plugins/platforms/cocoa/qnsview_drawing.mm +++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm @@ -211,17 +211,21 @@ - (void)viewDidChangeBackingProperties { - CALayer *layer = self.layer; - if (!layer) - return; + qCDebug(lcQpaDrawing) << "Backing properties changed for" << self; - layer.contentsScale = self.window.backingScaleFactor; + if (CALayer *layer = self.layer) { + layer.contentsScale = self.window.backingScaleFactor; - // Metal layers must be manually updated on e.g. screen change - if ([layer isKindOfClass:CAMetalLayer.class]) { - [self updateMetalLayerDrawableSize:static_cast(layer)]; - [self setNeedsDisplay:YES]; + // Metal layers must be manually updated on e.g. screen change + if ([layer isKindOfClass:CAMetalLayer.class]) + [self updateMetalLayerDrawableSize:static_cast(layer)]; } + + // Ideally we would plumb this situation through QPA in a way that lets + // clients invalidate their own caches, recreate QBackingStore, etc. + // For now we trigger an expose, and let QCocoaBackingStore deal with + // buffer invalidation internally. + [self setNeedsDisplay:YES]; } @end -- cgit v1.2.3