summaryrefslogtreecommitdiffstats
path: root/src/virt-viewer-display-spice.c
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2014-03-12 11:12:15 -0500
committerJonathon Jongsma <jjongsma@redhat.com>2014-03-13 10:13:42 -0500
commitfe167a6668a131c6182f749c826e52046607cb6f (patch)
treef31df5c1ebdfbed5dc7c643f569caabbbac52405 /src/virt-viewer-display-spice.c
parent02fb004a8e1c6b949aa16d82ac23456d787dce7c (diff)
downloadvirt-viewer-fe167a6668a131c6182f749c826e52046607cb6f.tar.gz
virt-viewer-fe167a6668a131c6182f749c826e52046607cb6f.tar.xz
virt-viewer-fe167a6668a131c6182f749c826e52046607cb6f.zip
Fix broken 'release-cursor' accel when not specified in --hotkeys
When the --hotkeys option is given, all hotkeys that are not explicitly specified are disabled. The method used to disable hotkeys is to change the accel map entry to key=0, mods=0. However, when we decide whether to set a grab sequence on the spice dispay widget, we simply use the return value for gtk_accel_map_lookup_entry and assume that a TRUE value returned from this function means that the hotkey is enabled. In reality, this function will return TRUE for disabled hotkeys, but the 'key' variable will be set to key=0, mods=0. The result is that if I start virt-viewer like this: virt-viewer --hotkeys secure-attention=ctrl+alt+end ... and the guest that I'm attached to uses server mouse mode, it will be impossible to release the grab on the spice widget. Because we will explicitly disable the grab keys in the spice widget and handle the 'release-cursor' hotkey in virt-viewer, but the hotkey is an empty accel key. Instead of simply checking the return value of gtk_accel_map_lookup_entry, we have to inspect the return value for 'key' and check whether any keys are actually assigned.
Diffstat (limited to 'src/virt-viewer-display-spice.c')
-rw-r--r--src/virt-viewer-display-spice.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 8bffe5b..c44dfcb 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -230,8 +230,11 @@ enable_accel_changed(VirtViewerApp *app,
GParamSpec *pspec G_GNUC_UNUSED,
VirtViewerDisplaySpice *self)
{
- if (virt_viewer_app_get_enable_accel(app)
- && gtk_accel_map_lookup_entry("<virt-viewer>/view/release-cursor", NULL)) {
+ 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) {
SpiceGrabSequence *seq = spice_grab_sequence_new(0, NULL);
/* disable default grab sequence */
spice_display_set_grab_keys(self->priv->display, seq);