Alexandre Julliard : winex11: Avoid accessing the internals of the window structure in the Map/ UnmapNotify handlers.

Alexandre Julliard julliard at winehq.org
Fri Feb 29 14:20:34 CST 2008


Module: wine
Branch: master
Commit: 5785ee08d06db70d3e187cf31add2739b3a36b9e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5785ee08d06db70d3e187cf31add2739b3a36b9e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Feb 29 13:43:13 2008 +0100

winex11: Avoid accessing the internals of the window structure in the Map/UnmapNotify handlers.

---

 dlls/winex11.drv/winpos.c |   56 ++++++++++++---------------------------------
 1 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c
index 4f3c3ad..f1f4111 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




More information about the wine-cvs mailing list