Commit 64c0e2ac authored by Alexandre Julliard's avatar Alexandre Julliard

Removed the remaining TSX calls.

parent 3976f463
......@@ -73,7 +73,6 @@
#include <fcntl.h>
#include <time.h>
#include "ts_xlib.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
......@@ -1351,11 +1350,13 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
selectionAcquired = S_NOSELECTION;
if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
wine_tsx11_lock();
if (XGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD)))
{
......@@ -1386,9 +1387,11 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
/*
* Query the selection owner for the TARGETS property
*/
if (TSXGetSelectionOwner(display,XA_PRIMARY) ||
TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
wine_tsx11_lock();
if (XGetSelectionOwner(display,XA_PRIMARY) ||
XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{
wine_tsx11_unlock();
if (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, &xe))
selectionCacheSrc = XA_PRIMARY;
else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), &xe))
......@@ -1397,17 +1400,23 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
return -1;
}
else /* No selection owner so report 0 targets available */
{
wine_tsx11_unlock();
return 0;
}
/* Read the TARGETS property contents */
if(TSXGetWindowProperty(display, xe.xselection.requestor, xe.xselection.property,
wine_tsx11_lock();
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);
/*
......@@ -1472,7 +1481,9 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
}
/* Free the list of targets */
TSXFree(targetList);
wine_tsx11_lock();
XFree(targetList);
wine_tsx11_unlock();
}
return cSelectionTargets;
......@@ -1608,9 +1619,11 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
/*
* First request a zero length in order to figure out the request size.
*/
if(TSXGetWindowProperty(display,w,prop,0,0,False, AnyPropertyType,
wine_tsx11_lock();
if(XGetWindowProperty(display,w,prop,0,0,False, AnyPropertyType,
&atype, &aformat, &nitems, &itemSize, &val) != Success)
{
wine_tsx11_unlock();
WARN("Failed to get property size\n");
return bRet;
}
......@@ -1618,7 +1631,7 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
/* Free zero length return data if any */
if (val)
{
TSXFree(val);
XFree(val);
val = NULL;
}
......@@ -1628,9 +1641,10 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
bwc = aformat/8;
/* Read property in 4K blocks */
if (TSXGetWindowProperty(display,w,prop,0,4096,False, AnyPropertyType/*reqType*/,
if (XGetWindowProperty(display,w,prop,0,4096,False, AnyPropertyType/*reqType*/,
&atype, &aformat, &nitems, &remain, &buffer) != Success)
{
wine_tsx11_unlock();
WARN("Failed to read property\n");
return bRet;
}
......@@ -1638,14 +1652,15 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
val = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nitems*bwc);
memcpy(val,buffer,nitems*bwc);
TSXFree(buffer);
XFree(buffer);
for (total = nitems*bwc, val_cnt = 0; remain;)
{
val_cnt +=nitems*bwc;
if (TSXGetWindowProperty(display, w, prop, (total / 4), 4096, False,
if (XGetWindowProperty(display, w, prop, (total / 4), 4096, False,
AnyPropertyType, &atype, &aformat, &nitems, &remain, &buffer) != Success)
{
wine_tsx11_unlock();
WARN("Failed to read property\n");
HeapFree(GetProcessHeap(), 0, val);
return bRet;
......@@ -1654,8 +1669,9 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
total += nitems*bwc;
HeapReAlloc(GetProcessHeap(),0,val, total);
memcpy(&val[val_cnt], buffer, nitems*(aformat/8));
TSXFree(buffer);
XFree(buffer);
}
wine_tsx11_unlock();
bRet = X11DRV_CLIPBOARD_InsertClipboardData(lpData->wFormatID, 0, lpData->lpDrvImportFunc(val, total), 0);
......@@ -1801,26 +1817,30 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd)
if ((selType == x11drv_atom(CLIPBOARD)) && (selectionAcquired & S_PRIMARY))
{
TRACE("Lost clipboard. Check if we need to release PRIMARY\n");
if (selectionWindow == TSXGetSelectionOwner(display,XA_PRIMARY))
wine_tsx11_lock();
if (selectionWindow == XGetSelectionOwner(display,XA_PRIMARY))
{
TRACE("We still own PRIMARY. Releasing PRIMARY.\n");
XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);
}
else
TRACE("We no longer own PRIMARY\n");
wine_tsx11_unlock();
}
/* We really lost PRIMARY but want to voluntarily lose CLIPBOARD */
if ((selType == XA_PRIMARY) && (selectionAcquired & S_CLIPBOARD))
{
TRACE("Lost PRIMARY. Check if we need to release CLIPBOARD\n");
if (selectionWindow == TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
wine_tsx11_lock();
if (selectionWindow == XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{
TRACE("We still own CLIPBOARD. Releasing CLIPBOARD.\n");
XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), None, CurrentTime);
}
else
TRACE("We no longer own CLIPBOARD\n");
wine_tsx11_unlock();
}
/* Destroy private objects */
......@@ -1943,19 +1963,21 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
owner = X11DRV_get_whole_window(GetAncestor(hWndClipWindow, GA_ROOT));
wine_tsx11_lock();
/* Grab PRIMARY selection if not owned */
if (!(selectionAcquired & S_PRIMARY))
TSXSetSelectionOwner(display, XA_PRIMARY, owner, CurrentTime);
XSetSelectionOwner(display, XA_PRIMARY, owner, CurrentTime);
/* Grab CLIPBOARD selection if not owned */
if (!(selectionAcquired & S_CLIPBOARD))
TSXSetSelectionOwner(display, x11drv_atom(CLIPBOARD), owner, CurrentTime);
XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), owner, CurrentTime);
if (TSXGetSelectionOwner(display,XA_PRIMARY) == owner)
if (XGetSelectionOwner(display,XA_PRIMARY) == owner)
selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (selectionAcquired)
{
......@@ -1969,11 +1991,13 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
selectionAcquired = S_NOSELECTION;
if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
wine_tsx11_lock();
if (XGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD)))
{
......@@ -2251,19 +2275,21 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar)
TRACE("\tswitching selection from %08x to %08x\n",
(unsigned)selectionPrevWindow, (unsigned)selectionWindow);
wine_tsx11_lock();
/* Assume ownership for the PRIMARY and CLIPBOARD selection */
if (saveSelectionState & S_PRIMARY)
TSXSetSelectionOwner(display, XA_PRIMARY, selectionWindow, CurrentTime);
XSetSelectionOwner(display, XA_PRIMARY, selectionWindow, CurrentTime);
TSXSetSelectionOwner(display, x11drv_atom(CLIPBOARD), selectionWindow, CurrentTime);
XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), selectionWindow, CurrentTime);
/* Restore the selection masks */
selectionAcquired = saveSelectionState;
/* Lose the selection if something went wrong */
if (((saveSelectionState & S_PRIMARY) &&
(TSXGetSelectionOwner(display, XA_PRIMARY) != selectionWindow)) ||
(TSXGetSelectionOwner(display, x11drv_atom(CLIPBOARD)) != selectionWindow))
(XGetSelectionOwner(display, XA_PRIMARY) != selectionWindow)) ||
(XGetSelectionOwner(display, x11drv_atom(CLIPBOARD)) != selectionWindow))
{
bLostSelection = TRUE;
}
......@@ -2275,6 +2301,7 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar)
ClipboardSelectionOwner = selectionWindow;
}
wine_tsx11_unlock();
}
else
{
......
......@@ -24,7 +24,7 @@
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ts_xlib.h"
#include <X11/Xlib.h>
#include <X11/extensions/xf86dga.h>
#include "x11drv.h"
......@@ -126,7 +126,9 @@ void X11DRV_XF86DGA2_Init(void)
void X11DRV_XF86DGA2_Cleanup(void)
{
if (modes) TSXFree(modes);
wine_tsx11_lock();
if (modes) XFree(modes);
wine_tsx11_unlock();
}
static XDGADevice *dga_dev;
......
......@@ -24,8 +24,7 @@
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include "ts_xlib.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
#ifdef HAVE_LIBXXF86DGA2
......@@ -632,6 +631,8 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
EVENT_SelectionRequest_AddTARGETS(targets, &cTargets, alias);
}
wine_tsx11_lock();
if (TRACE_ON(clipboard))
{
int i;
......@@ -639,17 +640,18 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
{
if (targets[i])
{
char *itemFmtName = TSXGetAtomName(display, targets[i]);
char *itemFmtName = XGetAtomName(display, targets[i]);
TRACE_(clipboard)("\tAtom# %d: Property %ld Type %s\n", i, targets[i], itemFmtName);
TSXFree(itemFmtName);
XFree(itemFmtName);
}
}
}
/* We may want to consider setting the type to xaTargets instead,
* in case some apps expect this instead of XA_ATOM */
TSXChangeProperty(display, requestor, rprop, XA_ATOM, 32,
XChangeProperty(display, requestor, rprop, XA_ATOM, 32,
PropModeReplace, (unsigned char *)targets, cTargets);
wine_tsx11_unlock();
HeapFree(GetProcessHeap(), 0, targets);
......@@ -678,7 +680,6 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
unsigned long remain;
Atom* targetPropList=NULL;
unsigned long cTargetPropList = 0;
/* Atom xAtomPair = TSXInternAtom(display, "ATOM_PAIR", False); */
/* If the specified property is None the requestor is an obsolete client.
* We support these by using the specified target atom as the reply property.
......@@ -692,15 +693,20 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
/* Read the MULTIPLE property contents. This should contain a list of
* (target,property) atom pairs.
*/
if(TSXGetWindowProperty(display, pevent->requestor, rprop,
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
{
TRACE("\tType %s,Format %d,nItems %ld, Remain %ld\n",
TSXGetAtomName(display, atype), aformat, cTargetPropList, remain);
XGetAtomName(display, atype), aformat, cTargetPropList, remain);
wine_tsx11_unlock();
/*
* Make sure we got what we expect.
......@@ -723,12 +729,15 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
if (TRACE_ON(event))
{
char *targetName = TSXGetAtomName(display, targetPropList[i]);
char *propName = TSXGetAtomName(display, targetPropList[i+1]);
char *targetName, *propName;
wine_tsx11_lock();
targetName = XGetAtomName(display, targetPropList[i]);
propName = XGetAtomName(display, targetPropList[i+1]);
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
i/2, targetName, propName);
TSXFree(targetName);
TSXFree(propName);
XFree(targetName);
XFree(propName);
wine_tsx11_unlock();
}
/* We must have a non "None" property to service a MULTIPLE target atom */
......@@ -751,7 +760,9 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
}
/* Free the list of targets/properties */
TSXFree(targetPropList);
wine_tsx11_lock();
XFree(targetPropList);
wine_tsx11_unlock();
}
END:
......@@ -829,19 +840,16 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO
TRACE_(clipboard)("\tUpdating property %s, %ld bytes\n",
lpFormat->Name, cBytes);
TSXChangeProperty(display, request, rprop, event->target,
wine_tsx11_lock();
XChangeProperty(display, request, rprop, event->target,
8, PropModeReplace, (unsigned char *)lpClipData, cBytes);
wine_tsx11_unlock();
GlobalUnlock(hClipData);
GlobalFree(hClipData);
}
}
}
else
{
TRACE_(clipboard)("Request for property %s (%ld) failed\n",
TSXGetAtomName(display, event->target), event->target);
}
}
END:
......@@ -887,15 +895,15 @@ static void EVENT_PropertyNotify( XPropertyEvent *event )
{
case PropertyDelete:
{
TRACE("\tPropertyDelete for atom %s on window %ld\n",
TSXGetAtomName(event->display, event->atom), (long)event->window);
TRACE("\tPropertyDelete for atom %ld on window %ld\n",
event->atom, (long)event->window);
break;
}
case PropertyNewValue:
{
TRACE("\tPropertyNewValue for atom %s on window %ld\n\n",
TSXGetAtomName(event->display, event->atom), (long)event->window);
TRACE("\tPropertyNewValue for atom %ld on window %ld\n\n",
event->atom, (long)event->window);
break;
}
......@@ -980,9 +988,11 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
pWnd = WIN_FindWndPtr(hWnd);
TSXQueryPointer( event->display, get_whole_window(pWnd), &w_aux_root, &w_aux_child,
wine_tsx11_lock();
XQueryPointer( event->display, get_whole_window(pWnd), &w_aux_root, &w_aux_child,
&x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y,
(unsigned int*)&aux_long);
wine_tsx11_unlock();
/* find out drop point and drop window */
if( x < 0 || y < 0 ||
......@@ -1013,10 +1023,12 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if (!bAccept) return;
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
wine_tsx11_lock();
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
x11drv_atom(DndSelection), 0, 65535, FALSE,
AnyPropertyType, &u.atom_aux, (int *) &u.pt_aux.y,
&data_length, &aux_long, &p_data);
wine_tsx11_unlock();
if( !aux_long && p_data) /* don't bother if > 64K */
{
......@@ -1073,7 +1085,9 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
}
}
}
if( p_data ) TSXFree(p_data);
wine_tsx11_lock();
if( p_data ) XFree(p_data);
wine_tsx11_unlock();
}
/**********************************************************************
......@@ -1102,10 +1116,12 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
if (!(GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return;
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
wine_tsx11_lock();
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
x11drv_atom(DndSelection), 0, 65535, FALSE,
AnyPropertyType, &u.atom_aux, &u.i,
&data_length, &aux_long, &p_data);
wine_tsx11_unlock();
if (aux_long)
WARN("property too large, truncated!\n");
TRACE("urls=%s\n", p_data);
......@@ -1130,8 +1146,10 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
}
if( drop_len && drop_len < 65535 ) {
TSXQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux,
wine_tsx11_lock();
XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux,
&x, &y, &u.i, &u.i, &u.i);
wine_tsx11_unlock();
drop_len += sizeof(DROPFILES) + 1;
hDrop = GlobalAlloc( GMEM_SHARE, drop_len );
......@@ -1183,7 +1201,9 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L );
}
}
if( p_data ) TSXFree(p_data);
wine_tsx11_lock();
if( p_data ) XFree(p_data);
wine_tsx11_unlock();
}
}
......@@ -1223,10 +1243,12 @@ static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event )
int i;
Atom atom;
} u; /* unused */
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
wine_tsx11_lock();
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
dndSelection, 0, 65535, FALSE,
AnyPropertyType, &u.atom, &u.i,
&u.l, &u.l, &p_data);
wine_tsx11_unlock();
TRACE("message_type=%ld, data=%ld,%ld,%ld,%ld,%ld, msg=%s\n",
event->message_type, event->data.l[0], event->data.l[1],
event->data.l[2], event->data.l[3], event->data.l[4],
......
......@@ -27,8 +27,7 @@
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include "ts_xlib.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
#ifdef HAVE_XKB
......@@ -1108,7 +1107,9 @@ void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event )
if ((keysym >= XK_ISO_Lock && keysym <= XK_ISO_Last_Group_Lock) ||
keysym == XK_Mode_switch)
{
TRACE("Ignoring %s keyboard event\n", TSXKeysymToString(keysym));
wine_tsx11_lock();
TRACE("Ignoring %s keyboard event\n", XKeysymToString(keysym));
wine_tsx11_unlock();
return;
}
......@@ -1130,7 +1131,9 @@ void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event )
if (TRACE_ON(key)){
char *ksname;
ksname = TSXKeysymToString(keysym);
wine_tsx11_lock();
ksname = XKeysymToString(keysym);
wine_tsx11_unlock();
if (!ksname)
ksname = "No Name";
TRACE_(key)("%s : keysym=%lX (%s), # of chars=%d / 0x%02x / '%s'\n",
......@@ -1662,12 +1665,14 @@ SHORT X11DRV_VkKeyScanEx(WCHAR wChar, HKL hkl)
keysym = (unsigned char)cChar; /* (!) cChar is signed */
if (keysym <= 27) keysym += 0xFF00; /* special chars : return, backspace... */
keycode = TSXKeysymToKeycode(display, keysym); /* keysym -> keycode */
wine_tsx11_lock();
keycode = XKeysymToKeycode(display, keysym); /* keysym -> keycode */
if (!keycode)
{ /* It didn't work ... let's try with deadchar code. */
TRACE("retrying with | 0xFE00\n");
keycode = TSXKeysymToKeycode(display, keysym | 0xFE00);
keycode = XKeysymToKeycode(display, keysym | 0xFE00);
}
wine_tsx11_unlock();
TRACE("'%c'(%#lx, %lu): got keycode %#.2x (%d)\n",
cChar, keysym, keysym, keycode, keycode);
......@@ -1682,14 +1687,16 @@ SHORT X11DRV_VkKeyScanEx(WCHAR wChar, HKL hkl)
}
index = -1;
wine_tsx11_lock();
for (i = 0; i < 4; i++) /* find shift state */
{
if (TSXKeycodeToKeysym(display, keycode, i) == keysym)
if (XKeycodeToKeysym(display, keycode, i) == keysym)
{
index = i;
break;
}
}
wine_tsx11_unlock();
switch (index)
{
......@@ -1894,9 +1901,11 @@ INT X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize)
break;
if (keyi <= max_keycode)
{
wine_tsx11_lock();
keyc = (KeyCode) keyi;
keys = TSXKeycodeToKeysym(thread_display(), keyc, 0);
name = TSXKeysymToString(keys);
keys = XKeycodeToKeysym(thread_display(), keyc, 0);
name = XKeysymToString(keys);
wine_tsx11_unlock();
TRACE("found scan=%04x keyc=%04x keysym=%04x string=%s\n",
scanCode, keyc, (int)keys, name);
if (lpBuffer && nSize && name)
......@@ -2130,7 +2139,9 @@ INT X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
{
char *ksname;
ksname = TSXKeysymToString(keysym);
wine_tsx11_lock();
ksname = XKeysymToString(keysym);
wine_tsx11_unlock();
if (!ksname)
ksname = "No Name";
if ((keysym >> 8) != 0xff)
......
......@@ -20,7 +20,7 @@
#include "config.h"
#include "ts_xlib.h"
#include <X11/Xlib.h>
#ifdef HAVE_LIBXXF86DGA2
#include <X11/extensions/xf86dga.h>
#endif
......@@ -527,15 +527,17 @@ void X11DRV_GetCursorPos(LPPOINT pos)
int rootX, rootY, winX, winY;
unsigned int xstate;
if (!TSXQueryPointer( display, root_window, &root, &child,
wine_tsx11_lock();
if (XQueryPointer( display, root_window, &root, &child,
&rootX, &rootY, &winX, &winY, &xstate ))
return;
{
update_key_state( xstate );
update_button_state( xstate );
TRACE("pointer at (%d,%d)\n", winX, winY );
pos->x = winX;
pos->y = winY;
}
wine_tsx11_unlock();
}
/***********************************************************************
......
......@@ -28,7 +28,7 @@
# include <unistd.h>
#endif
#include "ts_xlib.h"
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
......@@ -977,7 +977,9 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
if (!create_whole_window( display, wndPtr )) goto failed;
if (!create_client_window( display, wndPtr )) goto failed;
TSXSync( display, False );
wine_tsx11_lock();
XSync( display, False );
wine_tsx11_unlock();
SetPropA( hwnd, whole_window_atom, (HANDLE)data->whole_window );
SetPropA( hwnd, client_window_atom, (HANDLE)data->client_window );
......
......@@ -21,7 +21,7 @@
#include "config.h"
#include "ts_xlib.h"
#include <X11/Xlib.h>
#ifdef HAVE_LIBXSHAPE
#include <X11/IntrinsicP.h>
#include <X11/extensions/shape.h>
......@@ -804,7 +804,9 @@ static void set_visible_style( HWND hwnd, BOOL set )
X11DRV_sync_window_style( display, win );
X11DRV_set_wm_hints( display, win );
TRACE( "mapping win %p\n", hwnd );
TSXMapWindow( display, get_whole_window(win) );
wine_tsx11_lock();
XMapWindow( display, get_whole_window(win) );
wine_tsx11_unlock();
}
}
else
......@@ -814,7 +816,9 @@ static void set_visible_style( HWND hwnd, BOOL set )
if (!IsRectEmpty( &win->rectWindow ) && get_whole_window(win) && is_window_top_level(win))
{
TRACE( "unmapping win %p\n", hwnd );
TSXUnmapWindow( thread_display(), get_whole_window(win) );
wine_tsx11_lock();
XUnmapWindow( thread_display(), get_whole_window(win) );
wine_tsx11_unlock();
}
}
done:
......@@ -851,12 +855,16 @@ void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle )
X11DRV_sync_window_style( display, wndPtr );
X11DRV_set_wm_hints( display, wndPtr );
}
TSXMapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_lock();
XMapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_unlock();
}
else if (!is_window_top_level(wndPtr)) /* don't unmap managed windows */
{
TRACE( "unmapping win %p\n", hwnd );
TSXUnmapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_lock();
XUnmapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_unlock();
}
}
}
......@@ -974,7 +982,9 @@ BOOL X11DRV_SetWindowPos( WINDOWPOS *winpos )
{
/* resizing to zero size -> unmap */
TRACE( "unmapping zero size win %p\n", winpos->hwnd );
TSXUnmapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_lock();
XUnmapWindow( display, get_whole_window(wndPtr) );
wine_tsx11_unlock();
}
wine_tsx11_lock();
......@@ -1430,19 +1440,22 @@ static Window __get_common_ancestor( Display *display, Window A, Window B,
Window root, *childrenB;
unsigned totalB;
wine_tsx11_lock();
while( A != B && A && B )
{
TSXQueryTree( display, A, &root, &A, children, total );
TSXQueryTree( display, B, &root, &B, &childrenB, &totalB );
if( childrenB ) TSXFree( childrenB );
if( *children ) TSXFree( *children ), *children = NULL;
XQueryTree( display, A, &root, &A, children, total );
XQueryTree( display, B, &root, &B, &childrenB, &totalB );
if( childrenB ) XFree( childrenB );
if( *children ) XFree( *children ), *children = NULL;
}
if( A && B )
{
TSXQueryTree( display, A, &root, &B, children, total );
XQueryTree( display, A, &root, &B, children, total );
wine_tsx11_unlock();
return A;
}
wine_tsx11_unlock();
return 0 ;
}
......@@ -1451,12 +1464,14 @@ static Window __get_top_decoration( Display *display, Window w, Window ancestor
Window* children, root, prev = w, parent = w;
unsigned total;
wine_tsx11_lock();
do
{
w = parent;
TSXQueryTree( display, w, &root, &parent, &children, &total );
if( children ) TSXFree( children );
XQueryTree( display, w, &root, &parent, &children, &total );
if( children ) XFree( children );
} while( parent && parent != ancestor );
wine_tsx11_unlock();
TRACE("\t%08x -> %08x\n", (unsigned)prev, (unsigned)w );
return ( parent ) ? w : 0 ;
}
......@@ -1524,7 +1539,9 @@ static HWND query_zorder( Display *display, HWND hWndCheck)
}
}
}
if( children ) TSXFree( children );
wine_tsx11_lock();
if( children ) XFree( children );
wine_tsx11_unlock();
done:
HeapFree( GetProcessHeap(), 0, list );
......
......@@ -53,6 +53,9 @@ struct tagCURSORICONINFO;
struct tagPALETTEOBJ;
struct tagWINDOWPOS;
extern void wine_tsx11_lock(void);
extern void wine_tsx11_unlock(void);
/* X physical pen */
typedef struct
{
......
......@@ -20,7 +20,6 @@
#include "config.h"
#include "ts_xlib.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
......@@ -123,15 +122,17 @@ int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
{
unsigned int i = 0;
wine_tsx11_lock();
for (; i < count; i++)
{
if (xdndtypes[i] != 0)
{
char * pn = TSXGetAtomName(event->display, xdndtypes[i]);
char * pn = XGetAtomName(event->display, xdndtypes[i]);
TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes[i], pn);
TSXFree(pn);
XFree(pn);
}
}
wine_tsx11_unlock();
}
/* Do a one-time data read and cache results */
......@@ -275,7 +276,9 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
wine_tsx11_unlock();
entries += X11DRV_XDND_MapFormat(types[i], data, icount * (actfmt / 8));
TSXFree(data);
wine_tsx11_lock();
XFree(data);
wine_tsx11_unlock();
}
*count = entries;
......
......@@ -22,7 +22,7 @@
#include <string.h>
#include <stdio.h>
#include "ts_xlib.h"
#include <X11/Xlib.h>
#ifdef HAVE_LIBXXF86VM
#define XMD_H
......@@ -216,7 +216,9 @@ void X11DRV_XF86VM_Init(void)
void X11DRV_XF86VM_Cleanup(void)
{
if (real_xf86vm_modes) TSXFree(real_xf86vm_modes);
wine_tsx11_lock();
if (real_xf86vm_modes) XFree(real_xf86vm_modes);
wine_tsx11_unlock();
}
void X11DRV_XF86VM_SetExclusiveMode(int lock)
......
......@@ -24,10 +24,6 @@
#include "config.h"
#include "wine/port.h"
#include <X11/Xatom.h>
#include "ts_xlib.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
......@@ -441,15 +437,14 @@ static UINT16 __genericCheckSum( const void *ptr, int size )
*
* These functions also do TILDE to HYPHEN conversion
*/
static LFD* LFD_Parse(LPSTR lpFont)
static BOOL LFD_Parse(LPSTR lpFont, LFD *lfd)
{
LFD* lfd;
char *lpch = lpFont, *lfd_fld[LFD_FIELDS], *field_start;
int i;
if (*lpch != HYPHEN)
{
WARN("font '%s' doesn't begin with '%c'\n", lpFont, HYPHEN);
return NULL;
return FALSE;
}
field_start = ++lpch;
......@@ -482,9 +477,6 @@ static LFD* LFD_Parse(LPSTR lpFont)
if (*lpch)
WARN("Extra ignored in font '%s'\n", lpFont);
lfd = HeapAlloc( GetProcessHeap(), 0, sizeof(LFD) );
if (lfd)
{
lfd->foundry = lfd_fld[0];
lfd->family = lfd_fld[1];
lfd->weight = lfd_fld[2];
......@@ -499,8 +491,7 @@ static LFD* LFD_Parse(LPSTR lpFont)
lfd->average_width = lfd_fld[11];
lfd->charset_registry = lfd_fld[12];
lfd->charset_encoding = lfd_fld[13];
}
return lfd;
return TRUE;
}
......@@ -1064,15 +1055,18 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
if( pEL ) *pEL = 0;
if(XFT) {
if(TSXGetFontProperty((XFontStruct*)x_fs, x11drv_atom(RAW_CAP_HEIGHT), &height))
wine_tsx11_lock();
if(XGetFontProperty((XFontStruct*)x_fs, x11drv_atom(RAW_CAP_HEIGHT), &height))
*pIL = XFT->ascent -
(INT)(XFT->pixelsize / 1000.0 * height);
else
*pIL = 0;
wine_tsx11_unlock();
return;
}
if( TSXGetFontProperty((XFontStruct*)x_fs, XA_CAP_HEIGHT, &height) == FALSE )
wine_tsx11_lock();
if( XGetFontProperty((XFontStruct*)x_fs, XA_CAP_HEIGHT, &height) == FALSE )
{
if( x_fs->per_char )
if( bIsLatin && ((unsigned char)'X' <= (max - min)) )
......@@ -1089,6 +1083,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
else
height = x_fs->min_bounds.ascent;
}
wine_tsx11_unlock();
*pIL = x_fs->ascent - height;
}
......@@ -1464,17 +1459,15 @@ static void XFONT_LoadDefault(LPCSTR ini, LPCSTR fonttype)
if (*buffer)
{
LFD* lfd;
LFD lfd;
char* pch = buffer;
while( *pch && isspace(*pch) ) pch++;
TRACE("Using '%s' as default %sfont\n", pch, fonttype);
lfd = LFD_Parse(pch);
if (lfd && lfd->foundry && lfd->family)
XFONT_LoadDefaultLFD(lfd, fonttype);
if (LFD_Parse(pch, &lfd) && lfd.foundry && lfd.family)
XFONT_LoadDefaultLFD(&lfd, fonttype);
else
WARN("Ini section [%s]%s is malformed\n", INIFontSection, ini);
HeapFree(GetProcessHeap(), 0, lfd);
}
}
}
......@@ -1659,7 +1652,7 @@ static void XFONT_LoadAliases(void)
char *lpResource;
char buffer[MAX_LFD_LENGTH];
int i = 0;
LFD* lfd;
LFD lfd;
HKEY hkey;
/* built-ins first */
......@@ -1671,16 +1664,14 @@ static void XFONT_LoadAliases(void)
RegCloseKey(hkey);
}
TRACE("Using '%s' as default serif font\n", buffer);
lfd = LFD_Parse(buffer);
/* NB XFONT_InitialCapitals should not change these standard aliases */
if (lfd)
if (LFD_Parse(buffer, &lfd))
{
XFONT_LoadAlias( lfd, "Tms Roman", FALSE);
XFONT_LoadAlias( lfd, "MS Serif", FALSE);
XFONT_LoadAlias( lfd, "Times New Roman", FALSE);
/* NB XFONT_InitialCapitals should not change these standard aliases */
XFONT_LoadAlias( &lfd, "Tms Roman", FALSE);
XFONT_LoadAlias( &lfd, "MS Serif", FALSE);
XFONT_LoadAlias( &lfd, "Times New Roman", FALSE);
XFONT_LoadDefaultLFD( lfd, "serif ");
HeapFree(GetProcessHeap(), 0, lfd);
XFONT_LoadDefaultLFD( &lfd, "serif ");
}
strcpy(buffer, "-adobe-helvetica-");
......@@ -1691,17 +1682,15 @@ static void XFONT_LoadAliases(void)
RegCloseKey(hkey);
}
TRACE("Using '%s' as default sans serif font\n", buffer);
lfd = LFD_Parse(buffer);
if (lfd)
if (LFD_Parse(buffer, &lfd))
{
XFONT_LoadAlias( lfd, "Helv", FALSE);
XFONT_LoadAlias( lfd, "MS Sans Serif", FALSE);
XFONT_LoadAlias( lfd, "MS Shell Dlg", FALSE);
XFONT_LoadAlias( lfd, "System", FALSE);
XFONT_LoadAlias( lfd, "Arial", FALSE);
XFONT_LoadAlias( &lfd, "Helv", FALSE);
XFONT_LoadAlias( &lfd, "MS Sans Serif", FALSE);
XFONT_LoadAlias( &lfd, "MS Shell Dlg", FALSE);
XFONT_LoadAlias( &lfd, "System", FALSE);
XFONT_LoadAlias( &lfd, "Arial", FALSE);
XFONT_LoadDefaultLFD( lfd, "sans serif ");
HeapFree(GetProcessHeap(), 0, lfd);
XFONT_LoadDefaultLFD( &lfd, "sans serif ");
}
/* then user specified aliases */
......@@ -1727,12 +1716,7 @@ static void XFONT_LoadAliases(void)
bSubst = (XFONT_GetStringItem( lpResource )) ? TRUE : FALSE;
if( lpResource && *lpResource )
{
lfd = LFD_Parse(lpResource);
if (lfd)
{
XFONT_LoadAlias(lfd, buffer, bSubst);
HeapFree(GetProcessHeap(), 0, lfd);
}
if (LFD_Parse(lpResource, &lfd)) XFONT_LoadAlias(&lfd, buffer, bSubst);
}
else
WARN("malformed font alias '%s'\n", buffer );
......@@ -1810,13 +1794,13 @@ void XFONT_RemoveFontResource( fontResource** ppfr )
static void XFONT_LoadIgnore(char* lfdname)
{
fontResource** ppfr;
LFD lfd;
LFD* lfd = LFD_Parse(lfdname);
if (lfd && lfd->foundry && lfd->family)
if (LFD_Parse(lfdname, &lfd) && lfd.foundry && lfd.family)
{
for( ppfr = &fontList; *ppfr ; ppfr = &((*ppfr)->next))
{
if( XFONT_SameFoundryAndFamily( (*ppfr)->resource, lfd) )
if( XFONT_SameFoundryAndFamily( (*ppfr)->resource, &lfd) )
{
TRACE("Ignoring '-%s-%s-'\n",
(*ppfr)->resource->foundry, (*ppfr)->resource->family );
......@@ -1828,8 +1812,6 @@ static void XFONT_LoadIgnore(char* lfdname)
}
else
WARN("Malformed font resource\n");
HeapFree(GetProcessHeap(), 0, lfd);
}
static void XFONT_LoadIgnores(void)
......@@ -2047,7 +2029,7 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
for( i = 0; i < x_count; i++ )
{
char* typeface;
LFD* lfd;
LFD lfd;
int j;
char buffer[MAX_LFD_LENGTH];
char* lpstr;
......@@ -2058,8 +2040,7 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
strcpy( typeface, x_pattern[i] );
if (i % 10 == 0) MESSAGE("Font metrics: %.1f%% done\n", 100.0 * i / x_count);
lfd = LFD_Parse(typeface);
if (!lfd)
if (!LFD_Parse(typeface, &lfd))
{
HeapFree(GetProcessHeap(), 0, typeface);
continue;
......@@ -2069,14 +2050,14 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
for( pfr = NULL, fr = fontList; fr; fr = fr->next )
{
if( XFONT_SameFoundryAndFamily(fr->resource, lfd))
if( XFONT_SameFoundryAndFamily(fr->resource, &lfd))
break;
pfr = fr;
}
if( !fi ) fi = (fontInfo*) HeapAlloc(GetProcessHeap(), 0, sizeof(fontInfo));
if( !LFD_InitFontInfo( fi, lfd, x_pattern[i]) )
if( !LFD_InitFontInfo( fi, &lfd, x_pattern[i]) )
goto nextfont;
if( !fr ) /* add new family */
......@@ -2090,11 +2071,11 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
fr->resource = (LFD*) HeapAlloc(GetProcessHeap(), 0, sizeof(LFD));
memset(fr->resource, 0, sizeof(LFD));
TRACE("family: -%s-%s-\n", lfd->foundry, lfd->family );
fr->resource->foundry = HeapAlloc(GetProcessHeap(), 0, strlen(lfd->foundry)+1);
strcpy( (char *)fr->resource->foundry, lfd->foundry );
fr->resource->family = HeapAlloc(GetProcessHeap(), 0, strlen(lfd->family)+1);
strcpy( (char *)fr->resource->family, lfd->family );
TRACE("family: -%s-%s-\n", lfd.foundry, lfd.family );
fr->resource->foundry = HeapAlloc(GetProcessHeap(), 0, strlen(lfd.foundry)+1);
strcpy( (char *)fr->resource->foundry, lfd.foundry );
fr->resource->family = HeapAlloc(GetProcessHeap(), 0, strlen(lfd.family)+1);
strcpy( (char *)fr->resource->family, lfd.family );
fr->resource->weight = "";
if( pfr ) pfr->next = fr;
......@@ -2125,7 +2106,7 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
sprintf(pxl_string, "%d", fi->lfd_height);
sprintf(res_string, "%d", fi->lfd_resolution);
lfd1 = *lfd;
lfd1 = lfd;
lfd1.pixel_size = pxl_string;
lfd1.point_size = "*";
lfd1.resolution_x = res_string;
......@@ -2141,7 +2122,9 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
if ((x_fs = safe_XLoadQueryFont(gdi_display, lpstr)) != 0)
{
XFONT_SetFontMetric( fi, fr, x_fs );
TSXFreeFont( gdi_display, x_fs );
wine_tsx11_lock();
XFreeFont( gdi_display, x_fs );
wine_tsx11_unlock();
XFONT_FixupPointSize(fi);
......@@ -2157,7 +2140,6 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
XFONT_CheckFIList( fr, fi, UNMARK_SUBSETS );
}
nextfont:
HeapFree(GetProcessHeap(), 0, lfd);
HeapFree(GetProcessHeap(), 0, typeface);
}
if( fi ) HeapFree(GetProcessHeap(), 0, fi);
......@@ -2294,7 +2276,12 @@ static BOOL XFONT_ReadCachedMetrics( int fd, int res, unsigned x_checksum, int x
{
size_t len = strlen(lpch) + 1;
TRACE("\t%s, %i instances\n", lpch, pfr->fi_count );
pfr->resource = LFD_Parse(lpch);
pfr->resource = HeapAlloc(GetProcessHeap(),0,sizeof(LFD));
if (!LFD_Parse(lpch, pfr->resource))
{
HeapFree( GetProcessHeap(), 0, pfr->resource );
pfr->resource = NULL;
}
lpch += len;
offset += len;
if (offset > length)
......@@ -2857,7 +2844,9 @@ static fontObject* XFONT_GetCacheEntry(void)
if(fontCache[j].lpX11Trans)
HeapFree( GetProcessHeap(), 0, fontCache[j].lpX11Trans );
TSXFreeFont( gdi_display, fontCache[j].fs );
wine_tsx11_lock();
XFreeFont( gdi_display, fontCache[j].fs );
wine_tsx11_unlock();
memset( fontCache + j, 0, sizeof(fontObject) );
return (fontCache + j);
......@@ -3040,31 +3029,25 @@ static BOOL XFONT_SetX11Trans( fontObject *pfo )
{
char *fontName;
Atom nameAtom;
LFD* lfd;
LFD lfd;
TSXGetFontProperty( pfo->fs, XA_FONT, &nameAtom );
fontName = TSXGetAtomName( gdi_display, nameAtom );
lfd = LFD_Parse(fontName);
if (!lfd)
wine_tsx11_lock();
XGetFontProperty( pfo->fs, XA_FONT, &nameAtom );
fontName = XGetAtomName( gdi_display, nameAtom );
if (!LFD_Parse(fontName, &lfd) || lfd.pixel_size[0] != '[')
{
TSXFree(fontName);
return FALSE;
}
if (lfd->pixel_size[0] != '[') {
HeapFree(GetProcessHeap(), 0, lfd);
TSXFree(fontName);
XFree(fontName);
wine_tsx11_unlock();
return FALSE;
}
#define PX pfo->lpX11Trans
sscanf(lfd->pixel_size, "[%f%f%f%f]", &PX->a, &PX->b, &PX->c, &PX->d);
TSXFree(fontName);
HeapFree(GetProcessHeap(), 0, lfd);
sscanf(lfd.pixel_size, "[%f%f%f%f]", &PX->a, &PX->b, &PX->c, &PX->d);
XFree(fontName);
TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_ASCENT), &PX->RAW_ASCENT );
TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_DESCENT), &PX->RAW_DESCENT );
XGetFontProperty( pfo->fs, x11drv_atom(RAW_ASCENT), &PX->RAW_ASCENT );
XGetFontProperty( pfo->fs, x11drv_atom(RAW_DESCENT), &PX->RAW_DESCENT );
wine_tsx11_unlock();
PX->pixelsize = hypot(PX->a, PX->b);
PX->ascent = PX->pixelsize / 1000.0 * PX->RAW_ASCENT;
......
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