[virt-tools-list] [PATCH virt-viewer] vnc-display: Disable default grab sequence

Pavel Grunt pgrunt at redhat.com
Wed Jun 1 11:19:25 UTC 2016


It should be enabled only if the "release-cursor" sequence was not
specified (by using "--hotkeys=release-cursor=sequence"), otherwise
both sequences would release the cursor.

The solution is taken from the spice-display code.

Resolves: rhbz#1339575
---
 src/virt-viewer-display-vnc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/virt-viewer-display-vnc.c b/src/virt-viewer-display-vnc.c
index 9e7ac63..730b5cb 100644
--- a/src/virt-viewer-display-vnc.c
+++ b/src/virt-viewer-display-vnc.c
@@ -184,11 +184,32 @@ virt_viewer_display_vnc_resize_desktop(VncDisplay *vnc G_GNUC_UNUSED,
 }
 
 
+static void
+enable_accel_changed(VirtViewerApp *app,
+                     GParamSpec *pspec G_GNUC_UNUSED,
+                     VncDisplay *vnc)
+{
+    GtkAccelKey key = { 0 };
+    if (virt_viewer_app_get_enable_accel(app))
+        gtk_accel_map_lookup_entry("<virt-viewer>/view/release-cursor", &key);
+
+    if (key.accel_key || key.accel_mods) {
+        VncGrabSequence *seq = vnc_grab_sequence_new(0, NULL);
+        /* disable default grab sequence */
+        vnc_display_set_grab_keys(vnc, seq);
+        vnc_grab_sequence_free(seq);
+    } else {
+        vnc_display_set_grab_keys(vnc, NULL);
+    }
+}
+
+
 GtkWidget *
 virt_viewer_display_vnc_new(VirtViewerSessionVnc *session,
                             VncDisplay *vnc)
 {
     VirtViewerDisplayVnc *display;
+    VirtViewerApp *app;
 
     display = g_object_new(VIRT_VIEWER_TYPE_DISPLAY_VNC, "session", session, NULL);
 
@@ -226,6 +247,11 @@ virt_viewer_display_vnc_new(VirtViewerSessionVnc *session,
     g_signal_connect(display->priv->vnc, "vnc-initialized",
                      G_CALLBACK(virt_viewer_display_vnc_initialized), display);
 
+    app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(session));
+    virt_viewer_signal_connect_object(app, "notify::enable-accel",
+                                      G_CALLBACK(enable_accel_changed), display->priv->vnc, 0);
+    enable_accel_changed(app, NULL, display->priv->vnc);
+
     return GTK_WIDGET(display);
 }
 
-- 
2.8.3




More information about the virt-tools-list mailing list