[gtk-vnc] Don't drop mouse events that are out of bounds
- From: Daniel P. Berrange <dberrange src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-vnc] Don't drop mouse events that are out of bounds
- Date: Tue, 17 Sep 2013 16:29:24 +0000 (UTC)
commit 645bb94ecb36777c7fca6bedd79d564f6dd3cc00
Author: Daniel P. Berrange <berrange redhat com>
Date: Tue Sep 17 16:10:07 2013 +0100
Don't drop mouse events that are out of bounds
In absolute mode, if the mouse cursor goes outside the bounds
of the window, we drop the motion event entirely. This is bad
because only one of the co-ordinates may be out of bounds, and
the server still wants to see movement in the other axis. Instead
of dropping the events, just clamp co-ordinates to the boundary.
Signed-off-by: Daniel P. Berrange <berrange redhat com>
src/vncdisplay.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index 51a6b0f..5b8da84 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -764,11 +764,19 @@ static gboolean motion_event(GtkWidget *widget, GdkEventMotion *motion)
dx = (int)motion->x;
dy = (int)motion->y;
- /* Drop out of bounds motion to avoid upsetting
- * the server */
- if (dx < 0 || dx >= fbw ||
- dy < 0 || dy >= fbh)
- return FALSE;
+ /* If the co-ords are out of bounds we want to clamp
+ * them to the boundaries. We don't want to actually
+ * drop the events though, because even if the X coord
+ * is out of bounds we want the server to see Y coord
+ * changes, and vica-verca. */
+ if (dx < 0)
+ dx = 0;
+ if (dy < 0)
+ dy = 0;
+ if (dx >= fbw)
+ dx = fbw - 1;
+ if (dy >= fbh)
+ dy = fbh - 1;
} else {
/* Just send the delta since last motion event */
dx = (int)motion->x + 0x7FFF - priv->last_x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]