Port key handling code to GTK3

GTK3 removed some previously-deprecated API that we still use. This
includes GDK_DISPLAY(), gdk_x11_drawable_get_xdisplay(), and some
key constants.

Port our code to the new API.

[split patch into several parts, added minimal description]
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
This commit is contained in:
Raul Gutierrez Segales 2011-11-15 22:56:24 +01:00 committed by Simon Schampijer
parent e2c07af748
commit 2bfb38ef82
3 changed files with 22 additions and 19 deletions

View File

@ -352,9 +352,11 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
bad_keyval = TRUE; bad_keyval = TRUE;
} }
} }
} else if (keycode != NULL) } else if (keycode != NULL) {
*keycode = XKeysymToKeycode (GDK_DISPLAY(), keyval); GdkDisplay *display = gdk_display_get_default ();
*keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY(display),
keyval);
}
accelerator += len; accelerator += len;
len -= len; len -= len;
} }
@ -624,20 +626,20 @@ reload_modmap (GdkKeymap *keymap,
j = 0; j = 0;
while (j < n_entries) while (j < n_entries)
{ {
if (keyvals[j] == GDK_Num_Lock) if (keyvals[j] == GDK_KEY_Num_Lock)
mask |= EGG_VIRTUAL_NUM_LOCK_MASK; mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
else if (keyvals[j] == GDK_Scroll_Lock) else if (keyvals[j] == GDK_KEY_Scroll_Lock)
mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK; mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
else if (keyvals[j] == GDK_Meta_L || else if (keyvals[j] == GDK_KEY_Meta_L ||
keyvals[j] == GDK_Meta_R) keyvals[j] == GDK_KEY_Meta_R)
mask |= EGG_VIRTUAL_META_MASK; mask |= EGG_VIRTUAL_META_MASK;
else if (keyvals[j] == GDK_Hyper_L || else if (keyvals[j] == GDK_KEY_Hyper_L ||
keyvals[j] == GDK_Hyper_R) keyvals[j] == GDK_KEY_Hyper_R)
mask |= EGG_VIRTUAL_HYPER_MASK; mask |= EGG_VIRTUAL_HYPER_MASK;
else if (keyvals[j] == GDK_Super_L || else if (keyvals[j] == GDK_KEY_Super_L ||
keyvals[j] == GDK_Super_R) keyvals[j] == GDK_KEY_Super_R)
mask |= EGG_VIRTUAL_SUPER_MASK; mask |= EGG_VIRTUAL_SUPER_MASK;
else if (keyvals[j] == GDK_Mode_switch) else if (keyvals[j] == GDK_KEY_Mode_switch)
mask |= EGG_VIRTUAL_MODE_SWITCH_MASK; mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
++j; ++j;

View File

@ -32,8 +32,8 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gtk/gtkwindow.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h>
struct EggDesktopFile { struct EggDesktopFile {
GKeyFile *key_file; GKeyFile *key_file;

View File

@ -18,9 +18,9 @@
*/ */
#include <X11/X.h> #include <X11/X.h>
#include <gdk/gdkscreen.h> #include <X11/Xlib.h>
#include <gdk/gdkx.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "sugar-key-grabber.h" #include "sugar-key-grabber.h"
#include "eggaccelerators.h" #include "eggaccelerators.h"
@ -160,11 +160,12 @@ sugar_key_grabber_init(SugarKeyGrabber *grabber)
static void static void
grab_key_real (Key *key, GdkWindow *root, gboolean grab, int result) grab_key_real (Key *key, GdkWindow *root, gboolean grab, int result)
{ {
Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default ());
if (grab) if (grab)
XGrabKey (GDK_DISPLAY(), key->keycode, (result | key->state), XGrabKey (display, key->keycode, (result | key->state),
GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync); GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync);
else else
XUngrabKey(GDK_DISPLAY(), key->keycode, (result | key->state), XUngrabKey(display, key->keycode, (result | key->state),
GDK_WINDOW_XID (root)); GDK_WINDOW_XID (root));
} }
@ -255,7 +256,7 @@ sugar_key_grabber_is_modifier(SugarKeyGrabber *grabber, guint keycode, guint mas
gint start, end, i, mod_index; gint start, end, i, mod_index;
gboolean is_modifier = FALSE; gboolean is_modifier = FALSE;
xdisplay = gdk_x11_drawable_get_xdisplay(GDK_DRAWABLE (grabber->root)); xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default ());
modmap = XGetModifierMapping(xdisplay); modmap = XGetModifierMapping(xdisplay);