gtk: warp bugfixes.

gtk: Allow to activate grab-on-hover from the command line
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJTJvonAAoJEEy22O7T6HE4VdYP/izgsEsHx15DZ46V5dT1uKMa
 prFlky+mAgkaaM+YSCjaz7rynt5J6iJiSQjy4+eoo71n9JWwch+UX3AedGdyaf0U
 Lz93UHOxCq1/H7v9LKG+MDfgZ2iHOdW+638eHMOKdHnEI/J0+fVNNGagEI+RnRCn
 ad2DZgMp3B/cz+I7YXEykKsQkOGWECHK0BxesZkoPa8LwBGOHh/rg8XpsMBFsq6I
 mgsv7tbtGVXV1egPLx6XoQHpJxaAMHndI4UIrQgJOWbA6f8wFG/XjvmJfKRfaX21
 yLRW3r/xxIM3udQ2GwMTOEQ1piv50rVG3B0kBwy3DdOcVVz6AwI+hJQn35iiUi0j
 6Acs+Yx1qClIenLrnc9NHtVP80vHVsQJsRSu410fvbdpmLvncixAJGOmmz86MP9w
 4WVDhb/OaIG4i3CwNBiX+E1rI7ufwIQvAa8m4yk193p8IEhgriLYJLmVMAXWTTOK
 hgohidguVIBMd2LWh3oqKRDHJj146DrokwxlS8UgiQLYLsLHblQMVP4G6tB622lr
 tlzhkXLzaYGbf/iBVTq1midiClv1YzhoqxRgGrA5FIBbHdRMOULfVLYpQyFVrzq0
 wWotP5S9Y1IWCr+aNPP/z6KMPE4LQG08T37yuPFWS8lmMbGMXUb7byTtXQ4PVD+j
 NcBaGBtc0cV67zGudZ1G
 =1vBl
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/pull-gtk-3' into staging

gtk: warp bugfixes.
gtk: Allow to activate grab-on-hover from the command line

# gpg: Signature made Mon 17 Mar 2014 13:35:35 GMT using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-gtk-3:
  gtk: Don't warp absolute pointer
  gtk: Fix mouse warping with gtk3
  gtk: Allow to activate grab-on-hover from the command line

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
master
Peter Maydell 2014-03-17 15:51:57 +00:00
commit 87f6396293
4 changed files with 42 additions and 4 deletions

View File

@ -345,6 +345,6 @@ int index_from_key(const char *key);
/* 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_hover);
#endif

View File

@ -810,6 +810,7 @@ ETEXI
DEF("display", HAS_ARG, QEMU_OPTION_display,
"-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
" [,window_close=on|off]|curses|none|\n"
" gtk[,grab_on_hover=on|off]|\n"
" vnc=<display>[,<optargs>]\n"
" select display type\n", QEMU_ARCH_ALL)
STEXI
@ -833,6 +834,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 <arg>
@end table

View File

@ -340,13 +340,17 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
GdkDeviceManager *mgr;
gint x_root, y_root;
if (qemu_input_is_absolute()) {
return;
}
dpy = gtk_widget_get_display(s->drawing_area);
mgr = gdk_display_get_device_manager(dpy);
gdk_window_get_root_coords(gtk_widget_get_window(s->drawing_area),
x, y, &x_root, &y_root);
gdk_device_warp(gdk_device_manager_get_client_pointer(mgr),
gtk_widget_get_screen(s->drawing_area),
x, y);
x_root, y_root);
}
#else
static void gd_mouse_set(DisplayChangeListener *dcl,
@ -355,6 +359,10 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
gint x_root, y_root;
if (qemu_input_is_absolute()) {
return;
}
gdk_window_get_root_coords(gtk_widget_get_window(s->drawing_area),
x, y, &x_root, &y_root);
gdk_display_warp_pointer(gtk_widget_get_display(s->drawing_area),
@ -1438,7 +1446,7 @@ static const DisplayChangeListenerOps dcl_ops = {
.dpy_cursor_define = gd_cursor_define,
};
void gtk_display_init(DisplayState *ds, bool full_screen)
void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
char *filename;
@ -1517,6 +1525,9 @@ void gtk_display_init(DisplayState *ds, bool full_screen)
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));
}
register_displaychangelistener(&s->dcl);

24
vl.c
View File

@ -143,6 +143,9 @@ int vga_interface_type = VGA_NONE;
static int full_screen = 0;
static int no_frame = 0;
int no_quit = 0;
#ifdef CONFIG_GTK
static bool grab_on_hover;
#endif
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
@ -2276,6 +2279,25 @@ static DisplayType select_display(const char *p)
} else if (strstart(p, "gtk", &opts)) {
#ifdef CONFIG_GTK
display = DT_GTK;
while (*opts) {
const char *nextopt;
if (strstart(opts, ",grab_on_hover=", &nextopt)) {
opts = nextopt;
if (strstart(opts, "on", &nextopt)) {
grab_on_hover = true;
} else if (strstart(opts, "off", &nextopt)) {
grab_on_hover = false;
} else {
goto invalid_gtk_args;
}
} else {
invalid_gtk_args:
fprintf(stderr, "Invalid GTK option string: %s\n", p);
exit(1);
}
opts = nextopt;
}
#else
fprintf(stderr, "GTK support is disabled\n");
exit(1);
@ -4404,7 +4426,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: