Commit cf1be587 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Remove the remaining X11 locking calls.

parent 26fb3d4a
......@@ -112,15 +112,15 @@ static Pixmap BRUSH_DitherColor( COLORREF color, int depth)
Pixmap pixmap;
GC gc;
wine_tsx11_lock();
XLockDisplay( gdi_display );
if (!ditherImage)
{
ditherImage = XCreateImage( gdi_display, visual, depth, ZPixmap, 0,
NULL, MATRIX_SIZE, MATRIX_SIZE, 32, 0 );
if (!ditherImage)
{
wine_tsx11_unlock();
ERR("Could not create dither image\n");
XUnlockDisplay( gdi_display );
return 0;
}
ditherImage->data = HeapAlloc( GetProcessHeap(), 0,
......@@ -152,7 +152,7 @@ static Pixmap BRUSH_DitherColor( COLORREF color, int depth)
gc = XCreateGC( gdi_display, pixmap, 0, NULL );
XPutImage( gdi_display, pixmap, gc, ditherImage, 0, 0, 0, 0, MATRIX_SIZE, MATRIX_SIZE );
XFreeGC( gdi_display, gc );
wine_tsx11_unlock();
XUnlockDisplay( gdi_display );
return pixmap;
}
......
......@@ -2157,11 +2157,9 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(Display *display, LPCLIPBOARDINFO
/*
* Query the selection owner for the TARGETS property
*/
wine_tsx11_lock();
if ((use_primary_selection && XGetSelectionOwner(display,XA_PRIMARY)) ||
XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{
wine_tsx11_unlock();
if (use_primary_selection && (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, x11drv_atom(TARGETS), &xe)))
selectionCacheSrc = XA_PRIMARY;
else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), x11drv_atom(TARGETS), &xe))
......@@ -2190,24 +2188,13 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(Display *display, LPCLIPBOARDINFO
}
}
}
else /* No selection owner so report 0 targets available */
{
wine_tsx11_unlock();
return 0;
}
else return 0; /* No selection owner so report 0 targets available */
/* Read the TARGETS property contents */
wine_tsx11_lock();
if(XGetWindowProperty(display, xe.xselection.requestor, xe.xselection.property,
if (!XGetWindowProperty(display, xe.xselection.requestor, xe.xselection.property,
0, 0x3FFF, True, AnyPropertyType/*XA_ATOM*/, &atype, &aformat, &cSelectionTargets,
&remain, (unsigned char**)&targetList) != Success)
{
wine_tsx11_unlock();
WARN("Failed to read TARGETS property\n");
}
else
{
wine_tsx11_unlock();
TRACE("Type %lx,Format %d,nItems %ld, Remain %ld\n",
atype, aformat, cSelectionTargets, remain);
/*
......@@ -2234,6 +2221,7 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(Display *display, LPCLIPBOARDINFO
/* Free the list of targets */
XFree(targetList);
}
else WARN("Failed to read TARGETS property\n");
return cSelectionTargets;
}
......@@ -2339,11 +2327,9 @@ static BOOL X11DRV_CLIPBOARD_GetProperty(Display *display, Window w, Atom prop,
for (;;)
{
wine_tsx11_lock();
if (XGetWindowProperty(display, w, prop, pos, INT_MAX / 4, False,
AnyPropertyType, atype, &aformat, &nitems, &remain, &buffer) != Success)
{
wine_tsx11_unlock();
WARN("Failed to read property\n");
HeapFree( GetProcessHeap(), 0, val );
return FALSE;
......@@ -2356,14 +2342,12 @@ static BOOL X11DRV_CLIPBOARD_GetProperty(Display *display, Window w, Atom prop,
if (!*data)
{
XFree( buffer );
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, val );
return FALSE;
}
val = *data;
memcpy( (int *)val + pos, buffer, count );
XFree( buffer );
wine_tsx11_unlock();
if (!remain)
{
*datasize = pos * sizeof(int) + count;
......@@ -2572,7 +2556,6 @@ static void X11DRV_CLIPBOARD_ReleaseSelection(Display *display, Atom selType, Wi
{
TRACE("Lost clipboard. Check if we need to release PRIMARY\n");
wine_tsx11_lock();
if (selectionWindow == XGetSelectionOwner(display, XA_PRIMARY))
{
TRACE("We still own PRIMARY. Releasing PRIMARY.\n");
......@@ -2580,13 +2563,11 @@ static void X11DRV_CLIPBOARD_ReleaseSelection(Display *display, Atom selType, Wi
}
else
TRACE("We no longer own PRIMARY\n");
wine_tsx11_unlock();
}
else if ((selType == XA_PRIMARY) && (selectionAcquired & S_CLIPBOARD))
{
TRACE("Lost PRIMARY. Check if we need to release CLIPBOARD\n");
wine_tsx11_lock();
if (selectionWindow == XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{
TRACE("We still own CLIPBOARD. Releasing CLIPBOARD.\n");
......@@ -2594,7 +2575,6 @@ static void X11DRV_CLIPBOARD_ReleaseSelection(Display *display, Atom selType, Wi
}
else
TRACE("We no longer own CLIPBOARD\n");
wine_tsx11_unlock();
}
selectionWindow = None;
......@@ -2631,8 +2611,6 @@ static void selection_acquire(void)
owner = thread_selection_wnd();
display = thread_display();
wine_tsx11_lock();
selectionAcquired = 0;
selectionWindow = 0;
......@@ -2649,8 +2627,6 @@ static void selection_acquire(void)
if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (selectionAcquired)
{
selectionWindow = owner;
......@@ -3043,8 +3019,6 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
format->lpDrvExportFunc && format->drvData)
targets[i++] = format->drvData;
wine_tsx11_lock();
if (TRACE_ON(clipboard))
{
unsigned int i;
......@@ -3060,7 +3034,6 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
* in case some apps expect this instead of XA_ATOM */
XChangeProperty(display, requestor, rprop, XA_ATOM, 32,
PropModeReplace, (unsigned char *)targets, cTargets);
wine_tsx11_unlock();
HeapFree(GetProcessHeap(), 0, targets);
......@@ -3102,16 +3075,10 @@ static Atom X11DRV_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent
/* Read the MULTIPLE property contents. This should contain a list of
* (target,property) atom pairs.
*/
wine_tsx11_lock();
if(XGetWindowProperty(display, pevent->requestor, rprop,
0, 0x3FFF, False, AnyPropertyType, &atype,&aformat,
&cTargetPropList, &remain,
(unsigned char**)&targetPropList) != Success)
{
wine_tsx11_unlock();
TRACE("\tCouldn't read MULTIPLE property\n");
}
else
if (!XGetWindowProperty(display, pevent->requestor, rprop,
0, 0x3FFF, False, AnyPropertyType, &atype,&aformat,
&cTargetPropList, &remain,
(unsigned char**)&targetPropList) != Success)
{
if (TRACE_ON(clipboard))
{
......@@ -3120,7 +3087,6 @@ static Atom X11DRV_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent
typeName, aformat, cTargetPropList, remain);
XFree(typeName);
}
wine_tsx11_unlock();
/*
* Make sure we got what we expect.
......@@ -3174,6 +3140,7 @@ static Atom X11DRV_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent
/* Free the list of targets/properties */
XFree(targetPropList);
}
else TRACE("Couldn't read MULTIPLE property\n");
return rprop;
}
......@@ -3246,7 +3213,6 @@ static void X11DRV_HandleSelectionRequest( HWND hWnd, XSelectionRequestEvent *ev
TRACE("\tUpdating property %s, %d bytes\n",
debugstr_format(lpFormat->wFormatID), cBytes);
wine_tsx11_lock();
do
{
int nelements = min(cBytes, 65536);
......@@ -3256,7 +3222,6 @@ static void X11DRV_HandleSelectionRequest( HWND hWnd, XSelectionRequestEvent *ev
cBytes -= nelements;
lpClipData += nelements;
} while (cBytes > 0);
wine_tsx11_unlock();
GlobalUnlock(hClipData);
GlobalFree(hClipData);
......
......@@ -138,8 +138,6 @@ Window CDECL X11DRV_create_desktop( UINT width, UINT height )
TRACE( "%u x %u\n", width, height );
wine_tsx11_lock();
/* Create window */
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | EnterWindowMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask | FocusChangeMask;
......@@ -162,7 +160,6 @@ Window CDECL X11DRV_create_desktop( UINT width, UINT height )
1);
}
XFlush( display );
wine_tsx11_unlock();
if (win != None) X11DRV_init_desktop( win, width, height );
return win;
}
......@@ -230,7 +227,6 @@ static void update_desktop_fullscreen( unsigned int width, unsigned int height)
TRACE("action=%li\n", xev.xclient.data.l[0]);
wine_tsx11_lock();
XSendEvent( display, DefaultRootWindow(display), False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev );
......@@ -238,7 +234,6 @@ static void update_desktop_fullscreen( unsigned int width, unsigned int height)
xev.xclient.data.l[2] = x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ);
XSendEvent( display, DefaultRootWindow(display), False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev );
wine_tsx11_unlock();
}
/***********************************************************************
......
......@@ -366,13 +366,11 @@ static inline void call_event_handler( Display *display, XEvent *event )
TRACE( "%lu %s for hwnd/window %p/%lx\n",
event->xany.serial, 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;
handlers[event->type]( hwnd, event );
thread_data->current_event = prev;
wine_tsx11_lock();
}
......@@ -386,7 +384,6 @@ static int process_events( Display *display, Bool (*filter)(Display*, XEvent*,XP
enum event_merge_action action = MERGE_DISCARD;
prev_event.type = 0;
wine_tsx11_lock();
while (XCheckIfEvent( display, &event, filter, (char *)arg ))
{
count++;
......@@ -442,7 +439,6 @@ static int process_events( Display *display, Bool (*filter)(Display*, XEvent*,XP
if (prev_event.type) call_event_handler( display, &prev_event );
free_event_data( &prev_event );
XFlush( gdi_display );
wine_tsx11_unlock();
if (count) TRACE( "processed %d events\n", count );
return count;
}
......@@ -880,7 +876,6 @@ static BOOL is_net_wm_state_maximized( Display *display, struct x11drv_win_data
if (!data->whole_window) return FALSE;
wine_tsx11_lock();
if (!XGetWindowProperty( display, data->whole_window, x11drv_atom(_NET_WM_STATE), 0,
65536/sizeof(CARD32), False, XA_ATOM, &type, &format, &count,
&remaining, (unsigned char **)&state ))
......@@ -896,7 +891,6 @@ static BOOL is_net_wm_state_maximized( Display *display, struct x11drv_win_data
}
XFree( state );
}
wine_tsx11_unlock();
return (ret == 2);
}
......@@ -1099,7 +1093,6 @@ static int get_window_wm_state( Display *display, struct x11drv_win_data *data )
int format, ret = -1;
unsigned long count, remaining;
wine_tsx11_lock();
if (!XGetWindowProperty( display, data->whole_window, x11drv_atom(WM_STATE), 0,
sizeof(*state)/sizeof(CARD32), False, x11drv_atom(WM_STATE),
&type, &format, &count, &remaining, (unsigned char **)&state ))
......@@ -1108,7 +1101,6 @@ static int get_window_wm_state( Display *display, struct x11drv_win_data *data )
ret = state->state;
XFree( state );
}
wine_tsx11_unlock();
return ret;
}
......@@ -1223,20 +1215,13 @@ void wait_for_withdrawn_state( Display *display, struct x11drv_win_data *data, B
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, FALSE );
wine_tsx11_lock();
}
else handle_wm_state_notify( data, &event.xproperty, FALSE );
}
wine_tsx11_unlock();
if (!count)
{
......
......@@ -176,7 +176,6 @@ static Cursor get_empty_cursor(void)
static Cursor cursor;
static const char data[] = { 0 };
wine_tsx11_lock();
if (!cursor)
{
XColor bg;
......@@ -186,11 +185,12 @@ static Cursor get_empty_cursor(void)
pixmap = XCreateBitmapFromData( gdi_display, root_window, data, 1, 1 );
if (pixmap)
{
cursor = XCreatePixmapCursor( gdi_display, pixmap, pixmap, &bg, &bg, 0, 0 );
Cursor new = XCreatePixmapCursor( gdi_display, pixmap, pixmap, &bg, &bg, 0, 0 );
if (InterlockedCompareExchangePointer( (void **)&cursor, (void *)new, 0 ))
XFreeCursor( gdi_display, new );
XFreePixmap( gdi_display, pixmap );
}
}
wine_tsx11_unlock();
return cursor;
}
......@@ -207,7 +207,7 @@ void set_window_cursor( Window window, HCURSOR handle )
/* try to create it */
if (!(cursor = create_cursor( handle ))) return;
wine_tsx11_lock();
XLockDisplay( gdi_display );
if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&prev ))
{
/* someone else was here first */
......@@ -219,7 +219,7 @@ void set_window_cursor( Window window, HCURSOR handle )
XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor );
TRACE( "cursor %p created %lx\n", handle, cursor );
}
wine_tsx11_unlock();
XUnlockDisplay( gdi_display );
}
XDefineCursor( gdi_display, window, cursor );
......@@ -271,7 +271,6 @@ static void enable_xinput2(void)
}
if (data->xi2_state == xi_unavailable) return;
wine_tsx11_lock();
if (data->xi2_devices) pXIFreeDeviceInfo( data->xi2_devices );
data->xi2_devices = devices = pXIQueryDevice( data->display, XIAllDevices, &data->xi2_device_count );
for (i = 0; i < data->xi2_device_count; ++i)
......@@ -312,8 +311,6 @@ static void enable_xinput2(void)
data->xi2_state = xi_enabled;
}
}
wine_tsx11_unlock();
#endif
}
......@@ -336,7 +333,6 @@ static void disable_xinput2(void)
mask.mask = NULL;
mask.mask_len = 0;
wine_tsx11_lock();
for (i = 0; i < data->xi2_device_count; ++i)
{
if (devices[i].use == XISlavePointer && devices[i].attachment == data->xi2_core_pointer)
......@@ -348,7 +344,6 @@ static void disable_xinput2(void)
pXIFreeDeviceInfo( devices );
data->xi2_devices = NULL;
data->xi2_device_count = 0;
wine_tsx11_unlock();
#endif
}
......@@ -385,7 +380,6 @@ static BOOL grab_clipping_window( const RECT *clip )
TRACE( "clipping to %s win %lx\n", wine_dbgstr_rect(clip), clip_window );
wine_tsx11_lock();
if (!data->clip_hwnd) XUnmapWindow( data->display, clip_window );
XMoveResizeWindow( data->display, clip_window,
clip->left - virtual_screen_rect.left, clip->top - virtual_screen_rect.top,
......@@ -401,7 +395,6 @@ static BOOL grab_clipping_window( const RECT *clip )
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, clip_window, None, CurrentTime ))
clipping_cursor = 1;
wine_tsx11_unlock();
if (!clipping_cursor)
{
......@@ -1202,14 +1195,12 @@ void CDECL X11DRV_DestroyCursorIcon( HCURSOR handle )
{
Cursor cursor;
wine_tsx11_lock();
if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
{
TRACE( "%p xid %lx\n", handle, cursor );
XFreeCursor( gdi_display, cursor );
XDeleteContext( gdi_display, (XID)handle, cursor_context );
}
wine_tsx11_unlock();
}
/***********************************************************************
......@@ -1252,7 +1243,6 @@ BOOL CDECL X11DRV_GetCursorPos(LPPOINT pos)
unsigned int xstate;
BOOL ret;
wine_tsx11_lock();
ret = XQueryPointer( display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &xstate );
if (ret)
{
......@@ -1261,7 +1251,6 @@ BOOL CDECL X11DRV_GetCursorPos(LPPOINT pos)
pos->y = winY + virtual_screen_rect.top;
TRACE( "pointer at (%d,%d) server pos %d,%d\n", pos->x, pos->y, old.x, old.y );
}
wine_tsx11_unlock();
return ret;
}
......@@ -1520,7 +1509,6 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev )
input.u.mi.dx = 0;
input.u.mi.dy = 0;
wine_tsx11_lock();
for (i = 0; i < thread_data->xi2_device_count; ++i)
{
if (devices[i].deviceid != event->deviceid) continue;
......@@ -1551,8 +1539,6 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev )
break;
}
wine_tsx11_unlock();
if (thread_data->warp_serial)
{
if ((long)(xev->serial - thread_data->warp_serial) < 0)
......
......@@ -493,7 +493,6 @@ static BOOL init_systray(void)
}
display = thread_init_display();
wine_tsx11_lock();
if (DefaultScreen( display ) == 0)
systray_atom = x11drv_atom(_NET_SYSTEM_TRAY_S0);
else
......@@ -503,7 +502,6 @@ static BOOL init_systray(void)
systray_atom = XInternAtom( display, systray_buffer, False );
}
XSelectInput( display, root_window, StructureNotifyMask );
wine_tsx11_unlock();
init_done = TRUE;
return TRUE;
......
......@@ -135,7 +135,6 @@ static void remove_startup_notification(Display *display, Window window)
src = message;
srclen = strlen(src) + 1;
wine_tsx11_lock();
while (srclen > 0)
{
int msglen = srclen;
......@@ -149,7 +148,6 @@ static void remove_startup_notification(Display *display, Window window)
XSendEvent( display, DefaultRootWindow( display ), False, PropertyChangeMask, &xevent );
xevent.xclient.message_type = x11drv_atom(_NET_STARTUP_INFO);
}
wine_tsx11_unlock();
}
......@@ -343,8 +341,6 @@ static Window create_client_window( Display *display, struct x11drv_win_data *da
if ((cy = data->client_rect.bottom - data->client_rect.top) <= 0) cy = 1;
else if (cy > 65535) cy = 65535;
wine_tsx11_lock();
if (vis)
{
attr.colormap = XCreateColormap( display, root_window, vis->visual,
......@@ -360,7 +356,7 @@ static Window create_client_window( Display *display, struct x11drv_win_data *da
client_visual, mask, &attr );
if (!client)
{
wine_tsx11_unlock();
if (vis) XFreeColormap( display, attr.colormap );
return 0;
}
......@@ -377,8 +373,6 @@ static Window create_client_window( Display *display, struct x11drv_win_data *da
XMapWindow( display, data->client_window );
XSaveContext( display, data->client_window, winContext, (char *)data->hwnd );
wine_tsx11_unlock();
SetPropA( data->hwnd, client_window_prop, (HANDLE)data->client_window );
return data->client_window;
}
......@@ -499,7 +493,6 @@ static void sync_window_text( Display *display, Window win, const WCHAR *text )
}
WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL);
wine_tsx11_lock();
if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success)
{
XSetWMName( display, win, &prop );
......@@ -513,7 +506,6 @@ static void sync_window_text( Display *display, Window win, const WCHAR *text )
*/
XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
8, PropModeReplace, (unsigned char *) utf8_buffer, count);
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, utf8_buffer );
HeapFree( GetProcessHeap(), 0, buffer );
......@@ -562,7 +554,6 @@ static BOOL set_win_format( HWND hwnd, XID fbconfig_id )
XSetWindowAttributes attrib;
static Window dummy_parent;
wine_tsx11_lock();
attrib.override_redirect = True;
if (!dummy_parent)
{
......@@ -591,21 +582,17 @@ static BOOL set_win_format( HWND hwnd, XID fbconfig_id )
}
XFree(vis);
XFlush( gdi_display );
wine_tsx11_unlock();
}
else
#endif
{
WARN("XComposite is not available, using GLXPixmap hack\n");
wine_tsx11_lock();
if(data->pixmap) XFreePixmap(gdi_display, data->pixmap);
data->pixmap = XCreatePixmap(gdi_display, root_window, w, h, vis->depth);
if(!data->pixmap)
{
XFree(vis);
wine_tsx11_unlock();
return FALSE;
}
......@@ -618,7 +605,6 @@ static BOOL set_win_format( HWND hwnd, XID fbconfig_id )
}
XFree(vis);
XFlush( gdi_display );
wine_tsx11_unlock();
if (data->pixmap) SetPropA(hwnd, pixmap_prop, (HANDLE)data->pixmap);
}
......@@ -663,13 +649,11 @@ static void sync_gl_drawable(struct x11drv_win_data *data)
if (!(vis = visual_from_fbconfig_id(data->fbconfig_id))) return;
wine_tsx11_lock();
pix = XCreatePixmap(gdi_display, root_window, w, h, vis->depth);
if(!pix)
{
ERR("Failed to create pixmap for offscreen rendering\n");
XFree(vis);
wine_tsx11_unlock();
return;
}
......@@ -679,7 +663,6 @@ static void sync_gl_drawable(struct x11drv_win_data *data)
ERR("Failed to create drawable for offscreen rendering\n");
XFreePixmap(gdi_display, pix);
XFree(vis);
wine_tsx11_unlock();
return;
}
......@@ -695,7 +678,6 @@ static void sync_gl_drawable(struct x11drv_win_data *data)
data->gl_drawable = glxp;
XFlush( gdi_display );
wine_tsx11_unlock();
SetPropA(data->hwnd, gl_drawable_prop, (HANDLE)data->gl_drawable);
SetPropA(data->hwnd, pixmap_prop, (HANDLE)data->pixmap);
......@@ -750,7 +732,6 @@ static Window create_icon_window( Display *display, struct x11drv_win_data *data
attr.backing_store = NotUseful/*WhenMapped*/;
attr.colormap = X11DRV_PALETTE_PaletteXColormap; /* Needed due to our visual */
wine_tsx11_lock();
data->icon_window = XCreateWindow( display, root_window, 0, 0,
GetSystemMetrics( SM_CXICON ),
GetSystemMetrics( SM_CYICON ),
......@@ -759,7 +740,6 @@ static Window create_icon_window( Display *display, struct x11drv_win_data *data
CWEventMask | CWBitGravity | CWBackingStore | CWColormap, &attr );
XSaveContext( display, data->icon_window, winContext, (char *)data->hwnd );
XFlush( display ); /* make sure the window exists before we start painting to it */
wine_tsx11_unlock();
TRACE( "created %lx\n", data->icon_window );
SetPropA( data->hwnd, icon_window_prop, (HANDLE)data->icon_window );
......@@ -1113,8 +1093,6 @@ static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data
XClassHint *class_hints;
char *process_name = get_process_name();
wine_tsx11_lock();
/* wm protocols */
i = 0;
protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
......@@ -1150,8 +1128,6 @@ static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&user_time_window, 1 );
data->wm_hints = XAllocWMHints();
wine_tsx11_unlock();
if (data->wm_hints)
{
data->wm_hints->flags = 0;
......@@ -1215,8 +1191,6 @@ static void set_wm_hints( Display *display, struct x11drv_win_data *data )
if ((owner_win = get_owner_whole_window( owner, data->managed ))) group_leader = owner_win;
}
wine_tsx11_lock();
if (owner_win) XSetTransientForHint( display, data->whole_window, owner_win );
/* size hints */
......@@ -1242,8 +1216,6 @@ static void set_wm_hints( Display *display, struct x11drv_win_data *data )
data->wm_hints->window_group = group_leader;
XSetWMHints( display, data->whole_window, data->wm_hints );
}
wine_tsx11_unlock();
}
......@@ -1268,20 +1240,24 @@ Window init_clip_window(void)
*/
void update_user_time( Time time )
{
wine_tsx11_lock();
if (!user_time_window)
{
user_time_window = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, 0, InputOnly,
DefaultVisual(gdi_display,DefaultScreen(gdi_display)), 0, NULL );
Window win = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, 0, InputOnly,
DefaultVisual(gdi_display,DefaultScreen(gdi_display)), 0, NULL );
if (InterlockedCompareExchangePointer( (void **)&user_time_window, (void *)win, 0 ))
XDestroyWindow( gdi_display, win );
TRACE( "user time window %lx\n", user_time_window );
}
if (time && (!last_user_time || (long)(time - last_user_time) > 0))
if (!time) return;
XLockDisplay( gdi_display );
if (!last_user_time || (long)(time - last_user_time) > 0)
{
last_user_time = time;
XChangeProperty( gdi_display, user_time_window, x11drv_atom(_NET_WM_USER_TIME),
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&time, 1 );
}
wine_tsx11_unlock();
XUnlockDisplay( gdi_display );
}
/***********************************************************************
......@@ -1783,7 +1759,6 @@ static void destroy_whole_window( Display *display, struct x11drv_win_data *data
TRACE( "win %p xwin %lx/%lx\n", data->hwnd, data->whole_window, data->client_window );
wine_tsx11_lock();
XDeleteContext( display, data->whole_window, winContext );
XDeleteContext( display, data->client_window, winContext );
if (!already_destroyed) XDestroyWindow( display, data->whole_window );
......@@ -1801,7 +1776,6 @@ static void destroy_whole_window( Display *display, struct x11drv_win_data *data
XFlush( display );
XFree( data->wm_hints );
data->wm_hints = NULL;
wine_tsx11_unlock();
RemovePropA( data->hwnd, whole_window_prop );
RemovePropA( data->hwnd, client_window_prop );
}
......@@ -2706,7 +2680,6 @@ static BOOL is_netwm_supported( Display *display, Atom atom )
static int net_supported_count = -1;
int i;
wine_tsx11_lock();
if (net_supported_count == -1)
{
Atom type;
......@@ -2720,7 +2693,6 @@ static BOOL is_netwm_supported( Display *display, Atom atom )
else
net_supported_count = 0;
}
wine_tsx11_unlock();
for (i = 0; i < net_supported_count; i++)
if (net_supported[i] == atom) return TRUE;
......
......@@ -550,13 +550,10 @@ BOOL CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
PK_BUTTONS | PK_X | PK_Y | PK_NORMAL_PRESSURE | PK_ORIENTATION;
strcpyW(gSysDevice.PNPID, SZ_NON_PLUGINPLAY);
wine_tsx11_lock();
devices = pXListInputDevices(data->display, &num_devices);
if (!devices)
{
WARN("XInput Extensions reported as not available\n");
wine_tsx11_unlock();
return FALSE;
}
TRACE("XListInputDevices reports %d devices\n", num_devices);
......@@ -777,7 +774,6 @@ BOOL CDECL X11DRV_LoadTabletInfo(HWND hwnddefault)
WARN("Did not find a valid stylus, unable to determine system context parameters. Wintab is disabled.\n");
}
wine_tsx11_unlock();
return TRUE;
}
......@@ -807,7 +803,6 @@ static void set_button_state(int curnum, XID deviceid)
int loop;
int rc = 0;
wine_tsx11_lock();
device = pXOpenDevice(data->display,deviceid);
state = pXQueryDeviceState(data->display,device);
......@@ -832,7 +827,6 @@ static void set_button_state(int curnum, XID deviceid)
}
}
pXFreeDeviceState(state);
wine_tsx11_unlock();
button_state[curnum] = rc;
}
......@@ -976,7 +970,6 @@ int CDECL X11DRV_AttachEventQueueToTablet(HWND hOwner)
TRACE("Creating context for window %p (%lx) %i cursors\n", hOwner, win, gNumCursors);
wine_tsx11_lock();
devices = pXListInputDevices(data->display, &num_devices);
X11DRV_expect_error(data->display,Tablet_ErrorHandler,NULL);
......@@ -1046,7 +1039,6 @@ int CDECL X11DRV_AttachEventQueueToTablet(HWND hOwner)
X11DRV_check_error();
if (NULL != devices) pXFreeDeviceList(devices);
wine_tsx11_unlock();
return 0;
}
......
......@@ -244,12 +244,9 @@ static inline BOOL ignore_error( Display *display, XErrorEvent *event )
*
* Setup a callback function that will be called on an X error. The
* callback must return non-zero if the error is the one it expected.
* This function acquires the x11 lock; X11DRV_check_error must be
* called in all cases to release it.
*/
void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg )
{
wine_tsx11_lock();
err_callback = callback;
err_callback_display = display;
err_callback_arg = arg;
......@@ -262,16 +259,12 @@ void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void
* X11DRV_check_error
*
* Check if an expected X11 error occurred; return non-zero if yes.
* Also release the x11 lock obtained in X11DRV_expect_error.
* The caller is responsible for calling XSync first if necessary.
*/
int X11DRV_check_error(void)
{
int ret;
err_callback = NULL;
ret = err_callback_result;
wine_tsx11_unlock();
return ret;
return err_callback_result;
}
......@@ -657,10 +650,8 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
ERR( "could not create data\n" );
ExitProcess(1);
}
wine_tsx11_lock();
if (!(data->display = XOpenDisplay(NULL)))
{
wine_tsx11_unlock();
ERR_(winediag)( "x11drv: Can't open display: %s. Please ensure that your X server is running and that $DISPLAY is set correctly.\n", XDisplayName(NULL));
ExitProcess(1);
}
......@@ -673,7 +664,6 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
#endif
if (TRACE_ON(synchronous)) XSynchronize( data->display, True );
wine_tsx11_unlock();
set_queue_display_fd( data->display );
TlsSetValue( thread_data_tls_index, data );
......@@ -726,7 +716,7 @@ void CDECL X11DRV_SetScreenSaveActive(BOOL bActivate)
int timeout, interval, prefer_blanking, allow_exposures;
static int last_timeout = 15 * 60;
wine_tsx11_lock();
XLockDisplay( gdi_display );
XGetScreenSaver(gdi_display, &timeout, &interval, &prefer_blanking,
&allow_exposures);
if (timeout) last_timeout = timeout;
......@@ -734,5 +724,5 @@ void CDECL X11DRV_SetScreenSaveActive(BOOL bActivate)
timeout = bActivate ? last_timeout : 0;
XSetScreenSaver(gdi_display, timeout, interval, prefer_blanking,
allow_exposures);
wine_tsx11_unlock();
XUnlockDisplay( gdi_display );
}
......@@ -242,10 +242,9 @@ void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event )
if (TRACE_ON(xdnd))
{
unsigned int i = 0;
unsigned int i;
wine_tsx11_lock();
for (; i < count; i++)
for (i = 0; i < count; i++)
{
if (xdndtypes[i] != 0)
{
......@@ -254,7 +253,6 @@ void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event )
XFree(pn);
}
}
wine_tsx11_unlock();
}
/* Do a one-time data read and cache results */
......
......@@ -257,10 +257,8 @@ void X11DRV_ForceXIMReset(HWND hwnd)
{
char* leftover;
TRACE("Forcing Reset %p\n",ic);
wine_tsx11_lock();
leftover = XmbResetIC(ic);
XFree(leftover);
wine_tsx11_unlock();
}
}
......@@ -279,16 +277,12 @@ void X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen)
else
state = XIMPreeditDisable;
wine_tsx11_lock();
attr = XVaCreateNestedList(0, XNPreeditState, state, NULL);
if (attr != NULL)
{
XSetICValues(ic, XNPreeditAttributes, attr, NULL);
XFree(attr);
}
wine_tsx11_unlock();
}
......@@ -299,8 +293,6 @@ void X11DRV_SetPreeditState(HWND hwnd, BOOL fOpen)
*/
BOOL X11DRV_InitXIM( const char *input_style )
{
BOOL ret;
if (!strcasecmp(input_style, "offthespot"))
ximStyleRequest = STYLE_OFFTHESPOT;
else if (!strcasecmp(input_style, "overthespot"))
......@@ -308,18 +300,17 @@ BOOL X11DRV_InitXIM( const char *input_style )
else if (!strcasecmp(input_style, "root"))
ximStyleRequest = STYLE_ROOT;
wine_tsx11_lock();
if (!(ret = XSupportsLocale()))
if (!XSupportsLocale())
{
WARN("X does not support locale.\n");
return FALSE;
}
else if (XSetLocaleModifiers("") == NULL)
if (XSetLocaleModifiers("") == NULL)
{
WARN("Could not set locale modifiers.\n");
ret = FALSE;
return FALSE;
}
wine_tsx11_unlock();
return ret;
return TRUE;
}
......@@ -332,9 +323,7 @@ static void X11DRV_DestroyIM(XIM xim, XPointer p, XPointer data)
TRACE("xim = %p, p = %p\n", xim, p);
thread_data->xim = NULL;
ximStyle = 0;
wine_tsx11_lock();
XRegisterIMInstantiateCallback( thread_data->display, NULL, NULL, NULL, open_xim_callback, NULL );
wine_tsx11_unlock();
}
/***********************************************************************
......@@ -456,9 +445,7 @@ static BOOL open_xim( Display *display )
else
thread_data->font_set = NULL;
wine_tsx11_unlock();
IME_UpdateAssociation(NULL);
wine_tsx11_lock();
return TRUE;
}
......@@ -472,10 +459,8 @@ void X11DRV_SetupXIM(void)
{
Display *display = thread_display();
wine_tsx11_lock();
if (!open_xim( display ))
XRegisterIMInstantiateCallback( display, NULL, NULL, NULL, open_xim_callback, NULL );
wine_tsx11_unlock();
}
static BOOL X11DRV_DestroyIC(XIC xic, XPointer p, XPointer data)
......@@ -501,8 +486,6 @@ XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
TRACE("xim = %p\n", xim);
wine_tsx11_lock();
/* use complex and slow XIC initialization method only for CJK */
if (langid != LANG_CHINESE &&
langid != LANG_JAPANESE &&
......@@ -514,7 +497,6 @@ XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
XNFocusWindow, win,
XNDestroyCallback, &destroy,
NULL);
wine_tsx11_unlock();
data->xic = xic;
return xic;
}
......@@ -614,7 +596,5 @@ XIC X11DRV_CreateIC(XIM xim, struct x11drv_win_data *data)
if (status != NULL)
XFree(status);
wine_tsx11_unlock();
return xic;
}
......@@ -163,8 +163,6 @@ void xinerama_init( unsigned int width, unsigned int height )
int i;
RECT rect;
wine_tsx11_lock();
SetRect( &rect, 0, 0, width, height );
if (root_window != DefaultRootWindow( gdi_display ) || !query_screens())
......@@ -196,8 +194,6 @@ void xinerama_init( unsigned int width, unsigned int height )
screen_height = primary->rcMonitor.bottom - primary->rcMonitor.top;
TRACE( "virtual size: %s primary size: %dx%d\n",
wine_dbgstr_rect(&virtual_screen_rect), screen_width, screen_height );
wine_tsx11_unlock();
}
......
......@@ -116,19 +116,16 @@ static int xrandr10_get_current_mode(void)
{
SizeID size;
Rotation rot;
Window root;
XRRScreenConfiguration *sc;
short rate;
unsigned int i;
int res = -1;
wine_tsx11_lock();
root = RootWindow (gdi_display, DefaultScreen(gdi_display));
sc = pXRRGetScreenInfo (gdi_display, root);
sc = pXRRGetScreenInfo (gdi_display, DefaultRootWindow( gdi_display ));
size = pXRRConfigCurrentConfiguration (sc, &rot);
rate = pXRRConfigCurrentRate (sc);
pXRRFreeScreenConfigInfo(sc);
wine_tsx11_unlock();
for (i = 0; i < xrandr_mode_count; ++i)
{
if (xrandr10_modes[i] == size && dd_modes[i].refresh_rate == rate)
......@@ -154,8 +151,7 @@ static LONG xrandr10_set_current_mode( int mode )
Status stat;
short rate;
wine_tsx11_lock();
root = RootWindow (gdi_display, DefaultScreen(gdi_display));
root = DefaultRootWindow( gdi_display );
sc = pXRRGetScreenInfo (gdi_display, root);
size = pXRRConfigCurrentConfiguration (sc, &rot);
mode = mode % xrandr_mode_count;
......@@ -174,7 +170,7 @@ static LONG xrandr10_set_current_mode( int mode )
stat = pXRRSetScreenConfig( gdi_display, sc, root, size, rot, CurrentTime );
pXRRFreeScreenConfigInfo(sc);
wine_tsx11_unlock();
if (stat == RRSetConfigSuccess)
{
X11DRV_resize_desktop( dd_modes[mode].width, dd_modes[mode].height );
......@@ -271,10 +267,8 @@ static int xrandr12_get_current_mode(void)
XRRCrtcInfo *crtc_info;
int i, ret = -1;
wine_tsx11_lock();
if (!(resources = xrandr_get_screen_resources( gdi_display, root_window )))
{
wine_tsx11_unlock();
ERR("Failed to get screen resources.\n");
return 0;
}
......@@ -282,7 +276,6 @@ static int xrandr12_get_current_mode(void)
if (!resources->ncrtc || !(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[0] )))
{
pXRRFreeScreenResources( resources );
wine_tsx11_unlock();
ERR("Failed to get CRTC info.\n");
return 0;
}
......@@ -301,7 +294,6 @@ static int xrandr12_get_current_mode(void)
pXRRFreeCrtcInfo( crtc_info );
pXRRFreeScreenResources( resources );
wine_tsx11_unlock();
if (ret == -1)
{
......@@ -320,10 +312,8 @@ static LONG xrandr12_set_current_mode( int mode )
mode = mode % xrandr_mode_count;
wine_tsx11_lock();
if (!(resources = xrandr_get_screen_resources( gdi_display, root_window )))
{
wine_tsx11_unlock();
ERR("Failed to get screen resources.\n");
return DISP_CHANGE_FAILED;
}
......@@ -331,7 +321,6 @@ static LONG xrandr12_set_current_mode( int mode )
if (!resources->ncrtc || !(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[0] )))
{
pXRRFreeScreenResources( resources );
wine_tsx11_unlock();
ERR("Failed to get CRTC info.\n");
return DISP_CHANGE_FAILED;
}
......@@ -344,7 +333,6 @@ static LONG xrandr12_set_current_mode( int mode )
pXRRFreeCrtcInfo( crtc_info );
pXRRFreeScreenResources( resources );
wine_tsx11_unlock();
if (status != RRSetConfigSuccess)
{
......@@ -448,11 +436,10 @@ void X11DRV_XRandR_Init(void)
if (!(ret = load_xrandr())) return; /* can't load the Xrandr library */
/* see if Xrandr is available */
wine_tsx11_lock();
if (!pXRRQueryExtension( gdi_display, &event_base, &error_base )) goto done;
if (!pXRRQueryExtension( gdi_display, &event_base, &error_base )) return;
X11DRV_expect_error( gdi_display, XRandRErrorHandler, NULL );
ok = pXRRQueryVersion( gdi_display, &major, &minor );
if (X11DRV_check_error() || !ok) goto done;
if (X11DRV_check_error() || !ok) return;
TRACE("Found XRandR %d.%d.\n", major, minor);
......@@ -470,9 +457,6 @@ void X11DRV_XRandR_Init(void)
else
#endif
xrandr10_init_modes();
done:
wine_tsx11_unlock();
}
#else /* SONAME_LIBXRANDR */
......
......@@ -137,7 +137,6 @@ static LONG X11DRV_XF86VM_SetCurrentMode(int mode)
}
mode = mode % real_xf86vm_mode_count;
wine_tsx11_lock();
TRACE("Resizing X display to %dx%d\n",
real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
pXF86VidModeSwitchToMode(gdi_display, DefaultScreen(gdi_display), real_xf86vm_modes[mode]);
......@@ -147,7 +146,6 @@ static LONG X11DRV_XF86VM_SetCurrentMode(int mode)
XWarpPointer(gdi_display, None, DefaultRootWindow(gdi_display), 0, 0, 0, 0, 0, 0);
#endif
XSync(gdi_display, False);
wine_tsx11_unlock();
X11DRV_resize_desktop( real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay );
return DISP_CHANGE_SUCCESSFUL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment