[Spice-devel] [PATCH spice-gtk] Handle grab-broken event

Hans de Goede hdegoede at redhat.com
Sat Mar 31 02:28:57 PDT 2012


Looks good, ACK.

Regards,

Hans


On 03/31/2012 02:06 AM, Marc-André Lureau wrote:
> This fixes the pointer being "trapped" in the center of the screen in
> server-side mouse mode. It also correctly inform the client that the
> pointer/keyboard is no longer grabbed so it can adjust its UI state
> accordingly (remote the "press ctrl+alt to ungrab" messages etc).
>
> I can reproduce only with RHEVM22 host, and a RHEL6 guest, when
> switching consoles.
> ---
>   gtk/spice-widget.c |   19 ++++++++++++++++++-
>   1 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index 4a907e1..c4ccc56 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -349,6 +349,23 @@ static GdkCursor* get_blank_cursor(void)
>       return gdk_cursor_new(GDK_BLANK_CURSOR);
>   }
>
> +static gboolean grab_broken(SpiceDisplay *self, GdkEventGrabBroken *event,
> +                            gpointer user_data G_GNUC_UNUSED)
> +{
> +    SpiceDisplayPrivate *d = self->priv;
> +
> +    SPICE_DEBUG("%s (%d)", __FUNCTION__, event->implicit);
> +    if (event->keyboard) {
> +        d->keyboard_grab_active = false;
> +        g_signal_emit(self, signals[SPICE_DISPLAY_KEYBOARD_GRAB], 0, false);
> +    } else {
> +        d->mouse_grab_active = false;
> +        g_signal_emit(self, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
> +    }
> +
> +    return false;
> +}
> +
>   static void spice_display_init(SpiceDisplay *display)
>   {
>       GtkWidget *widget = GTK_WIDGET(display);
> @@ -356,6 +373,7 @@ static void spice_display_init(SpiceDisplay *display)
>
>       d = display->priv = SPICE_DISPLAY_GET_PRIVATE(display);
>
> +    g_signal_connect(display, "grab-broken-event", G_CALLBACK(grab_broken), NULL);
>       gtk_widget_add_events(widget,
>                             GDK_STRUCTURE_MASK |
>                             GDK_POINTER_MOTION_MASK |
> @@ -368,7 +386,6 @@ static void spice_display_init(SpiceDisplay *display)
>       gtk_widget_set_double_buffered(widget, false);
>       gtk_widget_set_can_focus(widget, true);
>       gtk_widget_set_has_window(widget, true);
> -
>       d->keycode_map = vnc_display_keymap_gdk2xtkbd_table(&d->keycode_maplen);
>       d->grabseq = spice_grab_sequence_new_from_string("Control_L+Alt_L");
>       d->activeseq = g_new0(gboolean, d->grabseq->nkeysyms);


More information about the Spice-devel mailing list