From c4d671497933ff5df718430ec35d7074fe458510 Mon Sep 17 00:00:00 2001 From: sefler Date: Mon, 12 Sep 2022 13:29:11 +0800 Subject: [PATCH] touchpad scrolling works now --- common/xrdp_constants.h | 4 ++++ xrdp/xrdp_wm.c | 43 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h index 1e844697..7824b318 100644 --- a/common/xrdp_constants.h +++ b/common/xrdp_constants.h @@ -270,6 +270,10 @@ #define WM_BUTTON8DOWN 116 #define WM_BUTTON9UP 117 #define WM_BUTTON9DOWN 118 + +#define WM_TOUCH_VSCROLL 140 +#define WM_TOUCH_HSCROLL 141 + #define WM_INVALIDATE 200 #define CB_ITEMCHANGE 300 diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 61261a97..828d0a72 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1230,6 +1230,28 @@ xrdp_wm_clear_popup(struct xrdp_wm *self) return 0; } +/*****************************************************************************/ +int +xrdp_wm_mouse_touch(struct xrdp_wm *self, int gesture, int param) +{ + LOG(LOG_LEVEL_INFO, "mouse touch event gesture %d param %d", gesture, param); + + switch (gesture) { + // vertical scroll + case 0: + self->mm->mod->mod_event(self->mm->mod, WM_TOUCH_VSCROLL, + self->mouse_x, self->mouse_y, param, 0); + break; + // horizantal scroll + case 1: + self->mm->mod->mod_event(self->mm->mod, WM_TOUCH_HSCROLL, + self->mouse_x, self->mouse_y, param, 0); + break; + } + + return 0; +} + /*****************************************************************************/ int xrdp_wm_mouse_click(struct xrdp_wm *self, int x, int y, int but, int down) @@ -1775,13 +1797,30 @@ xrdp_wm_process_input_mouse(struct xrdp_wm *self, int device_flags, /* vertical mouse wheel */ if (device_flags & PTRFLAGS_WHEEL) { + int delta = 0; if (device_flags & PTRFLAGS_WHEEL_NEGATIVE) { - xrdp_wm_mouse_click(self, 0, 0, 5, 0); + delta = (device_flags & WheelRotationMask) | ~WheelRotationMask; + if (delta != 0) + { + xrdp_wm_mouse_touch(self, 0, delta); + } + else + { + xrdp_wm_mouse_click(self, 0, 0, 5, 0); + } } else { - xrdp_wm_mouse_click(self, 0, 0, 4, 0); + delta = device_flags & WheelRotationMask; + if (delta != 0) + { + xrdp_wm_mouse_touch(self, 0, delta); + } + else + { + xrdp_wm_mouse_click(self, 0, 0, 4, 0); + } } }