[Spice-devel] [PATCH spice-gtk v3 4/6] gtk: Avoid deprecated gdk_keyboard_grab
Victor Toso
victortoso at redhat.com
Mon Jan 23 13:44:33 UTC 2017
Hi,
On Fri, Jan 20, 2017 at 04:53:51PM +0100, Pavel Grunt wrote:
I think it doesn't hurt to include that gdk_keyboard_grab() was
deprecated in 3.0 and gdk_device_grab() should be used but this one was
also deprecated for gdk_seat_grab() in 3.20 :)
> ---
> src/spice-widget.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 94d7f9a..aa03556 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -120,6 +120,9 @@ static void size_allocate(GtkWidget *widget, GtkAllocation *conf, gpointer data)
> static gboolean draw_event(GtkWidget *widget, cairo_t *cr, gpointer data);
> static void update_size_request(SpiceDisplay *display);
> static GdkDevice *spice_display_get_pointer(SpiceDisplay *display);
> +#if GTK_CHECK_VERSION(3, 20, 0)
> +static GdkSeat *spice_display_get_default_seat(SpiceDisplay *display);
> +#endif
Right, I did not check all the patches before reviewing, my bad.
Still, I would introduce this function in this patch instead of 2/7.
>
> /* ---------------------------------------------------------------- */
>
> @@ -857,8 +860,19 @@ static void try_keyboard_grab(SpiceDisplay *display)
> GetModuleHandle(NULL), 0);
> g_warn_if_fail(d->keyboard_hook != NULL);
> #endif
> +#if GTK_CHECK_VERSION(3, 20, 0)
> + status = gdk_seat_grab(spice_display_get_default_seat(display),
> + gtk_widget_get_window(widget),
> + GDK_SEAT_CAPABILITY_KEYBOARD,
> + FALSE,
> + NULL,
> + NULL,
> + NULL,
> + NULL);
> +#else
> status = gdk_keyboard_grab(gtk_widget_get_window(widget), FALSE,
> GDK_CURRENT_TIME);
> +#endif
> if (status != GDK_GRAB_SUCCESS) {
> g_warning("keyboard grab failed %u", status);
> d->keyboard_grab_active = false;
> @@ -877,7 +891,11 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
> return;
>
> SPICE_DEBUG("ungrab keyboard");
> +#if GTK_CHECK_VERSION(3, 20, 0)
> + gdk_seat_ungrab(spice_display_get_default_seat(display));
> +#else
> gdk_keyboard_ungrab(GDK_CURRENT_TIME);
> +#endif
Looks good
Reviewed-by: Victor Toso <victortoso at redhat.com>
> #ifdef G_OS_WIN32
> // do not use g_clear_pointer as Windows API have different linkage
> if (d->keyboard_hook) {
> --
> 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: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170123/ccae05af/attachment.sig>
More information about the Spice-devel
mailing list