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

diff --git a/dlls/x11drv/clipboard.c b/dlls/x11drv/clipboard.c
index 55847b5..9901701 100644
--- a/dlls/x11drv/clipboard.c
+++ b/dlls/x11drv/clipboard.c
@@ -98,21 +98,6 @@
 #define S_PRIMARY        1
 #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 Window selectionWindow = None;          /* The top level X window which owns the selection */
 static BOOL clearAllSelections = FALSE;        /* Always lose all selections */
@@ -138,7 +123,7 @@
     Atom rprop, LPWINE_CLIPDATA lpdata, LPDWORD lpBytes);
 HANDLE X11DRV_CLIPBOARD_ExportEnhMetaFile(Window requestor, Atom aTarget,
     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_RenderSynthesizedText(UINT wFormatID);
 static void X11DRV_CLIPBOARD_FreeData(LPWINE_CLIPDATA lpData);
@@ -154,7 +139,7 @@
  * WARNING: This data ordering is dependent on the WINE_CLIPFORMAT structure
  * declared in clipboard.h
  */
-WINE_CLIPFORMAT ClipFormats[]  =
+static WINE_CLIPFORMAT ClipFormats[]  =
 {
     { CF_TEXT, "WCF_TEXT",  0, CF_FLAG_BUILTINFMT, X11DRV_CLIPBOARD_ImportClipboardData,
         X11DRV_CLIPBOARD_ExportClipboardData, NULL, &ClipFormats[1]},
@@ -223,25 +208,34 @@
         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 */
-PROPERTYFORMATMAP PropertyFormatMap[] =
-{ 
-    { "text/rtf", "Rich Text Format" },
+static const struct
+{
+    LPCSTR lpszFormat;
+    UINT   prop;
+} PropertyFormatMap[] =
+{
+    { "Rich Text Format", XATOM_text_rtf },
     /* Temporarily disable text/html because Evolution incorrectly pastes strings with extra nulls */
     /*{ "text/html", "HTML Format" },*/
-    { "image/gif", "GIF" },
+    { "GIF", XATOM_image_gif }
 };
 
 
 /* Maps equivalent X properties. It is assumed that lpszProperty must already 
    be in ClipFormats or PropertyFormatMap. */
-PROPERTYALIASMAP PropertyAliasMap[] =
-{ 
-    /* lpszProperty, Alias */
-    { "text/rtf", 0, "text/richtext", 0 },
-    { "XAString", XA_STRING, _COMPOUNDTEXT, 0 },
-    { "XAString", XA_STRING, _TEXT, 0 },
+static const struct
+{
+    UINT drvDataProperty;
+    UINT drvDataAlias;
+} PropertyAliasMap[] =
+{
+    /* DataProperty,   DataAlias */
+    { XATOM_text_rtf,  XATOM_text_richtext },
+    { XA_STRING,       XATOM_COMPOUND_TEXT },
+    { XA_STRING,       XATOM_TEXT },
 };
 
 
@@ -254,7 +248,7 @@
 /*
  * Clipboard sequence number
  */
-UINT wSeqNo = 0;
+static UINT wSeqNo = 0;
 
 /**************************************************************************
  *                Internal Clipboard implementation methods
@@ -263,20 +257,12 @@
 /**************************************************************************
  *		X11DRV_InitClipboard
  */
-BOOL X11DRV_InitClipboard(Display *display)
+void X11DRV_InitClipboard(Display *display)
 {
     INT i;
     HKEY hkey;
-    PROPERTYALIASMAP *lpalias;
     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))
     {
 	char buffer[20];
@@ -299,21 +285,9 @@
     }
 
     /* Register known mapping between window formats and X properties */
-    for (i = 0; i < sizeof(PropertyFormatMap)/sizeof(PROPERTYFORMATMAP); i++)
-        X11DRV_CLIPBOARD_InsertClipboardFormat(PropertyFormatMap[i].lpszFormat, 
-            PropertyFormatMap[i].lpszProperty);
-
-    /* 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;
+    for (i = 0; i < sizeof(PropertyFormatMap)/sizeof(PropertyFormatMap[0]); i++)
+        X11DRV_CLIPBOARD_InsertClipboardFormat(PropertyFormatMap[i].lpszFormat,
+                                               GET_ATOM(PropertyFormatMap[i].prop));
 }
 
 
@@ -363,11 +337,11 @@
     unsigned int i;
     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;
         }
    }
@@ -384,11 +358,11 @@
     unsigned int i;
     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;
         }
    }
@@ -426,7 +400,7 @@
 /**************************************************************************
  *		InsertClipboardFormat
  */
-UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, LPCSTR PropertyName)
+static UINT X11DRV_CLIPBOARD_InsertClipboardFormat(LPCSTR FormatName, Atom prop)
 {
     LPWINE_CLIPFORMAT lpFormat;
     LPWINE_CLIPFORMAT lpNewFormat;
@@ -451,7 +425,7 @@
     strcpy(lpNewFormat->Name, FormatName);
     lpNewFormat->wFlags = 0;
     lpNewFormat->wFormatID = GlobalAddAtomA(lpNewFormat->Name);
-    lpNewFormat->drvData = TSXInternAtom(thread_display(), PropertyName, False);
+    lpNewFormat->drvData = prop;
     lpNewFormat->lpDrvImportFunc = X11DRV_CLIPBOARD_ImportClipboardData;
     lpNewFormat->lpDrvExportFunc = X11DRV_CLIPBOARD_ExportClipboardData;
 
@@ -465,11 +439,8 @@
     lpFormat->NextFormat = lpNewFormat;
     lpNewFormat->PrevFormat = lpFormat;
 
-    TRACE("Registering format(%d): %s drvData(%d): %s\n", 
-        lpNewFormat->wFormatID, 
-        FormatName,
-        lpNewFormat->drvData, 
-        PropertyName);
+    TRACE("Registering format(%d): %s drvData %d\n",
+        lpNewFormat->wFormatID, FormatName, lpNewFormat->drvData);
 
     return lpNewFormat->wFormatID;
 }
@@ -1154,7 +1125,7 @@
 
     if (lpstr)
     {
-        if (aTarget == xaCompoundText)
+        if (aTarget == x11drv_atom(COMPOUND_TEXT))
            style = XCompoundTextStyle;
         else
            style = XStdICCTextStyle;
@@ -1186,7 +1157,7 @@
     {
         if (aTarget == XA_STRING)
             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,
                 rprop, lpData, lpBytes);
         else
@@ -1275,7 +1246,8 @@
     Bool res;
 
     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();
 
     /*
@@ -1292,7 +1264,7 @@
     }
 
     /* 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 */
         WARN("Failed to retrieve TARGETS for selection %ld.\n", selection);
@@ -1332,7 +1304,7 @@
         if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
 	    selectionAcquired |= S_PRIMARY;
 
-        if (TSXGetSelectionOwner(display,xaClipboard) == selectionWindow)
+        if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
 	    selectionAcquired |= S_CLIPBOARD;
 
         if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD)))
