diff options
author | Patrick Luby <plubius@neooffice.org> | 2023-01-24 20:28:22 -0500 |
---|---|---|
committer | Patrick Luby <plubius@neooffice.org> | 2023-01-26 14:19:29 +0000 |
commit | a0d825133656c6329c0e7e3b0b6bafbd51e87271 (patch) | |
tree | f8e3a4d703b2b6ea6295a5e3fcd15b2a6a1f237a /vcl/osx | |
parent | f12ea381d52e2c26e966d15d281b41eafaddb5bb (diff) |
tdf#147342 Notify Skia that the window's backing properties changed
Change-Id: I4185a240a2ca6df1c92e86ff9950f86234d4ace8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146142
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Diffstat (limited to 'vcl/osx')
-rw-r--r-- | vcl/osx/salframe.cxx | 2 | ||||
-rw-r--r-- | vcl/osx/salframeview.mm | 21 | ||||
-rw-r--r-- | vcl/osx/salgdiutils.cxx | 27 |
3 files changed, 47 insertions, 3 deletions
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index 90dd38704bcd..02a3879648db 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -287,6 +287,8 @@ void AquaSalFrame::screenParametersChanged() { OSX_SALDATA_RUNINMAIN( screenParametersChanged() ) + sal::aqua::resetWindowScaling(); + UpdateFrameGeometry(); if( mpGraphics ) diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index b36cd23721ea..9eded8a40fe8 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -500,6 +500,27 @@ static AquaSalFrame* getMouseContainerFrame() (void)pNotification; } +-(void)windowDidChangeBackingProperties:(NSNotification *)pNotification +{ + (void)pNotification; +#if HAVE_FEATURE_SKIA + SolarMutexGuard aGuard; + + sal::aqua::resetWindowScaling(); + + if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) + { + // tdf#147342 Notify Skia that the window's backing properties changed + if ( SkiaHelper::isVCLSkiaEnabled() ) + { + AquaSalGraphics* pGraphics = mpFrame->mpGraphics; + if ( pGraphics ) + pGraphics->WindowBackingPropertiesChanged(); + } + } +#endif +} + -(void)dockMenuItemTriggered: (id)sender { (void)sender; diff --git a/vcl/osx/salgdiutils.cxx b/vcl/osx/salgdiutils.cxx index 603a8b612d42..d65897e25a83 100644 --- a/vcl/osx/salgdiutils.cxx +++ b/vcl/osx/salgdiutils.cxx @@ -35,6 +35,11 @@ #include <osx/salframe.h> #include <osx/saldata.hxx> +#if HAVE_FEATURE_SKIA +#include <tools/sk_app/mac/WindowContextFactory_mac.h> +#include <vcl/skia/SkiaHelper.hxx> +#endif + // TODO: Scale will be set to 2.0f as default after implementation of full scaled display support . This will allow moving of // windows between non retina and retina displays without blurry text and graphics. Static variables have to be removed thereafter. @@ -50,15 +55,17 @@ namespace sal::aqua { float getWindowScaling() { + // Related: tdf#147342 Any changes to this function must be copied to the + // sk_app::GetBackingScaleFactor() function in the following file: + // workdir/UnpackedTarball/skia/tools/sk_app/mac/WindowContextFactory_mac.h if (!bWindowScaling) { NSArray *aScreens = [NSScreen screens]; if (aScreens != nullptr) { - int nScreens = [aScreens count]; - for (int i = 0; i < nScreens; i++) + for (NSScreen *aScreen : aScreens) { - float fScale = [[aScreens objectAtIndex:i] backingScaleFactor]; + float fScale = [aScreen backingScaleFactor]; if (fScale > fWindowScale) fWindowScale = fScale; } @@ -72,6 +79,20 @@ float getWindowScaling() } return fWindowScale; } + +void resetWindowScaling() +{ + // Related: tdf#147342 Force recalculation of the window scaling but keep + // the previous window scaling as the minimum so that we don't lose the + // resolution in cached images if a HiDPI monitor is disconnected and + // then reconnected. +#if HAVE_FEATURE_SKIA + if ( SkiaHelper::isVCLSkiaEnabled() ) + sk_app::ResetBackingScaleFactor(); +#endif + bWindowScaling = false; + getWindowScaling(); +} } // end aqua void AquaSalGraphics::SetWindowGraphics( AquaSalFrame* pFrame ) |