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

This commit is contained in:
Alexandre Julliard 2008-02-29 13:43:13 +01:00
parent 84d260ec60
commit 5785ee08d0
1 changed files with 15 additions and 41 deletions

View File

@ -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;
}
TRACE( "minimizing win %p/%lx\n", hwnd, data->whole_window );
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 );
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