vcl/win/window/salframe.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
New commits: commit 0da1cbd18838b91241ded0730d0db12debf4d597 Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Mon Aug 29 13:57:10 2022 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Mon Aug 29 14:31:03 2022 +0200 Don't position dialogs relative to other dialogs When calling setPosSize on a dialog, and there are other dialogs on top of it, the dialog was positioned relative to its parent dialog. Fix this, so that dialogs are always positioned relative to the main window (if there is one). Revert of/Follow up to 8750c812c9b808ee980f7e0ce0e6ce91e75e1424 Change-Id: I69f189865b118f9bc20077d48591fbd9e83b014f diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 79e101057358..cdb18fcc25fb 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -1281,23 +1281,30 @@ void WinSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, nWidth = aWinRect.right - aWinRect.left + 1; nHeight = aWinRect.bottom - aWinRect.top + 1; - if ( !(nPosSize & SWP_NOMOVE) && ::GetParent( mhWnd ) ) + // For dialogs (WS_POPUP && WS_DLGFRAME), we need to find the "real" parent, + // in case multiple dialogs are stacked on each other + // (wo don't want to position the second dialog relative to the first one, but relative to the main window) + HWND hWndParent = ImplGetParentHwnd(mhWnd); + while ( hWndParent && (GetWindowStyle( hWndParent ) & WS_POPUP) && (GetWindowStyle( hWndParent ) & WS_DLGFRAME) ) + { + hWndParent = ::ImplGetParentHwnd( hWndParent ); + } + + if ( !(nPosSize & SWP_NOMOVE) && hWndParent ) { RECT aParentRect; - GetClientRect( ImplGetParentHwnd( mhWnd ), &aParentRect ); + GetClientRect( hWndParent, &aParentRect ); if( AllSettings::GetLayoutRTL() ) nX = (aParentRect.right - aParentRect.left) - nWidth-1 - nX; - //#110386#, do not transform coordinates for system child windows and dialogs - if( !(GetWindowStyle( mhWnd ) & WS_CHILD) && - !(GetWindowStyle( mhWnd ) & WS_DLGFRAME) ) + //#110386#, do not transform coordinates for system child windows + if( !(GetWindowStyle( mhWnd ) & WS_CHILD) ) { POINT aPt; aPt.x = nX; aPt.y = nY; - HWND parentHwnd = ImplGetParentHwnd( mhWnd ); - WinSalFrame* pParentFrame = GetWindowPtr( parentHwnd ); + WinSalFrame* pParentFrame = GetWindowPtr( hWndParent ); if ( pParentFrame && pParentFrame->mnShowState == SW_SHOWMAXIMIZED ) { // #i42485#: parent will be shown maximized in which case @@ -1307,7 +1314,7 @@ void WinSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, aPt.y += pParentFrame->maGeometry.nY; } else - ClientToScreen( parentHwnd, &aPt ); + ClientToScreen( hWndParent, &aPt ); nX = aPt.x; nY = aPt.y;