@@ -1365,12 +1337,12 @@
      * Query the selection owner for the TARGETS property
      */
     if (TSXGetSelectionOwner(display,XA_PRIMARY) ||
-        TSXGetSelectionOwner(display,xaClipboard))
+        TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)))
     {
     if (X11DRV_CLIPBOARD_QueryTargets(display, w, XA_PRIMARY, &xe))
         selectionCacheSrc = XA_PRIMARY;
-    else if (X11DRV_CLIPBOARD_QueryTargets(display, w, xaClipboard, &xe))
-        selectionCacheSrc = xaClipboard;
+    else if (X11DRV_CLIPBOARD_QueryTargets(display, w, x11drv_atom(CLIPBOARD), &xe))
+        selectionCacheSrc = x11drv_atom(CLIPBOARD);
     else
             return -1;
     }
@@ -1392,7 +1364,7 @@
         * The TARGETS property should have returned us a list of atoms
         * 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;
 
@@ -1478,7 +1450,7 @@
 
             wine_tsx11_lock();
             XConvertSelection(display, selectionCacheSrc, lpFormat->drvData,
-                              xaSelectionData, w, CurrentTime);
+                              x11drv_atom(SELECTION_DATA), w, CurrentTime);
             wine_tsx11_unlock();
 
             /* wait until SelectionNotify is received */
