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,38 +1935,6 @@ void wxWindowMSW::DoClientToScreen(int *x, int *y) const
bool bool
wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height) wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
{ {
#if wxUSE_DEFERRED_SIZING
// 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();
HDWP hdwp = parent ? (HDWP)parent->m_hDWP : NULL;
if ( hdwp )
{
hdwp = ::DeferWindowPos(hdwp, (HWND)hwnd, NULL, x, y, width, height,
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
if ( !hdwp )
{
wxLogLastError(wxT("DeferWindowPos"));
}
}
if ( parent )
{
// hdwp must be updated as it may have been changed
parent->m_hDWP = (WXHANDLE)hdwp;
}
if ( hdwp )
{
// did deferred move, remember new coordinates of the window as they're
// different from what Windows would return for it
return true;
}
// 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 // 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 // RTL window and changing width without moving the position would enlarge the
// window in the wrong direction, so we need to adjust for it // window in the wrong direction, so we need to adjust for it
@@ -1986,6 +1954,41 @@ wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
} }
} }
#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 = GetParent();
HDWP hdwp = parent ? (HDWP)parent->m_hDWP : NULL;
if ( hdwp )
{
hdwp = ::DeferWindowPos(hdwp, (HWND)hwnd, NULL, x, y, width, height,
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
if ( !hdwp )
{
wxLogLastError(wxT("DeferWindowPos"));
}
}
if ( parent )
{
// hdwp must be updated as it may have been changed
parent->m_hDWP = (WXHANDLE)hdwp;
}
if ( hdwp )
{
// did deferred move, remember new coordinates of the window as they're
// different from what Windows would return for it
return true;
}
// otherwise (or if deferring failed) move the window in place immediately
}
#endif // wxUSE_DEFERRED_SIZING
if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) ) if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) )
{ {
wxLogLastError(wxT("MoveWindow")); wxLogLastError(wxT("MoveWindow"));