[Spice-devel] [PATCH spice-gtk v2 5/5] gtk: Avoid deprecated gdk_pointer_grab

Christophe Fergeau cfergeau at redhat.com
Wed Dec 21 10:51:06 UTC 2016


For the record, without this patch, the client mouse cursor is not
hidden as expected when running on wayland and the guest is in mouse
server mode, not sure why...
So in addition to switching away from deprecated API, this fixes/works
around a bug.

Christophe

On Mon, Dec 19, 2016 at 05:26:36PM +0100, Pavel Grunt wrote:
> ---
>  src/spice-widget.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 791f5b0..cf18fa6 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -1016,6 +1016,17 @@ static gboolean do_pointer_grab(SpiceDisplay *display)
>  #endif
>  
>      try_keyboard_grab(display);
> +    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> +#if GTK_CHECK_VERSION(3, 20, 0)
> +    status = gdk_seat_grab(spice_display_get_default_seat(display),
> +                           window,
> +                           GDK_SEAT_CAPABILITY_ALL_POINTING,
> +                           TRUE,
> +                           blank,
> +                           NULL,
> +                           NULL,
> +                           NULL);
> +#else
>      /*
>       * from gtk-vnc:
>       * For relative mouse to work correctly when grabbed we need to
> @@ -1025,8 +1036,6 @@ static gboolean do_pointer_grab(SpiceDisplay *display)
>       * what window the pointer is actally over, so use 'FALSE' for
>       * 'owner_events' parameter
>       */
> -    /* FIXME: gdk_pointer_grab() is deprecated */
> -    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>      status = gdk_pointer_grab(window, FALSE,
>                       GDK_POINTER_MOTION_MASK |
>                       GDK_BUTTON_PRESS_MASK |
> @@ -1036,6 +1045,7 @@ static gboolean do_pointer_grab(SpiceDisplay *display)
>                       NULL,
>                       blank,
>                       GDK_CURRENT_TIME);
> +#endif
>      G_GNUC_END_IGNORE_DEPRECATIONS
>      grab_successful = (status == GDK_GRAB_SUCCESS);
>      if (!grab_successful) {
> @@ -1135,9 +1145,6 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
>  
>  }
>  
> -/* FIXME: gdk_pointer_ungrab()/gdk_display_warp_pointer() are deprecated */
> -G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> -
>  static void try_mouse_ungrab(SpiceDisplay *display)
>  {
>      SpiceDisplayPrivate *d = display->priv;
> @@ -1147,7 +1154,13 @@ static void try_mouse_ungrab(SpiceDisplay *display)
>      if (!d->mouse_grab_active)
>          return;
>  
> +    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> +#if GTK_CHECK_VERSION(3, 20, 0)
> +    gdk_seat_ungrab(spice_display_get_default_seat(display));
> +#else
>      gdk_pointer_ungrab(GDK_CURRENT_TIME);
> +#endif
> +    G_GNUC_END_IGNORE_DEPRECATIONS
>      gtk_grab_remove(GTK_WIDGET(display));
>  #ifdef G_OS_WIN32
>      ClipCursor(NULL);
> @@ -1170,7 +1183,6 @@ static void try_mouse_ungrab(SpiceDisplay *display)
>      g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
>      spice_gtk_session_set_pointer_grabbed(d->gtk_session, false);
>  }
> -G_GNUC_END_IGNORE_DEPRECATIONS
>  
>  static void update_mouse_grab(SpiceDisplay *display)
>  {
> -- 
> 2.11.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161221/af07f235/attachment.sig>


More information about the Spice-devel mailing list