Removed the remaining TSX calls.

This commit is contained in:
Alexandre Julliard 2003-11-21 21:48:36 +00:00
parent 3976f4632c
commit 64c0e2ac96
11 changed files with 283 additions and 209 deletions

View File

@ -73,7 +73,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
#include "ts_xlib.h"
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winreg.h" #include "winreg.h"
@ -1351,11 +1350,13 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
selectionAcquired = S_NOSELECTION; selectionAcquired = S_NOSELECTION;
if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow) wine_tsx11_lock();
if (XGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
selectionAcquired |= S_PRIMARY; selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow) if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
selectionAcquired |= S_CLIPBOARD; selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD))) 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 * Query the selection owner for the TARGETS property
*/ */
if (TSXGetSelectionOwner(display,XA_PRIMARY) || wine_tsx11_lock();
TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD))) if (XGetSelectionOwner(display,XA_PRIMARY) ||
XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{ {
wine_tsx11_unlock();
if (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, &xe)) if (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, &xe))
selectionCacheSrc = XA_PRIMARY; selectionCacheSrc = XA_PRIMARY;
else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), &xe)) else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), &xe))
@ -1397,17 +1400,23 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
return -1; return -1;
} }
else /* No selection owner so report 0 targets available */ else /* No selection owner so report 0 targets available */
{
wine_tsx11_unlock();
return 0; return 0;
}
/* Read the TARGETS property contents */ /* 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, 0, 0x3FFF, True, AnyPropertyType/*XA_ATOM*/, &atype, &aformat, &cSelectionTargets,
&remain, (unsigned char**)&targetList) != Success) &remain, (unsigned char**)&targetList) != Success)
{ {
wine_tsx11_unlock();
WARN("Failed to read TARGETS property\n"); WARN("Failed to read TARGETS property\n");
} }
else else
{ {
wine_tsx11_unlock();
TRACE("Type %lx,Format %d,nItems %ld, Remain %ld\n", TRACE("Type %lx,Format %d,nItems %ld, Remain %ld\n",
atype, aformat, cSelectionTargets, remain); atype, aformat, cSelectionTargets, remain);
/* /*
@ -1472,7 +1481,9 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
} }
/* Free the list of targets */ /* Free the list of targets */
TSXFree(targetList); wine_tsx11_lock();
XFree(targetList);
wine_tsx11_unlock();
} }
return cSelectionTargets; 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. * 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) &atype, &aformat, &nitems, &itemSize, &val) != Success)
{ {
wine_tsx11_unlock();
WARN("Failed to get property size\n"); WARN("Failed to get property size\n");
return bRet; return bRet;
} }
@ -1618,7 +1631,7 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
/* Free zero length return data if any */ /* Free zero length return data if any */
if (val) if (val)
{ {
TSXFree(val); XFree(val);
val = NULL; val = NULL;
} }
@ -1628,9 +1641,10 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
bwc = aformat/8; bwc = aformat/8;
/* Read property in 4K blocks */ /* 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) &atype, &aformat, &nitems, &remain, &buffer) != Success)
{ {
wine_tsx11_unlock();
WARN("Failed to read property\n"); WARN("Failed to read property\n");
return bRet; 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); val = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nitems*bwc);
memcpy(val,buffer,nitems*bwc); memcpy(val,buffer,nitems*bwc);
TSXFree(buffer); XFree(buffer);
for (total = nitems*bwc, val_cnt = 0; remain;) for (total = nitems*bwc, val_cnt = 0; remain;)
{ {
val_cnt +=nitems*bwc; 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) AnyPropertyType, &atype, &aformat, &nitems, &remain, &buffer) != Success)
{ {
wine_tsx11_unlock();
WARN("Failed to read property\n"); WARN("Failed to read property\n");
HeapFree(GetProcessHeap(), 0, val); HeapFree(GetProcessHeap(), 0, val);
return bRet; return bRet;
@ -1654,8 +1669,9 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, A
total += nitems*bwc; total += nitems*bwc;
HeapReAlloc(GetProcessHeap(),0,val, total); HeapReAlloc(GetProcessHeap(),0,val, total);
memcpy(&val[val_cnt], buffer, nitems*(aformat/8)); 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); 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)) if ((selType == x11drv_atom(CLIPBOARD)) && (selectionAcquired & S_PRIMARY))
{ {
TRACE("Lost clipboard. Check if we need to release PRIMARY\n"); 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"); TRACE("We still own PRIMARY. Releasing PRIMARY.\n");
XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime); XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);
} }
else else
TRACE("We no longer own PRIMARY\n"); TRACE("We no longer own PRIMARY\n");
wine_tsx11_unlock();
} }
/* We really lost PRIMARY but want to voluntarily lose CLIPBOARD */ /* We really lost PRIMARY but want to voluntarily lose CLIPBOARD */
if ((selType == XA_PRIMARY) && (selectionAcquired & S_CLIPBOARD)) if ((selType == XA_PRIMARY) && (selectionAcquired & S_CLIPBOARD))
{ {
TRACE("Lost PRIMARY. Check if we need to release CLIPBOARD\n"); 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"); TRACE("We still own CLIPBOARD. Releasing CLIPBOARD.\n");
XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), None, CurrentTime); XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), None, CurrentTime);
} }
else else
TRACE("We no longer own CLIPBOARD\n"); TRACE("We no longer own CLIPBOARD\n");
wine_tsx11_unlock();
} }
/* Destroy private objects */ /* Destroy private objects */
@ -1943,19 +1963,21 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
owner = X11DRV_get_whole_window(GetAncestor(hWndClipWindow, GA_ROOT)); owner = X11DRV_get_whole_window(GetAncestor(hWndClipWindow, GA_ROOT));
wine_tsx11_lock();
/* Grab PRIMARY selection if not owned */ /* Grab PRIMARY selection if not owned */
if (!(selectionAcquired & S_PRIMARY)) if (!(selectionAcquired & S_PRIMARY))
TSXSetSelectionOwner(display, XA_PRIMARY, owner, CurrentTime); XSetSelectionOwner(display, XA_PRIMARY, owner, CurrentTime);
/* Grab CLIPBOARD selection if not owned */ /* Grab CLIPBOARD selection if not owned */
if (!(selectionAcquired & S_CLIPBOARD)) 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; selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner) if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
selectionAcquired |= S_CLIPBOARD; selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (selectionAcquired) if (selectionAcquired)
{ {
@ -1969,11 +1991,13 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
selectionAcquired = S_NOSELECTION; selectionAcquired = S_NOSELECTION;
if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow) wine_tsx11_lock();
if (XGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
selectionAcquired |= S_PRIMARY; selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow) if (XGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
selectionAcquired |= S_CLIPBOARD; selectionAcquired |= S_CLIPBOARD;
wine_tsx11_unlock();
if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD))) 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", TRACE("\tswitching selection from %08x to %08x\n",
(unsigned)selectionPrevWindow, (unsigned)selectionWindow); (unsigned)selectionPrevWindow, (unsigned)selectionWindow);
wine_tsx11_lock();
/* Assume ownership for the PRIMARY and CLIPBOARD selection */ /* Assume ownership for the PRIMARY and CLIPBOARD selection */
if (saveSelectionState & S_PRIMARY) 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 */ /* Restore the selection masks */
selectionAcquired = saveSelectionState; selectionAcquired = saveSelectionState;
/* Lose the selection if something went wrong */ /* Lose the selection if something went wrong */
if (((saveSelectionState & S_PRIMARY) && if (((saveSelectionState & S_PRIMARY) &&
(TSXGetSelectionOwner(display, XA_PRIMARY) != selectionWindow)) || (XGetSelectionOwner(display, XA_PRIMARY) != selectionWindow)) ||
(TSXGetSelectionOwner(display, x11drv_atom(CLIPBOARD)) != selectionWindow)) (XGetSelectionOwner(display, x11drv_atom(CLIPBOARD)) != selectionWindow))
{ {
bLostSelection = TRUE; bLostSelection = TRUE;
} }
@ -2275,6 +2301,7 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar)
ClipboardSelectionOwner = selectionWindow; ClipboardSelectionOwner = selectionWindow;
} }
wine_tsx11_unlock();
} }
else else
{ {

View File

@ -24,7 +24,7 @@
#define NONAMELESSUNION #define NONAMELESSUNION
#define NONAMELESSSTRUCT #define NONAMELESSSTRUCT
#include "ts_xlib.h" #include <X11/Xlib.h>
#include <X11/extensions/xf86dga.h> #include <X11/extensions/xf86dga.h>
#include "x11drv.h" #include "x11drv.h"
@ -126,7 +126,9 @@ void X11DRV_XF86DGA2_Init(void)
void X11DRV_XF86DGA2_Cleanup(void) void X11DRV_XF86DGA2_Cleanup(void)
{ {
if (modes) TSXFree(modes); wine_tsx11_lock();
if (modes) XFree(modes);
wine_tsx11_unlock();
} }
static XDGADevice *dga_dev; static XDGADevice *dga_dev;

View File

@ -24,8 +24,7 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xlib.h>
#include "ts_xlib.h"
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#ifdef HAVE_LIBXXF86DGA2 #ifdef HAVE_LIBXXF86DGA2
@ -632,6 +631,8 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
EVENT_SelectionRequest_AddTARGETS(targets, &cTargets, alias); EVENT_SelectionRequest_AddTARGETS(targets, &cTargets, alias);
} }
wine_tsx11_lock();
if (TRACE_ON(clipboard)) if (TRACE_ON(clipboard))
{ {
int i; int i;
@ -639,17 +640,18 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
{ {
if (targets[i]) 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); 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, /* We may want to consider setting the type to xaTargets instead,
* in case some apps expect this instead of XA_ATOM */ * 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); PropModeReplace, (unsigned char *)targets, cTargets);
wine_tsx11_unlock();
HeapFree(GetProcessHeap(), 0, targets); HeapFree(GetProcessHeap(), 0, targets);
@ -678,7 +680,6 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
unsigned long remain; unsigned long remain;
Atom* targetPropList=NULL; Atom* targetPropList=NULL;
unsigned long cTargetPropList = 0; unsigned long cTargetPropList = 0;
/* Atom xAtomPair = TSXInternAtom(display, "ATOM_PAIR", False); */
/* If the specified property is None the requestor is an obsolete client. /* 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. * 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 /* Read the MULTIPLE property contents. This should contain a list of
* (target,property) atom pairs. * (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, 0, 0x3FFF, False, AnyPropertyType, &atype,&aformat,
&cTargetPropList, &remain, &cTargetPropList, &remain,
(unsigned char**)&targetPropList) != Success) (unsigned char**)&targetPropList) != Success)
{
wine_tsx11_unlock();
TRACE("\tCouldn't read MULTIPLE property\n"); TRACE("\tCouldn't read MULTIPLE property\n");
}
else else
{ {
TRACE("\tType %s,Format %d,nItems %ld, Remain %ld\n", 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. * Make sure we got what we expect.
@ -723,12 +729,15 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
if (TRACE_ON(event)) if (TRACE_ON(event))
{ {
char *targetName = TSXGetAtomName(display, targetPropList[i]); char *targetName, *propName;
char *propName = TSXGetAtomName(display, targetPropList[i+1]); wine_tsx11_lock();
targetName = XGetAtomName(display, targetPropList[i]);
propName = XGetAtomName(display, targetPropList[i+1]);
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n", TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
i/2, targetName, propName); i/2, targetName, propName);
TSXFree(targetName); XFree(targetName);
TSXFree(propName); XFree(propName);
wine_tsx11_unlock();
} }
/* We must have a non "None" property to service a MULTIPLE target atom */ /* 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 */ /* Free the list of targets/properties */
TSXFree(targetPropList); wine_tsx11_lock();
XFree(targetPropList);
wine_tsx11_unlock();
} }
END: END:
@ -829,19 +840,16 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO
TRACE_(clipboard)("\tUpdating property %s, %ld bytes\n", TRACE_(clipboard)("\tUpdating property %s, %ld bytes\n",
lpFormat->Name, cBytes); lpFormat->Name, cBytes);
TSXChangeProperty(display, request, rprop, event->target, wine_tsx11_lock();
XChangeProperty(display, request, rprop, event->target,
8, PropModeReplace, (unsigned char *)lpClipData, cBytes); 8, PropModeReplace, (unsigned char *)lpClipData, cBytes);
wine_tsx11_unlock();
GlobalUnlock(hClipData); GlobalUnlock(hClipData);
GlobalFree(hClipData); GlobalFree(hClipData);
} }
} }
} }
else
{
TRACE_(clipboard)("Request for property %s (%ld) failed\n",
TSXGetAtomName(display, event->target), event->target);
}
} }
END: END:
@ -887,15 +895,15 @@ static void EVENT_PropertyNotify( XPropertyEvent *event )
{ {
case PropertyDelete: case PropertyDelete:
{ {
TRACE("\tPropertyDelete for atom %s on window %ld\n", TRACE("\tPropertyDelete for atom %ld on window %ld\n",
TSXGetAtomName(event->display, event->atom), (long)event->window); event->atom, (long)event->window);
break; break;
} }
case PropertyNewValue: case PropertyNewValue:
{ {
TRACE("\tPropertyNewValue for atom %s on window %ld\n\n", TRACE("\tPropertyNewValue for atom %ld on window %ld\n\n",
TSXGetAtomName(event->display, event->atom), (long)event->window); event->atom, (long)event->window);
break; break;
} }
@ -980,9 +988,11 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
pWnd = WIN_FindWndPtr(hWnd); 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, &x, &y, (int *) &u.pt_aux.x, (int *) &u.pt_aux.y,
(unsigned int*)&aux_long); (unsigned int*)&aux_long);
wine_tsx11_unlock();
/* find out drop point and drop window */ /* find out drop point and drop window */
if( x < 0 || y < 0 || if( x < 0 || y < 0 ||
@ -1013,10 +1023,12 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if (!bAccept) return; if (!bAccept) return;
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display), wine_tsx11_lock();
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
x11drv_atom(DndSelection), 0, 65535, FALSE, x11drv_atom(DndSelection), 0, 65535, FALSE,
AnyPropertyType, &u.atom_aux, (int *) &u.pt_aux.y, AnyPropertyType, &u.atom_aux, (int *) &u.pt_aux.y,
&data_length, &aux_long, &p_data); &data_length, &aux_long, &p_data);
wine_tsx11_unlock();
if( !aux_long && p_data) /* don't bother if > 64K */ 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; 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, x11drv_atom(DndSelection), 0, 65535, FALSE,
AnyPropertyType, &u.atom_aux, &u.i, AnyPropertyType, &u.atom_aux, &u.i,
&data_length, &aux_long, &p_data); &data_length, &aux_long, &p_data);
wine_tsx11_unlock();
if (aux_long) if (aux_long)
WARN("property too large, truncated!\n"); WARN("property too large, truncated!\n");
TRACE("urls=%s\n", p_data); TRACE("urls=%s\n", p_data);
@ -1130,8 +1146,10 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
} }
if( drop_len && drop_len < 65535 ) { 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); &x, &y, &u.i, &u.i, &u.i);
wine_tsx11_unlock();
drop_len += sizeof(DROPFILES) + 1; drop_len += sizeof(DROPFILES) + 1;
hDrop = GlobalAlloc( GMEM_SHARE, drop_len ); 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 ); 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; int i;
Atom atom; Atom atom;
} u; /* unused */ } u; /* unused */
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display), wine_tsx11_lock();
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
dndSelection, 0, 65535, FALSE, dndSelection, 0, 65535, FALSE,
AnyPropertyType, &u.atom, &u.i, AnyPropertyType, &u.atom, &u.i,
&u.l, &u.l, &p_data); &u.l, &u.l, &p_data);
wine_tsx11_unlock();
TRACE("message_type=%ld, data=%ld,%ld,%ld,%ld,%ld, msg=%s\n", 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->message_type, event->data.l[0], event->data.l[1],
event->data.l[2], event->data.l[3], event->data.l[4], event->data.l[2], event->data.l[3], event->data.l[4],

View File

@ -27,8 +27,7 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xlib.h>
#include "ts_xlib.h"
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#ifdef HAVE_XKB #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) || if ((keysym >= XK_ISO_Lock && keysym <= XK_ISO_Last_Group_Lock) ||
keysym == XK_Mode_switch) 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; return;
} }
@ -1130,7 +1131,9 @@ void X11DRV_KeyEvent( HWND hwnd, XKeyEvent *event )
if (TRACE_ON(key)){ if (TRACE_ON(key)){
char *ksname; char *ksname;
ksname = TSXKeysymToString(keysym); wine_tsx11_lock();
ksname = XKeysymToString(keysym);
wine_tsx11_unlock();
if (!ksname) if (!ksname)
ksname = "No Name"; ksname = "No Name";
TRACE_(key)("%s : keysym=%lX (%s), # of chars=%d / 0x%02x / '%s'\n", 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 */ keysym = (unsigned char)cChar; /* (!) cChar is signed */
if (keysym <= 27) keysym += 0xFF00; /* special chars : return, backspace... */ 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) if (!keycode)
{ /* It didn't work ... let's try with deadchar code. */ { /* It didn't work ... let's try with deadchar code. */
TRACE("retrying with | 0xFE00\n"); 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", TRACE("'%c'(%#lx, %lu): got keycode %#.2x (%d)\n",
cChar, keysym, keysym, keycode, keycode); cChar, keysym, keysym, keycode, keycode);
@ -1682,14 +1687,16 @@ SHORT X11DRV_VkKeyScanEx(WCHAR wChar, HKL hkl)
} }
index = -1; index = -1;
wine_tsx11_lock();
for (i = 0; i < 4; i++) /* find shift state */ for (i = 0; i < 4; i++) /* find shift state */
{ {
if (TSXKeycodeToKeysym(display, keycode, i) == keysym) if (XKeycodeToKeysym(display, keycode, i) == keysym)
{ {
index = i; index = i;
break; break;
} }
} }
wine_tsx11_unlock();
switch (index) switch (index)
{ {
@ -1894,9 +1901,11 @@ INT X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize)
break; break;
if (keyi <= max_keycode) if (keyi <= max_keycode)
{ {
wine_tsx11_lock();
keyc = (KeyCode) keyi; keyc = (KeyCode) keyi;
keys = TSXKeycodeToKeysym(thread_display(), keyc, 0); keys = XKeycodeToKeysym(thread_display(), keyc, 0);
name = TSXKeysymToString(keys); name = XKeysymToString(keys);
wine_tsx11_unlock();
TRACE("found scan=%04x keyc=%04x keysym=%04x string=%s\n", TRACE("found scan=%04x keyc=%04x keysym=%04x string=%s\n",
scanCode, keyc, (int)keys, name); scanCode, keyc, (int)keys, name);
if (lpBuffer && nSize && name) if (lpBuffer && nSize && name)
@ -2130,7 +2139,9 @@ INT X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
{ {
char *ksname; char *ksname;
ksname = TSXKeysymToString(keysym); wine_tsx11_lock();
ksname = XKeysymToString(keysym);
wine_tsx11_unlock();
if (!ksname) if (!ksname)
ksname = "No Name"; ksname = "No Name";
if ((keysym >> 8) != 0xff) if ((keysym >> 8) != 0xff)

View File

@ -20,7 +20,7 @@
#include "config.h" #include "config.h"
#include "ts_xlib.h" #include <X11/Xlib.h>
#ifdef HAVE_LIBXXF86DGA2 #ifdef HAVE_LIBXXF86DGA2
#include <X11/extensions/xf86dga.h> #include <X11/extensions/xf86dga.h>
#endif #endif
@ -527,15 +527,17 @@ void X11DRV_GetCursorPos(LPPOINT pos)
int rootX, rootY, winX, winY; int rootX, rootY, winX, winY;
unsigned int xstate; 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 )) &rootX, &rootY, &winX, &winY, &xstate ))
return; {
update_key_state( xstate ); update_key_state( xstate );
update_button_state( xstate ); update_button_state( xstate );
TRACE("pointer at (%d,%d)\n", winX, winY ); TRACE("pointer at (%d,%d)\n", winX, winY );
pos->x = winX; pos->x = winX;
pos->y = winY; pos->y = winY;
}
wine_tsx11_unlock();
} }
/*********************************************************************** /***********************************************************************

View File

@ -28,7 +28,7 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#include "ts_xlib.h" #include <X11/Xlib.h>
#include <X11/Xresource.h> #include <X11/Xresource.h>
#include <X11/Xutil.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_whole_window( display, wndPtr )) goto failed;
if (!create_client_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, whole_window_atom, (HANDLE)data->whole_window );
SetPropA( hwnd, client_window_atom, (HANDLE)data->client_window ); SetPropA( hwnd, client_window_atom, (HANDLE)data->client_window );

View File

@ -21,7 +21,7 @@
#include "config.h" #include "config.h"
#include "ts_xlib.h" #include <X11/Xlib.h>
#ifdef HAVE_LIBXSHAPE #ifdef HAVE_LIBXSHAPE
#include <X11/IntrinsicP.h> #include <X11/IntrinsicP.h>
#include <X11/extensions/shape.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_sync_window_style( display, win );
X11DRV_set_wm_hints( display, win ); X11DRV_set_wm_hints( display, win );
TRACE( "mapping win %p\n", hwnd ); 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 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)) if (!IsRectEmpty( &win->rectWindow ) && get_whole_window(win) && is_window_top_level(win))
{ {
TRACE( "unmapping win %p\n", hwnd ); 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: done:
@ -851,12 +855,16 @@ void X11DRV_SetWindowStyle( HWND hwnd, LONG oldStyle )
X11DRV_sync_window_style( display, wndPtr ); X11DRV_sync_window_style( display, wndPtr );
X11DRV_set_wm_hints( 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 */ else if (!is_window_top_level(wndPtr)) /* don't unmap managed windows */
{ {
TRACE( "unmapping win %p\n", hwnd ); 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 */ /* resizing to zero size -> unmap */
TRACE( "unmapping zero size win %p\n", winpos->hwnd ); 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(); wine_tsx11_lock();
@ -1430,19 +1440,22 @@ static Window __get_common_ancestor( Display *display, Window A, Window B,
Window root, *childrenB; Window root, *childrenB;
unsigned totalB; unsigned totalB;
wine_tsx11_lock();
while( A != B && A && B ) while( A != B && A && B )
{ {
TSXQueryTree( display, A, &root, &A, children, total ); XQueryTree( display, A, &root, &A, children, total );
TSXQueryTree( display, B, &root, &B, &childrenB, &totalB ); XQueryTree( display, B, &root, &B, &childrenB, &totalB );
if( childrenB ) TSXFree( childrenB ); if( childrenB ) XFree( childrenB );
if( *children ) TSXFree( *children ), *children = NULL; if( *children ) XFree( *children ), *children = NULL;
} }
if( A && B ) if( A && B )
{ {
TSXQueryTree( display, A, &root, &B, children, total ); XQueryTree( display, A, &root, &B, children, total );
wine_tsx11_unlock();
return A; return A;
} }
wine_tsx11_unlock();
return 0 ; return 0 ;
} }
@ -1451,12 +1464,14 @@ static Window __get_top_decoration( Display *display, Window w, Window ancestor
Window* children, root, prev = w, parent = w; Window* children, root, prev = w, parent = w;
unsigned total; unsigned total;
wine_tsx11_lock();
do do
{ {
w = parent; w = parent;
TSXQueryTree( display, w, &root, &parent, &children, &total ); XQueryTree( display, w, &root, &parent, &children, &total );
if( children ) TSXFree( children ); if( children ) XFree( children );
} while( parent && parent != ancestor ); } while( parent && parent != ancestor );
wine_tsx11_unlock();
TRACE("\t%08x -> %08x\n", (unsigned)prev, (unsigned)w ); TRACE("\t%08x -> %08x\n", (unsigned)prev, (unsigned)w );
return ( parent ) ? w : 0 ; 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: done:
HeapFree( GetProcessHeap(), 0, list ); HeapFree( GetProcessHeap(), 0, list );

View File

@ -53,6 +53,9 @@ struct tagCURSORICONINFO;
struct tagPALETTEOBJ; struct tagPALETTEOBJ;
struct tagWINDOWPOS; struct tagWINDOWPOS;
extern void wine_tsx11_lock(void);
extern void wine_tsx11_unlock(void);
/* X physical pen */ /* X physical pen */
typedef struct typedef struct
{ {

View File

@ -20,7 +20,6 @@
#include "config.h" #include "config.h"
#include "ts_xlib.h"
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
@ -123,15 +122,17 @@ int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
{ {
unsigned int i = 0; unsigned int i = 0;
wine_tsx11_lock();
for (; i < count; i++) for (; i < count; i++)
{ {
if (xdndtypes[i] != 0) 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); TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes[i], pn);
TSXFree(pn); XFree(pn);
} }
} }
wine_tsx11_unlock();
} }
/* Do a one-time data read and cache results */ /* 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(); wine_tsx11_unlock();
entries += X11DRV_XDND_MapFormat(types[i], data, icount * (actfmt / 8)); entries += X11DRV_XDND_MapFormat(types[i], data, icount * (actfmt / 8));
TSXFree(data); wine_tsx11_lock();
XFree(data);
wine_tsx11_unlock();
} }
*count = entries; *count = entries;

View File

@ -22,7 +22,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "ts_xlib.h" #include <X11/Xlib.h>
#ifdef HAVE_LIBXXF86VM #ifdef HAVE_LIBXXF86VM
#define XMD_H #define XMD_H
@ -216,7 +216,9 @@ void X11DRV_XF86VM_Init(void)
void X11DRV_XF86VM_Cleanup(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) void X11DRV_XF86VM_SetExclusiveMode(int lock)

View File

@ -24,10 +24,6 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include <X11/Xatom.h>
#include "ts_xlib.h"
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
@ -441,15 +437,14 @@ static UINT16 __genericCheckSum( const void *ptr, int size )
* *
* These functions also do TILDE to HYPHEN conversion * 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; char *lpch = lpFont, *lfd_fld[LFD_FIELDS], *field_start;
int i; int i;
if (*lpch != HYPHEN) if (*lpch != HYPHEN)
{ {
WARN("font '%s' doesn't begin with '%c'\n", lpFont, HYPHEN); WARN("font '%s' doesn't begin with '%c'\n", lpFont, HYPHEN);
return NULL; return FALSE;
} }
field_start = ++lpch; field_start = ++lpch;
@ -482,9 +477,6 @@ static LFD* LFD_Parse(LPSTR lpFont)
if (*lpch) if (*lpch)
WARN("Extra ignored in font '%s'\n", lpFont); WARN("Extra ignored in font '%s'\n", lpFont);
lfd = HeapAlloc( GetProcessHeap(), 0, sizeof(LFD) );
if (lfd)
{
lfd->foundry = lfd_fld[0]; lfd->foundry = lfd_fld[0];
lfd->family = lfd_fld[1]; lfd->family = lfd_fld[1];
lfd->weight = lfd_fld[2]; lfd->weight = lfd_fld[2];
@ -499,8 +491,7 @@ static LFD* LFD_Parse(LPSTR lpFont)
lfd->average_width = lfd_fld[11]; lfd->average_width = lfd_fld[11];
lfd->charset_registry = lfd_fld[12]; lfd->charset_registry = lfd_fld[12];
lfd->charset_encoding = lfd_fld[13]; lfd->charset_encoding = lfd_fld[13];
} return TRUE;
return lfd;
} }
@ -1064,15 +1055,18 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
if( pEL ) *pEL = 0; if( pEL ) *pEL = 0;
if(XFT) { 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 - *pIL = XFT->ascent -
(INT)(XFT->pixelsize / 1000.0 * height); (INT)(XFT->pixelsize / 1000.0 * height);
else else
*pIL = 0; *pIL = 0;
wine_tsx11_unlock();
return; 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( x_fs->per_char )
if( bIsLatin && ((unsigned char)'X' <= (max - min)) ) if( bIsLatin && ((unsigned char)'X' <= (max - min)) )
@ -1089,6 +1083,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
else else
height = x_fs->min_bounds.ascent; height = x_fs->min_bounds.ascent;
} }
wine_tsx11_unlock();
*pIL = x_fs->ascent - height; *pIL = x_fs->ascent - height;
} }
@ -1464,17 +1459,15 @@ static void XFONT_LoadDefault(LPCSTR ini, LPCSTR fonttype)
if (*buffer) if (*buffer)
{ {
LFD* lfd; LFD lfd;
char* pch = buffer; char* pch = buffer;
while( *pch && isspace(*pch) ) pch++; while( *pch && isspace(*pch) ) pch++;
TRACE("Using '%s' as default %sfont\n", pch, fonttype); TRACE("Using '%s' as default %sfont\n", pch, fonttype);
lfd = LFD_Parse(pch); if (LFD_Parse(pch, &lfd) && lfd.foundry && lfd.family)
if (lfd && lfd->foundry && lfd->family) XFONT_LoadDefaultLFD(&lfd, fonttype);
XFONT_LoadDefaultLFD(lfd, fonttype);
else else
WARN("Ini section [%s]%s is malformed\n", INIFontSection, ini); 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 *lpResource;
char buffer[MAX_LFD_LENGTH]; char buffer[MAX_LFD_LENGTH];
int i = 0; int i = 0;
LFD* lfd; LFD lfd;
HKEY hkey; HKEY hkey;
/* built-ins first */ /* built-ins first */
@ -1671,16 +1664,14 @@ static void XFONT_LoadAliases(void)
RegCloseKey(hkey); RegCloseKey(hkey);
} }
TRACE("Using '%s' as default serif font\n", buffer); TRACE("Using '%s' as default serif font\n", buffer);
lfd = LFD_Parse(buffer); if (LFD_Parse(buffer, &lfd))
/* NB XFONT_InitialCapitals should not change these standard aliases */
if (lfd)
{ {
XFONT_LoadAlias( lfd, "Tms Roman", FALSE); /* NB XFONT_InitialCapitals should not change these standard aliases */
XFONT_LoadAlias( lfd, "MS Serif", FALSE); XFONT_LoadAlias( &lfd, "Tms Roman", FALSE);
XFONT_LoadAlias( lfd, "Times New Roman", FALSE); XFONT_LoadAlias( &lfd, "MS Serif", FALSE);
XFONT_LoadAlias( &lfd, "Times New Roman", FALSE);
XFONT_LoadDefaultLFD( lfd, "serif "); XFONT_LoadDefaultLFD( &lfd, "serif ");
HeapFree(GetProcessHeap(), 0, lfd);
} }
strcpy(buffer, "-adobe-helvetica-"); strcpy(buffer, "-adobe-helvetica-");
@ -1691,17 +1682,15 @@ static void XFONT_LoadAliases(void)
RegCloseKey(hkey); RegCloseKey(hkey);
} }
TRACE("Using '%s' as default sans serif font\n", buffer); TRACE("Using '%s' as default sans serif font\n", buffer);
lfd = LFD_Parse(buffer); if (LFD_Parse(buffer, &lfd))
if (lfd)
{ {
XFONT_LoadAlias( lfd, "Helv", FALSE); XFONT_LoadAlias( &lfd, "Helv", FALSE);
XFONT_LoadAlias( lfd, "MS Sans Serif", FALSE); XFONT_LoadAlias( &lfd, "MS Sans Serif", FALSE);
XFONT_LoadAlias( lfd, "MS Shell Dlg", FALSE); XFONT_LoadAlias( &lfd, "MS Shell Dlg", FALSE);
XFONT_LoadAlias( lfd, "System", FALSE); XFONT_LoadAlias( &lfd, "System", FALSE);
XFONT_LoadAlias( lfd, "Arial", FALSE); XFONT_LoadAlias( &lfd, "Arial", FALSE);
XFONT_LoadDefaultLFD( lfd, "sans serif "); XFONT_LoadDefaultLFD( &lfd, "sans serif ");
HeapFree(GetProcessHeap(), 0, lfd);
} }
/* then user specified aliases */ /* then user specified aliases */
@ -1727,12 +1716,7 @@ static void XFONT_LoadAliases(void)
bSubst = (XFONT_GetStringItem( lpResource )) ? TRUE : FALSE; bSubst = (XFONT_GetStringItem( lpResource )) ? TRUE : FALSE;
if( lpResource && *lpResource ) if( lpResource && *lpResource )
{ {
lfd = LFD_Parse(lpResource); if (LFD_Parse(lpResource, &lfd)) XFONT_LoadAlias(&lfd, buffer, bSubst);
if (lfd)
{
XFONT_LoadAlias(lfd, buffer, bSubst);
HeapFree(GetProcessHeap(), 0, lfd);
}
} }
else else
WARN("malformed font alias '%s'\n", buffer ); WARN("malformed font alias '%s'\n", buffer );
@ -1810,13 +1794,13 @@ void XFONT_RemoveFontResource( fontResource** ppfr )
static void XFONT_LoadIgnore(char* lfdname) static void XFONT_LoadIgnore(char* lfdname)
{ {
fontResource** ppfr; fontResource** ppfr;
LFD lfd;
LFD* lfd = LFD_Parse(lfdname); if (LFD_Parse(lfdname, &lfd) && lfd.foundry && lfd.family)
if (lfd && lfd->foundry && lfd->family)
{ {
for( ppfr = &fontList; *ppfr ; ppfr = &((*ppfr)->next)) for( ppfr = &fontList; *ppfr ; ppfr = &((*ppfr)->next))
{ {
if( XFONT_SameFoundryAndFamily( (*ppfr)->resource, lfd) ) if( XFONT_SameFoundryAndFamily( (*ppfr)->resource, &lfd) )
{ {
TRACE("Ignoring '-%s-%s-'\n", TRACE("Ignoring '-%s-%s-'\n",
(*ppfr)->resource->foundry, (*ppfr)->resource->family ); (*ppfr)->resource->foundry, (*ppfr)->resource->family );
@ -1828,8 +1812,6 @@ static void XFONT_LoadIgnore(char* lfdname)
} }
else else
WARN("Malformed font resource\n"); WARN("Malformed font resource\n");
HeapFree(GetProcessHeap(), 0, lfd);
} }
static void XFONT_LoadIgnores(void) 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++ ) for( i = 0; i < x_count; i++ )
{ {
char* typeface; char* typeface;
LFD* lfd; LFD lfd;
int j; int j;
char buffer[MAX_LFD_LENGTH]; char buffer[MAX_LFD_LENGTH];
char* lpstr; char* lpstr;
@ -2058,8 +2040,7 @@ static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, in
strcpy( typeface, x_pattern[i] ); strcpy( typeface, x_pattern[i] );
if (i % 10 == 0) MESSAGE("Font metrics: %.1f%% done\n", 100.0 * i / x_count); if (i % 10 == 0) MESSAGE("Font metrics: %.1f%% done\n", 100.0 * i / x_count);
lfd = LFD_Parse(typeface); if (!LFD_Parse(typeface, &lfd))
if (!lfd)
{ {
HeapFree(GetProcessHeap(), 0, typeface); HeapFree(GetProcessHeap(), 0, typeface);
continue; 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 ) for( pfr = NULL, fr = fontList; fr; fr = fr->next )
{ {
if( XFONT_SameFoundryAndFamily(fr->resource, lfd)) if( XFONT_SameFoundryAndFamily(fr->resource, &lfd))
break; break;
pfr = fr; pfr = fr;
} }
if( !fi ) fi = (fontInfo*) HeapAlloc(GetProcessHeap(), 0, sizeof(fontInfo)); 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; goto nextfont;
if( !fr ) /* add new family */ 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)); fr->resource = (LFD*) HeapAlloc(GetProcessHeap(), 0, sizeof(LFD));
memset(fr->resource, 0, sizeof(LFD)); memset(fr->resource, 0, sizeof(LFD));
TRACE("family: -%s-%s-\n", lfd->foundry, lfd->family ); TRACE("family: -%s-%s-\n", lfd.foundry, lfd.family );
fr->resource->foundry = HeapAlloc(GetProcessHeap(), 0, strlen(lfd->foundry)+1); fr->resource->foundry = HeapAlloc(GetProcessHeap(), 0, strlen(lfd.foundry)+1);
strcpy( (char *)fr->resource->foundry, lfd->foundry ); strcpy( (char *)fr->resource->foundry, lfd.foundry );
fr->resource->family = HeapAlloc(GetProcessHeap(), 0, strlen(lfd->family)+1); fr->resource->family = HeapAlloc(GetProcessHeap(), 0, strlen(lfd.family)+1);
strcpy( (char *)fr->resource->family, lfd->family ); strcpy( (char *)fr->resource->family, lfd.family );
fr->resource->weight = ""; fr->resource->weight = "";
if( pfr ) pfr->next = fr; 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(pxl_string, "%d", fi->lfd_height);
sprintf(res_string, "%d", fi->lfd_resolution); sprintf(res_string, "%d", fi->lfd_resolution);
lfd1 = *lfd; lfd1 = lfd;
lfd1.pixel_size = pxl_string; lfd1.pixel_size = pxl_string;
lfd1.point_size = "*"; lfd1.point_size = "*";
lfd1.resolution_x = res_string; 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) if ((x_fs = safe_XLoadQueryFont(gdi_display, lpstr)) != 0)
{ {
XFONT_SetFontMetric( fi, fr, x_fs ); 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); 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 ); XFONT_CheckFIList( fr, fi, UNMARK_SUBSETS );
} }
nextfont: nextfont:
HeapFree(GetProcessHeap(), 0, lfd);
HeapFree(GetProcessHeap(), 0, typeface); HeapFree(GetProcessHeap(), 0, typeface);
} }
if( fi ) HeapFree(GetProcessHeap(), 0, fi); 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; size_t len = strlen(lpch) + 1;
TRACE("\t%s, %i instances\n", lpch, pfr->fi_count ); 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; lpch += len;
offset += len; offset += len;
if (offset > length) if (offset > length)
@ -2857,7 +2844,9 @@ static fontObject* XFONT_GetCacheEntry(void)
if(fontCache[j].lpX11Trans) if(fontCache[j].lpX11Trans)
HeapFree( GetProcessHeap(), 0, 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) ); memset( fontCache + j, 0, sizeof(fontObject) );
return (fontCache + j); return (fontCache + j);
@ -3040,31 +3029,25 @@ static BOOL XFONT_SetX11Trans( fontObject *pfo )
{ {
char *fontName; char *fontName;
Atom nameAtom; Atom nameAtom;
LFD* lfd; LFD lfd;
TSXGetFontProperty( pfo->fs, XA_FONT, &nameAtom ); wine_tsx11_lock();
fontName = TSXGetAtomName( gdi_display, nameAtom ); XGetFontProperty( pfo->fs, XA_FONT, &nameAtom );
lfd = LFD_Parse(fontName); fontName = XGetAtomName( gdi_display, nameAtom );
if (!lfd) if (!LFD_Parse(fontName, &lfd) || lfd.pixel_size[0] != '[')
{ {
TSXFree(fontName); XFree(fontName);
wine_tsx11_unlock();
return FALSE; return FALSE;
} }
if (lfd->pixel_size[0] != '[') {
HeapFree(GetProcessHeap(), 0, lfd);
TSXFree(fontName);
return FALSE;
}
#define PX pfo->lpX11Trans #define PX pfo->lpX11Trans
sscanf(lfd->pixel_size, "[%f%f%f%f]", &PX->a, &PX->b, &PX->c, &PX->d); sscanf(lfd.pixel_size, "[%f%f%f%f]", &PX->a, &PX->b, &PX->c, &PX->d);
TSXFree(fontName); XFree(fontName);
HeapFree(GetProcessHeap(), 0, lfd);
TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_ASCENT), &PX->RAW_ASCENT ); XGetFontProperty( 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_DESCENT), &PX->RAW_DESCENT );
wine_tsx11_unlock();
PX->pixelsize = hypot(PX->a, PX->b); PX->pixelsize = hypot(PX->a, PX->b);
PX->ascent = PX->pixelsize / 1000.0 * PX->RAW_ASCENT; PX->ascent = PX->pixelsize / 1000.0 * PX->RAW_ASCENT;