Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/xorgxrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt335672 <30179339+matt335672@users.noreply.github.com>2022-09-16 15:52:41 +0300
committerGitHub <noreply@github.com>2022-09-16 15:52:41 +0300
commit150c0b2eb7bf470939d97baae24af192758cfa7a (patch)
treef4e3034a23690f57b65d240294e57f49e09aab6c
parent6b56cbc1f01d17c4b61b106f92bcc2a7b62fae2f (diff)
parent32eaaed113402908b8984594f7f5e73e80c2169f (diff)
Merge pull request #234 from seflerZ/touchpad
Enable touchpad inertial scrolling(fix touchpad scrolls too fast)
-rw-r--r--.gitignore1
-rw-r--r--module/rdp.h1
-rw-r--r--module/rdpClientCon.c20
-rw-r--r--module/rdpInput.c24
-rw-r--r--xrdpmouse/rdpMouse.c73
5 files changed, 65 insertions, 54 deletions
diff --git a/.gitignore b/.gitignore
index 99bf72f..ce91cc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,4 @@ NEWS
README
stamp-h1
test-driver
+.vscode/*
diff --git a/module/rdp.h b/module/rdp.h
index 66e1f20..050f962 100644
--- a/module/rdp.h
+++ b/module/rdp.h
@@ -288,7 +288,6 @@ struct _rdpRec
int do_dirty_ons; /* boolean */
int disconnect_scheduled; /* boolean */
int do_kill_disconnected; /* boolean */
- int do_touchpad_scroll_hack; /* boolean */
OsTimerPtr disconnectTimer;
int disconnect_timeout_s;
diff --git a/module/rdpClientCon.c b/module/rdpClientCon.c
index 504d261..e4e0317 100644
--- a/module/rdpClientCon.c
+++ b/module/rdpClientCon.c
@@ -1473,26 +1473,6 @@ rdpClientConInit(rdpPtr dev)
LLOGLN(0, ("rdpClientConInit: kill disconnected [%d] timeout [%d] sec",
dev->do_kill_disconnected, dev->disconnect_timeout_s));
- /* neutrinolabs/xorgxrdp#150 */
- ptext = getenv("XRDP_XORG_TOUCHPAD_SCROLL_HACK");
- if (ptext != 0)
- {
- i = atoi(ptext);
- if (i != 0 ||
- 0 == strcasecmp(ptext, "true") ||
- 0 == strcasecmp(ptext, "yes") ||
- 0 == strcasecmp(ptext, "on"))
- {
- dev->do_touchpad_scroll_hack = 1;
- }
- else
- {
- dev->do_touchpad_scroll_hack = 0;
- }
- }
-
- LLOGLN(0, ("rdpClientConInit: do_touchpad_scroll_hack [%d]",
- dev->do_touchpad_scroll_hack));
return 0;
}
diff --git a/module/rdpInput.c b/module/rdpInput.c
index edb4b01..daedf39 100644
--- a/module/rdpInput.c
+++ b/module/rdpInput.c
@@ -115,30 +115,6 @@ rdpInputMouseEvent(rdpPtr dev, int msg,
{
dev->last_event_time_ms = GetTimeInMillis();
- /*
- * Workaround for too fast vertical scroll on touchpad.
- * Provided by @seflerZ on neutrinolabs/xorgxrdp#150
- */
- if (dev->do_touchpad_scroll_hack)
- {
- if (msg == WM_BUTTON4UP ||
- msg == WM_BUTTON4DOWN ||
- msg == WM_BUTTON5UP ||
- msg == WM_BUTTON5DOWN)
- {
-
- if (dev->last_event_time_ms - dev->last_wheel_time_ms < 10)
- {
- return 0;
- }
- }
-
- if (msg == WM_BUTTON4UP || msg == WM_BUTTON5UP)
- {
- dev->last_wheel_time_ms = dev->last_event_time_ms;
- }
- }
-
if (g_input_proc[1].proc != 0)
{
return g_input_proc[1].proc(dev, msg, param1, param2, param3, param4);
diff --git a/xrdpmouse/rdpMouse.c b/xrdpmouse/rdpMouse.c
index 555e1e3..2221734 100644
--- a/xrdpmouse/rdpMouse.c
+++ b/xrdpmouse/rdpMouse.c
@@ -50,6 +50,9 @@ xrdp mouse module
#include "rdpInput.h"
#include "rdpDraw.h"
+#define NBUTTONS 9
+#define NAXES 4
+
/******************************************************************************/
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
@@ -121,14 +124,14 @@ PtrAddEvent(rdpPointer *pointer)
LLOGLN(10, ("PtrAddEvent: x %d y %d", pointer->cursor_x, pointer->cursor_y));
if ((pointer->old_cursor_x != pointer->cursor_x) ||
- (pointer->old_cursor_y != pointer->cursor_y))
+ (pointer->old_cursor_y != pointer->cursor_y))
{
rdpEnqueueMotion(pointer->device, pointer->cursor_x, pointer->cursor_y);
pointer->old_cursor_x = pointer->cursor_x;
pointer->old_cursor_y = pointer->cursor_y;
}
- for (i = 0; i < 9; i++)
+ for (i = 0; i < NBUTTONS; i++)
{
if ((pointer->button_mask ^ pointer->old_button_mask) & (1 << i))
{
@@ -151,6 +154,40 @@ PtrAddEvent(rdpPointer *pointer)
}
/******************************************************************************/
+// Maybe make it configurable later
+#define SCALE_FACTOR 10
+
+static void
+PtrAddScrollEvent(rdpPointer *pointer, int vertical, int delta)
+{
+ ValuatorMask *scroll_events_mask;
+ int mask_pos;
+ int scaled_delta;
+
+ LLOGLN(10, ("PtrAddScrollEvent: vertical %d y %d", vertical, delta));
+
+ scroll_events_mask = valuator_mask_new(NAXES);
+ mask_pos = vertical ? 2 : 3;
+ scaled_delta = delta / SCALE_FACTOR == 0 ? delta > 0 ? 1 : -1 : delta / SCALE_FACTOR;
+
+ // XWindow's and RDP's scrolling directions are exactly opposite
+ // on vertical(Need document references).
+ if (vertical)
+ {
+ scaled_delta = -scaled_delta;
+ }
+
+ valuator_mask_zero(scroll_events_mask);
+ valuator_mask_set_double(scroll_events_mask, mask_pos, scaled_delta);
+
+ xf86PostMotionEventM(pointer->device, FALSE, scroll_events_mask);
+
+ valuator_mask_free(&scroll_events_mask);
+
+ pointer->old_button_mask = pointer->button_mask;
+}
+
+/******************************************************************************/
static int
rdpInputMouse(rdpPtr dev, int msg,
long param1, long param2,
@@ -159,7 +196,7 @@ rdpInputMouse(rdpPtr dev, int msg,
rdpPointer *pointer;
LLOGLN(10, ("rdpInputMouse: msg %d param1 %ld param2 %ld param3 %ld param4 %ld",
- msg, param1, param2, param3, param4));
+ msg, param1, param2, param3, param4));
pointer = &(dev->pointer);
switch (msg)
{
@@ -242,6 +279,12 @@ rdpInputMouse(rdpPtr dev, int msg,
pointer->button_mask = pointer->button_mask | 256;
PtrAddEvent(pointer);
break;
+ case WM_TOUCH_VSCROLL:
+ PtrAddScrollEvent(pointer, TRUE, param3);
+ break;
+ case WM_TOUCH_HSCROLL:
+ PtrAddScrollEvent(pointer, FALSE, param3);
+ break;
}
return 0;
}
@@ -250,11 +293,10 @@ rdpInputMouse(rdpPtr dev, int msg,
static int
rdpmouseControl(DeviceIntPtr device, int what)
{
-#define NBUTTONS 9
BYTE map[NBUTTONS + 1]; /* Indexed from 1 */
DevicePtr pDev;
Atom btn_labels[NBUTTONS];
- Atom axes_labels[2];
+ Atom axes_labels[NAXES];
rdpPtr dev;
int i;
@@ -282,11 +324,24 @@ rdpmouseControl(DeviceIntPtr device, int what)
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
+ axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
InitPointerDeviceStruct(pDev, map, NBUTTONS, btn_labels, rdpmouseCtrl,
- GetMotionHistorySize(), 2, axes_labels);
+ GetMotionHistorySize(), NAXES, axes_labels);
+
dev = rdpGetDevFromScreen(NULL);
dev->pointer.device = device;
+
+ // Initialize scroll valuators
+ xf86InitValuatorAxisStruct(device, 2, axes_labels[2]
+ , 0, -1, 0, 0, 0, Relative);
+ xf86InitValuatorAxisStruct(device, 3, axes_labels[3]
+ , 0, -1, 0, 0, 0, Relative);
+
+ SetScrollValuator(device, 2, SCROLL_TYPE_VERTICAL, 10, 0);
+ SetScrollValuator(device, 3, SCROLL_TYPE_HORIZONTAL, 10, 0);
+
rdpRegisterInputCallback(1, rdpInputMouse);
break;
case DEVICE_ON:
@@ -323,7 +378,7 @@ rdpmousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
InputInfoPtr info;
LLOGLN(0, ("rdpmousePreInit: drv %p dev %p, flags 0x%x",
- drv, dev, flags));
+ drv, dev, flags));
info = xf86AllocateInput(drv, 0);
info->name = dev->identifier;
info->device_control = rdpmouseControl;
@@ -346,7 +401,7 @@ static int
rdpmousePreInit(InputDriverPtr drv, InputInfoPtr info, int flags)
{
LLOGLN(0, ("rdpmousePreInit: drv %p info %p, flags 0x%x",
- drv, info, flags));
+ drv, info, flags));
info->device_control = rdpmouseControl;
info->type_name = g_Mouse_str;
return 0;
@@ -359,7 +414,7 @@ static void
rdpmouseUnInit(InputDriverPtr drv, InputInfoPtr info, int flags)
{
LLOGLN(0, ("rdpmouseUnInit: drv %p info %p, flags 0x%x",
- drv, info, flags));
+ drv, info, flags));
rdpUnregisterInputCallback(rdpInputMouse);
}