Shuffle code a bit to make it easier to skip deferring window position

This commit is contained in:
Cătălin Răceanu
2018-04-12 05:22:55 +03:00
parent 4cdd3001c2
commit f751f15b9f

View File

@@ -1935,10 +1935,31 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const
bool
wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
{
// toplevel window's coordinates are mirrored if the TLW is a child of another
// RTL window and changing width without moving the position would enlarge the
// window in the wrong direction, so we need to adjust for it
if ( IsTopLevel() )
{
// note that this may be different from GetParent() for wxDialogs
HWND tlwParent = ::GetParent((HWND)hwnd);
if ( tlwParent && (::GetWindowLong(tlwParent, GWL_EXSTYLE) & WS_EX_LAYOUTRTL) != 0 )
{
RECT old;
::GetWindowRect((HWND) hwnd, &old);
if ( old.left == x && old.right - old.left != width )
{
x -= width - (old.right - old.left);
}
// else: not a simple resize
}
}
#if wxUSE_DEFERRED_SIZING
else
{
// if our parent had prepared a defer window handle for us, use it (unless
// we are a top level window)
wxWindowMSW * const parent = IsTopLevel() ? NULL : GetParent();
wxWindowMSW * const parent = GetParent();
HDWP hdwp = parent ? (HDWP)parent->m_hDWP : NULL;
if ( hdwp )
@@ -1965,27 +1986,9 @@ wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
}
// otherwise (or if deferring failed) move the window in place immediately
}
#endif // wxUSE_DEFERRED_SIZING
// toplevel window's coordinates are mirrored if the TLW is a child of another
// RTL window and changing width without moving the position would enlarge the
// window in the wrong direction, so we need to adjust for it
if ( IsTopLevel() )
{
// note that this may be different from GetParent() for wxDialogs
HWND tlwParent = ::GetParent((HWND)hwnd);
if ( tlwParent && (::GetWindowLong(tlwParent, GWL_EXSTYLE) & WS_EX_LAYOUTRTL) != 0 )
{
RECT old;
::GetWindowRect((HWND) hwnd, &old);
if ( old.left == x && old.right - old.left != width )
{
x -= width - (old.right - old.left);
}
// else: not a simple resize
}
}
if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) )
{
wxLogLastError(wxT("MoveWindow"));