vcl/inc/quartz/salgdi.h |    1 
 vcl/osx/salgdiutils.cxx |   50 +++++++++++++++++++++++-------------------------
 vcl/osx/salmacos.cxx    |    2 -
 vcl/quartz/salgdi.cxx   |    8 -------
 4 files changed, 25 insertions(+), 36 deletions(-)

New commits:
commit f318b856ed055f1952276355f811153f6b29c93e
Author:     Thorsten Wagner <thorsten.wagne...@gmail.com>
AuthorDate: Wed Jan 27 01:01:10 2021 +0100
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Wed Jan 27 10:09:59 2021 +0100

    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 <t...@collabora.com>

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 69b735787bdc..4897d96c6089 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -174,7 +174,6 @@ class AquaSalGraphics : public SalGraphics
 #ifdef MACOSX
     /// is this a window graphics
     bool                                    mbWindow;
-    bool                                    mbWindowScaling;
 
 #else // IOS
 
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>
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 8dd9ec9222ad..ae6a40cfd4e2 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -205,14 +205,6 @@ AquaSalGraphics::AquaSalGraphics()
     , mbVirDev( false )
 #ifdef MACOSX
     , mbWindow( false )
-
-    // Window scaling independent from main display may be forced by setting 
VCL_MACOS_FORCE_WINDOW_SCALING environment variable. If
-    // unset window scaling from main display will be used. After 
implementation of full support of scaled displays window scaling
-    // will be set to 2.0f for macOS as default.
-
-    // TODO: After implementation of full support of scaled displays 
VCL_FORCE_WINDOW_SCALING control has to be removed.
-
-    , mbWindowScaling( getenv("VCL_MACOS_FORCE_WINDOW_SCALING") )
 #else
     , mbForeignContext( false )
 #endif
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to