[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 3/4] gtk: Remember the last grabbed pointer posit
From: |
Takashi Iwai |
Subject: |
[Qemu-devel] [PATCH v2 3/4] gtk: Remember the last grabbed pointer position |
Date: |
Wed, 2 Apr 2014 14:32:32 +0200 |
It's pretty annoying that the pointer reappears at a random place once
after grabbing and ungrabbing the input. Better to restore to the
original position where the pointer was grabbed.
Reference: https://bugzilla.novell.com/show_bug.cgi?id=849587
Signed-off-by: Takashi Iwai <address@hidden>
---
ui/gtk.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index c407fc8dd1a3..9b8df1224fdb 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -159,6 +159,8 @@ typedef struct GtkDisplayState
gboolean last_set;
int last_x;
int last_y;
+ int grab_x_root;
+ int grab_y_root;
double scale_x;
double scale_y;
@@ -970,8 +972,8 @@ static void gd_ungrab_keyboard(GtkDisplayState *s)
static void gd_grab_pointer(GtkDisplayState *s)
{
-#if GTK_CHECK_VERSION(3, 0, 0)
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
+#if GTK_CHECK_VERSION(3, 0, 0)
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
GList *devices = gdk_device_manager_list_devices(mgr,
GDK_DEVICE_TYPE_MASTER);
@@ -995,6 +997,8 @@ static void gd_grab_pointer(GtkDisplayState *s)
tmp = tmp->next;
}
g_list_free(devices);
+ gdk_device_get_position(gdk_device_manager_get_client_pointer(mgr),
+ NULL, &s->grab_x_root, &s->grab_y_root);
#else
gdk_pointer_grab(gtk_widget_get_window(s->drawing_area),
FALSE, /* All events to come to our window directly */
@@ -1006,13 +1010,15 @@ static void gd_grab_pointer(GtkDisplayState *s)
NULL, /* Allow cursor to move over entire desktop */
s->null_cursor,
GDK_CURRENT_TIME);
+ gdk_display_get_pointer(display, NULL,
+ &s->grab_x_root, &s->grab_y_root, NULL);
#endif
}
static void gd_ungrab_pointer(GtkDisplayState *s)
{
-#if GTK_CHECK_VERSION(3, 0, 0)
GdkDisplay *display = gtk_widget_get_display(s->drawing_area);
+#if GTK_CHECK_VERSION(3, 0, 0)
GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
GList *devices = gdk_device_manager_list_devices(mgr,
GDK_DEVICE_TYPE_MASTER);
@@ -1026,8 +1032,14 @@ static void gd_ungrab_pointer(GtkDisplayState *s)
tmp = tmp->next;
}
g_list_free(devices);
+ gdk_device_warp(gdk_device_manager_get_client_pointer(mgr),
+ gtk_widget_get_screen(s->drawing_area),
+ s->grab_x_root, s->grab_y_root);
#else
gdk_pointer_ungrab(GDK_CURRENT_TIME);
+ gdk_display_warp_pointer(display,
+ gtk_widget_get_screen(s->drawing_area),
+ s->grab_x_root, s->grab_y_root);
#endif
}
--
1.9.1
- Re: [Qemu-devel] [PATCH v2 4/4] gtk: Add "Grab On Click" option, (continued)
- Re: [Qemu-devel] [PATCH v2 4/4] gtk: Add "Grab On Click" option, Gerd Hoffmann, 2014/04/02
- [Qemu-devel] [PATCH] gtk: Grab pointer on click when in relative mode, Cole Robinson, 2014/04/02
- Re: [Qemu-devel] [PATCH] gtk: Grab pointer on click when in relative mode, Gerd Hoffmann, 2014/04/02
- Re: [Qemu-devel] [PATCH] gtk: Grab pointer on click when in relative mode, Takashi Iwai, 2014/04/02
- Re: [Qemu-devel] [PATCH] gtk: Grab pointer on click when in relative mode, Cole Robinson, 2014/04/02
- Re: [Qemu-devel] [PATCH] gtk: Grab pointer on click when in relative mode, Takashi Iwai, 2014/04/03
[Qemu-devel] [PATCH v2 1/4] gtk: Use gtk generic event signal instead of motion-notify-event, Takashi Iwai, 2014/04/02
[Qemu-devel] [PATCH v2 3/4] gtk: Remember the last grabbed pointer position,
Takashi Iwai <=
[Qemu-devel] [PATCH v2 2/4] gtk: Fix the relative pointer tracking mode, Takashi Iwai, 2014/04/02