mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:54:13 +00:00
winex11.drv: Store the display file descriptor directly in the server message queue.
Get rid of a few WaitForMultipleObjectsEx hacks.
This commit is contained in:
parent
0cb29f47ca
commit
072698c953
4 changed files with 34 additions and 22 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue