Commit d09c3289 authored by Alexandre Julliard's avatar Alexandre Julliard

Intern all the atoms we'll need in one step to avoid multiple server

round trips.
parent f01e7c63
...@@ -98,21 +98,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard); ...@@ -98,21 +98,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard);
#define S_PRIMARY 1 #define S_PRIMARY 1
#define S_CLIPBOARD 2 #define S_CLIPBOARD 2
/* CLIPBOARD atom names */
#define _CLIPBOARD "CLIPBOARD"
#define _TARGETS "TARGETS"
#define _MULTIPLE "MULTIPLE"
#define _SELECTIONDATA "SELECTION_DATA"
#define _TEXT "TEXT"
#define _COMPOUNDTEXT "COMPOUND_TEXT"
Atom xaClipboard = None;
Atom xaTargets = None;
Atom xaMultiple = None;
Atom xaSelectionData = None;
Atom xaText = None;
Atom xaCompoundText = None;
static int selectionAcquired = 0; /* Contains the current selection masks */ static int selectionAcquired = 0; /* Contains the current selection masks */
static Window selectionWindow = None; /* The top level X window which owns the selection */ static Window selectionWindow = None; /* The top level X window which owns the selection */
static BOOL clearAllSelections = FALSE; /* Always lose all selections */ static BOOL clearAllSelections = FALSE; /* Always lose all selections */
...@@ -138,7 +123,7 @@ HANDLE X11DRV_CLIPBOARD_ExportMetaFilePict(Window requestor, Atom aTarget, ...@@ -138,7 +123,7 @@ HANDLE X11DRV_CLIPBOARD_ExportMetaFilePict(Window requestor, Atom aTarget,
Atom rprop, LPWINE_CLIPDATA lpdata, LPDWORD lpBytes); Atom rprop, LPWINE_CLIPDATA lpdata, LPDWORD lpBytes);
HANDLE X11DRV_CLIPBOARD_ExportEnhMetaFile(Window requestor, Atom aTarget, HANDLE X11DRV_CLIPBOARD_ExportEnhMetaFile(Window requestor, Atom aTarget,
Atom rprop, LPWINE_CLIPDATA lpdata, LPDWORD lpBytes); Atom rprop, LPWINE_CLIPDATA lpdata, LPDWORD lpBytes);
UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyName); static UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, Atom prop);
static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, Atom prop); static BOOL X11DRV_CLIPBOARD_ReadSelection(LPWINE_CLIPFORMAT lpData, Window w, Atom prop);
static BOOL X11DRV_CLIPBOARD_RenderSynthesizedText(UINT wFormatID); static BOOL X11DRV_CLIPBOARD_RenderSynthesizedText(UINT wFormatID);
static void X11DRV_CLIPBOARD_FreeData(LPWINE_CLIPDATA lpData); static void X11DRV_CLIPBOARD_FreeData(LPWINE_CLIPDATA lpData);
...@@ -154,7 +139,7 @@ static BOOL X11DRV_CLIPBOARD_RenderSynthesizedFormat(LPWINE_CLIPDATA lpData); ...@@ -154,7 +139,7 @@ static BOOL X11DRV_CLIPBOARD_RenderSynthesizedFormat(LPWINE_CLIPDATA lpData);
* WARNING: This data ordering is dependent on the WINE_CLIPFORMAT structure * WARNING: This data ordering is dependent on the WINE_CLIPFORMAT structure
* declared in clipboard.h * declared in clipboard.h
*/ */
WINE_CLIPFORMAT ClipFormats[] = static WINE_CLIPFORMAT ClipFormats[] =
{ {
{ CF_TEXT, "WCF_TEXT", 0, CF_FLAG_BUILTINFMT, X11DRV_CLIPBOARD_ImportClipboardData, { CF_TEXT, "WCF_TEXT", 0, CF_FLAG_BUILTINFMT, X11DRV_CLIPBOARD_ImportClipboardData,
X11DRV_CLIPBOARD_ExportClipboardData, NULL, &ClipFormats[1]}, X11DRV_CLIPBOARD_ExportClipboardData, NULL, &ClipFormats[1]},
...@@ -223,25 +208,34 @@ WINE_CLIPFORMAT ClipFormats[] = ...@@ -223,25 +208,34 @@ WINE_CLIPFORMAT ClipFormats[] =
X11DRV_CLIPBOARD_ExportClipboardData, &ClipFormats[20], NULL} X11DRV_CLIPBOARD_ExportClipboardData, &ClipFormats[20], NULL}
}; };
#define GET_ATOM(prop) (((prop) < FIRST_XATOM) ? (Atom)(prop) : X11DRV_Atoms[(prop) - FIRST_XATOM])
/* Maps X properties to Windows formats */ /* Maps X properties to Windows formats */
PROPERTYFORMATMAP PropertyFormatMap[] = static const struct
{ {
{ "text/rtf", "Rich Text Format" }, LPCSTR lpszFormat;
UINT prop;
} PropertyFormatMap[] =
{
{ "Rich Text Format", XATOM_text_rtf },
/* Temporarily disable text/html because Evolution incorrectly pastes strings with extra nulls */ /* Temporarily disable text/html because Evolution incorrectly pastes strings with extra nulls */
/*{ "text/html", "HTML Format" },*/ /*{ "text/html", "HTML Format" },*/
{ "image/gif", "GIF" }, { "GIF", XATOM_image_gif }
}; };
/* Maps equivalent X properties. It is assumed that lpszProperty must already /* Maps equivalent X properties. It is assumed that lpszProperty must already
be in ClipFormats or PropertyFormatMap. */ be in ClipFormats or PropertyFormatMap. */
PROPERTYALIASMAP PropertyAliasMap[] = static const struct
{ {
/* lpszProperty, Alias */ UINT drvDataProperty;
{ "text/rtf", 0, "text/richtext", 0 }, UINT drvDataAlias;
{ "XAString", XA_STRING, _COMPOUNDTEXT, 0 }, } PropertyAliasMap[] =
{ "XAString", XA_STRING, _TEXT, 0 }, {
/* DataProperty, DataAlias */
{ XATOM_text_rtf, XATOM_text_richtext },
{ XA_STRING, XATOM_COMPOUND_TEXT },
{ XA_STRING, XATOM_TEXT },
}; };
...@@ -254,7 +248,7 @@ static UINT ClipDataCount = 0; ...@@ -254,7 +248,7 @@ static UINT ClipDataCount = 0;
/* /*
* Clipboard sequence number * Clipboard sequence number
*/ */
UINT wSeqNo = 0; static UINT wSeqNo = 0;
/************************************************************************** /**************************************************************************
* Internal Clipboard implementation methods * Internal Clipboard implementation methods
...@@ -263,20 +257,12 @@ UINT wSeqNo = 0; ...@@ -263,20 +257,12 @@ UINT wSeqNo = 0;
/************************************************************************** /**************************************************************************
* X11DRV_InitClipboard * X11DRV_InitClipboard
*/ */
BOOL X11DRV_InitClipboard(Display *display) void X11DRV_InitClipboard(Display *display)
{ {
INT i; INT i;
HKEY hkey; HKEY hkey;
PROPERTYALIASMAP *lpalias;
LPWINE_CLIPFORMAT lpFormat = ClipFormats; LPWINE_CLIPFORMAT lpFormat = ClipFormats;
xaClipboard = TSXInternAtom( display, _CLIPBOARD, FALSE );
xaTargets = TSXInternAtom( display, _TARGETS, FALSE );
xaMultiple = TSXInternAtom(display, _MULTIPLE, False);
xaSelectionData = TSXInternAtom(display, _SELECTIONDATA, False);
xaText = TSXInternAtom(display, _TEXT, False);
xaCompoundText = TSXInternAtom(display, _COMPOUNDTEXT, False);
if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Clipboard", &hkey)) if(!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Clipboard", &hkey))
{ {
char buffer[20]; char buffer[20];
...@@ -299,21 +285,9 @@ BOOL X11DRV_InitClipboard(Display *display) ...@@ -299,21 +285,9 @@ BOOL X11DRV_InitClipboard(Display *display)
} }
/* Register known mapping between window formats and X properties */ /* Register known mapping between window formats and X properties */
for (i = 0; i < sizeof(PropertyFormatMap)/sizeof(PROPERTYFORMATMAP); i++) for (i = 0; i < sizeof(PropertyFormatMap)/sizeof(PropertyFormatMap[0]); i++)
X11DRV_CLIPBOARD_InsertClipboardFormat(PropertyFormatMap[i].lpszFormat, X11DRV_CLIPBOARD_InsertClipboardFormat(PropertyFormatMap[i].lpszFormat,
PropertyFormatMap[i].lpszProperty); GET_ATOM(PropertyFormatMap[i].prop));
/* Register known mapping between X properties */
for (i = 0; i < sizeof(PropertyAliasMap)/sizeof(PROPERTYALIASMAP); i++)
{
lpalias = &PropertyAliasMap[i];
if (!lpalias->drvDataProperty)
lpalias->drvDataProperty = TSXInternAtom(display, lpalias->lpszProperty, False);
if (!lpalias->drvDataAlias)
lpalias->drvDataAlias = TSXInternAtom(display, lpalias->lpszAlias, False);
}
return TRUE;
} }
...@@ -363,11 +337,11 @@ LPWINE_CLIPFORMAT X11DRV_CLIPBOARD_LookupAliasProperty(UINT drvDataAlias) ...@@ -363,11 +337,11 @@ LPWINE_CLIPFORMAT X11DRV_CLIPBOARD_LookupAliasProperty(UINT drvDataAlias)
unsigned int i; unsigned int i;
LPWINE_CLIPFORMAT lpFormat = NULL; LPWINE_CLIPFORMAT lpFormat = NULL;
for (i = 0; i < sizeof(PropertyAliasMap)/sizeof(PROPERTYALIASMAP); i++) for (i = 0; i < sizeof(PropertyAliasMap)/sizeof(PropertyAliasMap[0]); i++)
{ {
if (PropertyAliasMap[i].drvDataAlias == drvDataAlias) if (GET_ATOM(PropertyAliasMap[i].drvDataAlias) == drvDataAlias)
{ {
lpFormat = X11DRV_CLIPBOARD_LookupProperty(PropertyAliasMap[i].drvDataProperty); lpFormat = X11DRV_CLIPBOARD_LookupProperty(GET_ATOM(PropertyAliasMap[i].drvDataProperty));
break; break;
} }
} }
...@@ -384,11 +358,11 @@ UINT X11DRV_CLIPBOARD_LookupPropertyAlias(UINT drvDataProperty) ...@@ -384,11 +358,11 @@ UINT X11DRV_CLIPBOARD_LookupPropertyAlias(UINT drvDataProperty)
unsigned int i; unsigned int i;
UINT alias = 0; UINT alias = 0;
for (i = 0; i < sizeof(PropertyAliasMap)/sizeof(PROPERTYALIASMAP); i++) for (i = 0; i < sizeof(PropertyAliasMap)/sizeof(PropertyAliasMap[0]); i++)
{ {
if (PropertyAliasMap[i].drvDataProperty == drvDataProperty) if (GET_ATOM(PropertyAliasMap[i].drvDataProperty) == drvDataProperty)
{ {
alias = PropertyAliasMap[i].drvDataAlias; alias = GET_ATOM(PropertyAliasMap[i].drvDataAlias);
break; break;
} }
} }
...@@ -426,7 +400,7 @@ LPWINE_CLIPDATA X11DRV_CLIPBOARD_LookupData(DWORD wID) ...@@ -426,7 +400,7 @@ LPWINE_CLIPDATA X11DRV_CLIPBOARD_LookupData(DWORD wID)
/************************************************************************** /**************************************************************************
* InsertClipboardFormat * InsertClipboardFormat
*/ */
UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyName) static UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, Atom prop)
{ {
LPWINE_CLIPFORMAT lpFormat; LPWINE_CLIPFORMAT lpFormat;
LPWINE_CLIPFORMAT lpNewFormat; LPWINE_CLIPFORMAT lpNewFormat;
...@@ -451,7 +425,7 @@ UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyNa ...@@ -451,7 +425,7 @@ UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyNa
strcpy(lpNewFormat->Name, FormatName); strcpy(lpNewFormat->Name, FormatName);
lpNewFormat->wFlags = 0; lpNewFormat->wFlags = 0;
lpNewFormat->wFormatID = GlobalAddAtomA(lpNewFormat->Name); lpNewFormat->wFormatID = GlobalAddAtomA(lpNewFormat->Name);
lpNewFormat->drvData = TSXInternAtom(thread_display(), PropertyName, False); lpNewFormat->drvData = prop;
lpNewFormat->lpDrvImportFunc = X11DRV_CLIPBOARD_ImportClipboardData; lpNewFormat->lpDrvImportFunc = X11DRV_CLIPBOARD_ImportClipboardData;
lpNewFormat->lpDrvExportFunc = X11DRV_CLIPBOARD_ExportClipboardData; lpNewFormat->lpDrvExportFunc = X11DRV_CLIPBOARD_ExportClipboardData;
...@@ -465,11 +439,8 @@ UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyNa ...@@ -465,11 +439,8 @@ UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyNa
lpFormat->NextFormat = lpNewFormat; lpFormat->NextFormat = lpNewFormat;
lpNewFormat->PrevFormat = lpFormat; lpNewFormat->PrevFormat = lpFormat;
TRACE("Registering format(%d): %s drvData(%d): %s\n", TRACE("Registering format(%d): %s drvData %d\n",
lpNewFormat->wFormatID, lpNewFormat->wFormatID, FormatName, lpNewFormat->drvData);
FormatName,
lpNewFormat->drvData,
PropertyName);
return lpNewFormat->wFormatID; return lpNewFormat->wFormatID;
} }
...@@ -1154,7 +1125,7 @@ HANDLE X11DRV_CLIPBOARD_ExportCompoundText(Window requestor, Atom aTarget, Atom ...@@ -1154,7 +1125,7 @@ HANDLE X11DRV_CLIPBOARD_ExportCompoundText(Window requestor, Atom aTarget, Atom
if (lpstr) if (lpstr)
{ {
if (aTarget == xaCompoundText) if (aTarget == x11drv_atom(COMPOUND_TEXT))
style = XCompoundTextStyle; style = XCompoundTextStyle;
else else
style = XStdICCTextStyle; style = XStdICCTextStyle;
...@@ -1186,7 +1157,7 @@ HANDLE X11DRV_CLIPBOARD_ExportString(Window requestor, Atom aTarget, Atom rprop, ...@@ -1186,7 +1157,7 @@ HANDLE X11DRV_CLIPBOARD_ExportString(Window requestor, Atom aTarget, Atom rprop,
{ {
if (aTarget == XA_STRING) if (aTarget == XA_STRING)
return X11DRV_CLIPBOARD_ExportXAString(lpData, lpBytes); return X11DRV_CLIPBOARD_ExportXAString(lpData, lpBytes);
else if (aTarget == xaCompoundText || aTarget == xaText) else if (aTarget == x11drv_atom(COMPOUND_TEXT) || aTarget == x11drv_atom(TEXT))
return X11DRV_CLIPBOARD_ExportCompoundText(requestor, aTarget, return X11DRV_CLIPBOARD_ExportCompoundText(requestor, aTarget,
rprop, lpData, lpBytes); rprop, lpData, lpBytes);
else else
...@@ -1275,7 +1246,8 @@ static BOOL X11DRV_CLIPBOARD_QueryTargets(Display *display, Window w, Atom selec ...@@ -1275,7 +1246,8 @@ static BOOL X11DRV_CLIPBOARD_QueryTargets(Display *display, Window w, Atom selec
Bool res; Bool res;
wine_tsx11_lock(); wine_tsx11_lock();
XConvertSelection(display, selection, xaTargets, xaSelectionData, w, CurrentTime); XConvertSelection(display, selection, x11drv_atom(TARGETS),
x11drv_atom(SELECTION_DATA), w, CurrentTime);
wine_tsx11_unlock(); wine_tsx11_unlock();
/* /*
...@@ -1292,7 +1264,7 @@ static BOOL X11DRV_CLIPBOARD_QueryTargets(Display *display, Window w, Atom selec ...@@ -1292,7 +1264,7 @@ static BOOL X11DRV_CLIPBOARD_QueryTargets(Display *display, Window w, Atom selec
} }
/* Verify that the selection returned a valid TARGETS property */ /* Verify that the selection returned a valid TARGETS property */
if ((xe->xselection.target != xaTargets) || (xe->xselection.property == None)) if ((xe->xselection.target != x11drv_atom(TARGETS)) || (xe->xselection.property == None))
{ {
/* Selection owner failed to respond or we missed the SelectionNotify */ /* Selection owner failed to respond or we missed the SelectionNotify */
WARN("Failed to retrieve TARGETS for selection %ld.\n", selection); WARN("Failed to retrieve TARGETS for selection %ld.\n", selection);
...@@ -1332,7 +1304,7 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo) ...@@ -1332,7 +1304,7 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow) if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
selectionAcquired |= S_PRIMARY; selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,xaClipboard) == selectionWindow) if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
selectionAcquired |= S_CLIPBOARD; selectionAcquired |= S_CLIPBOARD;
if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD))) if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD)))
...@@ -1365,12 +1337,12 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo) ...@@ -1365,12 +1337,12 @@ 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) || if (TSXGetSelectionOwner(display,XA_PRIMARY) ||
TSXGetSelectionOwner(display,xaClipboard)) TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{ {
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, xaClipboard, &xe)) else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), &xe))
selectionCacheSrc = xaClipboard; selectionCacheSrc = x11drv_atom(CLIPBOARD);
else else
return -1; return -1;
} }
...@@ -1392,7 +1364,7 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo) ...@@ -1392,7 +1364,7 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
* The TARGETS property should have returned us a list of atoms * The TARGETS property should have returned us a list of atoms
* corresponding to each selection target format supported. * corresponding to each selection target format supported.
*/ */
if ((atype == XA_ATOM || atype == xaTargets) && aformat == 32) if ((atype == XA_ATOM || atype == x11drv_atom(TARGETS)) && aformat == 32)
{ {
INT i; INT i;
...@@ -1478,7 +1450,7 @@ static BOOL X11DRV_CLIPBOARD_ReadClipboardData(UINT wFormat) ...@@ -1478,7 +1450,7 @@ static BOOL X11DRV_CLIPBOARD_ReadClipboardData(UINT wFormat)
wine_tsx11_lock(); wine_tsx11_lock();
XConvertSelection(display, selectionCacheSrc, lpFormat->drvData, XConvertSelection(display, selectionCacheSrc, lpFormat->drvData,
xaSelectionData, w, CurrentTime); x11drv_atom(SELECTION_DATA), w, CurrentTime);
wine_tsx11_unlock(); wine_tsx11_unlock();
/* wait until SelectionNotify is received */ /* wait until SelectionNotify is received */
...@@ -1498,7 +1470,7 @@ static BOOL X11DRV_CLIPBOARD_ReadClipboardData(UINT wFormat) ...@@ -1498,7 +1470,7 @@ static BOOL X11DRV_CLIPBOARD_ReadClipboardData(UINT wFormat)
{ {
wine_tsx11_lock(); wine_tsx11_lock();
XConvertSelection(display, selectionCacheSrc, alias, XConvertSelection(display, selectionCacheSrc, alias,
xaSelectionData, w, CurrentTime); x11drv_atom(SELECTION_DATA), w, CurrentTime);
wine_tsx11_unlock(); wine_tsx11_unlock();
/* wait until SelectionNotify is received */ /* wait until SelectionNotify is received */
...@@ -1726,7 +1698,7 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd) ...@@ -1726,7 +1698,7 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd)
* dictate that *all* selections should be cleared on loss of a selection, * dictate that *all* selections should be cleared on loss of a selection,
* we must give up all the selections we own. * we must give up all the selections we own.
*/ */
if (clearAllSelections || (selType == xaClipboard)) if (clearAllSelections || (selType == x11drv_atom(CLIPBOARD)))
{ {
CLIPBOARDINFO cbinfo; CLIPBOARDINFO cbinfo;
...@@ -1752,7 +1724,7 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd) ...@@ -1752,7 +1724,7 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd)
if (OpenClipboard(hwnd)) if (OpenClipboard(hwnd))
{ {
/* We really lost CLIPBOARD but want to voluntarily lose PRIMARY */ /* We really lost CLIPBOARD but want to voluntarily lose PRIMARY */
if ((selType == xaClipboard) && (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)) if (selectionWindow == TSXGetSelectionOwner(display,XA_PRIMARY))
...@@ -1768,10 +1740,10 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd) ...@@ -1768,10 +1740,10 @@ void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd)
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,xaClipboard)) if (selectionWindow == TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
{ {
TRACE("We still own CLIPBOARD. Releasing CLIPBOARD.\n"); TRACE("We still own CLIPBOARD. Releasing CLIPBOARD.\n");
XSetSelectionOwner(display, xaClipboard, 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");
...@@ -1835,6 +1807,7 @@ static BOOL X11DRV_CLIPBOARD_IsSelectionOwner(void) ...@@ -1835,6 +1807,7 @@ static BOOL X11DRV_CLIPBOARD_IsSelectionOwner(void)
INT X11DRV_RegisterClipboardFormat(LPCSTR FormatName) INT X11DRV_RegisterClipboardFormat(LPCSTR FormatName)
{ {
LPWINE_CLIPFORMAT lpFormat = ClipFormats; LPWINE_CLIPFORMAT lpFormat = ClipFormats;
Atom prop;
if (FormatName == NULL) if (FormatName == NULL)
return 0; return 0;
...@@ -1854,7 +1827,8 @@ INT X11DRV_RegisterClipboardFormat(LPCSTR FormatName) ...@@ -1854,7 +1827,8 @@ INT X11DRV_RegisterClipboardFormat(LPCSTR FormatName)
lpFormat = lpFormat->NextFormat; lpFormat = lpFormat->NextFormat;
} }
return X11DRV_CLIPBOARD_InsertClipboardFormat(FormatName, FormatName); prop = TSXInternAtom( thread_display(), FormatName, False );
return X11DRV_CLIPBOARD_InsertClipboardFormat(FormatName, prop);
} }
...@@ -1919,12 +1893,12 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow) ...@@ -1919,12 +1893,12 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
/* Grab CLIPBOARD selection if not owned */ /* Grab CLIPBOARD selection if not owned */
if (!(selectionAcquired & S_CLIPBOARD)) if (!(selectionAcquired & S_CLIPBOARD))
TSXSetSelectionOwner(display, xaClipboard, owner, CurrentTime); TSXSetSelectionOwner(display, x11drv_atom(CLIPBOARD), owner, CurrentTime);
if (TSXGetSelectionOwner(display,XA_PRIMARY) == owner) if (TSXGetSelectionOwner(display,XA_PRIMARY) == owner)
selectionAcquired |= S_PRIMARY; selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,xaClipboard) == owner) if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
selectionAcquired |= S_CLIPBOARD; selectionAcquired |= S_CLIPBOARD;
if (selectionAcquired) if (selectionAcquired)
...@@ -1942,7 +1916,7 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow) ...@@ -1942,7 +1916,7 @@ void X11DRV_AcquireClipboard(HWND hWndClipWindow)
if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow) if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
selectionAcquired |= S_PRIMARY; selectionAcquired |= S_PRIMARY;
if (TSXGetSelectionOwner(display,xaClipboard) == selectionWindow) if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
selectionAcquired |= S_CLIPBOARD; selectionAcquired |= S_CLIPBOARD;
if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD))) if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD)))
...@@ -2225,7 +2199,7 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar) ...@@ -2225,7 +2199,7 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar)
if (saveSelectionState & S_PRIMARY) if (saveSelectionState & S_PRIMARY)
TSXSetSelectionOwner(display, XA_PRIMARY, selectionWindow, CurrentTime); TSXSetSelectionOwner(display, XA_PRIMARY, selectionWindow, CurrentTime);
TSXSetSelectionOwner(display, xaClipboard, selectionWindow, CurrentTime); TSXSetSelectionOwner(display, x11drv_atom(CLIPBOARD), selectionWindow, CurrentTime);
/* Restore the selection masks */ /* Restore the selection masks */
selectionAcquired = saveSelectionState; selectionAcquired = saveSelectionState;
...@@ -2233,7 +2207,7 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar) ...@@ -2233,7 +2207,7 @@ void X11DRV_ResetSelectionOwner(HWND hwnd, BOOL bFooBar)
/* 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)) || (TSXGetSelectionOwner(display, XA_PRIMARY) != selectionWindow)) ||
(TSXGetSelectionOwner(display, xaClipboard) != selectionWindow)) (TSXGetSelectionOwner(display, x11drv_atom(CLIPBOARD)) != selectionWindow))
{ {
bLostSelection = TRUE; bLostSelection = TRUE;
} }
......
...@@ -69,6 +69,7 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data ) ...@@ -69,6 +69,7 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
MSG msg; MSG msg;
HWND hwnd; HWND hwnd;
WND *win; WND *win;
Atom atom = x11drv_atom(WM_DELETE_WINDOW);
NtCurrentTeb()->driver_data = driver_data; NtCurrentTeb()->driver_data = driver_data;
display = thread_display(); display = thread_display();
...@@ -82,7 +83,8 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data ) ...@@ -82,7 +83,8 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc ); SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc );
wine_tsx11_lock(); wine_tsx11_lock();
XSetWMProtocols( display, root_window, &wmDeleteWindow, 1 ); XChangeProperty ( display, root_window, x11drv_atom(WM_PROTOCOLS),
XA_ATOM, 32, PropModeReplace, (char *)&atom, 1 );
XMapWindow( display, root_window ); XMapWindow( display, root_window );
wine_tsx11_unlock(); wine_tsx11_unlock();
......
...@@ -56,12 +56,6 @@ WINE_DECLARE_DEBUG_CHANNEL(clipboard); ...@@ -56,12 +56,6 @@ WINE_DECLARE_DEBUG_CHANNEL(clipboard);
/* X context to associate a hwnd to an X window */ /* X context to associate a hwnd to an X window */
extern XContext winContext; extern XContext winContext;
extern Atom wmProtocols;
extern Atom wmDeleteWindow;
extern Atom dndProtocol;
extern Atom dndSelection;
extern Atom netwmPing;
#define DndNotDnd -1 /* OffiX drag&drop */ #define DndNotDnd -1 /* OffiX drag&drop */
#define DndUnknown 0 #define DndUnknown 0
#define DndRawData 1 #define DndRawData 1
...@@ -434,7 +428,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event ) ...@@ -434,7 +428,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
if (!protocol) return; if (!protocol) return;
if (protocol == wmDeleteWindow) if (protocol == x11drv_atom(WM_DELETE_WINDOW))
{ {
/* Ignore the delete window request if the window has been disabled /* Ignore the delete window request if the window has been disabled
* and we are in managed mode. This is to disallow applications from * and we are in managed mode. This is to disallow applications from
...@@ -442,7 +436,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event ) ...@@ -442,7 +436,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
*/ */
if (IsWindowEnabled(hwnd)) PostMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 ); if (IsWindowEnabled(hwnd)) PostMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
} }
else if (protocol == wmTakeFocus) else if (protocol == x11drv_atom(WM_TAKE_FOCUS))
{ {
Time event_time = (Time)event->data.l[1]; Time event_time = (Time)event->data.l[1];
HWND last_focus = x11drv_thread_data()->last_focus; HWND last_focus = x11drv_thread_data()->last_focus;
...@@ -469,7 +463,9 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event ) ...@@ -469,7 +463,9 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
if (!hwnd) hwnd = last_focus; if (!hwnd) hwnd = last_focus;
if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, event_time ); if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, event_time );
} }
} else if (protocol == netwmPing) { }
else if (protocol == x11drv_atom(_NET_WM_PING))
{
XClientMessageEvent xev; XClientMessageEvent xev;
xev = *event; xev = *event;
...@@ -513,7 +509,7 @@ static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event ) ...@@ -513,7 +509,7 @@ static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event )
XSetICFocus( xic ); XSetICFocus( xic );
wine_tsx11_unlock(); wine_tsx11_unlock();
} }
if (wmTakeFocus) return; /* ignore FocusIn if we are using take focus */ if (use_take_focus) return; /* ignore FocusIn if we are using take focus */
if (!can_activate_window(hwnd)) if (!can_activate_window(hwnd))
{ {
...@@ -636,7 +632,7 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor, ...@@ -636,7 +632,7 @@ static Atom EVENT_SelectionRequest_TARGETS( Display *display, Window requestor,
return None; return None;
/* Create TARGETS property list (First item in list is TARGETS itself) */ /* Create TARGETS property list (First item in list is TARGETS itself) */
for (targets[0] = xaTargets, cTargets = 1, wFormat = 0; for (targets[0] = x11drv_atom(TARGETS), cTargets = 1, wFormat = 0;
(wFormat = X11DRV_EnumClipboardFormats(wFormat));) (wFormat = X11DRV_EnumClipboardFormats(wFormat));)
{ {
LPWINE_CLIPFORMAT lpFormat = X11DRV_CLIPBOARD_LookupFormat(wFormat); LPWINE_CLIPFORMAT lpFormat = X11DRV_CLIPBOARD_LookupFormat(wFormat);
...@@ -736,14 +732,17 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent * ...@@ -736,14 +732,17 @@ static Atom EVENT_SelectionRequest_MULTIPLE( HWND hWnd, XSelectionRequestEvent *
for (i = 0; i < cTargetPropList; i+=2) for (i = 0; i < cTargetPropList; i+=2)
{ {
char *targetName = TSXGetAtomName(display, targetPropList[i]);
char *propName = TSXGetAtomName(display, targetPropList[i+1]);
XSelectionRequestEvent event; XSelectionRequestEvent event;
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n", if (TRACE_ON(event))
i/2, targetName, propName); {
TSXFree(targetName); char *targetName = TSXGetAtomName(display, targetPropList[i]);
TSXFree(propName); char *propName = TSXGetAtomName(display, targetPropList[i+1]);
TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
i/2, targetName, propName);
TSXFree(targetName);
TSXFree(propName);
}
/* 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 */
if ( !targetPropList[i+1] ) if ( !targetPropList[i+1] )
...@@ -798,7 +797,7 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO ...@@ -798,7 +797,7 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO
*/ */
if ( !bIsMultiple ) if ( !bIsMultiple )
{ {
if (((event->selection != XA_PRIMARY) && (event->selection != xaClipboard))) if (((event->selection != XA_PRIMARY) && (event->selection != x11drv_atom(CLIPBOARD))))
goto END; goto END;
} }
...@@ -809,12 +808,12 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO ...@@ -809,12 +808,12 @@ static void EVENT_SelectionRequest( HWND hWnd, XSelectionRequestEvent *event, BO
if( rprop == None ) if( rprop == None )
rprop = event->target; rprop = event->target;
if(event->target == xaTargets) /* Return a list of all supported targets */ if(event->target == x11drv_atom(TARGETS)) /* Return a list of all supported targets */
{ {
/* TARGETS selection request */ /* TARGETS selection request */
rprop = EVENT_SelectionRequest_TARGETS( display, request, event->target, rprop ); rprop = EVENT_SelectionRequest_TARGETS( display, request, event->target, rprop );
} }
else if(event->target == xaMultiple) /* rprop contains a list of (target, property) atom pairs */ else if(event->target == x11drv_atom(MULTIPLE)) /* rprop contains a list of (target, property) atom pairs */
{ {
/* MULTIPLE selection request */ /* MULTIPLE selection request */
rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event ); rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event );
...@@ -884,7 +883,7 @@ END: ...@@ -884,7 +883,7 @@ END:
*/ */
static void EVENT_SelectionClear( HWND hWnd, XSelectionClearEvent *event ) static void EVENT_SelectionClear( HWND hWnd, XSelectionClearEvent *event )
{ {
if (event->selection == XA_PRIMARY || event->selection == xaClipboard) if (event->selection == XA_PRIMARY || event->selection == x11drv_atom(CLIPBOARD))
X11DRV_CLIPBOARD_ReleaseSelection( event->selection, event->window, hWnd ); X11DRV_CLIPBOARD_ReleaseSelection( event->selection, event->window, hWnd );
} }
...@@ -1029,7 +1028,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event ) ...@@ -1029,7 +1028,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if (!bAccept) return; if (!bAccept) return;
TSXGetWindowProperty( event->display, DefaultRootWindow(event->display), TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
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);
...@@ -1118,7 +1117,7 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) ...@@ -1118,7 +1117,7 @@ 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), TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
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);
if (aux_long) if (aux_long)
...@@ -1208,9 +1207,9 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) ...@@ -1208,9 +1207,9 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event ) static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event )
{ {
if (event->message_type != None && event->format == 32) { if (event->message_type != None && event->format == 32) {
if (event->message_type == wmProtocols) if (event->message_type == x11drv_atom(WM_PROTOCOLS))
handle_wm_protocols_message( hWnd, event ); handle_wm_protocols_message( hWnd, event );
else if (event->message_type == dndProtocol) else if (event->message_type == x11drv_atom(DndProtocol))
{ {
/* query window (drag&drop event contains only drag window) */ /* query window (drag&drop event contains only drag window) */
Window root, child; Window root, child;
......
...@@ -56,17 +56,35 @@ extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP ); ...@@ -56,17 +56,35 @@ extern Pixmap X11DRV_BITMAP_Pixmap( HBITMAP );
/* X context to associate a hwnd to an X window */ /* X context to associate a hwnd to an X window */
XContext winContext = 0; XContext winContext = 0;
Atom wmProtocols = None; Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
Atom wmDeleteWindow = None;
Atom wmTakeFocus = None; static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
Atom dndProtocol = None; {
Atom dndSelection = None; "CLIPBOARD",
Atom wmChangeState = None; "COMPOUND_TEXT",
Atom mwmHints = None; "MULTIPLE",
Atom kwmDockWindow = None; "SELECTION_DATA",
Atom netwmPid = None; "TARGETS",
Atom netwmPing = None; "TEXT",
Atom _kde_net_wm_system_tray_window_for = None; /* KDE 2 Final */ "UTF8_STRING",
"RAW_ASCENT",
"RAW_DESCENT",
"RAW_CAP_HEIGHT",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
"WM_TAKE_FOCUS",
"KWM_DOCKWINDOW",
"DndProtocol",
"DndSelection",
"_MOTIF_WM_HINTS",
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
"_NET_WM_PID",
"_NET_WM_PING",
"_NET_WM_NAME",
"image/gif",
"text/rtf",
"text/richtext"
};
static LPCSTR whole_window_atom; static LPCSTR whole_window_atom;
static LPCSTR client_window_atom; static LPCSTR client_window_atom;
...@@ -336,17 +354,19 @@ void X11DRV_set_wm_hints( Display *display, WND *win ) ...@@ -336,17 +354,19 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
Window group_leader; Window group_leader;
XClassHint *class_hints; XClassHint *class_hints;
XWMHints* wm_hints; XWMHints* wm_hints;
Atom protocols[2]; Atom protocols[3];
MwmHints mwm_hints;
int i; int i;
wine_tsx11_lock(); wine_tsx11_lock();
/* wm protocols */ /* wm protocols */
i = 0; i = 0;
protocols[i++] = wmDeleteWindow; protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
if (wmTakeFocus) protocols[i++] = wmTakeFocus; protocols[i++] = x11drv_atom(_NET_WM_PING);
if (netwmPing) protocols[i++] = netwmPing; if (use_take_focus) protocols[i++] = x11drv_atom(WM_TAKE_FOCUS);
XSetWMProtocols( display, data->whole_window, protocols, i ); XChangeProperty( display, data->whole_window, x11drv_atom(WM_PROTOCOLS),
XA_ATOM, 32, PropModeReplace, (char *)protocols, i );
/* class hints */ /* class hints */
if ((class_hints = XAllocClassHint())) if ((class_hints = XAllocClassHint()))
...@@ -373,44 +393,40 @@ void X11DRV_set_wm_hints( Display *display, WND *win ) ...@@ -373,44 +393,40 @@ void X11DRV_set_wm_hints( Display *display, WND *win )
if (win->dwExStyle & WS_EX_TRAYWINDOW) if (win->dwExStyle & WS_EX_TRAYWINDOW)
{ {
int val = 1; int val = 1;
if (kwmDockWindow != None) XChangeProperty( display, data->whole_window, x11drv_atom(KWM_DOCKWINDOW),
XChangeProperty( display, data->whole_window, kwmDockWindow, kwmDockWindow, x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace, (char*)&val, 1 );
32, PropModeReplace, (char*)&val, 1 ); XChangeProperty( display, data->whole_window, x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
if (_kde_net_wm_system_tray_window_for != None) XA_WINDOW, 32, PropModeReplace, (char*)&data->whole_window, 1 );
XChangeProperty( display, data->whole_window, _kde_net_wm_system_tray_window_for,
XA_WINDOW, 32, PropModeReplace, (char*)&data->whole_window, 1 );
} }
/* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */ /* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL); XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
/* set the pid. together, these properties are needed so the window manager can kill us if we freeze */ /* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
i = getpid(); i = getpid();
XChangeProperty(display, data->whole_window, netwmPid, XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1); XChangeProperty(display, data->whole_window, x11drv_atom(_NET_WM_PID),
XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1);
if (mwmHints != None)
{ mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
MwmHints mwm_hints; mwm_hints.functions = 0;
mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE;
mwm_hints.functions = 0; if (win->dwStyle & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE; if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
if (win->dwStyle & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE; if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE; if (win->dwStyle & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE;
if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE; mwm_hints.decorations = 0;
if (win->dwStyle & WS_SYSMENU) mwm_hints.functions |= MWM_FUNC_CLOSE; if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE;
mwm_hints.decorations = 0; if (win->dwExStyle & WS_EX_DLGMODALFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE; else if (win->dwStyle & WS_THICKFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH;
if (win->dwExStyle & WS_EX_DLGMODALFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER; else if ((win->dwStyle & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
else if (win->dwStyle & WS_THICKFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_RESIZEH; else if (win->dwStyle & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER;
else if ((win->dwStyle & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER; else if (!(win->dwStyle & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER;
else if (win->dwStyle & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER; if (win->dwStyle & WS_SYSMENU) mwm_hints.decorations |= MWM_DECOR_MENU;
else if (!(win->dwStyle & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER; if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MINIMIZE;
if (win->dwStyle & WS_SYSMENU) mwm_hints.decorations |= MWM_DECOR_MENU; if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE;
if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MINIMIZE;
if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.decorations |= MWM_DECOR_MAXIMIZE; XChangeProperty( display, data->whole_window, x11drv_atom(_MOTIF_WM_HINTS),
x11drv_atom(_MOTIF_WM_HINTS), 32, PropModeReplace,
XChangeProperty( display, data->whole_window, mwmHints, mwmHints, 32, (char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
PropModeReplace, (char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
}
wm_hints = XAllocWMHints(); wm_hints = XAllocWMHints();
wine_tsx11_unlock(); wine_tsx11_unlock();
...@@ -674,18 +690,8 @@ static void create_desktop( Display *display, WND *wndPtr ) ...@@ -674,18 +690,8 @@ static void create_desktop( Display *display, WND *wndPtr )
X11DRV_WND_DATA *data = wndPtr->pDriverData; X11DRV_WND_DATA *data = wndPtr->pDriverData;
wine_tsx11_lock(); wine_tsx11_lock();
winContext = XUniqueContext(); winContext = XUniqueContext();
wmProtocols = XInternAtom( display, "WM_PROTOCOLS", False ); XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
wmDeleteWindow = XInternAtom( display, "WM_DELETE_WINDOW", False );
if (use_take_focus) wmTakeFocus = XInternAtom( display, "WM_TAKE_FOCUS", False );
dndProtocol = XInternAtom( display, "DndProtocol" , False );
dndSelection = XInternAtom( display, "DndSelection" , False );
wmChangeState = XInternAtom( display, "WM_CHANGE_STATE", False );
mwmHints = XInternAtom( display, _XA_MWM_HINTS, False );
kwmDockWindow = XInternAtom( display, "KWM_DOCKWINDOW", False );
_kde_net_wm_system_tray_window_for = XInternAtom( display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False );
netwmPid = XInternAtom( display, "_NET_WM_PID", False );
netwmPing = XInternAtom( display, "_NET_WM_PING", False );
wine_tsx11_unlock(); wine_tsx11_unlock();
whole_window_atom = MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_whole_window" )); whole_window_atom = MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_whole_window" ));
...@@ -699,6 +705,8 @@ static void create_desktop( Display *display, WND *wndPtr ) ...@@ -699,6 +705,8 @@ static void create_desktop( Display *display, WND *wndPtr )
SetPropA( wndPtr->hwndSelf, client_window_atom, (HANDLE)root_window ); SetPropA( wndPtr->hwndSelf, client_window_atom, (HANDLE)root_window );
SetPropA( wndPtr->hwndSelf, "__wine_x11_visual_id", (HANDLE)XVisualIDFromVisual(visual) ); SetPropA( wndPtr->hwndSelf, "__wine_x11_visual_id", (HANDLE)XVisualIDFromVisual(visual) );
X11DRV_InitClipboard( display );
if (root_window != DefaultRootWindow(display)) X11DRV_create_desktop_thread(); if (root_window != DefaultRootWindow(display)) X11DRV_create_desktop_thread();
} }
...@@ -849,11 +857,8 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text ) ...@@ -849,11 +857,8 @@ BOOL X11DRV_SetWindowText( HWND hwnd, LPCWSTR text )
according to the standard according to the standard
( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ). ( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
*/ */
XChangeProperty( display, win, XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
XInternAtom(display, "_NET_WM_NAME", False), 8, PropModeReplace, (unsigned char *) utf8_buffer, count);
XInternAtom(display, "UTF8_STRING", False),
8, PropModeReplace, (unsigned char *) utf8_buffer,
count);
wine_tsx11_unlock(); wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, utf8_buffer ); HeapFree( GetProcessHeap(), 0, utf8_buffer );
......
...@@ -364,30 +364,43 @@ extern int use_xkb; ...@@ -364,30 +364,43 @@ extern int use_xkb;
extern int use_take_focus; extern int use_take_focus;
extern int managed_mode; extern int managed_mode;
extern Atom wmProtocols; /* atoms */
extern Atom wmDeleteWindow;
extern Atom wmTakeFocus;
extern Atom dndProtocol;
extern Atom dndSelection;
extern Atom wmChangeState;
extern Atom kwmDockWindow;
extern Atom _kde_net_wm_system_tray_window_for;
/* X11 clipboard driver */ enum x11drv_atoms
typedef struct tagPROPERTYFORMATMAP
{ {
LPCSTR lpszProperty; FIRST_XATOM = XA_LAST_PREDEFINED + 1,
LPCSTR lpszFormat; XATOM_CLIPBOARD = FIRST_XATOM,
} PROPERTYFORMATMAP; XATOM_COMPOUND_TEXT,
XATOM_MULTIPLE,
XATOM_SELECTION_DATA,
XATOM_TARGETS,
XATOM_TEXT,
XATOM_UTF8_STRING,
XATOM_RAW_ASCENT,
XATOM_RAW_DESCENT,
XATOM_RAW_CAP_HEIGHT,
XATOM_WM_PROTOCOLS,
XATOM_WM_DELETE_WINDOW,
XATOM_WM_TAKE_FOCUS,
XATOM_KWM_DOCKWINDOW,
XATOM_DndProtocol,
XATOM_DndSelection,
XATOM__MOTIF_WM_HINTS,
XATOM__KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
XATOM__NET_WM_PID,
XATOM__NET_WM_PING,
XATOM__NET_WM_NAME,
XATOM_image_gif,
XATOM_text_rtf,
XATOM_text_richtext,
NB_XATOMS
};
typedef struct tagPROPERTYALIASMAP extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
{
LPCSTR lpszProperty; #define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])
UINT drvDataProperty;
LPCSTR lpszAlias; /* X11 clipboard driver */
UINT drvDataAlias;
} PROPERTYALIASMAP;
typedef struct tagWINE_CLIPDATA { typedef struct tagWINE_CLIPDATA {
UINT wFormatID; UINT wFormatID;
...@@ -416,11 +429,7 @@ typedef struct tagWINE_CLIPFORMAT { ...@@ -416,11 +429,7 @@ typedef struct tagWINE_CLIPFORMAT {
#define CF_FLAG_BUILTINFMT 1 /* Built-in windows format */ #define CF_FLAG_BUILTINFMT 1 /* Built-in windows format */
#define CF_FLAG_SYNTHESIZED 8 /* Implicitly converted data */ #define CF_FLAG_SYNTHESIZED 8 /* Implicitly converted data */
extern Atom xaClipboard; extern void X11DRV_InitClipboard(Display *display);
extern Atom xaTargets;
extern Atom xaMultiple;
extern BOOL X11DRV_InitClipboard(Display *display);
extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd); extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
extern INT X11DRV_CountClipboardFormats(void); extern INT X11DRV_CountClipboardFormats(void);
extern UINT X11DRV_EnumClipboardFormats(UINT wFormat); extern UINT X11DRV_EnumClipboardFormats(UINT wFormat);
......
...@@ -379,13 +379,6 @@ static void process_attach(void) ...@@ -379,13 +379,6 @@ static void process_attach(void)
ExitProcess(1); ExitProcess(1);
} }
/* Initialize clipboard */
if (!X11DRV_InitClipboard( display ))
{
ERR( "Couldn't Initialize clipboard.\n" );
ExitProcess(1);
}
#ifdef HAVE_LIBXXF86VM #ifdef HAVE_LIBXXF86VM
/* initialize XVidMode */ /* initialize XVidMode */
X11DRV_XF86VM_Init(); X11DRV_XF86VM_Init();
......
...@@ -342,9 +342,6 @@ static int fontLF = -1, fontMRU = -1; /* last free, most recently used */ ...@@ -342,9 +342,6 @@ static int fontLF = -1, fontMRU = -1; /* last free, most recently used */
#define CHECK_PFONT(pFont) ( (((UINT)(pFont) & 0xFFFF0000) == X_PFONT_MAGIC) &&\ #define CHECK_PFONT(pFont) ( (((UINT)(pFont) & 0xFFFF0000) == X_PFONT_MAGIC) &&\
(((UINT)(pFont) & 0x0000FFFF) < fontCacheSize) ) (((UINT)(pFont) & 0x0000FFFF) < fontCacheSize) )
static Atom RAW_ASCENT;
static Atom RAW_DESCENT;
/*********************************************************************** /***********************************************************************
* Helper macros from X distribution * Helper macros from X distribution
*/ */
...@@ -1067,8 +1064,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs, ...@@ -1067,8 +1064,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
if( pEL ) *pEL = 0; if( pEL ) *pEL = 0;
if(XFT) { if(XFT) {
Atom RAW_CAP_HEIGHT = TSXInternAtom(gdi_display, "RAW_CAP_HEIGHT", TRUE); if(TSXGetFontProperty((XFontStruct*)x_fs, x11drv_atom(RAW_CAP_HEIGHT), &height))
if(TSXGetFontProperty((XFontStruct*)x_fs, RAW_CAP_HEIGHT, &height))
*pIL = XFT->ascent - *pIL = XFT->ascent -
(INT)(XFT->pixelsize / 1000.0 * height); (INT)(XFT->pixelsize / 1000.0 * height);
else else
...@@ -2032,13 +2028,10 @@ static int XLoadQueryFont_ErrorHandler(Display *dpy, XErrorEvent *event, void *a ...@@ -2032,13 +2028,10 @@ static int XLoadQueryFont_ErrorHandler(Display *dpy, XErrorEvent *event, void *a
static XFontStruct *safe_XLoadQueryFont(Display *display, char *name) static XFontStruct *safe_XLoadQueryFont(Display *display, char *name)
{ {
XFontStruct *ret; XFontStruct *ret;
wine_tsx11_lock();
X11DRV_expect_error(display, XLoadQueryFont_ErrorHandler, NULL); X11DRV_expect_error(display, XLoadQueryFont_ErrorHandler, NULL);
ret = XLoadQueryFont(display, name); ret = XLoadQueryFont(display, name);
if (X11DRV_check_error()) ret = NULL; if (X11DRV_check_error()) ret = NULL;
wine_tsx11_unlock();
return ret; return ret;
} }
...@@ -3020,12 +3013,6 @@ void X11DRV_FONT_InitX11Metrics( void ) ...@@ -3020,12 +3013,6 @@ void X11DRV_FONT_InitX11Metrics( void )
XFONT_GrowFreeList(0, fontCacheSize - 1); XFONT_GrowFreeList(0, fontCacheSize - 1);
TRACE("done!\n"); TRACE("done!\n");
/* update text caps parameter */
RAW_ASCENT = TSXInternAtom(gdi_display, "RAW_ASCENT", TRUE);
RAW_DESCENT = TSXInternAtom(gdi_display, "RAW_DESCENT", TRUE);
return;
} }
/*********************************************************************** /***********************************************************************
...@@ -3071,8 +3058,8 @@ static BOOL XFONT_SetX11Trans( fontObject *pfo ) ...@@ -3071,8 +3058,8 @@ static BOOL XFONT_SetX11Trans( fontObject *pfo )
TSXFree(fontName); TSXFree(fontName);
HeapFree(GetProcessHeap(), 0, lfd); HeapFree(GetProcessHeap(), 0, lfd);
TSXGetFontProperty( pfo->fs, RAW_ASCENT, &PX->RAW_ASCENT ); TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_ASCENT), &PX->RAW_ASCENT );
TSXGetFontProperty( pfo->fs, RAW_DESCENT, &PX->RAW_DESCENT ); TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_DESCENT), &PX->RAW_DESCENT );
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;
......
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