Commit 36956c1e authored by akallabeth's avatar akallabeth Committed by Felipe Borges

frdp-session/display: Support mouse buttons 4, 5, and horizontal wheel

Fixes #4
parent 9604933a
...@@ -117,12 +117,25 @@ frdp_display_button_press_event (GtkWidget *widget, ...@@ -117,12 +117,25 @@ frdp_display_button_press_event (GtkWidget *widget,
if (event->type == GDK_BUTTON_PRESS) if (event->type == GDK_BUTTON_PRESS)
flags |= FRDP_MOUSE_EVENT_DOWN; flags |= FRDP_MOUSE_EVENT_DOWN;
if (event->button == 1) switch(event->button) {
case GDK_BUTTON_PRIMARY:
flags |= FRDP_MOUSE_EVENT_BUTTON1; flags |= FRDP_MOUSE_EVENT_BUTTON1;
if (event->button == 2) break;
case GDK_BUTTON_MIDDLE:
flags |= FRDP_MOUSE_EVENT_BUTTON3; flags |= FRDP_MOUSE_EVENT_BUTTON3;
if (event->button == 3) break;
case GDK_BUTTON_SECONDARY:
flags |= FRDP_MOUSE_EVENT_BUTTON2; 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, frdp_session_mouse_event (priv->session,
flags, flags,
...@@ -145,12 +158,35 @@ frdp_display_scroll_event (GtkWidget *widget, ...@@ -145,12 +158,35 @@ frdp_display_scroll_event (GtkWidget *widget,
switch (event->direction) { switch (event->direction) {
case GDK_SCROLL_UP: case GDK_SCROLL_UP:
flags = FRDP_MOUSE_EVENT_WHEEL;
break; break;
case GDK_SCROLL_DOWN: 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; break;
case GDK_SCROLL_SMOOTH: 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"); g_debug ("scroll smooth unhandled");
return FALSE;
}
break;
default: default:
return FALSE; return FALSE;
} }
......
...@@ -649,6 +649,7 @@ frdp_session_mouse_event (FrdpSession *self, ...@@ -649,6 +649,7 @@ frdp_session_mouse_event (FrdpSession *self,
FrdpSessionPrivate *priv = self->priv; FrdpSessionPrivate *priv = self->priv;
rdpInput *input; rdpInput *input;
guint16 flags = 0; guint16 flags = 0;
guint16 xflags = 0;
g_return_if_fail (priv->freerdp_session != NULL); g_return_if_fail (priv->freerdp_session != NULL);
...@@ -663,6 +664,13 @@ frdp_session_mouse_event (FrdpSession *self, ...@@ -663,6 +664,13 @@ frdp_session_mouse_event (FrdpSession *self,
else else
flags |= 0x0078; 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) if (event & FRDP_MOUSE_EVENT_BUTTON1)
flags |= PTR_FLAGS_BUTTON1; flags |= PTR_FLAGS_BUTTON1;
...@@ -670,6 +678,10 @@ frdp_session_mouse_event (FrdpSession *self, ...@@ -670,6 +678,10 @@ frdp_session_mouse_event (FrdpSession *self,
flags |= PTR_FLAGS_BUTTON2; flags |= PTR_FLAGS_BUTTON2;
if (event & FRDP_MOUSE_EVENT_BUTTON3) if (event & FRDP_MOUSE_EVENT_BUTTON3)
flags |= PTR_FLAGS_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; input = priv->freerdp_session->input;
...@@ -678,11 +690,14 @@ frdp_session_mouse_event (FrdpSession *self, ...@@ -678,11 +690,14 @@ frdp_session_mouse_event (FrdpSession *self,
y = (y - priv->offset_y) / priv->scale; y = (y - priv->offset_y) / priv->scale;
} }
if (flags != 0) { x = x < 0.0 ? 0.0 : x;
x = x < 0.0 ? 0.0 : x; y = y < 0.0 ? 0.0 : y;
y = y < 0.0 ? 0.0 : y; if (xflags != 0) {
if (event & FRDP_MOUSE_EVENT_DOWN)
input->MouseEvent (input, flags, x, y); 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);
} }
} }
......
...@@ -40,13 +40,16 @@ struct _FrdpSession ...@@ -40,13 +40,16 @@ struct _FrdpSession
typedef enum typedef enum
{ {
FRDP_MOUSE_EVENT_MOVE = 1 << 0, FRDP_MOUSE_EVENT_MOVE = 1 << 0,
FRDP_MOUSE_EVENT_DOWN = 1 << 1, FRDP_MOUSE_EVENT_DOWN = 1 << 1,
FRDP_MOUSE_EVENT_WHEEL = 1 << 2, FRDP_MOUSE_EVENT_WHEEL = 1 << 2,
FRDP_MOUSE_EVENT_WHEEL_NEGATIVE = 1 << 3, FRDP_MOUSE_EVENT_WHEEL_NEGATIVE = 1 << 3,
FRDP_MOUSE_EVENT_BUTTON1 = 1 << 4, FRDP_MOUSE_EVENT_BUTTON1 = 1 << 4,
FRDP_MOUSE_EVENT_BUTTON2 = 1 << 5, FRDP_MOUSE_EVENT_BUTTON2 = 1 << 5,
FRDP_MOUSE_EVENT_BUTTON3 = 1 << 6, 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; } FrdpMouseEvent;
typedef enum typedef enum
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment