From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VfB4S-0000LE-48 for qemu-devel@nongnu.org; Sat, 09 Nov 2013 11:07:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VfB4M-0008OD-DO for qemu-devel@nongnu.org; Sat, 09 Nov 2013 11:07:36 -0500 Received: from mout.web.de ([212.227.15.14]:61530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VfB4M-0008O0-2U for qemu-devel@nongnu.org; Sat, 09 Nov 2013 11:07:30 -0500 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0MYejS-1V9mQU1Kfy-00VPiU for ; Sat, 09 Nov 2013 17:07:28 +0100 Message-ID: <527E5DB8.40300@web.de> Date: Sat, 09 Nov 2013 17:07:20 +0100 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8XCNCKRJgu51mTeiqqAJi6pfE4OG9mNPl" Subject: [Qemu-devel] [PATCH] gtk: Allow to activate grab-on-hover from the command line List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8XCNCKRJgu51mTeiqqAJi6pfE4OG9mNPl Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable From: Jan Kiszka As long as we have no persistent GTK configuration, this allows to enable the useful grab-on-hover feature already when starting the VM. Signed-off-by: Jan Kiszka --- include/ui/console.h | 2 +- qemu-options.hx | 5 +++++ ui/gtk.c | 5 ++++- vl.c | 22 +++++++++++++++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 98edf41..13420c1 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -339,6 +339,6 @@ int index_from_keycode(int code); =20 /* gtk.c */ void early_gtk_display_init(void); -void gtk_display_init(DisplayState *ds, bool full_screen); +void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_h= over); =20 #endif diff --git a/qemu-options.hx b/qemu-options.hx index 5dc8b75..2cb11b5 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -809,6 +809,7 @@ ETEXI DEF("display", HAS_ARG, QEMU_OPTION_display, "-display sdl[,frame=3Don|off][,alt_grab=3Don|off][,ctrl_grab=3Don|o= ff]\n" " [,window_close=3Don|off]|curses|none|\n" + " gtk[,grab_on_hover=3Don|off]|\n" " vnc=3D[,]\n" " select display type\n", QEMU_ARCH_ALL) STEXI @@ -832,6 +833,10 @@ graphics card, but its output will not be displayed = to the QEMU user. This option differs from the -nographic option in that it only affects what is done with video output; -nographic also changes the destination of the serial and parallel port data. +@item gtk +Display video output in a GTK window. This interface provides drop-down +menus and other UI elements to configure and control the VM during +runtime. @item vnc Start a VNC server on display @end table diff --git a/ui/gtk.c b/ui/gtk.c index b5f4f0b..43883b7 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1443,7 +1443,7 @@ static const DisplayChangeListenerOps dcl_ops =3D {= .dpy_cursor_define =3D gd_cursor_define, }; =20 -void gtk_display_init(DisplayState *ds, bool full_screen) +void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_h= over) { GtkDisplayState *s =3D g_malloc0(sizeof(*s)); char *filename; @@ -1522,6 +1522,9 @@ void gtk_display_init(DisplayState *ds, bool full_s= creen) if (full_screen) { gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item)); } + if (grab_on_hover) { + gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item)); + } =20 register_displaychangelistener(&s->dcl); =20 diff --git a/vl.c b/vl.c index 4ad15b8..7b1b02b 100644 --- a/vl.c +++ b/vl.c @@ -201,6 +201,7 @@ int vga_interface_type =3D VGA_NONE; static int full_screen =3D 0; static int no_frame =3D 0; int no_quit =3D 0; +static bool grab_on_hover; CharDriverState *serial_hds[MAX_SERIAL_PORTS]; CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; @@ -2222,6 +2223,25 @@ static DisplayType select_display(const char *p) } else if (strstart(p, "gtk", &opts)) { #ifdef CONFIG_GTK display =3D DT_GTK; + while (*opts) { + const char *nextopt; + + if (strstart(opts, ",grab_on_hover=3D", &nextopt)) { + opts =3D nextopt; + if (strstart(opts, "on", &nextopt)) { + grab_on_hover =3D true; + } else if (strstart(opts, "off", &nextopt)) { + grab_on_hover =3D false; + } else { + goto invalid_gtk_args; + } + } else { + invalid_gtk_args: + fprintf(stderr, "Invalid GTK option string: %s\n", p); + exit(1); + } + opts =3D nextopt; + } #else fprintf(stderr, "GTK support is disabled\n"); exit(1); @@ -4284,7 +4304,7 @@ int main(int argc, char **argv, char **envp) #endif #if defined(CONFIG_GTK) case DT_GTK: - gtk_display_init(ds, full_screen); + gtk_display_init(ds, full_screen, grab_on_hover); break; #endif default: --=20 1.8.1.1.298.ge7eed54 --8XCNCKRJgu51mTeiqqAJi6pfE4OG9mNPl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlJ+Xb4ACgkQitSsb3rl5xTLtACfSiACnfMFmiBVyLCNSsnbeB0M /+YAoIxV51c/7+Q9Ik4b3WgGclSGuF/4 =0Kmj -----END PGP SIGNATURE----- --8XCNCKRJgu51mTeiqqAJi6pfE4OG9mNPl--