Alexandre Julliard : winex11.drv:
Store the display file descriptor directly in the server message queue.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 4 12:32:28 CDT 2007
Module: wine
Branch: master
Commit: 072698c9539f5420f0996a3c03ea5f379786578e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=072698c9539f5420f0996a3c03ea5f379786578e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Apr 4 18:02:53 2007 +0200
winex11.drv: Store the display file descriptor directly in the server message queue.
Get rid of a few WaitForMultipleObjectsEx hacks.
---
dlls/user32/message.c | 3 +--
dlls/winex11.drv/event.c | 18 ++++++------------
dlls/winex11.drv/x11drv.h | 1 -
dlls/winex11.drv/x11drv_main.c | 34 +++++++++++++++++++++++++++-------
4 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index bde85d9..f612277 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -3188,13 +3188,12 @@ DWORD WINAPI MsgWaitForMultipleObjectsEx( DWORD count, CONST HANDLE *pHandles,
}
SERVER_END_REQ;
- /* Add the thread event to the handle list */
+ /* add the queue to the handle list */
for (i = 0; i < count; i++) handles[i] = pHandles[i];
handles[count] = get_server_queue_handle();
ReleaseThunkLock( &lock );
ret = USER_Driver->pMsgWaitForMultipleObjectsEx( count+1, handles, timeout, mask, flags );
- if (ret == count+1) ret = count; /* pretend the msg queue is ready */
if (lock) RestoreThunkLock( lock );
return ret;
}
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 0ea1f9c..ab890e9 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -278,32 +278,26 @@ static int process_events( Display *display, ULONG_PTR mask )
DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags )
{
- DWORD i, ret;
+ DWORD ret;
struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
- if (!data || data->process_event_count)
+ if (!data)
{
if (!count && !timeout) return WAIT_TIMEOUT;
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE );
}
- /* check whether only server queue handle was passed in */
- if (count < 2) flags &= ~MWMO_WAITALL;
+ if (data->process_event_count) mask = 0; /* don't process nested events */
data->process_event_count++;
- if (process_events( data->display, mask )) ret = count;
+ if (process_events( data->display, mask )) ret = count - 1;
else if (count || timeout)
{
- HANDLE new_handles[MAXIMUM_WAIT_OBJECTS+1]; /* FIXME! */
-
- for (i = 0; i < count; i++) new_handles[i] = handles[i];
- new_handles[count] = data->display_fd;
-
- ret = WaitForMultipleObjectsEx( count+1, new_handles, flags & MWMO_WAITALL,
+ ret = WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE );
- if (ret == count) process_events( data->display, mask );
+ if (ret == count - 1) process_events( data->display, mask );
}
else ret = WAIT_TIMEOUT;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 4053c2f..8de2e25 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -498,7 +498,6 @@ struct x11drv_escape_set_dce
struct x11drv_thread_data
{
Display *display;
- HANDLE display_fd;
int process_event_count; /* recursion count for event processing */
Cursor cursor; /* current cursor */
Window cursor_window; /* current window that contains the cursor */
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 078a514..8012c2d 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -459,7 +459,6 @@ static void thread_detach(void)
if (data)
{
X11DRV_ResetSelectionOwner();
- CloseHandle( data->display_fd );
wine_tsx11_lock();
if (data->xim) XCloseIM( data->xim );
XCloseDisplay( data->display );
@@ -489,6 +488,32 @@ static void process_detach(void)
}
+/* store the display fd into the message queue */
+static void set_queue_display_fd( Display *display )
+{
+ HANDLE handle;
+ int ret;
+
+ if (wine_server_fd_to_handle( ConnectionNumber(display), GENERIC_READ | SYNCHRONIZE, 0, &handle ))
+ {
+ MESSAGE( "x11drv: Can't allocate handle for display fd\n" );
+ ExitProcess(1);
+ }
+ SERVER_START_REQ( set_queue_fd )
+ {
+ req->handle = handle;
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ if (ret)
+ {
+ MESSAGE( "x11drv: Can't store handle for display fd\n" );
+ ExitProcess(1);
+ }
+ CloseHandle( handle );
+}
+
+
/***********************************************************************
* X11DRV thread initialisation routine
*/
@@ -535,12 +560,7 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
else if (!(data->xim = X11DRV_SetupXIM( data->display, input_style )))
WARN("Input Method is not available\n");
- if (wine_server_fd_to_handle( ConnectionNumber(data->display), GENERIC_READ | SYNCHRONIZE,
- 0, &data->display_fd ))
- {
- MESSAGE( "x11drv: Can't allocate handle for display fd\n" );
- ExitProcess(1);
- }
+ set_queue_display_fd( data->display );
data->process_event_count = 0;
data->cursor = None;
data->cursor_window = None;
More information about the wine-cvs
mailing list