From: Dave Airlie <airlied@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] gtk: respect cursor visibility
Date: Tue, 10 Dec 2013 11:04:34 +1000 [thread overview]
Message-ID: <1386637474-8165-3-git-send-email-airlied@gmail.com> (raw)
In-Reply-To: <1386637474-8165-1-git-send-email-airlied@gmail.com>
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
next prev parent reply other threads:[~2013-12-10 1:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2013-12-10 5:36 ` [Qemu-devel] gtk cursor patches Stefan Weil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386637474-8165-3-git-send-email-airlied@gmail.com \
--to=airlied@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).