summaryrefslogtreecommitdiff
path: root/vcl/osx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salframe.cxx2
-rw-r--r--vcl/osx/salframeview.mm21
-rw-r--r--vcl/osx/salgdiutils.cxx27
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 )