From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/window.c | 96 ++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 52 deletions(-)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index c6c44bcb59a..11304531f69 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1265,6 +1265,46 @@ static void window_set_net_wm_state( struct x11drv_win_data *data, UINT new_stat } }
+static void window_set_config( struct x11drv_win_data *data, const RECT *new_rect, BOOL above ) +{ + UINT style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ), mask = 0; + XWindowChanges changes; + + if (!data->whole_window) return; /* no window, nothing to update */ + + /* resizing a managed maximized window is not allowed */ + if (!(style & WS_MAXIMIZE) || !data->managed) + { + changes.width = new_rect->right - new_rect->left; + changes.height = new_rect->bottom - new_rect->top; + /* if window rect is empty force size to 1x1 */ + if (changes.width <= 0 || changes.height <= 0) changes.width = changes.height = 1; + if (changes.width > 65535) changes.width = 65535; + if (changes.height > 65535) changes.height = 65535; + mask |= CWWidth | CWHeight; + } + + /* only the size is allowed to change for the desktop window or systray docked windows */ + if (data->whole_window != root_window && !data->embedded) + { + POINT pt = virtual_screen_to_root( new_rect->left, new_rect->top ); + changes.x = pt.x; + changes.y = pt.y; + mask |= CWX | CWY; + } + + if (above) + { + changes.stack_mode = Above; + mask |= CWStackMode; + } + + data->configure_serial = NextRequest( data->display ); + TRACE( "window %p/%lx, requesting config %s above %u, serial %lu\n", data->hwnd, data->whole_window, + wine_dbgstr_rect(new_rect), above, data->configure_serial ); + XReconfigureWMWindow( data->display, data->whole_window, data->vis.screen, mask, &changes ); +} + /*********************************************************************** * update_net_wm_states */ @@ -1538,43 +1578,17 @@ static void sync_window_position( struct x11drv_win_data *data, UINT swp_flags ) { DWORD style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); DWORD ex_style = NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE ); - XWindowChanges changes; - unsigned int mask = 0; + BOOL above = FALSE;
if (data->managed && data->iconic) return;
- /* resizing a managed maximized window is not allowed */ - if (!(style & WS_MAXIMIZE) || !data->managed) - { - changes.width = data->rects.visible.right - data->rects.visible.left; - changes.height = data->rects.visible.bottom - data->rects.visible.top; - /* if window rect is empty force size to 1x1 */ - if (changes.width <= 0 || changes.height <= 0) changes.width = changes.height = 1; - if (changes.width > 65535) changes.width = 65535; - if (changes.height > 65535) changes.height = 65535; - mask |= CWWidth | CWHeight; - } - - /* only the size is allowed to change for the desktop window or systray docked windows */ - if (data->whole_window != root_window && !data->embedded) - { - POINT pt = virtual_screen_to_root( data->rects.visible.left, data->rects.visible.top ); - changes.x = pt.x; - changes.y = pt.y; - mask |= CWX | CWY; - } - if (!(swp_flags & SWP_NOZORDER) || (swp_flags & SWP_SHOWWINDOW)) { /* find window that this one must be after */ HWND prev = NtUserGetWindowRelative( data->hwnd, GW_HWNDPREV ); while (prev && !(NtUserGetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE)) prev = NtUserGetWindowRelative( prev, GW_HWNDPREV ); - if (!prev) /* top child */ - { - changes.stack_mode = Above; - mask |= CWStackMode; - } + if (!prev) above = TRUE; /* top child */ /* should use stack_mode Below but most window managers don't get it right */ /* and Above with a sibling doesn't work so well either, so we ignore it */ } @@ -1582,14 +1596,7 @@ static void sync_window_position( struct x11drv_win_data *data, UINT swp_flags ) set_size_hints( data, style ); set_mwm_hints( data, style, ex_style ); update_net_wm_states( data ); - data->configure_serial = NextRequest( data->display ); - XReconfigureWMWindow( data->display, data->whole_window, data->vis.screen, mask, &changes ); - - TRACE( "win %p/%lx pos %d,%d,%dx%d after %lx changes=%x serial=%lu\n", - data->hwnd, data->whole_window, (int)data->rects.visible.left, (int)data->rects.visible.top, - (int)(data->rects.visible.right - data->rects.visible.left), - (int)(data->rects.visible.bottom - data->rects.visible.top), - changes.sibling, mask, data->configure_serial ); + window_set_config( data, &data->rects.visible, above ); }
@@ -3072,22 +3079,7 @@ LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) { /* update the full screen state */ update_net_wm_states( data ); - - if (data->whole_window) - { - /* sync window position with the new virtual screen rect */ - POINT old_pos = {.x = data->rects.visible.left - wp, .y = data->rects.visible.top - lp}; - POINT pos = virtual_screen_to_root( data->rects.visible.left, data->rects.visible.top ); - XWindowChanges changes = {.x = pos.x, .y = pos.y}; - UINT mask = 0; - - if (old_pos.x != pos.x) mask |= CWX; - if (old_pos.y != pos.y) mask |= CWY; - - data->configure_serial = NextRequest( data->display ); - XReconfigureWMWindow( data->display, data->whole_window, data->vis.screen, mask, &changes ); - } - + window_set_config( data, &data->rects.visible, FALSE ); release_win_data( data ); } return 0;