[gtk/wip/otte/dnd: 19/30] x11: Register DND atoms with all other atoms



commit 992173c38216c6b9cfc00d947ec70d5764f4da16
Author: Benjamin Otte <otte redhat com>
Date:   Sat Feb 22 16:08:46 2020 +0100

    x11: Register DND atoms with all other atoms
    
    It's 2020, there's no need to be restrained with registering atoms.

 gdk/x11/gdkdisplay-x11.c | 19 +++++++++++++++-
 gdk/x11/gdkdisplay-x11.h |  3 ---
 gdk/x11/gdkdrag-x11.c    | 59 ------------------------------------------------
 gdk/x11/gdkdrop-x11.c    | 39 --------------------------------
 4 files changed, 18 insertions(+), 102 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index a4c37c11ab..5a863f9000 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -138,6 +138,7 @@ static const char *const precache_atoms[] = {
   "WM_PROTOCOLS",
   "WM_TAKE_FOCUS",
   "WM_WINDOW_ROLE",
+  "WM_STATE",
   "_NET_ACTIVE_WINDOW",
   "_NET_CURRENT_DESKTOP",
   "_NET_FRAME_EXTENTS",
@@ -177,7 +178,23 @@ static const char *const precache_atoms[] = {
   "_NET_VIRTUAL_ROOTS",
   "GDK_SELECTION",
   "_NET_WM_STATE_FOCUSED",
-  "GDK_VISUALS"
+  "GDK_VISUALS",
+  "XdndAware",
+  "XdndProxy",
+  "XdndActionAsk",
+  "XdndActionCopy",
+  "XdndActionLink",
+  "XdndActionList",
+  "XdndActionMove",
+  "XdndActionPrivate",
+  "XdndDrop",
+  "XdndEnter",
+  "XdndFinished",
+  "XdndLeave",
+  "XdndPosition",
+  "XdndSelection",
+  "XdndStatus",
+  "XdndTypeList"
 };
 
 static char *gdk_sm_client_id;
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index 5949123270..853ca6a032 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -124,9 +124,6 @@ struct _GdkX11Display
   gulong user_time;
 
   /* Sets of atoms for DND */
-  guint base_dnd_atoms_precached : 1;
-  guint xdnd_atoms_precached : 1;
-  guint motif_atoms_precached : 1;
   guint use_sync : 1;
 
   guint have_shapes : 1;
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index 04fa753fa3..8445a7340c 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -1242,59 +1242,6 @@ xdnd_check_dest (GdkDisplay *display,
   return retval ? (proxy ? proxy : win) : None;
 }
 
-/* Target side */
-
-static void
-base_precache_atoms (GdkDisplay *display)
-{
-  GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
-  if (!display_x11->base_dnd_atoms_precached)
-    {
-      static const char *const precache_atoms[] = {
-        "WM_STATE",
-        "XdndAware",
-        "XdndProxy"
-      };
-
-      _gdk_x11_precache_atoms (display,
-                               precache_atoms, G_N_ELEMENTS (precache_atoms));
-
-      display_x11->base_dnd_atoms_precached = TRUE;
-    }
-}
-
-static void
-xdnd_precache_atoms (GdkDisplay *display)
-{
-  GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
-  if (!display_x11->xdnd_atoms_precached)
-    {
-      static const gchar *const precache_atoms[] = {
-        "XdndActionAsk",
-        "XdndActionCopy",
-        "XdndActionLink",
-        "XdndActionList",
-        "XdndActionMove",
-        "XdndActionPrivate",
-        "XdndDrop",
-        "XdndEnter",
-        "XdndFinished",
-        "XdndLeave",
-        "XdndPosition",
-        "XdndSelection",
-        "XdndStatus",
-        "XdndTypeList"
-      };
-
-      _gdk_x11_precache_atoms (display,
-                               precache_atoms, G_N_ELEMENTS (precache_atoms));
-
-      display_x11->xdnd_atoms_precached = TRUE;
-    }
-}
-
 /* Source side */
 
 static void
@@ -1339,8 +1286,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay      *display,
   GdkSurface *surface;
   Window retval;
 
-  base_precache_atoms (display);
-
   /* Check for a local drag */
   surface = gdk_x11_surface_lookup_for_display (display, xid);
   if (surface)
@@ -1349,7 +1294,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay      *display,
         {
           *protocol = GDK_DRAG_PROTO_XDND;
           *version = 5;
-          xdnd_precache_atoms (display);
           GDK_DISPLAY_NOTE (display, DND, g_message ("Entering local Xdnd window %#x\n", (guint) xid));
           return xid;
         }
@@ -1363,7 +1307,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay      *display,
   else if ((retval = xdnd_check_dest (display, xid, version)))
     {
       *protocol = GDK_DRAG_PROTO_XDND;
-      xdnd_precache_atoms (display);
       GDK_DISPLAY_NOTE (display, DND, g_message ("Entering Xdnd window %#x\n", (guint) xid));
       return retval;
     }
@@ -1639,8 +1582,6 @@ _gdk_x11_surface_register_dnd (GdkSurface *surface)
 
   g_return_if_fail (surface != NULL);
 
-  base_precache_atoms (display);
-
   if (g_object_get_data (G_OBJECT (surface), "gdk-dnd-registered") != NULL)
     return;
   else
diff --git a/gdk/x11/gdkdrop-x11.c b/gdk/x11/gdkdrop-x11.c
index c85c17be0f..fa4ca6b45a 100644
--- a/gdk/x11/gdkdrop-x11.c
+++ b/gdk/x11/gdkdrop-x11.c
@@ -430,37 +430,6 @@ xdnd_source_surface_filter (GdkDisplay   *display,
   return FALSE;
 }
 
-static void
-xdnd_precache_atoms (GdkDisplay *display)
-{
-  GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
-  if (!display_x11->xdnd_atoms_precached)
-    {
-      static const gchar *const precache_atoms[] = {
-        "XdndActionAsk",
-        "XdndActionCopy",
-        "XdndActionLink",
-        "XdndActionList",
-        "XdndActionMove",
-        "XdndActionPrivate",
-        "XdndDrop",
-        "XdndEnter",
-        "XdndFinished",
-        "XdndLeave",
-        "XdndPosition",
-        "XdndSelection",
-        "XdndStatus",
-        "XdndTypeList"
-      };
-
-      _gdk_x11_precache_atoms (display,
-                               precache_atoms, G_N_ELEMENTS (precache_atoms));
-
-      display_x11->xdnd_atoms_precached = TRUE;
-    }
-}
-
 static gboolean
 xdnd_enter_filter (GdkSurface   *surface,
                    const XEvent *xevent)
@@ -490,8 +459,6 @@ xdnd_enter_filter (GdkSurface   *surface,
   display = gdk_surface_get_display (surface);
   display_x11 = GDK_X11_DISPLAY (display);
 
-  xdnd_precache_atoms (display);
-
   GDK_DISPLAY_NOTE (display, DND,
             g_message ("XdndEnter: source_window: %#lx, version: %#x",
                        source_window, version));
@@ -608,8 +575,6 @@ xdnd_leave_filter (GdkSurface   *surface,
             g_message ("XdndLeave: source_window: %#lx",
                        source_window));
 
-  xdnd_precache_atoms (display);
-
   if ((display_x11->current_drop != NULL) &&
       (GDK_X11_DROP (display_x11->current_drop)->source_window == source_window))
     {
@@ -644,8 +609,6 @@ xdnd_position_filter (GdkSurface   *surface,
             g_message ("XdndPosition: source_window: %#lx position: (%d, %d)  time: %d  action: %ld",
                        source_window, x_root, y_root, time, action));
 
-  xdnd_precache_atoms (display);
-
   drop = display_x11->current_drop;
   drop_x11 = GDK_X11_DROP (drop);
 
@@ -693,8 +656,6 @@ xdnd_drop_filter (GdkSurface   *surface,
             g_message ("XdndDrop: source_window: %#lx  time: %d",
                        source_window, time));
 
-  xdnd_precache_atoms (display);
-
   drop = display_x11->current_drop;
   drop_x11 = GDK_X11_DROP (drop);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]