From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXUnJ-0002Fw-Ry for qemu-devel@nongnu.org; Tue, 08 Apr 2014 08:06:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXUnE-0005S1-V9 for qemu-devel@nongnu.org; Tue, 08 Apr 2014 08:06:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXUnE-0005R6-MF for qemu-devel@nongnu.org; Tue, 08 Apr 2014 08:06:20 -0400 From: Gerd Hoffmann Date: Tue, 8 Apr 2014 14:06:12 +0200 Message-Id: <1396958772-3561-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1396958772-3561-1-git-send-email-kraxel@redhat.com> References: <1396958772-3561-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/1] gtk: Implement grab-on-click behavior in relative mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Takashi Iwai , Gerd Hoffmann , Anthony Liguori From: Takashi Iwai This patch changes the behavior in the relative mode to be compatible with other UIs, namely, grabbing the input at the first left click. It improves the usability a lot; otherwise you have to press ctl-alt-G or select from menu at each time you want to move the pointer. Also, the input grab is cleared when the current mode is switched to the absolute mode. The automatic reset of the implicit grabbing is needed since the switching to the absolute mode happens always after the click even on Gtk. That is, we cannot check whether the absolute mode is already available at the first click time even though it should have been switched in X11 input driver side. Signed-off-by: Takashi Iwai Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 6668bd8..00fbbcc 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -476,8 +476,15 @@ static void gd_change_runstate(void *opaque, int running, RunState state) static void gd_mouse_mode_change(Notifier *notify, void *data) { - gd_update_cursor(container_of(notify, GtkDisplayState, mouse_mode_notifier), - FALSE); + GtkDisplayState *s; + + s = container_of(notify, GtkDisplayState, mouse_mode_notifier); + /* release the grab at switching to absolute mode */ + if (qemu_input_is_absolute() && gd_is_grab_active(s)) { + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item), + FALSE); + } + gd_update_cursor(s, FALSE); } /** GTK Events **/ @@ -685,6 +692,14 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button, GtkDisplayState *s = opaque; InputButton btn; + /* implicitly grab the input at the first click in the relative mode */ + if (button->button == 1 && button->type == GDK_BUTTON_PRESS && + !qemu_input_is_absolute() && !gd_is_grab_active(s)) { + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item), + TRUE); + return TRUE; + } + if (button->button == 1) { btn = INPUT_BUTTON_LEFT; } else if (button->button == 2) { -- 1.8.3.1