[PATCH 2/2] Use GdkKeymap to listen for keyboard modifier changes

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

 



Connect to the GdkKeymap::state-changed signal to detect when the client
keyboard modifiers have changed. This keeps the client and the guest in sync
even when the SpiceDisplay widget isn't focused. New values are only sent down
to the guest if the new value is different than the current value.
---
 gtk/spice-keyboard-state-monitor.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gtk/spice-keyboard-state-monitor.c b/gtk/spice-keyboard-state-monitor.c
index 161dc43..023fc8f 100644
--- a/gtk/spice-keyboard-state-monitor.c
+++ b/gtk/spice-keyboard-state-monitor.c
@@ -157,9 +157,21 @@ static guint32 get_keyboard_lock_modifiers(void)
     return modifiers;
 }
 
+static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data)
+{
+    SpiceKeyboardStateMonitor *self = data;
+    guint modifiers = get_keyboard_lock_modifiers();
+    g_debug("%s: 0x%x", G_STRFUNC, modifiers);
+    spice_keyboard_state_monitor_sync_modifiers(self);
+}
+
 static void spice_keyboard_state_monitor_init(SpiceKeyboardStateMonitor *self)
 {
+    GdkKeymap *keymap = gdk_keymap_get_default();
+
     self->priv = KEYBOARD_STATE_MONITOR_PRIVATE(self);
+    spice_g_signal_connect_object(keymap, "state-changed",
+                                  G_CALLBACK(keymap_modifiers_changed), self, 0);
 }
 
 static gpointer spice_keyboard_state_monitor_new(gpointer data)
-- 
1.9.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]