[Spice-devel] [PATCH spice-gtk 4/7] vncdisplaykeymap: use a window to associate table

Marc-André Lureau marcandre.lureau at gmail.com
Fri May 10 13:46:05 PDT 2013


---
 gtk/spice-widget.c     |  5 ++++-
 gtk/vncdisplaykeymap.c | 12 ++++++------
 gtk/vncdisplaykeymap.h |  3 ++-
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 0b1fe31..065c02b 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -574,7 +574,6 @@ static void spice_display_init(SpiceDisplay *display)
 #endif
     gtk_widget_set_can_focus(widget, true);
     gtk_widget_set_has_window(widget, true);
-    d->keycode_map = vnc_display_keymap_gdk2xtkbd_table(&d->keycode_maplen);
     d->grabseq = spice_grab_sequence_new_from_string("Control_L+Alt_L");
     d->activeseq = g_new0(gboolean, d->grabseq->nkeysyms);
 
@@ -1716,9 +1715,13 @@ static void update_image(SpiceDisplay *display)
 static void realize(GtkWidget *widget)
 {
     SpiceDisplay *display = SPICE_DISPLAY(widget);
+    SpiceDisplayPrivate *d = display->priv;
 
     GTK_WIDGET_CLASS(spice_display_parent_class)->realize(widget);
 
+    d->keycode_map =
+        vnc_display_keymap_gdk2xtkbd_table(gtk_widget_get_window(widget),
+                                           &d->keycode_maplen);
     update_image(display);
 }
 
diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
index bf79f9b..1f17165 100644
--- a/gtk/vncdisplaykeymap.c
+++ b/gtk/vncdisplaykeymap.c
@@ -133,14 +133,14 @@ static gboolean check_for_xquartz(GdkDisplay *dpy)
 }
 #endif
 
-const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen)
+const guint16 const *vnc_display_keymap_gdk2xtkbd_table(GdkWindow *window,
+                                                        size_t *maplen)
 {
-	GdkDisplay *dpy = gdk_display_get_default();
-
 #ifdef GDK_WINDOWING_X11
-	if (GDK_IS_X11_DISPLAY(dpy)) {
+	if (GDK_IS_X11_WINDOW(window)) {
 		XkbDescPtr desc;
 		const gchar *keycodes = NULL;
+                GdkDisplay *dpy = gdk_window_get_display(window);
 
 		/* There is no easy way to determine what X11 server
 		 * and platform & keyboard driver is in use. Thus we
@@ -195,7 +195,7 @@ const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen)
 #endif
 
 #ifdef GDK_WINDOWING_WIN32
-	if (GDK_IS_WIN32_DISPLAY(dpy)) {
+	if (GDK_IS_WIN32_WINDOW(window)) {
 		VNC_DEBUG("Using Win32 virtual keycode mapping");
 		*maplen = G_N_ELEMENTS(keymap_win322xtkbd);
 		return keymap_win322xtkbd;
@@ -203,7 +203,7 @@ const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen)
 #endif
 
 #ifdef GDK_WINDOWING_QUARTZ
-	if (GDK_IS_QUARTZ_DISPLAY(dpy)) {
+	if (GDK_IS_QUARTZ_WINDOW(window)) {
 		VNC_DEBUG("Using OS-X virtual keycode mapping");
 		*maplen = G_N_ELEMENTS(keymap_osx2xtkbd);
 		return keymap_osx2xtkbd;
diff --git a/gtk/vncdisplaykeymap.h b/gtk/vncdisplaykeymap.h
index cee1b5a..3cb2abb 100644
--- a/gtk/vncdisplaykeymap.h
+++ b/gtk/vncdisplaykeymap.h
@@ -24,7 +24,8 @@
 
 #include <glib.h>
 
-const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen);
+const guint16 const *vnc_display_keymap_gdk2xtkbd_table(GdkWindow *window,
+                                                        size_t *maplen);
 guint16 vnc_display_keymap_gdk2xtkbd(const guint16 *keycode_map,
                                      size_t keycode_maplen,
                                      guint16 keycode);
-- 
1.8.2.1.342.gfa7285d



More information about the Spice-devel mailing list