vcl/headless/svpframe.cxx    |    1 +
 vcl/inc/headless/svpinst.hxx |    3 ---
 vcl/inc/salsys.hxx           |    3 +++
 vcl/win/window/salframe.cxx  |    7 +++++++
 4 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 322ea272bba63ba779120ca5ead4a4b40d1bb93f
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon Sep 26 11:04:09 2022 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Tue Sep 27 11:32:21 2022 +0200

    Fix some headless window sizes on Windows, to make `make check` more 
reliable
    
    ...by making it more resilient against varying screen sizes.  On my 
2560x1600
    Windows laptop, three `make check` tests systematically failed, and 
apparently
    all of them were caused by that larger-than-average screen (similar to what 
has
    been detailed in the commit message of 
3db6a93c558c55eed085b4386228f9951bb08936
    "Compute a better GetDefaultCenterPos"):
    
    * CppunitTest_sw_layoutwriter
    > test/source/xmltesttools.cxx:191:testTdf134298::TestBody
    > equality assertion failed
    > - Expected: 2
    > - Actual  : 3
    > - In <>, XPath '/root/page' number of nodes is incorrect
    
    * CppunitTest_sw_ooxmlexport12
    > 
sw/qa/extras/ooxmlexport/ooxmlexport12.cxx:526:testObjectCrossReference::TestBody
    > equality assertion failed
    > - Expected: Text 2
    > - Actual  : 2
    
    * CppunitTest_sw_uiwriter2
    > sw/qa/extras/uiwriter/uiwriter2.cxx:2702:testTdf122942::TestBody
    > equality assertion failed
    > - Expected: 2
    > - Actual  : 1
    
    Those tests are all run with both SAL_USE_VCLPLUGIN=svp and --headless.  
But svp
    is only present on Linux and is thus ignored on Windows.  And --headless, 
while
    preventing any windows from actually being shown, nevertheless uses the GUI 
code
    to set up window sizes.  So the idea here is to hack the Windows backend in
    strategic places so that it uses "appropriate" window sizes in --headless 
mode
    to make `make check` succeed.
    
    The Linux svp backend has a single place in vcl/headless/svpframe.cxx where 
it
    hardcodes the number of monitors to 1 and the screen size to 1024x768.  
However,
    for the Windows backend, code determining and using those values is somewhat
    spread, but it turned out that there is one strategic place in
    ImplSalGetWorkArea that does what we want (without touching the reported 
number
    of monitors at all), without (it appears) negatively affecting other 
scenarios.
    
    (It appears that macOS, also not supporting an svp backend, is similarly
    affected.  But it looks harder there to come up with such a strategic place 
to
    hardcode --headless window sizes, and at least my own macOS build's `make 
check`
    is unaffected as I use a default scaled 1829x1080 screen resolution there
    instead of the "raw" 3840x2160.)
    
    Change-Id: I822241f81497b9f6bed8e9688eddbe7d798c6b34
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140588
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 23a7e2595bda..5c6a713572d2 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -27,6 +27,7 @@
 #ifndef IOS
 #include <headless/svpgdi.hxx>
 #endif
+#include <salsys.hxx>
 
 #include <basegfx/vector/b2ivector.hxx>
 
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index 874ce672d97a..e9aada5bc001 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -32,9 +32,6 @@
 
 #include <sys/time.h>
 
-#define VIRTUAL_DESKTOP_WIDTH 1024
-#define VIRTUAL_DESKTOP_HEIGHT 768
-
 #ifdef IOS
 #define SvpSalInstance AquaSalInstance
 #endif
diff --git a/vcl/inc/salsys.hxx b/vcl/inc/salsys.hxx
index dff65b2f35cd..265380a1de2e 100644
--- a/vcl/inc/salsys.hxx
+++ b/vcl/inc/salsys.hxx
@@ -82,6 +82,9 @@ public:
 
 VCL_DLLPUBLIC SalSystem* ImplGetSalSystem();
 
+#define VIRTUAL_DESKTOP_WIDTH 1024
+#define VIRTUAL_DESKTOP_HEIGHT 768
+
 #endif // INCLUDED_VCL_INC_SALSYS_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 9880613e7fa3..95cb08e20b07 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -174,6 +174,13 @@ void WinSalFrame::UpdateFrameState()
 // if pParentRect is set, the workarea of the monitor that contains 
pParentRect is returned
 void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect )
 {
+    if (Application::IsHeadlessModeEnabled()) {
+        pRect->left = 0;
+        pRect->top = 0;
+        pRect->right = VIRTUAL_DESKTOP_WIDTH;
+        pRect->bottom = VIRTUAL_DESKTOP_HEIGHT;
+        return;
+    }
     // check if we or our parent is fullscreen, then the taskbar should be 
ignored
     bool bIgnoreTaskbar = false;
     WinSalFrame* pFrame = GetWindowPtr( hWnd );

Reply via email to