vcl/inc/win/salframe.h      |    2 +
 vcl/win/gdi/gdiimpl.cxx     |    6 +--
 vcl/win/window/salframe.cxx |   81 ++++++++++++++++++++------------------------
 3 files changed, 42 insertions(+), 47 deletions(-)

New commits:
commit 25f8b88ac9d602c1c518561c0f641a1e21699338
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 25 17:13:34 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Sep 26 07:11:48 2024 +0200

    tdf#160837 win: Move UpdateFrameGeometry to WinSalFrame
    
    Turn the previously static helper function
    UpdateFrameGeometry into a WinSalFrame method.
    
    It requires write access to the maGeometry member, which is
    currently still, but soon no longer public.
    
    Change-Id: Ief0dfee6061a5ea4e8ce497f1605b7c46c6e40c3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173959
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 21700c0fccba..ca3bbd8eb323 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -148,6 +148,7 @@ public:
 
     constexpr vcl::WindowState state() const { return m_eState; }
     void SetMaximizedFrameGeometry(HWND hWnd, RECT* pParentRect = nullptr);
+    void UpdateFrameGeometry();
     void UpdateFrameState();
     constexpr bool isFullScreen() const { return bool(m_eState & 
vcl::WindowState::FullScreen); }
 
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 60afa53cd71a..f1a753f05f82 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -115,8 +115,6 @@ bool WinSalFrame::mbInReparent = false;
 // Macros for support of WM_UNICHAR & Keyman 6.0
 #define Uni_SupplementaryPlanesStart    0x10000
 
