[gtk-frdp] frdp-session/display: Support mouse buttons 4, 5, and horizontal wheel
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-frdp] frdp-session/display: Support mouse buttons 4, 5, and horizontal wheel
- Date: Fri, 4 Jan 2019 10:10:11 +0000 (UTC)
commit 36956c1e7146bd75c6e6395f219e234ded6d429d
Author: akallabeth <akallabeth posteo net>
Date: Thu Nov 22 18:42:28 2018 +0100
frdp-session/display: Support mouse buttons 4, 5, and horizontal wheel
Fixes #4
src/frdp-display.c | 44 ++++++++++++++++++++++++++++++++++++++++----
src/frdp-session.c | 25 ++++++++++++++++++++-----
src/frdp-session.h | 17 ++++++++++-------
3 files changed, 70 insertions(+), 16 deletions(-)
---
diff --git a/src/frdp-display.c b/src/frdp-display.c
index 3936cfd..c7307d2 100644
--- a/src/frdp-display.c
+++ b/src/frdp-display.c
@@ -117,12 +117,25 @@ frdp_display_button_press_event (GtkWidget *widget,
if (event->type == GDK_BUTTON_PRESS)
flags |= FRDP_MOUSE_EVENT_DOWN;
- if (event->button == 1)
+ switch(event->button) {
+ case GDK_BUTTON_PRIMARY:
flags |= FRDP_MOUSE_EVENT_BUTTON1;
- if (event->button == 2)
+ break;
+ case GDK_BUTTON_MIDDLE:
flags |= FRDP_MOUSE_EVENT_BUTTON3;
- if (event->button == 3)
+ break;
+ case GDK_BUTTON_SECONDARY:
flags |= FRDP_MOUSE_EVENT_BUTTON2;
+ break;
+ case 8:
+ flags |= FRDP_MOUSE_EVENT_BUTTON4;
+ break;
+ case 9:
+ flags |= FRDP_MOUSE_EVENT_BUTTON5;
+ break;
+ default:
+ return FALSE;
+ }
frdp_session_mouse_event (priv->session,
flags,
@@ -145,12 +158,35 @@ frdp_display_scroll_event (GtkWidget *widget,
switch (event->direction) {
case GDK_SCROLL_UP:
+ flags = FRDP_MOUSE_EVENT_WHEEL;
break;
case GDK_SCROLL_DOWN:
- flags |= FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
+ flags = FRDP_MOUSE_EVENT_WHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
+ break;
+ case GDK_SCROLL_LEFT:
+ flags = FRDP_MOUSE_EVENT_HWHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
+ break;
+ case GDK_SCROLL_RIGHT:
+ flags = FRDP_MOUSE_EVENT_HWHEEL;
break;
case GDK_SCROLL_SMOOTH:
+ /* Calculate delta and decide which event we have
+ * a delta X means horizontal, a delta Y means vertical scroll.
+ * Fixes https://bugzilla.gnome.org/show_bug.cgi?id=675959
+ */
+ if (event->delta_x > 0.5)
+ flags = FRDP_MOUSE_EVENT_HWHEEL;
+ else if (event->delta_x < -0.5)
+ flags = FRDP_MOUSE_EVENT_HWHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
+ else if (event->delta_y > 0.5)
+ flags = FRDP_MOUSE_EVENT_WHEEL;
+ else if (event->delta_y < -0.5)
+ flags = FRDP_MOUSE_EVENT_WHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
+ else {
g_debug ("scroll smooth unhandled");
+ return FALSE;
+ }
+ break;
default:
return FALSE;
}
diff --git a/src/frdp-session.c b/src/frdp-session.c
index cfd8b1d..5ce5f86 100644
--- a/src/frdp-session.c
+++ b/src/frdp-session.c
@@ -649,6 +649,7 @@ frdp_session_mouse_event (FrdpSession *self,
FrdpSessionPrivate *priv = self->priv;
rdpInput *input;
guint16 flags = 0;
+ guint16 xflags = 0;
g_return_if_fail (priv->freerdp_session != NULL);
@@ -663,6 +664,13 @@ frdp_session_mouse_event (FrdpSession *self,
else
flags |= 0x0078;
}
+ if (event & FRDP_MOUSE_EVENT_HWHEEL) {
+ flags |= PTR_FLAGS_HWHEEL;
+ if (event & FRDP_MOUSE_EVENT_WHEEL_NEGATIVE)
+ flags |= PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
+ else
+ flags |= 0x0078;
+ }
if (event & FRDP_MOUSE_EVENT_BUTTON1)
flags |= PTR_FLAGS_BUTTON1;
@@ -670,6 +678,10 @@ frdp_session_mouse_event (FrdpSession *self,
flags |= PTR_FLAGS_BUTTON2;
if (event & FRDP_MOUSE_EVENT_BUTTON3)
flags |= PTR_FLAGS_BUTTON3;
+ if (event & FRDP_MOUSE_EVENT_BUTTON4)
+ xflags |= PTR_XFLAGS_BUTTON1;
+ if (event & FRDP_MOUSE_EVENT_BUTTON5)
+ xflags |= PTR_XFLAGS_BUTTON2;
input = priv->freerdp_session->input;
@@ -678,11 +690,14 @@ frdp_session_mouse_event (FrdpSession *self,
y = (y - priv->offset_y) / priv->scale;
}
- if (flags != 0) {
- x = x < 0.0 ? 0.0 : x;
- y = y < 0.0 ? 0.0 : y;
-
- input->MouseEvent (input, flags, x, y);
+ x = x < 0.0 ? 0.0 : x;
+ y = y < 0.0 ? 0.0 : y;
+ if (xflags != 0) {
+ if (event & FRDP_MOUSE_EVENT_DOWN)
+ xflags |= PTR_XFLAGS_DOWN;
+ freerdp_input_send_extended_mouse_event(input, xflags, x, y);
+ } else if (flags != 0) {
+ freerdp_input_send_mouse_event (input, flags, x, y);
}
}
diff --git a/src/frdp-session.h b/src/frdp-session.h
index 77cd908..a9a146d 100644
--- a/src/frdp-session.h
+++ b/src/frdp-session.h
@@ -40,13 +40,16 @@ struct _FrdpSession
typedef enum
{
- FRDP_MOUSE_EVENT_MOVE = 1 << 0,
- FRDP_MOUSE_EVENT_DOWN = 1 << 1,
- FRDP_MOUSE_EVENT_WHEEL = 1 << 2,
- FRDP_MOUSE_EVENT_WHEEL_NEGATIVE = 1 << 3,
- FRDP_MOUSE_EVENT_BUTTON1 = 1 << 4,
- FRDP_MOUSE_EVENT_BUTTON2 = 1 << 5,
- FRDP_MOUSE_EVENT_BUTTON3 = 1 << 6,
+ FRDP_MOUSE_EVENT_MOVE = 1 << 0,
+ FRDP_MOUSE_EVENT_DOWN = 1 << 1,
+ FRDP_MOUSE_EVENT_WHEEL = 1 << 2,
+ FRDP_MOUSE_EVENT_WHEEL_NEGATIVE = 1 << 3,
+ FRDP_MOUSE_EVENT_BUTTON1 = 1 << 4,
+ FRDP_MOUSE_EVENT_BUTTON2 = 1 << 5,
+ FRDP_MOUSE_EVENT_BUTTON3 = 1 << 6,
+ FRDP_MOUSE_EVENT_BUTTON4 = 1 << 7,
+ FRDP_MOUSE_EVENT_BUTTON5 = 1 << 8,
+ FRDP_MOUSE_EVENT_HWHEEL = 1 << 9,
} FrdpMouseEvent;
typedef enum
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]