[gtk+] Drop x11-specific code from the GTK+ dnd code
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Drop x11-specific code from the GTK+ dnd code
- Date: Wed, 26 Oct 2016 09:14:48 +0000 (UTC)
commit c9ce0bd4bac596d1d55c1008d2148d8ea58835b0
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 26 05:13:52 2016 -0400
Drop x11-specific code from the GTK+ dnd code
We were using passive grabs to listen for some individual
keys. Nowadays, the managed dnd code in the x11 backend
does the same.
gtk/gtkdnd.c | 228 ----------------------------------------------------------
1 files changed, 0 insertions(+), 228 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index a8c369a..238ed91 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -319,232 +319,6 @@ gtk_drag_get_ipc_widget (GtkWidget *widget)
return result;
}
-#if defined (GDK_WINDOWING_X11)
-
-/*
- * We want to handle a handful of keys during DND, e.g. Escape to abort.
- * Grabbing the keyboard has the unfortunate side-effect of preventing
- * useful things such as using Alt-Tab to cycle between windows or
- * switching workspaces. Therefore, we just grab the few keys we are
- * interested in. Note that we need to put the grabs on the root window
- * in order for them to still work when the focus is moved to another
- * app/workspace.
- *
- * GDK needs a little help to successfully deliver root key events...
- */
-
-static GdkFilterReturn
-root_key_filter (GdkXEvent *xevent,
- GdkEvent *event,
- gpointer data)
-{
- XEvent *ev = (XEvent *) xevent;
-
- if ((ev->type == KeyPress || ev->type == KeyRelease) &&
- ev->xkey.root == ev->xkey.window)
- ev->xkey.window = (Window)data;
- else if (ev->type == GenericEvent)
- {
- XGenericEventCookie *cookie;
- XIDeviceEvent *dev;
-
- cookie = &ev->xcookie;
- dev = (XIDeviceEvent *) cookie->data;
-
- if (dev->evtype == XI_KeyPress ||
- dev->evtype == XI_KeyRelease)
- dev->event = (Window)data;
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-typedef struct {
- gint keysym;
- gint modifiers;
-} GrabKey;
-
-static GrabKey grab_keys[] = {
- { XK_Escape, 0 },
- { XK_space, 0 },
- { XK_KP_Space, 0 },
- { XK_Return, 0 },
- { XK_KP_Enter, 0 },
- { XK_Up, 0 },
- { XK_Up, Mod1Mask },
- { XK_Down, 0 },
- { XK_Down, Mod1Mask },
- { XK_Left, 0 },
- { XK_Left, Mod1Mask },
- { XK_Right, 0 },
- { XK_Right, Mod1Mask },
- { XK_KP_Up, 0 },
- { XK_KP_Up, Mod1Mask },
- { XK_KP_Down, 0 },
- { XK_KP_Down, Mod1Mask },
- { XK_KP_Left, 0 },
- { XK_KP_Left, Mod1Mask },
- { XK_KP_Right, 0 },
- { XK_KP_Right, Mod1Mask }
-};
-
-static void
-grab_dnd_keys (GtkWidget *widget,
- GdkDevice *device,
- guint32 time)
-{
- guint i;
- GdkWindow *window, *root;
- gint keycode;
-#ifdef XINPUT_2
- gint deviceid;
- XIGrabModifiers mods;
- gint num_mods;
- XIEventMask evmask;
- unsigned char mask[(XI_LASTEVENT + 7)/8];
- gboolean using_xi2;
-
- window = gtk_widget_get_window (widget);
- if (!GDK_IS_X11_WINDOW (window))
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gdk_device_grab (device,
- gtk_widget_get_window (widget),
- GDK_OWNERSHIP_APPLICATION, FALSE,
- GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
- NULL, time);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- return;
- }
-
- deviceid = gdk_x11_device_get_id (device);
-
- if (GDK_IS_X11_DEVICE_XI2 (device))
- using_xi2 = TRUE;
- else
- using_xi2 = FALSE;
-#endif
-
- root = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
-
- gdk_error_trap_push ();
-
- for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
- {
- keycode = XKeysymToKeycode (GDK_WINDOW_XDISPLAY (window), grab_keys[i].keysym);
- if (keycode == NoSymbol)
- continue;
-
-#ifdef XINPUT_2
- if (using_xi2)
- {
- memset (mask, 0, sizeof (mask));
- XISetMask (mask, XI_KeyPress);
- XISetMask (mask, XI_KeyRelease);
-
- evmask.deviceid = deviceid;
- evmask.mask_len = sizeof (mask);
- evmask.mask = mask;
-
- num_mods = 1;
- mods.modifiers = grab_keys[i].modifiers;
-
- XIGrabKeycode (GDK_WINDOW_XDISPLAY (window),
- deviceid,
- keycode,
- GDK_WINDOW_XID (root),
- GrabModeAsync,
- GrabModeAsync,
- False,
- &evmask,
- num_mods,
- &mods);
- }
- else
-#endif
- XGrabKey (GDK_WINDOW_XDISPLAY (window),
- keycode, grab_keys[i].modifiers,
- GDK_WINDOW_XID (root),
- FALSE,
- GrabModeAsync,
- GrabModeAsync);
- }
-
- gdk_flush ();
- gdk_error_trap_pop_ignored ();
-
- gdk_window_add_filter (NULL, root_key_filter, (gpointer) GDK_WINDOW_XID (window));
-}
-
-static void
-ungrab_dnd_keys (GtkWidget *widget,
- GdkDevice *device,
- guint32 time)
-{
- guint i;
- GdkWindow *window, *root;
- gint keycode;
-#ifdef XINPUT_2
- XIGrabModifiers mods;
- gint num_mods;
- gint deviceid;
- gboolean using_xi2;
-
- window = gtk_widget_get_window (widget);
- if (!GDK_IS_X11_WINDOW (window))
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gdk_device_ungrab (device, time);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- return;
- }
-
- deviceid = gdk_x11_device_get_id (device);
-
- if (GDK_IS_X11_DEVICE_XI2 (device))
- using_xi2 = TRUE;
- else
- using_xi2 = FALSE;
-#endif
-
- root = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
-
- gdk_window_remove_filter (NULL, root_key_filter, (gpointer) GDK_WINDOW_XID (window));
-
- gdk_error_trap_push ();
-
- for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
- {
- keycode = XKeysymToKeycode (GDK_WINDOW_XDISPLAY (window), grab_keys[i].keysym);
- if (keycode == NoSymbol)
- continue;
-
-#ifdef XINPUT_2
- if (using_xi2)
- {
- num_mods = 1;
- mods.modifiers = grab_keys[i].modifiers;
-
- XIUngrabKeycode (GDK_WINDOW_XDISPLAY (window),
- deviceid,
- keycode,
- GDK_WINDOW_XID (root),
- num_mods,
- &mods);
- }
- else
-#endif
- XUngrabKey (GDK_WINDOW_XDISPLAY (window),
- keycode, grab_keys[i].modifiers,
- GDK_WINDOW_XID (root));
- }
-
- gdk_flush ();
- gdk_error_trap_pop_ignored ();
-}
-
-#else /* !GDK_WINDOWING_X11 */
-
static void
grab_dnd_keys (GtkWidget *widget,
GdkDevice *device,
@@ -569,8 +343,6 @@ ungrab_dnd_keys (GtkWidget *widget,
G_GNUC_END_IGNORE_DEPRECATIONS;
}
-#endif /* GDK_WINDOWING_X11 */
-
/*
* gtk_drag_release_ipc_widget:
* @widget: the widget to release
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]