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,
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;
}
......
......@@ -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);
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);
}
}
......
......@@ -47,6 +47,9 @@ typedef enum
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
......
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