Received: from eggs.gnu.org ([2001:4830:134:3::10]:46895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVLRT-0004Ve-U8 for qemu-devel@nongnu.org; Wed, 02 Apr 2014 09:43:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVLRN-0007d0-Rk for qemu-devel@nongnu.org; Wed, 02 Apr 2014 09:42:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58790 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVLRN-0007co-Ht for qemu-devel@nongnu.org; Wed, 02 Apr 2014 09:42:53 -0400 Date: Wed, 02 Apr 2014 15:42:52 +0200 Message-ID: From: Takashi Iwai In-Reply-To: <533C1096.30904@redhat.com> References: <1396441953-19260-1-git-send-email-tiwai@suse.de> <1396441953-19260-5-git-send-email-tiwai@suse.de> <533C1096.30904@redhat.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH v2 4/4] gtk: Add "Grab On Click" option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cole Robinson Cc: qemu-devel@nongnu.org, Anthony Liguori , kraxel@redhat.com At Wed, 02 Apr 2014 09:28:54 -0400, Cole Robinson wrote: > > On 04/02/2014 08:32 AM, Takashi Iwai wrote: > > I simply like it better, you don't? :) > > > > In fact, relative mouse mode is a pain without this feature, you need to > manually initiate a grab with ctrl+alt+g before mouse movement will even work. > Compare to our sdl front end, or virt-viewer, vinagre, virt-manager, where > grab-on-click is the default (there isn't even an option to disable that > behavior). > > I don't know what the original intention of the code was, but I think this > behavior should be the default. Anthony, Gerd, thoughts? I noticed later that the original gtk-ui behavior is better when vmmouse driver is available, i.e. the absolute mode is working. With grab-on-click, you have to ungrab at each time you want to leave from VM window. So I think we should leave the default behavior as is, since vmmouse driver is likely available in most cases. But, still having this in the menu makes our lives easier in case vmmouse isn't available or doesn't work with QEMU. Takashi > > - Cole > > > Signed-off-by: Takashi Iwai > > --- > > ui/gtk.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/ui/gtk.c b/ui/gtk.c > > index 9b8df1224fdb..ffaf91ea453a 100644 > > --- a/ui/gtk.c > > +++ b/ui/gtk.c > > @@ -141,6 +141,7 @@ typedef struct GtkDisplayState > > GtkWidget *zoom_fit_item; > > GtkWidget *grab_item; > > GtkWidget *grab_on_hover_item; > > + GtkWidget *grab_on_click_item; > > GtkWidget *vga_item; > > > > int nb_vcs; > > @@ -189,6 +190,11 @@ static bool gd_grab_on_hover(GtkDisplayState *s) > > return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_on_hover_item)); > > } > > > > +static bool gd_grab_on_click(GtkDisplayState *s) > > +{ > > + return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_on_click_item)); > > +} > > + > > static bool gd_on_vga(GtkDisplayState *s) > > { > > return gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook)) == 0; > > @@ -685,6 +691,12 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button, > > GtkDisplayState *s = opaque; > > InputButton btn; > > > > + if (button->button == 1 && button->type == GDK_BUTTON_PRESS && > > + !gd_is_grab_active(s) && gd_grab_on_click(s) && button->button == 1) { > > + 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) { > > @@ -1416,6 +1428,9 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_g > > s->grab_on_hover_item = gtk_check_menu_item_new_with_mnemonic(_("Grab On _Hover")); > > gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_on_hover_item); > > > > + s->grab_on_click_item = gtk_check_menu_item_new_with_mnemonic(_("Grab On _Click")); > > + gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_on_click_item); > > + > > s->grab_item = gtk_check_menu_item_new_with_mnemonic(_("_Grab Input")); > > gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->grab_item), > > "/View/Grab Input"); > > >