* [Qemu-devel] gtk cursor patches
@ 2013-12-10 1:04 Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 1/2] gtk: don't warp point in absolute mode Dave Airlie
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dave Airlie @ 2013-12-10 1:04 UTC (permalink / raw)
To: qemu-devel
These were just fallout fixes from exploring gtk multi-head with virtio-gpu,
hopefully they are useful to people before then, not sure if the warping/absolute interaction is defined or not.
Dave.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/2] gtk: don't warp point in absolute mode
2013-12-10 1:04 [Qemu-devel] gtk cursor patches Dave Airlie
@ 2013-12-10 1:04 ` Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 2/2] gtk: respect cursor visibility Dave Airlie
2013-12-10 5:36 ` [Qemu-devel] gtk cursor patches Stefan Weil
2 siblings, 0 replies; 4+ messages in thread
From: Dave Airlie @ 2013-12-10 1:04 UTC (permalink / raw)
To: qemu-devel
From: Dave Airlie <airlied@redhat.com>
This makes gtk act the same way as the current sdl backend, which doesn't
do the warp in this case.
If your guest GPU has hw pointer this leads you get endless loops where the
warp causes motion causes input events, causes the guest to move the cursor
causes warp.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
ui/gtk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ui/gtk.c b/ui/gtk.c
index 6316f5b..2abf289 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -338,6 +338,9 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
GdkDeviceManager *mgr;
gint x_root, y_root;
+ if (kbd_mouse_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),
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] gtk: respect cursor visibility
2013-12-10 1:04 [Qemu-devel] gtk cursor patches Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 1/2] gtk: don't warp point in absolute mode Dave Airlie
@ 2013-12-10 1:04 ` Dave Airlie
2013-12-10 5:36 ` [Qemu-devel] gtk cursor patches Stefan Weil
2 siblings, 0 replies; 4+ messages in thread
From: Dave Airlie @ 2013-12-10 1:04 UTC (permalink / raw)
To: qemu-devel
From: Dave Airlie <airlied@redhat.com>
If the guest asks for no cursor, switch gtk to using the null cursor.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
ui/gtk.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 2abf289..f60e66f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -158,6 +158,8 @@ typedef struct GtkDisplayState
bool external_pause_update;
bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
+
+ GdkCursor *current_cursor;
} GtkDisplayState;
static GtkDisplayState *global_state;
@@ -338,6 +340,11 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
GdkDeviceManager *mgr;
gint x_root, y_root;
+ if (!visible)
+ gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), s->null_cursor);
+ else
+ gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), s->current_cursor);
+
if (kbd_mouse_is_absolute())
return;
@@ -369,21 +376,23 @@ static void gd_cursor_define(DisplayChangeListener *dcl,
{
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
GdkPixbuf *pixbuf;
- GdkCursor *cursor;
+
+ if (s->current_cursor) {
+#if !GTK_CHECK_VERSION(3, 0, 0)
+ gdk_cursor_unref(s->current_cursor);
+#else
+ g_object_unref(s->current_cursor);
+#endif
+ s->current_cursor = NULL;
+ }
pixbuf = gdk_pixbuf_new_from_data((guchar *)(c->data),
GDK_COLORSPACE_RGB, true, 8,
c->width, c->height, c->width * 4,
NULL, NULL);
- cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(s->drawing_area),
+ s->current_cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(s->drawing_area),
pixbuf, c->hot_x, c->hot_y);
- gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), cursor);
g_object_unref(pixbuf);
-#if !GTK_CHECK_VERSION(3, 0, 0)
- gdk_cursor_unref(cursor);
-#else
- g_object_unref(cursor);
-#endif
}
static void gd_switch(DisplayChangeListener *dcl,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] gtk cursor patches
2013-12-10 1:04 [Qemu-devel] gtk cursor patches Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 1/2] gtk: don't warp point in absolute mode Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 2/2] gtk: respect cursor visibility Dave Airlie
@ 2013-12-10 5:36 ` Stefan Weil
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Weil @ 2013-12-10 5:36 UTC (permalink / raw)
To: Dave Airlie, qemu-devel
Am 10.12.2013 02:04, schrieb Dave Airlie:
> These were just fallout fixes from exploring gtk multi-head with virtio-gpu,
>
> hopefully they are useful to people before then, not sure if the warping/absolute interaction is defined or not.
>
> Dave.
Please check both patches using scripts/checkpatch.pl.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-10 5:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 1:04 [Qemu-devel] gtk cursor patches Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 1/2] gtk: don't warp point in absolute mode Dave Airlie
2013-12-10 1:04 ` [Qemu-devel] [PATCH 2/2] gtk: respect cursor visibility Dave Airlie
2013-12-10 5:36 ` [Qemu-devel] gtk cursor patches Stefan Weil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).