From a442d3b46db31fbaa8ee7aad64373bcb951bda7f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 2 Apr 2008 15:58:59 +0200 Subject: [PATCH] winex11: Rely on PropertyNotify events instead of Map/UnmapNotify to detect iconification. --- dlls/winex11.drv/event.c | 55 +++++++++++++++++++++++++++++++++++++---- dlls/winex11.drv/winpos.c | 62 ----------------------------------------------- dlls/winex11.drv/x11drv.h | 1 - 3 files changed, 50 insertions(+), 68 deletions(-) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 1bcec8c8837..c57d497e81c 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -104,7 +104,7 @@ static struct event_handler handlers[MAX_EVENT_HANDLERS] = /* VisibilityNotify */ /* CreateNotify */ { DestroyNotify, X11DRV_DestroyNotify }, - { UnmapNotify, X11DRV_UnmapNotify }, + /* UnmapNotify */ { MapNotify, X11DRV_MapNotify }, /* MapRequest */ /* ReparentNotify */ @@ -123,7 +123,7 @@ static struct event_handler handlers[MAX_EVENT_HANDLERS] = { MappingNotify, X11DRV_MappingNotify }, }; -static int nb_event_handlers = 19; /* change this if you add handlers above */ +static int nb_event_handlers = 18; /* change this if you add handlers above */ /* return the name of an X event */ @@ -691,7 +691,8 @@ int get_window_wm_state( Display *display, struct x11drv_win_data *data ) * * Handle a PropertyNotify for WM_STATE. */ -static void handle_wm_state_notify( struct x11drv_win_data *data, XPropertyEvent *event ) +static void handle_wm_state_notify( struct x11drv_win_data *data, XPropertyEvent *event, + BOOL update_window ) { switch(event->state) { @@ -710,6 +711,50 @@ static void handle_wm_state_notify( struct x11drv_win_data *data, XPropertyEvent } break; } + + if (!update_window || !data->managed || !data->mapped) return; + + if (data->iconic && data->wm_state == NormalState) /* restore window */ + { + int x, y; + unsigned int width, height, border, depth; + Window root, top; + WINDOWPLACEMENT wp; + RECT rect; + + /* FIXME: hack */ + wine_tsx11_lock(); + XGetGeometry( event->display, data->whole_window, &root, &x, &y, &width, &height, + &border, &depth ); + XTranslateCoordinates( event->display, data->whole_window, root, 0, 0, &x, &y, &top ); + wine_tsx11_unlock(); + rect.left = x; + rect.top = y; + rect.right = x + width; + rect.bottom = y + height; + OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top ); + X11DRV_X_to_window_rect( data, &rect ); + + wp.length = sizeof(wp); + GetWindowPlacement( data->hwnd, &wp ); + wp.flags = 0; + wp.showCmd = SW_RESTORE; + wp.rcNormalPosition = rect; + + TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window ); + data->iconic = FALSE; + data->lock_changes++; + SetWindowPlacement( data->hwnd, &wp ); + data->lock_changes--; + } + else if (!data->iconic && data->wm_state == IconicState) + { + TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window ); + data->iconic = TRUE; + data->lock_changes++; + ShowWindow( data->hwnd, SW_MINIMIZE ); + data->lock_changes--; + } } @@ -724,7 +769,7 @@ static void EVENT_PropertyNotify( HWND hwnd, XEvent *xev ) if (!hwnd) return; if (!(data = X11DRV_get_win_data( hwnd ))) return; - if (event->atom == x11drv_atom(WM_STATE)) handle_wm_state_notify( data, event ); + if (event->atom == x11drv_atom(WM_STATE)) handle_wm_state_notify( data, event, TRUE ); } @@ -762,7 +807,7 @@ void wait_for_withdrawn_state( Display *display, struct x11drv_win_data *data, B else { wine_tsx11_unlock(); - handle_wm_state_notify( data, &event.xproperty ); + handle_wm_state_notify( data, &event.xproperty, FALSE ); wine_tsx11_lock(); } } diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c index 13ec6f16871..e60d42afcc1 100644 --- a/dlls/winex11.drv/winpos.c +++ b/dlls/winex11.drv/winpos.c @@ -437,7 +437,6 @@ void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags, void X11DRV_MapNotify( HWND hwnd, XEvent *event ) { struct x11drv_win_data *data; - int state; if (!(data = X11DRV_get_win_data( hwnd ))) return; if (!data->mapped) return; @@ -446,71 +445,10 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event ) { HWND hwndFocus = GetFocus(); if (hwndFocus && IsChild( hwnd, hwndFocus )) X11DRV_SetFocus(hwndFocus); /* FIXME */ - return; } - if (!data->iconic) return; - - state = get_window_wm_state( event->xmap.display, data ); - if (state == NormalState) - { - int x, y; - unsigned int width, height, border, depth; - Window root, top; - WINDOWPLACEMENT wp; - RECT rect; - - /* FIXME: hack */ - wine_tsx11_lock(); - XGetGeometry( event->xmap.display, data->whole_window, &root, &x, &y, &width, &height, - &border, &depth ); - XTranslateCoordinates( event->xmap.display, data->whole_window, root, 0, 0, &x, &y, &top ); - wine_tsx11_unlock(); - rect.left = x; - rect.top = y; - rect.right = x + width; - rect.bottom = y + height; - OffsetRect( &rect, virtual_screen_rect.left, virtual_screen_rect.top ); - X11DRV_X_to_window_rect( data, &rect ); - - wp.length = sizeof(wp); - GetWindowPlacement( hwnd, &wp ); - wp.flags = 0; - wp.showCmd = SW_RESTORE; - wp.rcNormalPosition = rect; - - TRACE( "restoring win %p/%lx\n", hwnd, data->whole_window ); - data->iconic = FALSE; - data->lock_changes++; - SetWindowPlacement( hwnd, &wp ); - data->lock_changes--; - } - else TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state ); } -/********************************************************************** - * X11DRV_UnmapNotify - */ -void X11DRV_UnmapNotify( HWND hwnd, XEvent *event ) -{ - struct x11drv_win_data *data; - int state; - - if (!(data = X11DRV_get_win_data( hwnd ))) return; - if (!data->managed || !data->mapped || data->iconic) return; - - state = get_window_wm_state( event->xunmap.display, data ); - if (state == IconicState) - { - TRACE( "minimizing win %p/%lx\n", hwnd, data->whole_window ); - data->iconic = TRUE; - data->lock_changes++; - ShowWindow( hwnd, SW_MINIMIZE ); - data->lock_changes--; - } - else TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state ); -} - struct desktop_resize_data { RECT old_screen_rect; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 52670e8d225..fbf9ebcb82d 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -630,7 +630,6 @@ extern void X11DRV_KeymapNotify( HWND hwnd, XEvent *event ); extern void X11DRV_Expose( HWND hwnd, XEvent *event ); extern void X11DRV_DestroyNotify( HWND hwnd, XEvent *event ); extern void X11DRV_MapNotify( HWND hwnd, XEvent *event ); -extern void X11DRV_UnmapNotify( HWND hwnd, XEvent *event ); extern void X11DRV_ConfigureNotify( HWND hwnd, XEvent *event ); extern void X11DRV_SelectionRequest( HWND hWnd, XEvent *event ); extern void X11DRV_SelectionClear( HWND hWnd, XEvent *event ); -- 2.11.4.GIT