Skip to contentSkip to conversation

gtk fixes.

GIT PULL Gerd Hoffmann 2 participants 6 messages Mar 14, 2014 – Mar 17, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

gtk pull second round, this time a bit shorter as I've dropped the cleanup patches. Lesson learned: getting them right so we still build on all supported gtk2+3 versions isn't that easy. There is no reason to rush them, so lets sort that after 2.0 is out of the door.

please pull,
Gerd

The following changes since commit 5d92c74f8a1728a202ba9457872ab0f27ff15e81:

Update version for v2.0-rc0 (2014-03-13 20:08:15 -0700)

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-gtk-2

for you to fetch changes up to 67f7b5f60e38020e889de2cc0052d42756d3559c:

gtk: Don't warp absolute pointer (2014-03-14 10:42:51 +0100)

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

----------------------------------------------------------------
Cole Robinson (2):
gtk: Fix mouse warping with gtk3
gtk: Don't warp absolute pointer

Jan Kiszka (1):
gtk: Allow to activate grab-on-hover from the command line

 include/ui/console.h |  2 +-
 qemu-options.hx      |  5 +++++
 ui/gtk.c             | 15 +++++++++++++--
 vl.c                 | 22 +++++++++++++++++++++-
 4 files changed, 40 insertions(+), 4 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/3] gtk: Allow to activate grab-on-hover from the command line

From: Jan Kiszka <[email protected]>

As long as we have no persistent GTK configuration, this allows to enable the useful grab-on-hover feature already when starting the VM.

---
 include/ui/console.h |  2 +-
 qemu-options.hx      |  5 +++++
 ui/gtk.c             |  5 ++++-
 vl.c                 | 22 +++++++++++++++++++++-
 4 files changed, 31 insertions(+), 3 deletions(-)
include/ui/console.h +1 -1
index 08a38ea..8a86617 100644
@@ -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
qemu-options.hx +5 -0
index 068da2d..ee5437b 100644
@@ -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
ui/gtk.c +4 -1
index c3ac448..016804d 100644
@@ -1438,7 +1438,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 +1517,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);
 
vl.c +21 -1
index 842e897..3191efd 100644
@@ -143,6 +143,7 @@ int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
 static int no_frame = 0;
 int no_quit = 0;
+static bool grab_on_hover;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
 CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -2276,6 +2277,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);
@@ -4399,7 +4419,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:
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL 3/3] gtk: Don't warp absolute pointer

In reply to Gerd Hoffmann

From: Cole Robinson <[email protected]>

This matches the behavior of SDL, and makes the mouse usable when using -display gtk -vga qxl

https://bugzilla.redhat.com/show_bug.cgi?id=1051724

---
 ui/gtk.c | 8 ++++++++
 1 file changed, 8 insertions(+)
ui/gtk.c +8 -0
index e2394ac..baabf86 100644
@@ -340,6 +340,10 @@ 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),
@@ -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),
Signature · 1 line
1.8.3.1
#3 lore raw

[Qemu-devel] [PULL 2/3] gtk: Fix mouse warping with gtk3

In reply to Gerd Hoffmann

From: Cole Robinson <[email protected]>

We were using the wrong coordinates, this fixes things to match the original gtk2 implementation.

You can see this error in action by using -vga qxl, however even after this patch the mouse warps in small increments up and to the left, -7x and -3y pixels at a time, until the pointer is warped off the widget. I think it's a qxl bug, but the next patch covers it up.

---
 ui/gtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/gtk.c +1 -1
index 016804d..e2394ac 100644
@@ -346,7 +346,7 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
                                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,
Signature · 1 line
1.8.3.1
#4 lore raw
In reply to Gerd Hoffmann
Quoted 15 lines · Gerd Hoffmann

Hi,

gtk pull second round, this time a bit shorter as I've dropped the cleanup patches. Lesson learned: getting them right so we still build on all supported gtk2+3 versions isn't that easy. There is no reason to rush them, so lets sort that after 2.0 is out of the door.

please pull,
Gerd

The following changes since commit 5d92c74f8a1728a202ba9457872ab0f27ff15e81:

Update version for v2.0-rc0 (2014-03-13 20:08:15 -0700)

Quoted 7 lines

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-gtk-2

for you to fetch changes up to 67f7b5f60e38020e889de2cc0052d42756d3559c:

gtk: Don't warp absolute pointer (2014-03-14 10:42:51 +0100)

Doesn't build if CONFIG_GTK isn't defined:

/root/qemu/vl.c:146:14: error: 'grab_on_hover' defined but not used [-Werror=unused-variable]

thanks
-- PMM

#5 lore raw

Hi,

Quoted 4 lines

Doesn't build if CONFIG_GTK isn't defined:

/root/qemu/vl.c:146:14: error: 'grab_on_hover' defined but not used [-Werror=unused-variable]

Oops. /me wonders how that escaped my attention, my mingw test build should have hit this. Updated pull on the way.

sorry for the trouble,
Gerd