[virt-tools-list] [PATCH virt-viewer] Fix broken 'release-cursor' accel when not specified in --hotkeys
Marc-André Lureau
mlureau at redhat.com
Wed Mar 12 16:25:01 UTC 2014
ack
----- Original Message -----
> 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.
> ---
> src/virt-viewer-display-spice.c | 7 +++++--
> src/virt-viewer-window.c | 9 ++++++---
> 2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/src/virt-viewer-display-spice.c
> b/src/virt-viewer-display-spice.c
> index a803ab0..f36ba98 100644
> --- a/src/virt-viewer-display-spice.c
> +++ b/src/virt-viewer-display-spice.c
> @@ -235,8 +235,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);
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 05d5fe7..fe896c2 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -1157,10 +1157,13 @@ virt_viewer_window_update_title(VirtViewerWindow
> *self)
>
> if (priv->grabbed) {
> gchar *label;
> - GtkAccelKey key;
> + GtkAccelKey key = { 0 };
>
> - if (virt_viewer_app_get_enable_accel(priv->app)
> - &&
> 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);
> +
> + if (key.accel_key || key.accel_mods) {
> + DEBUG_LOG("release-cursor accel key: key=%u, mods=%x, flags=%u",
> key.accel_key, key.accel_mods, key.accel_flags);
> label = gtk_accelerator_get_label(key.accel_key,
> key.accel_mods);
> } else {
> label = g_strdup(_("Ctrl+Alt"));
> --
> 1.8.5.3
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>
More information about the virt-tools-list
mailing list