-static void UpdateFrameGeometry(WinSalFrame* pFrame);
-
 static void SetGeometrySize(vcl::WindowPosSize& rWinPosSize, const Size& rSize)
 {
     rWinPosSize.setWidth(rSize.Width() < 0 ? 0 : rSize.Width());
@@ -515,7 +513,7 @@ SalFrame* ImplSalCreateFrame( WinSalInstance* pInst,
     GetClientRect( hWnd, &aRect );
     pFrame->mbDefPos = true;
 
-    UpdateFrameGeometry(pFrame);
+    pFrame->UpdateFrameGeometry();
     pFrame->UpdateFrameState();
 
     if( pFrame->mnShowState == SW_SHOWMAXIMIZED )
@@ -1462,7 +1460,7 @@ void WinSalFrame::SetPosSize( tools::Long nX, tools::Long 
nY, tools::Long nWidth
 
     SetWindowPos( mhWnd, HWND_TOP, nX, nY, static_cast<int>(nWidth), 
static_cast<int>(nHeight), nPosFlags  );
 
-    UpdateFrameGeometry(this);
+    UpdateFrameGeometry();
 
     // Notification -- really ???
     if( nEvent != SalEvent::NONE )
@@ -4235,52 +4233,48 @@ void WinSalFrame::SetMaximizedFrameGeometry(HWND hWnd, 
RECT* pParentRect )
     SetGeometrySize(maGeometry, { aRect.right - aRect.left, aRect.bottom - 
aRect.top });
 }
 
-static void UpdateFrameGeometry(WinSalFrame* pFrame)
+void WinSalFrame::UpdateFrameGeometry()
 {
-    if( !pFrame )
-        return;
-    const HWND hWnd = pFrame->mhWnd;
-
     RECT aRect;
-    GetWindowRect( hWnd, &aRect );
-    pFrame->maGeometry.setPosSize({ 0, 0 }, { 0, 0 });
-    pFrame->maGeometry.setDecorations(0, 0, 0, 0);
-    pFrame->maGeometry.setScreen(0);
+    GetWindowRect(mhWnd, &aRect);
+    maGeometry.setPosSize({ 0, 0 }, { 0, 0 });
+    maGeometry.setDecorations(0, 0, 0, 0);
+    maGeometry.setScreen(0);
 
-    if ( IsIconic( hWnd ) )
+    if (IsIconic(mhWnd))
         return;
 
     POINT aPt;
     aPt.x=0;
     aPt.y=0;
-    ClientToScreen(hWnd, &aPt);
+    ClientToScreen(mhWnd, &aPt);
     int cx = aPt.x - aRect.left;
 
-    pFrame->maGeometry.setDecorations(cx, aPt.y - aRect.top, cx, 0);
-    pFrame->maGeometry.setPos({ aPt.x, aPt.y });
+    maGeometry.setDecorations(cx, aPt.y - aRect.top, cx, 0);
+    maGeometry.setPos({ aPt.x, aPt.y });
 
     RECT aInnerRect;
-    GetClientRect( hWnd, &aInnerRect );
+    GetClientRect(mhWnd, &aInnerRect);
     if( aInnerRect.right )
     {
         // improve right decoration
         aPt.x=aInnerRect.right;
         aPt.y=aInnerRect.top;
-        ClientToScreen(hWnd, &aPt);
-        pFrame->maGeometry.setRightDecoration(aRect.right - aPt.x);
+        ClientToScreen(mhWnd, &aPt);
+        maGeometry.setRightDecoration(aRect.right - aPt.x);
     }
     if( aInnerRect.bottom ) // may be zero if window was not shown yet
-        pFrame->maGeometry.setBottomDecoration(aRect.bottom - aPt.y - 
aInnerRect.bottom);
+        maGeometry.setBottomDecoration(aRect.bottom - aPt.y - 
aInnerRect.bottom);
     else
         // bottom border is typically the same as left/right
-        
pFrame->maGeometry.setBottomDecoration(pFrame->maGeometry.leftDecoration());
+        maGeometry.setBottomDecoration(maGeometry.leftDecoration());
 
     int nWidth  = aRect.right - aRect.left
-        - pFrame->maGeometry.rightDecoration() - 
pFrame->maGeometry.leftDecoration();
+        - maGeometry.rightDecoration() - maGeometry.leftDecoration();
     int nHeight = aRect.bottom - aRect.top
-        - pFrame->maGeometry.bottomDecoration() - 
pFrame->maGeometry.topDecoration();
-    SetGeometrySize(pFrame->maGeometry, { nWidth, nHeight });
-    pFrame->updateScreenNumber();
+        - maGeometry.bottomDecoration() - maGeometry.topDecoration();
+    SetGeometrySize(maGeometry, { nWidth, nHeight });
+    updateScreenNumber();
 }
 
 static void ImplCallClosePopupsHdl( HWND hWnd )
@@ -4309,7 +4303,7 @@ static void ImplHandleMoveMsg(HWND hWnd, LPARAM lParam)
     if (!pFrame)
         return;
 
-    UpdateFrameGeometry(pFrame);
+    pFrame->UpdateFrameGeometry();
 
 #ifdef NDEBUG
     (void) lParam;
@@ -4364,7 +4358,7 @@ static void ImplHandleSizeMsg(HWND hWnd, WPARAM wParam, 
LPARAM lParam)
     if (!pFrame)
         return;
 
-    UpdateFrameGeometry(pFrame);
+    pFrame->UpdateFrameGeometry();
 
 #ifdef NDEBUG
     (void) lParam;
commit b00d322c5fc7e275244a7848b735f7f93fec5791
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 25 17:00:42 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Sep 26 07:11:41 2024 +0200

    tdf#160837 win: Move SetMaximizedFrameGeometry to WinSalFrame
    
    Turn the previously static helper function
    SetMaximizedFrameGeometry into a WinSalFrame method.
    
    It requires write access to the maGeometry member, which is
    currently still, but soon no longer public.
    
    Change-Id: Iceef8a5366e6f4f5bf2163011651ee99ee908b2a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173958
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index e465eb1350b1..21700c0fccba 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -147,6 +147,7 @@ public:
     virtual bool                GetUseReducedAnimation() const override;
 
     constexpr vcl::WindowState state() const { return m_eState; }
+    void SetMaximizedFrameGeometry(HWND hWnd, RECT* pParentRect = nullptr);
     void UpdateFrameState();
     constexpr bool isFullScreen() const { return bool(m_eState & 
vcl::WindowState::FullScreen); }
 
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index cb718ff66bbc..60afa53cd71a 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -116,7 +116,6 @@ bool WinSalFrame::mbInReparent = false;
 #define Uni_SupplementaryPlanesStart    0x10000
 
 static void UpdateFrameGeometry(WinSalFrame* pFrame);
-static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* 
pParentRect = nullptr );
 
 static void SetGeometrySize(vcl::WindowPosSize& rWinPosSize, const Size& rSize)
 {
@@ -524,7 +523,7 @@ SalFrame* ImplSalCreateFrame( WinSalInstance* pInst,
         // #96084 set a useful internal window size because
         // the window will not be maximized (and the size updated) before 
show()
 
-        SetMaximizedFrameGeometry( hWnd, pFrame );
+        pFrame->SetMaximizedFrameGeometry(hWnd);
     }
 
     return pFrame;
@@ -1755,7 +1754,7 @@ void WinSalFrame::SetWindowState(const vcl::WindowData* 
pState)
             aStateRect.bottom = nY+nHeight;
             // #96084 set a useful internal window size because
             // the window will not be maximized (and the size updated) before 
show()
-            SetMaximizedFrameGeometry( mhWnd, this, &aStateRect );
+            SetMaximizedFrameGeometry(mhWnd, &aStateRect);
             SetWindowPos( mhWnd, nullptr,
                           maGeometry.x(), maGeometry.y(), maGeometry.width(), 
maGeometry.height(),
                           SWP_NOZORDER | SWP_NOACTIVATE | nPosSize );
@@ -4206,7 +4205,7 @@ static bool ImplHandlePaintMsg( HWND hWnd )
     return bPaintSuccessful;
 }
 
-static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* 
pParentRect )
+void WinSalFrame::SetMaximizedFrameGeometry(HWND hWnd, RECT* pParentRect )
 {
     // calculate and set frame geometry of a maximized window - useful if the 
window is still hidden
 
@@ -4229,11 +4228,11 @@ static void SetMaximizedFrameGeometry( HWND hWnd, 
WinSalFrame* pFrame, RECT* pPa
     ImplSalGetWorkArea( hWnd, &aRect, pParentRect );
 
     // a maximized window has no other borders than the caption
-    pFrame->maGeometry.setDecorations(0, pFrame->mbCaption ? 
GetSystemMetrics(SM_CYCAPTION) : 0, 0, 0);
+    maGeometry.setDecorations(0, mbCaption ? GetSystemMetrics(SM_CYCAPTION) : 
0, 0, 0);
 
-    aRect.top += pFrame->maGeometry.topDecoration();
-    pFrame->maGeometry.setPos({ aRect.left, aRect.top });
-    SetGeometrySize(pFrame->maGeometry, { aRect.right - aRect.left, 
aRect.bottom - aRect.top });
+    aRect.top += maGeometry.topDecoration();
+    maGeometry.setPos({ aRect.left, aRect.top });
+    SetGeometrySize(maGeometry, { aRect.right - aRect.left, aRect.bottom - 
aRect.top });
 }
 
 static void UpdateFrameGeometry(WinSalFrame* pFrame)
commit c3e89c03d340db7b80a36ada7cbd2ea9009ac075
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 25 16:30:56 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Sep 26 07:11:35 2024 +0200

    tdf#160837 win: Replace some direct access to SalFrame::maGeometry
    
    Replace some direct access to the (currently still, but
    soon no longer public) SalFrame::maGeometry member in
    Windows-specific code by using the public getter
    SalFrame::GetUnmirroredGeometry, or more specific getters
    for the height and width (SalFrame::GetWidth, SalFrame::GetHeight).
    
    Change-Id: I49babdc0f40fe41b44f968ce0a7d3c219a3f93d0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173957
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 1a186fc4ae8c..db936ae39bef 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -957,11 +957,11 @@ tools::Long WinSalGraphicsImpl::GetGraphicsWidth() const
         WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
         if( pFrame )
         {
-            if (pFrame->maGeometry.width())
-                return pFrame->maGeometry.width();
+            if (pFrame->GetWidth())
+                return pFrame->GetWidth();
             else
             {
-                // TODO: perhaps not needed, maGeometry should always be 
up-to-date
+                // TODO: perhaps not needed, width should always be up-to-date
                 RECT aRect;
                 GetClientRect( mrParent.gethWnd(), &aRect );
                 return aRect.right;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index eeb588c2a228..cb718ff66bbc 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -3367,7 +3367,7 @@ static bool ImplHandleMouseMsg( HWND hWnd, UINT nMsg,
             UpdateWindow( hWnd );
 
         if( AllSettings::GetLayoutRTL() )
-            aMouseEvt.mnX = pFrame->maGeometry.width() - 1 - aMouseEvt.mnX;
+            aMouseEvt.mnX = pFrame->GetWidth() - 1 - aMouseEvt.mnX;
 
         nRet = pFrame->CallCallback( nEvent, &aMouseEvt );
         if ( nMsg == WM_MOUSEMOVE )
@@ -3450,7 +3450,7 @@ static bool ImplHandleWheelMsg( HWND hWnd, UINT nMsg, 
WPARAM wParam, LPARAM lPar
             aWheelEvt.mnCode |= KEY_MOD2;
 
         if( AllSettings::GetLayoutRTL() )
-            aWheelEvt.mnX = pFrame->maGeometry.width() - 1 - aWheelEvt.mnX;
+            aWheelEvt.mnX = pFrame->GetWidth() - 1 - aWheelEvt.mnX;
 
         nRet = pFrame->CallCallback( SalEvent::WheelMouse, &aWheelEvt );
     }
@@ -4315,13 +4315,13 @@ static void ImplHandleMoveMsg(HWND hWnd, LPARAM lParam)
 #ifdef NDEBUG
     (void) lParam;
 #endif
-    SAL_WARN_IF(!IsIconic(hWnd) && pFrame->maGeometry.x() != 
static_cast<sal_Int16>(LOWORD(lParam)),
+    SAL_WARN_IF(!IsIconic(hWnd) && pFrame->GetUnmirroredGeometry().x() != 
static_cast<sal_Int16>(LOWORD(lParam)),
                 "vcl",
-                "Unexpected X: " << pFrame->maGeometry.x() << " instead of "
+                "Unexpected X: " << pFrame->GetUnmirroredGeometry().x() << " 
instead of "
                                  << static_cast<sal_Int16>(LOWORD(lParam)));
-    SAL_WARN_IF(!IsIconic(hWnd) && pFrame->maGeometry.y() != 
static_cast<sal_Int16>(HIWORD(lParam)),
+    SAL_WARN_IF(!IsIconic(hWnd) && pFrame->GetUnmirroredGeometry().y() != 
static_cast<sal_Int16>(HIWORD(lParam)),
                 "vcl",
-                "Unexpected Y: " << pFrame->maGeometry.y() << " instead of "
+                "Unexpected Y: " << pFrame->GetUnmirroredGeometry().y() << " 
instead of "
                                  << static_cast<sal_Int16>(HIWORD(lParam)));
 
     if (GetWindowStyle(hWnd) & WS_VISIBLE)
@@ -4370,8 +4370,8 @@ static void ImplHandleSizeMsg(HWND hWnd, WPARAM wParam, 
LPARAM lParam)
 #ifdef NDEBUG
     (void) lParam;
 #endif
-    assert(pFrame->maGeometry.width() == 
static_cast<sal_Int16>(LOWORD(lParam)));
-    assert(pFrame->maGeometry.height() == 
static_cast<sal_Int16>(HIWORD(lParam)));
+    assert(pFrame->GetWidth() == static_cast<sal_Int16>(LOWORD(lParam)));
+    assert(pFrame->GetHeight() == static_cast<sal_Int16>(HIWORD(lParam)));
 
     pFrame->UpdateFrameState();
 

Reply via email to