summaryrefslogtreecommitdiff
path: root/vcl/osx
diff options
context:
space:
mode:
authorThorsten Wagner <thorsten.wagner.4@gmail.com>2021-01-27 01:01:10 +0100
committerTor Lillqvist <tml@collabora.com>2021-01-27 10:09:59 +0100
commitf318b856ed055f1952276355f811153f6b29c93e (patch)
tree46c10ea82a1031f233cdec4e6c2630a9d337fb16 /vcl/osx
parentf2389a70da606768a39ee599de6a5b24058734aa (diff)
tdf#138122 Detect window scaling for multi display configurations on macOS
(1) Activate window scaling when at least one retina display is connected (2) Remove environment variable VCL_MACOS_FORCE_WINDOW_SCALING Change-Id: If6926ace7238f2be4ae91290872dbb3dbf658221 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110002 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salgdiutils.cxx50
-rw-r--r--vcl/osx/salmacos.cxx2
2 files changed, 25 insertions, 27 deletions
diff --git a/vcl/osx/salgdiutils.cxx b/vcl/osx/salgdiutils.cxx
index 01626d348999..f3ddd946f699 100644
--- a/vcl/osx/salgdiutils.cxx
+++ b/vcl/osx/salgdiutils.cxx
@@ -35,37 +35,35 @@
#include <osx/salframe.h>
#include <osx/saldata.hxx>
-float AquaSalGraphics::GetWindowScaling()
-{
- float fScale = 1.0f;
-
-#ifdef MACOSX
-
- // Window scaling independent from main display may be forced by setting VCL_MACOS_FORCE_WINDOW_SCALING environment variable
- // whose setting is stored in mbWindowScaling. After implementation of full support of scaled displays window scaling will be
- // set to 2.0f for macOS as default. This will allow moving of windows between non retina and retina displays without blurry
- // text and graphics.
+// 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.
- // TODO: After implementation of full support of scaled displays code has to be modified to set a scaling of 2.0f as default.
-
- if (mbWindowScaling)
- {
- fScale = 2.0f;
- return fScale;
- }
+// Currently scaled display support is not implemented for bitmaps. This will cause a slight performance degradation on displays
+// with single precision. To preserve performance for now, window scaling is only activated if at least one display with double
+// precision is present. Moving windows between displays is then possible without blurry text and graphics too. Adapting window
+// scaling when displays are added while application is running is not supported.
-#endif
+static bool bWindowScaling = false;
+static float fWindowScale = 1.0f;
- AquaSalFrame *pSalFrame = mpFrame;
- if (!pSalFrame)
- pSalFrame = static_cast<AquaSalFrame *>(GetSalData()->mpInstance->anyFrame());
- if (pSalFrame)
+float AquaSalGraphics::GetWindowScaling()
+{
+ if (!bWindowScaling)
{
- NSWindow *pNSWindow = pSalFrame->getNSWindow();
- if (pNSWindow)
- fScale = [pNSWindow backingScaleFactor];
+ NSArray *aScreens = [NSScreen screens];
+ if (aScreens != nullptr)
+ {
+ int nScreens = [aScreens count];
+ for (int i = 0; i < nScreens; i++)
+ {
+ float fScale = [[aScreens objectAtIndex:i] backingScaleFactor];
+ if (fScale > fWindowScale)
+ fWindowScale = fScale;
+ }
+ bWindowScaling = true;
+ }
}
- return fScale;
+ return fWindowScale;
}
void AquaSalGraphics::SetWindowGraphics( AquaSalFrame* pFrame )
diff --git a/vcl/osx/salmacos.cxx b/vcl/osx/salmacos.cxx
index 0f41dd9e8c4a..5b1265130cd0 100644
--- a/vcl/osx/salmacos.cxx
+++ b/vcl/osx/salmacos.cxx
@@ -19,7 +19,7 @@
// This file contains the macOS-specific versions of the functions which were touched in the commit
// to fix tdf#138122. The iOS-specific versions of these functions are kept (for now, when this
-// comment is written) as they were before that commit in vcl/isx/salios.cxx.
+// comment is written) as they were before that commit in vcl/ios/salios.cxx.
#include <sal/config.h>
#include <sal/log.hxx>