From 5785ee08d06db70d3e187cf31add2739b3a36b9e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 29 Feb 2008 13:43:13 +0100 Subject: [PATCH] winex11: Avoid accessing the internals of the window structure in the Map/UnmapNotify handlers. --- dlls/winex11.drv/winpos.c | 56 +++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c index 4f3c3ad9d8d..f1f41114146 100644 --- a/dlls/winex11.drv/winpos.c +++ b/dlls/winex11.drv/winpos.c @@ -440,7 +440,6 @@ void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags, void X11DRV_MapNotify( HWND hwnd, XEvent *event ) { struct x11drv_win_data *data; - WND *win; int state; if (!(data = X11DRV_get_win_data( hwnd ))) return; @@ -454,20 +453,13 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event ) } state = get_window_wm_state( event->xmap.display, data ); - if (state != NormalState) - { - TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state ); - return; - } - data->iconic = FALSE; - - if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) == (WS_VISIBLE|WS_MINIMIZE)) + if (state == NormalState) { int x, y; unsigned int width, height, border, depth; Window root, top; + WINDOWPLACEMENT wp; RECT rect; - LONG style = WS_VISIBLE; /* FIXME: hack */ wine_tsx11_lock(); @@ -482,17 +474,18 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event ) OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top ); X11DRV_X_to_window_rect( data, &rect ); - if (!(win = WIN_GetPtr( hwnd ))) return; - if (win->flags & WIN_RESTORE_MAX) style |= WS_MAXIMIZE; - WIN_SetStyle( hwnd, style, WS_MINIMIZE ); - WIN_ReleasePtr( win ); + wp.length = sizeof(wp); + wp.flags = 0; + wp.showCmd = SW_RESTORE; + wp.rcNormalPosition = rect; - SendMessageW( hwnd, WM_SHOWWINDOW, SW_RESTORE, 0 ); + TRACE( "restoring win %p/%lx\n", hwnd, data->whole_window ); + data->iconic = FALSE; data->lock_changes++; - SetWindowPos( hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_STATECHANGED ); + SetWindowPlacement( hwnd, &wp ); data->lock_changes--; } + else TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state ); } @@ -502,40 +495,21 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event ) void X11DRV_UnmapNotify( HWND hwnd, XEvent *event ) { struct x11drv_win_data *data; - WND *win; int state; if (!(data = X11DRV_get_win_data( hwnd ))) return; if (!data->managed || !data->mapped) return; state = get_window_wm_state( event->xunmap.display, data ); - if (state != IconicState) + if (state == IconicState) { - TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state ); - return; - } - data->iconic = TRUE; - - if (!(win = WIN_GetPtr( hwnd ))) return; - - if ((win->dwStyle & WS_VISIBLE) && X11DRV_is_window_rect_mapped( &win->rectWindow )) - { - if (win->dwStyle & WS_MAXIMIZE) - win->flags |= WIN_RESTORE_MAX; - else if (!(win->dwStyle & WS_MINIMIZE)) - win->flags &= ~WIN_RESTORE_MAX; - - WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE ); - WIN_ReleasePtr( win ); - - EndMenu(); - SendMessageW( hwnd, WM_SHOWWINDOW, SW_MINIMIZE, 0 ); + TRACE( "minimizing win %p/%lx\n", hwnd, data->whole_window ); + data->iconic = TRUE; data->lock_changes++; - SetWindowPos( hwnd, 0, 0, 0, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), - SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_STATECHANGED ); + ShowWindow( hwnd, SW_MINIMIZE ); data->lock_changes--; } - else WIN_ReleasePtr( win ); + else TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state ); } struct desktop_resize_data -- 2.11.4.GIT