From: Takashi Iwai <tiwai@suse.de>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PATCH 2/4] gtk: Fix the relative pointer tracking mode
Date: Thu, 13 Feb 2014 12:15:37 +0100 [thread overview]
Message-ID: <1392290139-17250-3-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1392290139-17250-1-git-send-email-tiwai@suse.de>
The relative pointer tracking mode was still buggy even after the
previous fix of the motion-notify-event since the events are filtered
out when the pointer moves outside the drawing window due to the
boundary check for the absolute mode.
This patch fixes the issue by moving the unnecessary boundary check
into the if block of absolute mode, and keep the coordinate in the
relative mode even if it's outside the drawing area. But this makes
the coordinate (last_x, last_y) possibly pointing to (-1,-1),
introduce a new flag to indicate the last coordinate has been
updated.
Reference: https://bugzilla.novell.com/show_bug.cgi?id=849587
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
ui/gtk.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 4d5ea8e6bb38..b72272ebac3f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -148,6 +148,7 @@ typedef struct GtkDisplayState
DisplayChangeListener dcl;
DisplaySurface *ds;
int button_mask;
+ gboolean last_set;
int last_x;
int last_y;
@@ -604,16 +605,15 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
x = (motion->x - mx) / s->scale_x;
y = (motion->y - my) / s->scale_y;
- if (x < 0 || y < 0 ||
- x >= surface_width(s->ds) ||
- y >= surface_height(s->ds)) {
- return TRUE;
- }
-
if (kbd_mouse_is_absolute()) {
+ if (x < 0 || y < 0 ||
+ x >= surface_width(s->ds) ||
+ y >= surface_height(s->ds)) {
+ return TRUE;
+ }
dx = x * 0x7FFF / (surface_width(s->ds) - 1);
dy = y * 0x7FFF / (surface_height(s->ds) - 1);
- } else if (s->last_x == -1 || s->last_y == -1) {
+ } else if (!s->last_set) {
dx = 0;
dy = 0;
} else {
@@ -623,6 +623,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
s->last_x = x;
s->last_y = y;
+ s->last_set = TRUE;
if (kbd_mouse_is_absolute() || gd_is_grab_active(s)) {
kbd_mouse_event(dx, dy, 0, s->button_mask);
@@ -661,8 +662,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
GdkDisplay *display = gtk_widget_get_display(widget);
gdk_display_warp_pointer(display, screen, x, y);
#endif
- s->last_x = -1;
- s->last_y = -1;
+ s->last_set = FALSE;
return FALSE;
}
}
--
1.8.5.2
next prev parent reply other threads:[~2014-02-13 11:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 11:15 [Qemu-devel] [PATCH 0/4] Fix relative pointer tracking on Gtk UI Takashi Iwai
2014-02-13 11:15 ` [Qemu-devel] [PATCH 1/4] gtk: Use gtk generic event signal instead of motion-notify-event Takashi Iwai
2014-02-13 11:15 ` Takashi Iwai [this message]
2014-02-13 11:15 ` [Qemu-devel] [PATCH 3/4] gtk: Remember the last grabbed pointer position Takashi Iwai
2014-02-13 11:15 ` [Qemu-devel] [PATCH 4/4] gtk: Add "Grab On Click" option Takashi Iwai
2014-04-01 20:34 ` [Qemu-devel] [PATCH 0/4] Fix relative pointer tracking on Gtk UI Cole Robinson
2014-04-02 12:29 ` Takashi Iwai
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=1392290139-17250-3-git-send-email-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=aliguori@amazon.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).