diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2022-06-03 00:24:24 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2022-06-04 20:25:54 +0200 |
commit | 428cc8da98ddb73f8abeaa3bddb555f3bd896a29 (patch) | |
tree | 7e1a5efd09e10800a5f7f09900c024db6a8a5f71 | |
parent | 434d471e9b8e54626af332974268ffd8fce4a78e (diff) |
WIN refactor geometry updating
Change-Id: I34e710c022e6362dc2381327eb896610c35bcbf0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135425
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r-- | vcl/win/window/salframe.cxx | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 6f3b3ca507e5..2ae47ec57630 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -131,6 +131,22 @@ bool WinSalFrame::mbInReparent = false; static void UpdateFrameGeometry( HWND hWnd, WinSalFrame* pFrame ); static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* pParentRect = nullptr ); +static void UpdateGeometry(WinSalFrame* pFrame, RECT& aRect) +{ + RECT aRect2 = aRect; + AdjustWindowRectEx(&aRect2, GetWindowStyle(pFrame->mhWnd), + FALSE, GetWindowExStyle(pFrame->mhWnd)); + tools::Long nTopDeco = abs(aRect.top - aRect2.top); + tools::Long nLeftDeco = abs(aRect.left - aRect2.left); + tools::Long nBottomDeco = abs(aRect.bottom - aRect2.bottom); + tools::Long nRightDeco = abs(aRect.right - aRect2.right); + + pFrame->maState.mnX = aRect.left + nLeftDeco; + pFrame->maState.mnY = aRect.top + nTopDeco; + pFrame->maState.mnWidth = aRect.right - aRect.left - nLeftDeco - nRightDeco; + pFrame->maState.mnHeight = aRect.bottom - aRect.top - nTopDeco - nBottomDeco; +} + static void ImplSaveFrameState( WinSalFrame* pFrame ) { // save position, size and state for GetWindowState() @@ -154,42 +170,15 @@ static void ImplSaveFrameState( WinSalFrame* pFrame ) WINDOWPLACEMENT aPlacement; aPlacement.length = sizeof(aPlacement); if( GetWindowPlacement( pFrame->mhWnd, &aPlacement ) ) - { - RECT aRect = aPlacement.rcNormalPosition; - RECT aRect2 = aRect; - AdjustWindowRectEx( &aRect2, GetWindowStyle( pFrame->mhWnd ), - FALSE, GetWindowExStyle( pFrame->mhWnd ) ); - tools::Long nTopDeco = abs( aRect.top - aRect2.top ); - tools::Long nLeftDeco = abs( aRect.left - aRect2.left ); - tools::Long nBottomDeco = abs( aRect.bottom - aRect2.bottom ); - tools::Long nRightDeco = abs( aRect.right - aRect2.right ); - - pFrame->maState.mnX = aRect.left + nLeftDeco; - pFrame->maState.mnY = aRect.top + nTopDeco; - pFrame->maState.mnWidth = aRect.right - aRect.left - nLeftDeco - nRightDeco; - pFrame->maState.mnHeight = aRect.bottom - aRect.top - nTopDeco - nBottomDeco; - } + UpdateGeometry(pFrame, aPlacement.rcNormalPosition); } else { RECT aRect; GetWindowRect( pFrame->mhWnd, &aRect ); - - // to be consistent with Unix, the frame state is without(!) decoration - RECT aRect2 = aRect; - AdjustWindowRectEx( &aRect2, GetWindowStyle( pFrame->mhWnd ), - FALSE, GetWindowExStyle( pFrame->mhWnd ) ); - tools::Long nTopDeco = abs( aRect.top - aRect2.top ); - tools::Long nLeftDeco = abs( aRect.left - aRect2.left ); - tools::Long nBottomDeco = abs( aRect.bottom - aRect2.bottom ); - tools::Long nRightDeco = abs( aRect.right - aRect2.right ); + UpdateGeometry(pFrame, aRect); pFrame->maState.mnState &= ~WindowStateState(WindowStateState::Minimized | WindowStateState::Maximized); - // subtract decoration - pFrame->maState.mnX = aRect.left+nLeftDeco; - pFrame->maState.mnY = aRect.top+nTopDeco; - pFrame->maState.mnWidth = aRect.right-aRect.left-nLeftDeco-nRightDeco; - pFrame->maState.mnHeight = aRect.bottom-aRect.top-nTopDeco-nBottomDeco; if ( bVisible ) pFrame->mnShowState = SW_SHOWNORMAL; pFrame->mbRestoreMaximize = false; |