From 5977c723259b76c0d08e6a6cb77f78f08e806028 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 13 Mar 2008 13:35:02 +0100 Subject: [PATCH] winex11: Store a pointer to the X11 event currently being handled instead of a simple count. --- dlls/winex11.drv/event.c | 11 +++++++---- dlls/winex11.drv/x11drv.h | 2 +- dlls/winex11.drv/x11drv_main.c | 12 ++---------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index b85d0f1e1d2..cd6eaf628a4 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -291,6 +291,8 @@ static inline void call_event_handler( Display *display, XEvent *event ) { HWND hwnd; x11drv_event_handler handler; + XEvent *prev; + struct x11drv_thread_data *thread_data; if (!(handler = find_handler( event->type ))) { @@ -305,7 +307,11 @@ static inline void call_event_handler( Display *display, XEvent *event ) TRACE( "%s for hwnd/window %p/%lx\n", dbgstr_event( event->type ), hwnd, event->xany.window ); wine_tsx11_unlock(); + thread_data = x11drv_thread_data(); + prev = thread_data->current_event; + thread_data->current_event = event; handler( hwnd, event ); + thread_data->current_event = prev; wine_tsx11_lock(); } @@ -364,9 +370,7 @@ DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, timeout, flags & MWMO_ALERTABLE ); } - if (data->process_event_count) mask = 0; /* don't process nested events */ - - data->process_event_count++; + if (data->current_event) mask = 0; /* don't process nested events */ if (process_events( data->display, filter_event, mask )) ret = count - 1; else if (count || timeout) @@ -377,7 +381,6 @@ DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, } else ret = WAIT_TIMEOUT; - data->process_event_count--; return ret; } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a685e64d644..52670e8d225 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -499,7 +499,7 @@ struct x11drv_escape_set_drawable struct x11drv_thread_data { Display *display; - int process_event_count; /* recursion count for event processing */ + XEvent *current_event; /* event currently being processed */ Cursor cursor; /* current cursor */ Window cursor_window; /* current window that contains the cursor */ Window grab_window; /* window that currently grabs the mouse */ diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 0ea3a1b94b2..d445e64405a 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -617,7 +617,7 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) { struct x11drv_thread_data *data; - if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) ))) + if (!(data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data) ))) { ERR( "could not create data\n" ); ExitProcess(1); @@ -651,18 +651,10 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) if (TRACE_ON(synchronous)) XSynchronize( data->display, True ); wine_tsx11_unlock(); - if (!use_xim) - data->xim = NULL; - else if (!(data->xim = X11DRV_SetupXIM( data->display, input_style ))) + if (use_xim && !(data->xim = X11DRV_SetupXIM( data->display, input_style ))) WARN("Input Method is not available\n"); set_queue_display_fd( data->display ); - data->process_event_count = 0; - data->cursor = None; - data->cursor_window = None; - data->grab_window = None; - data->last_focus = 0; - data->selection_wnd = 0; TlsSetValue( thread_data_tls_index, data ); X11DRV_SetCursor( NULL ); return data;