summaryrefslogtreecommitdiff
path: root/vcl/osx
diff options
context:
space:
mode:
authorThorsten Wagner <thorsten.wagner.4@gmail.com>2021-02-21 01:34:54 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-02-23 08:22:05 +0100
commit0c36f364b14aacd0eeb53087ae2fce54402dc741 (patch)
treeb454d23eb3912a766f77761596e07094c88064d2 /vcl/osx
parent0ee761853fd93dd66805d53636fe55c8879063da (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 (3) Disable related unit tests unless bitmap scaling has been implemented Change-Id: I218119a21e319e22bf17c609608724fce180f000 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111267 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/osx')
-rw-r--r--vcl/osx/salgdiutils.cxx50
-rw-r--r--vcl/osx/salmacos.cxx4
2 files changed, 26 insertions, 28 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..f6403dea2725 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>
@@ -331,7 +331,7 @@ bool AquaSalVirtualDevice::SetSize(tools::Long nDX, tools::Long nDY)
mnWidth = nDX;
mnHeight = nDY;
- fScale = mpGraphics->GetWindowScaling();
+ fScale = AquaSalGraphics::GetWindowScaling();
CGColorSpaceRef aColorSpace;
uint32_t nFlags;
if (mnBitmapDepth && (mnBitmapDepth < 16))