winex11: Move handling of WM_STATE changes to a separate function, and call it directly from wait_from_withdrawn_state.

This commit is contained in:
Alexandre Julliard 2008-04-02 15:55:25 +02:00
parent 997bea9b89
commit f89aa12829
1 changed files with 40 additions and 16 deletions

View File

@ -687,28 +687,19 @@ int get_window_wm_state( Display *display, struct x11drv_win_data *data )
/***********************************************************************
* EVENT_PropertyNotify
* handle_wm_state_notify
*
* Handle a PropertyNotify for WM_STATE.
*/
static void EVENT_PropertyNotify( HWND hwnd, XEvent *xev )
static void handle_wm_state_notify( struct x11drv_win_data *data, XPropertyEvent *event )
{
XPropertyEvent *event = &xev->xproperty;
struct x11drv_win_data *data;
if (!hwnd) return;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
switch(event->state)
{
case PropertyDelete:
if (event->atom == x11drv_atom(WM_STATE))
{
data->wm_state = WithdrawnState;
TRACE( "%p/%lx: WM_STATE deleted\n", data->hwnd, data->whole_window );
}
data->wm_state = WithdrawnState;
TRACE( "%p/%lx: WM_STATE deleted\n", data->hwnd, data->whole_window );
break;
case PropertyNewValue:
if (event->atom == x11drv_atom(WM_STATE))
{
int new_state = get_window_wm_state( event->display, data );
if (new_state != -1 && new_state != data->wm_state)
@ -722,6 +713,21 @@ static void EVENT_PropertyNotify( HWND hwnd, XEvent *xev )
}
/***********************************************************************
* EVENT_PropertyNotify
*/
static void EVENT_PropertyNotify( HWND hwnd, XEvent *xev )
{
XPropertyEvent *event = &xev->xproperty;
struct x11drv_win_data *data;
if (!hwnd) return;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
if (event->atom == x11drv_atom(WM_STATE)) handle_wm_state_notify( data, event );
}
/* event filter to wait for a WM_STATE change notification on a window */
static Bool is_wm_state_notify( Display *display, XEvent *event, XPointer arg )
{
@ -744,7 +750,25 @@ void wait_for_withdrawn_state( Display *display, struct x11drv_win_data *data, B
while (data->whole_window && ((data->wm_state == WithdrawnState) == !set))
{
if (!process_events( display, is_wm_state_notify, data->whole_window ))
XEvent event;
int count = 0;
wine_tsx11_lock();
while (XCheckIfEvent( display, &event, is_wm_state_notify, (char *)data->whole_window ))
{
count++;
if (XFilterEvent( &event, None )) continue; /* filtered, ignore it */
if (event.type == DestroyNotify) call_event_handler( display, &event );
else
{
wine_tsx11_unlock();
handle_wm_state_notify( data, &event.xproperty );
wine_tsx11_lock();
}
}
wine_tsx11_unlock();
if (!count)
{
struct pollfd pfd;
int timeout = end - GetTickCount();