@@ -1498,7 +1470,7 @@
 	    {
                 wine_tsx11_lock();
                 XConvertSelection(display, selectionCacheSrc, alias,
-                                  xaSelectionData, w, CurrentTime);
+                                  x11drv_atom(SELECTION_DATA), w, CurrentTime);
                 wine_tsx11_unlock();
 
                 /* wait until SelectionNotify is received */
@@ -1726,7 +1698,7 @@
              * dictate that *all* selections should be cleared on loss of a selection,
              * we must give up all the selections we own.
              */
-            if (clearAllSelections || (selType == xaClipboard))
+            if (clearAllSelections || (selType == x11drv_atom(CLIPBOARD)))
             {
                 CLIPBOARDINFO cbinfo;
 
@@ -1752,7 +1724,7 @@
                     if (OpenClipboard(hwnd))
                     {
                       /* 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");
                           if (selectionWindow == TSXGetSelectionOwner(display,XA_PRIMARY))
@@ -1768,10 +1740,10 @@
                       if ((selType == XA_PRIMARY) && (selectionAcquired & S_CLIPBOARD))
                       {
 		          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");
-                              XSetSelectionOwner(display, xaClipboard, None, CurrentTime);
+                              XSetSelectionOwner(display, x11drv_atom(CLIPBOARD), None, CurrentTime);
                           }
 		          else
 		              TRACE("We no longer own CLIPBOARD\n");
@@ -1835,6 +1807,7 @@
 INT X11DRV_RegisterClipboardFormat(LPCSTR FormatName)
 {
     LPWINE_CLIPFORMAT lpFormat = ClipFormats;
+    Atom prop;
 
     if (FormatName == NULL) 
         return 0;
@@ -1854,7 +1827,8 @@
 	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 @@
 
         /* Grab CLIPBOARD selection if not owned */
         if (!(selectionAcquired & S_CLIPBOARD))
-            TSXSetSelectionOwner(display, xaClipboard, owner, CurrentTime);
+            TSXSetSelectionOwner(display, x11drv_atom(CLIPBOARD), owner, CurrentTime);
 
         if (TSXGetSelectionOwner(display,XA_PRIMARY) == owner)
 	    selectionAcquired |= S_PRIMARY;
 
-        if (TSXGetSelectionOwner(display,xaClipboard) == owner)
+        if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == owner)
 	    selectionAcquired |= S_CLIPBOARD;
 
         if (selectionAcquired)
@@ -1942,7 +1916,7 @@
         if (TSXGetSelectionOwner(display,XA_PRIMARY) == selectionWindow)
 	    selectionAcquired |= S_PRIMARY;
 
-        if (TSXGetSelectionOwner(display,xaClipboard) == selectionWindow)
+        if (TSXGetSelectionOwner(display,x11drv_atom(CLIPBOARD)) == selectionWindow)
 	    selectionAcquired |= S_CLIPBOARD;
 
         if (!(selectionAcquired == (S_PRIMARY | S_CLIPBOARD)))
@@ -2225,7 +2199,7 @@
         if (saveSelectionState & S_PRIMARY)
             TSXSetSelectionOwner(display, XA_PRIMARY, selectionWindow, CurrentTime);
 
-        TSXSetSelectionOwner(display, xaClipboard, selectionWindow, CurrentTime);
+        TSXSetSelectionOwner(display, x11drv_atom(CLIPBOARD), selectionWindow, CurrentTime);
 
         /* Restore the selection masks */
         selectionAcquired = saveSelectionState;
@@ -2233,7 +2207,7 @@
         /* Lose the selection if something went wrong */
         if (((saveSelectionState & S_PRIMARY) &&
            (TSXGetSelectionOwner(display, XA_PRIMARY) != selectionWindow)) || 
-           (TSXGetSelectionOwner(display, xaClipboard) != selectionWindow))
+           (TSXGetSelectionOwner(display, x11drv_atom(CLIPBOARD)) != selectionWindow))
         {
             bLostSelection = TRUE;
         }
