[virt-tools-list] [virt-viewer 3/3] Improve check for overridden grab key combination

Christophe Fergeau cfergeau at redhat.com
Mon Dec 10 14:42:46 UTC 2012


remote-viewer can either use the default grab/ungrab handled by
spice-gtk, or override it and use the standard gtk+ accelerator
mechanism. However, the code currently assumes that if any accelerator
is set in remote-viewer, then the grab key has been overridden.
This commit makes sure the grab key is actually overridden before assuming
so.
---
 src/virt-viewer-display-spice.c | 3 ++-
 src/virt-viewer-window.c        | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index b5f4859..b6fbf4f 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -223,7 +223,8 @@ enable_accel_changed(VirtViewerApp *app,
                      GParamSpec *pspec G_GNUC_UNUSED,
                      VirtViewerDisplaySpice *self)
 {
-    if (virt_viewer_app_get_enable_accel(app)) {
+    if (virt_viewer_app_get_enable_accel(app)
+            && gtk_accel_map_lookup_entry("<virt-viewer>/view/release-cursor", NULL)) {
         SpiceGrabSequence *seq = spice_grab_sequence_new(0, NULL);
         /* disable default grab sequence */
         spice_display_set_grab_keys(self->priv->display, seq);
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index a260366..6adba8e 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1017,10 +1017,10 @@ virt_viewer_window_update_title(VirtViewerWindow *self)
 
     if (priv->grabbed) {
         gchar *label;
+        GtkAccelKey key;
 
-        if (virt_viewer_app_get_enable_accel(priv->app)) {
-            GtkAccelKey key;
-            gtk_accel_map_lookup_entry("<virt-viewer>/view/release-cursor", &key);
+        if (virt_viewer_app_get_enable_accel(priv->app)
+                && gtk_accel_map_lookup_entry("<virt-viewer>/view/release-cursor", &key)) {
             label = gtk_accelerator_get_label(key.accel_key, key.accel_mods);
         } else {
             label = g_strdup(_("Ctrl+Alt"));
-- 
1.8.0.1




More information about the virt-tools-list mailing list