From patchwork Wed May 11 10:48:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9067831 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9E69E9F1C3 for ; Wed, 11 May 2016 10:49:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9D6A20142 for ; Wed, 11 May 2016 10:49:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13013200EC for ; Wed, 11 May 2016 10:49:05 +0000 (UTC) Received: from localhost ([::1]:51582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0RhQ-0005I0-0W for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 May 2016 06:49:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0RhH-0005Eh-R7 for qemu-devel@nongnu.org; Wed, 11 May 2016 06:48:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0RhE-00074u-Hh for qemu-devel@nongnu.org; Wed, 11 May 2016 06:48:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0RhE-00074p-8F for qemu-devel@nongnu.org; Wed, 11 May 2016 06:48:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72E3A3B703 for ; Wed, 11 May 2016 10:48:51 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4BAmonE031969; Wed, 11 May 2016 06:48:50 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id D7FB182881; Wed, 11 May 2016 12:48:48 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 11 May 2016 12:48:47 +0200 Message-Id: <1462963727-20533-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 11 May 2016 10:48:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] [untested] gtk: update grab code for gtk 3.20 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Cole Robinson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,FSL_HELO_HOME, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Applies on top of the pending ui pull request. Fixes the remaining gtk 3.20 warnings. Not tested (other than building) because I don't have a F24 box at hand. Feedback welcome. Signed-off-by: Gerd Hoffmann Reviewed-by: Cole Robinson Tested-by: Cole Robinson --- ui/gtk.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index a34f3c1..2d8e7ec 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1315,7 +1315,31 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque) gd_update_full_redraw(vc); } -#if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) +static void gd_grab_update(VirtualConsole *vc, bool kbd, bool ptr) +{ + GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area); + GdkSeat *seat = gdk_display_get_default_seat(display); + GdkWindow *window = gtk_widget_get_window(vc->gfx.drawing_area); + GdkSeatCapabilities caps = 0; + GdkCursor *cursor = NULL; + + if (kbd) { + caps |= GDK_SEAT_CAPABILITY_KEYBOARD; + } + if (ptr) { + caps |= GDK_SEAT_CAPABILITY_ALL_POINTING; + cursor = vc->s->null_cursor; + } + + if (caps) { + gdk_seat_grab(seat, window, caps, false, cursor, + NULL, NULL, NULL); + } else { + gdk_seat_ungrab(seat); + } +} +#elif GTK_CHECK_VERSION(3, 0, 0) static void gd_grab_devices(VirtualConsole *vc, bool grab, GdkInputSource source, GdkEventMask mask, GdkCursor *cursor) @@ -1352,7 +1376,9 @@ static void gd_grab_keyboard(VirtualConsole *vc, const char *reason) } } -#if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) + gd_grab_update(vc, true, vc->s->ptr_owner == vc); +#elif GTK_CHECK_VERSION(3, 0, 0) gd_grab_devices(vc, true, GDK_SOURCE_KEYBOARD, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL); @@ -1375,7 +1401,9 @@ static void gd_ungrab_keyboard(GtkDisplayState *s) } s->kbd_owner = NULL; -#if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) + gd_grab_update(vc, false, vc->s->ptr_owner == vc); +#elif GTK_CHECK_VERSION(3, 0, 0) gd_grab_devices(vc, false, GDK_SOURCE_KEYBOARD, 0, NULL); #else gdk_keyboard_ungrab(GDK_CURRENT_TIME); @@ -1396,7 +1424,11 @@ static void gd_grab_pointer(VirtualConsole *vc, const char *reason) } } -#if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) + gd_grab_update(vc, vc->s->kbd_owner == vc, true); + gdk_device_get_position(gd_get_pointer(display), + NULL, &vc->s->grab_x_root, &vc->s->grab_y_root); +#elif GTK_CHECK_VERSION(3, 0, 0) gd_grab_devices(vc, true, GDK_SOURCE_MOUSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | @@ -1428,14 +1460,19 @@ static void gd_grab_pointer(VirtualConsole *vc, const char *reason) static void gd_ungrab_pointer(GtkDisplayState *s) { VirtualConsole *vc = s->ptr_owner; + GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area); if (vc == NULL) { return; } s->ptr_owner = NULL; - GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area); -#if GTK_CHECK_VERSION(3, 0, 0) +#if GTK_CHECK_VERSION(3, 20, 0) + gd_grab_update(vc, vc->s->kbd_owner == vc, false); + gdk_device_warp(gd_get_pointer(display), + gtk_widget_get_screen(vc->gfx.drawing_area), + vc->s->grab_x_root, vc->s->grab_y_root); +#elif GTK_CHECK_VERSION(3, 0, 0) gd_grab_devices(vc, false, GDK_SOURCE_MOUSE, 0, NULL); gdk_device_warp(gd_get_pointer(display), gtk_widget_get_screen(vc->gfx.drawing_area),