diff --git a/dlls/x11drv/desktop.c b/dlls/x11drv/desktop.c
index 916d267..1809cdc 100644
--- a/dlls/x11drv/desktop.c
+++ b/dlls/x11drv/desktop.c
@@ -69,6 +69,7 @@
     MSG msg;
     HWND hwnd;
     WND *win;
+    Atom atom = x11drv_atom(WM_DELETE_WINDOW);
 
     NtCurrentTeb()->driver_data = driver_data;
     display = thread_display();
@@ -82,7 +83,8 @@
 
     SetWindowLongW( hwnd, GWL_WNDPROC, (LONG)desktop_winproc );
     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 );
     wine_tsx11_unlock();
 
diff --git a/dlls/x11drv/event.c b/dlls/x11drv/event.c
index 3f640f7..1d2d490 100644
--- a/dlls/x11drv/event.c
+++ b/dlls/x11drv/event.c
@@ -56,12 +56,6 @@
 /* X context to associate a hwnd to an X window */
 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 DndUnknown      0
 #define DndRawData      1
@@ -434,7 +428,7 @@
 
     if (!protocol) return;
 
-    if (protocol == wmDeleteWindow)
+    if (protocol == x11drv_atom(WM_DELETE_WINDOW))
     {
         /* Ignore the delete window request if the window has been disabled
          * and we are in managed mode. This is to disallow applications from
@@ -442,7 +436,7 @@
          */
         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];
         HWND last_focus = x11drv_thread_data()->last_focus;
@@ -469,7 +463,9 @@
             if (!hwnd) hwnd = last_focus;
             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;
       xev = *event;
       
@@ -513,7 +509,7 @@
         XSetICFocus( xic );
         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))
     {
@@ -636,7 +632,7 @@
         return None;
 
     /* 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));)
     {
         LPWINE_CLIPFORMAT lpFormat = X11DRV_CLIPBOARD_LookupFormat(wFormat);
@@ -736,14 +732,17 @@
 
           for (i = 0; i < cTargetPropList; i+=2)
           {
-              char *targetName = TSXGetAtomName(display, targetPropList[i]);
-              char *propName = TSXGetAtomName(display, targetPropList[i+1]);
               XSelectionRequestEvent event;
 
-              TRACE("MULTIPLE(%d): Target='%s' Prop='%s'\n",
-                    i/2, targetName, propName);
-              TSXFree(targetName);
-              TSXFree(propName);
+              if (TRACE_ON(event))
+              {
+                  char *targetName = TSXGetAtomName(display, targetPropList[i]);
+                  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 */
               if ( !targetPropList[i+1] )
@@ -798,7 +797,7 @@
    */
   if ( !bIsMultiple )
   {
-    if (((event->selection != XA_PRIMARY) && (event->selection != xaClipboard)))
+    if (((event->selection != XA_PRIMARY) && (event->selection != x11drv_atom(CLIPBOARD))))
        goto END;
   }
 
@@ -809,12 +808,12 @@
   if( rprop == None )
       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 */
       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 */
       rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event );
@@ -884,7 +883,7 @@
  */
 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 );
 }
 
@@ -1029,7 +1028,7 @@
     if (!bAccept) return;
 
     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,
                           &data_length, &aux_long, &p_data);
 
