summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-08-29 13:57:10 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-08-29 14:31:03 +0200
commit0da1cbd18838b91241ded0730d0db12debf4d597 (patch)
tree34e72ef227173ddaea5bbf2b1dd2d75911ff80fb /vcl
parentbff9f605b3c9ea2eec7f7fd5a2f7cc356c86956c (diff)
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
Diffstat (limited to 'vcl')
-rw-r--r--vcl/win/window/salframe.cxx23
1 files changed, 15 insertions, 8 deletions
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;