x11: Register DND atoms with all other atoms

It's 2020, there's no need to be restrained with registering atoms.
This commit is contained in:
Benjamin Otte 2020-02-22 16:08:46 +01:00
parent b0f6996892
commit 992173c382
4 changed files with 18 additions and 102 deletions

View File

@ -138,6 +138,7 @@ static const char *const precache_atoms[] = {
"WM_PROTOCOLS", "WM_PROTOCOLS",
"WM_TAKE_FOCUS", "WM_TAKE_FOCUS",
"WM_WINDOW_ROLE", "WM_WINDOW_ROLE",
"WM_STATE",
"_NET_ACTIVE_WINDOW", "_NET_ACTIVE_WINDOW",
"_NET_CURRENT_DESKTOP", "_NET_CURRENT_DESKTOP",
"_NET_FRAME_EXTENTS", "_NET_FRAME_EXTENTS",
@ -177,7 +178,23 @@ static const char *const precache_atoms[] = {
"_NET_VIRTUAL_ROOTS", "_NET_VIRTUAL_ROOTS",
"GDK_SELECTION", "GDK_SELECTION",
"_NET_WM_STATE_FOCUSED", "_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; static char *gdk_sm_client_id;

View File

@ -124,9 +124,6 @@ struct _GdkX11Display
gulong user_time; gulong user_time;
/* Sets of atoms for DND */ /* 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 use_sync : 1;
guint have_shapes : 1; guint have_shapes : 1;

View File

@ -1242,59 +1242,6 @@ xdnd_check_dest (GdkDisplay *display,
return retval ? (proxy ? proxy : win) : None; 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 */ /* Source side */
static void static void
@ -1339,8 +1286,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
GdkSurface *surface; GdkSurface *surface;
Window retval; Window retval;
base_precache_atoms (display);
/* Check for a local drag */ /* Check for a local drag */
surface = gdk_x11_surface_lookup_for_display (display, xid); surface = gdk_x11_surface_lookup_for_display (display, xid);
if (surface) if (surface)
@ -1349,7 +1294,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
{ {
*protocol = GDK_DRAG_PROTO_XDND; *protocol = GDK_DRAG_PROTO_XDND;
*version = 5; *version = 5;
xdnd_precache_atoms (display);
GDK_DISPLAY_NOTE (display, DND, g_message ("Entering local Xdnd window %#x\n", (guint) xid)); GDK_DISPLAY_NOTE (display, DND, g_message ("Entering local Xdnd window %#x\n", (guint) xid));
return xid; return xid;
} }
@ -1363,7 +1307,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
else if ((retval = xdnd_check_dest (display, xid, version))) else if ((retval = xdnd_check_dest (display, xid, version)))
{ {
*protocol = GDK_DRAG_PROTO_XDND; *protocol = GDK_DRAG_PROTO_XDND;
xdnd_precache_atoms (display);
GDK_DISPLAY_NOTE (display, DND, g_message ("Entering Xdnd window %#x\n", (guint) xid)); GDK_DISPLAY_NOTE (display, DND, g_message ("Entering Xdnd window %#x\n", (guint) xid));
return retval; return retval;
} }
@ -1639,8 +1582,6 @@ _gdk_x11_surface_register_dnd (GdkSurface *surface)
g_return_if_fail (surface != NULL); g_return_if_fail (surface != NULL);
base_precache_atoms (display);
if (g_object_get_data (G_OBJECT (surface), "gdk-dnd-registered") != NULL) if (g_object_get_data (G_OBJECT (surface), "gdk-dnd-registered") != NULL)
return; return;
else else

View File

@ -430,37 +430,6 @@ xdnd_source_surface_filter (GdkDisplay *display,
return FALSE; 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 static gboolean
xdnd_enter_filter (GdkSurface *surface, xdnd_enter_filter (GdkSurface *surface,
const XEvent *xevent) const XEvent *xevent)
@ -490,8 +459,6 @@ xdnd_enter_filter (GdkSurface *surface,
display = gdk_surface_get_display (surface); display = gdk_surface_get_display (surface);
display_x11 = GDK_X11_DISPLAY (display); display_x11 = GDK_X11_DISPLAY (display);
xdnd_precache_atoms (display);
GDK_DISPLAY_NOTE (display, DND, GDK_DISPLAY_NOTE (display, DND,
g_message ("XdndEnter: source_window: %#lx, version: %#x", g_message ("XdndEnter: source_window: %#lx, version: %#x",
source_window, version)); source_window, version));
@ -608,8 +575,6 @@ xdnd_leave_filter (GdkSurface *surface,
g_message ("XdndLeave: source_window: %#lx", g_message ("XdndLeave: source_window: %#lx",
source_window)); source_window));
xdnd_precache_atoms (display);
if ((display_x11->current_drop != NULL) && if ((display_x11->current_drop != NULL) &&
(GDK_X11_DROP (display_x11->current_drop)->source_window == source_window)) (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", g_message ("XdndPosition: source_window: %#lx position: (%d, %d) time: %d action: %ld",
source_window, x_root, y_root, time, action)); source_window, x_root, y_root, time, action));
xdnd_precache_atoms (display);
drop = display_x11->current_drop; drop = display_x11->current_drop;
drop_x11 = GDK_X11_DROP (drop); drop_x11 = GDK_X11_DROP (drop);
@ -693,8 +656,6 @@ xdnd_drop_filter (GdkSurface *surface,
g_message ("XdndDrop: source_window: %#lx time: %d", g_message ("XdndDrop: source_window: %#lx time: %d",
source_window, time)); source_window, time));
xdnd_precache_atoms (display);
drop = display_x11->current_drop; drop = display_x11->current_drop;
drop_x11 = GDK_X11_DROP (drop); drop_x11 = GDK_X11_DROP (drop);