@@ -1118,7 +1117,7 @@
   if (!(GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return;
 
   TSXGetWindowProperty( event->display, DefaultRootWindow(event->display),
-			dndSelection, 0, 65535, FALSE,
+			x11drv_atom(DndSelection), 0, 65535, FALSE,
 			AnyPropertyType, &u.atom_aux, &u.i,
 			&data_length, &aux_long, &p_data);
   if (aux_long)
@@ -1208,9 +1207,9 @@
 static void EVENT_ClientMessage( HWND hWnd, XClientMessageEvent *event )
 {
   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 );
-    else if (event->message_type == dndProtocol)
+    else if (event->message_type == x11drv_atom(DndProtocol))
     {
         /* query window (drag&drop event contains only drag window) */
         Window root, child;
diff --git a/dlls/x11drv/window.c b/dlls/x11drv/window.c
index 3f97325..77e1f2e 100644
--- a/dlls/x11drv/window.c
+++ b/dlls/x11drv/window.c
@@ -56,17 +56,35 @@
 /* X context to associate a hwnd to an X window */
 XContext winContext = 0;
 
-Atom wmProtocols = None;
-Atom wmDeleteWindow = None;
-Atom wmTakeFocus = None;
-Atom dndProtocol = None;
-Atom dndSelection = None;
-Atom wmChangeState = None;
-Atom mwmHints = None;
-Atom kwmDockWindow = None;
-Atom netwmPid = None;
-Atom netwmPing = None;
-Atom _kde_net_wm_system_tray_window_for = None; /* KDE 2 Final */
+Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
+
+static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
+{
+    "CLIPBOARD",
+    "COMPOUND_TEXT",
+    "MULTIPLE",
+    "SELECTION_DATA",
+    "TARGETS",
+    "TEXT",
+    "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 client_window_atom;
@@ -336,17 +354,19 @@
     Window group_leader;
     XClassHint *class_hints;
     XWMHints* wm_hints;
-    Atom protocols[2];
+    Atom protocols[3];
+    MwmHints mwm_hints;
     int i;
 
     wine_tsx11_lock();
 
     /* wm protocols */
     i = 0;
-    protocols[i++] = wmDeleteWindow;
-    if (wmTakeFocus) protocols[i++] = wmTakeFocus;
-    if (netwmPing) protocols[i++] = netwmPing;
-    XSetWMProtocols( display, data->whole_window, protocols, i );
+    protocols[i++] = x11drv_atom(WM_DELETE_WINDOW);
+    protocols[i++] = x11drv_atom(_NET_WM_PING);
+    if (use_take_focus) protocols[i++] = x11drv_atom(WM_TAKE_FOCUS);
+    XChangeProperty( display, data->whole_window, x11drv_atom(WM_PROTOCOLS),
+                     XA_ATOM, 32, PropModeReplace, (char *)protocols, i );
 
     /* class hints */
     if ((class_hints = XAllocClassHint()))
@@ -373,44 +393,40 @@
     if (win->dwExStyle & WS_EX_TRAYWINDOW)
     {
         int val = 1;
-        if (kwmDockWindow != None)
-            XChangeProperty( display, data->whole_window, kwmDockWindow, kwmDockWindow,
-                             32, PropModeReplace, (char*)&val, 1 );
-        if (_kde_net_wm_system_tray_window_for != None)
-            XChangeProperty( display, data->whole_window, _kde_net_wm_system_tray_window_for,
-                             XA_WINDOW, 32, PropModeReplace, (char*)&data->whole_window, 1 );
+        XChangeProperty( display, data->whole_window, x11drv_atom(KWM_DOCKWINDOW),
+                         x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace, (char*)&val, 1 );
+        XChangeProperty( display, data->whole_window, x11drv_atom(_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 */
     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 */
     i = getpid();
-    XChangeProperty(display, data->whole_window, netwmPid, XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1);
-    
-    if (mwmHints != None)
-    {
-        MwmHints mwm_hints;
-        mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
-        mwm_hints.functions = 0;
-        if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE;
-        if (win->dwStyle & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
-        if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
-        if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
-        if (win->dwStyle & WS_SYSMENU)    mwm_hints.functions |= MWM_FUNC_CLOSE;
-        mwm_hints.decorations = 0;
-        if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE;
-        if (win->dwExStyle & WS_EX_DLGMODALFRAME) 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_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
-        else if (win->dwStyle & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER;
-        else if (!(win->dwStyle & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER;
-        if (win->dwStyle & WS_SYSMENU)  mwm_hints.decorations |= MWM_DECOR_MENU;
-        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(_NET_WM_PID),
+                    XA_CARDINAL, 32, PropModeReplace, (char *)&i, 1);
 
-        XChangeProperty( display, data->whole_window, mwmHints, mwmHints, 32,
-                         PropModeReplace, (char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
-    }
+    mwm_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
+    mwm_hints.functions = 0;
+    if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.functions |= MWM_FUNC_MOVE;
+    if (win->dwStyle & WS_THICKFRAME) mwm_hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+    if (win->dwStyle & WS_MINIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MINIMIZE;
+    if (win->dwStyle & WS_MAXIMIZEBOX) mwm_hints.functions |= MWM_FUNC_MAXIMIZE;
+    if (win->dwStyle & WS_SYSMENU)    mwm_hints.functions |= MWM_FUNC_CLOSE;
+    mwm_hints.decorations = 0;
+    if ((win->dwStyle & WS_CAPTION) == WS_CAPTION) mwm_hints.decorations |= MWM_DECOR_TITLE;
+    if (win->dwExStyle & WS_EX_DLGMODALFRAME) 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_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) mwm_hints.decorations |= MWM_DECOR_BORDER;
+    else if (win->dwStyle & WS_BORDER) mwm_hints.decorations |= MWM_DECOR_BORDER;
+    else if (!(win->dwStyle & (WS_CHILD|WS_POPUP))) mwm_hints.decorations |= MWM_DECOR_BORDER;
+    if (win->dwStyle & WS_SYSMENU)  mwm_hints.decorations |= MWM_DECOR_MENU;
+    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,
+                     (char*)&mwm_hints, sizeof(mwm_hints)/sizeof(long) );
 
     wm_hints = XAllocWMHints();
     wine_tsx11_unlock();
@@ -674,18 +690,8 @@
     X11DRV_WND_DATA *data = wndPtr->pDriverData;
 
     wine_tsx11_lock();
-    winContext     = XUniqueContext();
-    wmProtocols    = XInternAtom( display, "WM_PROTOCOLS", False );
-    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 );
+    winContext = XUniqueContext();
+    XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
     wine_tsx11_unlock();
 
     whole_window_atom  = MAKEINTATOMA( GlobalAddAtomA( "__wine_x11_whole_window" ));
@@ -699,6 +705,8 @@
     SetPropA( wndPtr->hwndSelf, client_window_atom, (HANDLE)root_window );
     SetPropA( wndPtr->hwndSelf, "__wine_x11_visual_id", (HANDLE)XVisualIDFromVisual(visual) );
 
+    X11DRV_InitClipboard( display );
+
     if (root_window != DefaultRootWindow(display)) X11DRV_create_desktop_thread();
 }
 
@@ -849,11 +857,8 @@
         according to the standard
         ( http://www.pps.jussieu.fr/~jch/software/UTF8_STRING/UTF8_STRING.text ).
         */
-        XChangeProperty( display, win,
-            XInternAtom(display, "_NET_WM_NAME", False),
-            XInternAtom(display, "UTF8_STRING", False),
-            8, PropModeReplace, (unsigned char *) utf8_buffer,
-            count);
+        XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING),
+                         8, PropModeReplace, (unsigned char *) utf8_buffer, count);
         wine_tsx11_unlock();
 
         HeapFree( GetProcessHeap(), 0, utf8_buffer );
diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h
index 62a129a..3b0ecb3 100644
--- a/dlls/x11drv/x11drv.h
+++ b/dlls/x11drv/x11drv.h
@@ -364,31 +364,44 @@
 extern int use_take_focus;
 extern int managed_mode;
 
-extern Atom wmProtocols;
-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;
+/* atoms */
+
+enum x11drv_atoms
+{
+    FIRST_XATOM = XA_LAST_PREDEFINED + 1,
+    XATOM_CLIPBOARD = FIRST_XATOM,
+    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
+};
+
+extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
+
+#define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])
 
 /* X11 clipboard driver */
 
-typedef struct tagPROPERTYFORMATMAP
-{
-    LPCSTR lpszProperty;
-    LPCSTR lpszFormat;
-} PROPERTYFORMATMAP;
-
-typedef struct tagPROPERTYALIASMAP
-{
-    LPCSTR lpszProperty;
-    UINT drvDataProperty;
-    LPCSTR lpszAlias;
-    UINT drvDataAlias;
-} PROPERTYALIASMAP;
-
 typedef struct tagWINE_CLIPDATA {
     UINT        wFormatID;
     HANDLE16    hData16;
@@ -416,11 +429,7 @@
 #define CF_FLAG_BUILTINFMT   1 /* Built-in windows format */
 #define CF_FLAG_SYNTHESIZED  8 /* Implicitly converted data */
 
-extern Atom xaClipboard;
-extern Atom xaTargets;
-extern Atom xaMultiple;
-
-extern BOOL X11DRV_InitClipboard(Display *display);
+extern void X11DRV_InitClipboard(Display *display);
 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
 extern INT X11DRV_CountClipboardFormats(void);
 extern UINT X11DRV_EnumClipboardFormats(UINT wFormat);
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
index e915341..c789851 100644
--- a/dlls/x11drv/x11drv_main.c
+++ b/dlls/x11drv/x11drv_main.c
@@ -379,13 +379,6 @@
         ExitProcess(1);
     }
 
-    /* Initialize clipboard */
-    if (!X11DRV_InitClipboard( display ))
-    {
-        ERR( "Couldn't Initialize clipboard.\n" );
-        ExitProcess(1);
-    }
-
 #ifdef HAVE_LIBXXF86VM
     /* initialize XVidMode */
     X11DRV_XF86VM_Init();
diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c
index 9620505..03997a3 100644
--- a/graphics/x11drv/xfont.c
+++ b/graphics/x11drv/xfont.c
@@ -342,9 +342,6 @@
 #define CHECK_PFONT(pFont) ( (((UINT)(pFont) & 0xFFFF0000) == X_PFONT_MAGIC) &&\
 			     (((UINT)(pFont) & 0x0000FFFF) < fontCacheSize) )
 
-static Atom RAW_ASCENT;
-static Atom RAW_DESCENT;
-
 /***********************************************************************
  *           Helper macros from X distribution
  */
@@ -1067,8 +1064,7 @@
     if( pEL ) *pEL = 0;
 
     if(XFT) {
-        Atom RAW_CAP_HEIGHT = TSXInternAtom(gdi_display, "RAW_CAP_HEIGHT", TRUE);
-	if(TSXGetFontProperty((XFontStruct*)x_fs, RAW_CAP_HEIGHT, &height))
+	if(TSXGetFontProperty((XFontStruct*)x_fs, x11drv_atom(RAW_CAP_HEIGHT), &height))
 	    *pIL = XFT->ascent -
                             (INT)(XFT->pixelsize / 1000.0 * height);
 	else
@@ -2032,13 +2028,10 @@
 static XFontStruct *safe_XLoadQueryFont(Display *display, char *name)
 {
     XFontStruct *ret;
-    
-    wine_tsx11_lock();
+
     X11DRV_expect_error(display, XLoadQueryFont_ErrorHandler, NULL);
     ret = XLoadQueryFont(display, name);
     if (X11DRV_check_error()) ret = NULL;
-    wine_tsx11_unlock();
-
     return ret;
 }
 
@@ -3020,12 +3013,6 @@
   XFONT_GrowFreeList(0, fontCacheSize - 1);
 
   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 @@
   TSXFree(fontName);
   HeapFree(GetProcessHeap(), 0, lfd);
 
-  TSXGetFontProperty( pfo->fs, RAW_ASCENT, &PX->RAW_ASCENT );
-  TSXGetFontProperty( pfo->fs, RAW_DESCENT, &PX->RAW_DESCENT );
+  TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_ASCENT), &PX->RAW_ASCENT );
+  TSXGetFontProperty( pfo->fs, x11drv_atom(RAW_DESCENT), &PX->RAW_DESCENT );
 
   PX->pixelsize = hypot(PX->a, PX->b);
   PX->ascent = PX->pixelsize / 1000.0 * PX->RAW_ASCENT;