[Spice-devel] [PATCH spice-gtk] widget: don't grab mouse when switching to server mode

Christophe Fergeau cfergeau at redhat.com
Tue Apr 30 02:18:45 PDT 2013


On Tue, Apr 30, 2013 at 01:44:25AM +0200, Marc-André Lureau wrote:
> spice-gtk used to try taking the grab when switching to server mode, so
> that the current mouse interaction, ex a drag, isn't interrupted if the

s/ex/for example/

> agent dies. However, shuting down a VM will automatically try taking the

s/shuting/shutting/

> grab when the is no tablet input, and agent exits.

s/the/there/

> 
> Some users are complaining about it (especially when they don't know the
> ungrab combination).
> 
> Instead, let's try to keep the grab only if we have currently a mouse
> button pressed.

ACK.

Christophe

> 
> https://bugzilla.redhat.com/show_bug.cgi?id=873272
> ---
>  gtk/spice-widget.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index d260367..b882106 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -1999,10 +1999,14 @@ static void spice_display_class_init(SpiceDisplayClass *klass)
>  
>  /* ---------------------------------------------------------------- */
>  
> +#define SPICE_GDK_BUTTONS_MASK \
> +    (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK|GDK_BUTTON4_MASK|GDK_BUTTON5_MASK)
> +
>  static void update_mouse_mode(SpiceChannel *channel, gpointer data)
>  {
>      SpiceDisplay *display = data;
>      SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
> +    GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
>  
>      g_object_get(channel, "mouse-mode", &d->mouse_mode, NULL);
>      SPICE_DEBUG("mouse mode %d", d->mouse_mode);
> @@ -2012,9 +2016,16 @@ static void update_mouse_mode(SpiceChannel *channel, gpointer data)
>          try_mouse_ungrab(display);
>          break;
>      case SPICE_MOUSE_MODE_SERVER:
> -        try_mouse_grab(display);
>          d->mouse_guest_x = -1;
>          d->mouse_guest_y = -1;
> +
> +        if (window != NULL) {
> +            GdkModifierType modifiers;
> +            gdk_window_get_pointer(window, NULL, NULL, &modifiers);
> +
> +            if (modifiers & SPICE_GDK_BUTTONS_MASK)
> +                try_mouse_grab(display);
> +        }
>          break;
>      default:
>          g_warn_if_reached();
> -- 
> 1.8.2.1.342.gfa7285d
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130430/a3e6b684/attachment.pgp>


More information about the Spice-devel mailing list