From a2ac6b694a270fe388150be47e23942974937e65 Mon Sep 17 00:00:00 2001 From: sefler Date: Sun, 20 Nov 2022 13:23:45 +0800 Subject: [PATCH] code refactored --- xrdp/xrdp_mm.c | 5 ----- xrdp/xrdp_types.h | 8 ++++++++ xrdp/xrdp_wm.c | 21 ++++----------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 7b2f517c..cfb35e3d 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -56,11 +56,6 @@ xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *port); static void xrdp_mm_connect_sm(struct xrdp_mm *self); -/* Code values used in 'code=' settings */ -#define XVNC_SESSION_CODE 0 -#define XRDP_SESSION_CODE 10 -#define XORG_SESSION_CODE 20 - /*****************************************************************************/ struct xrdp_mm * xrdp_mm_create(struct xrdp_wm *owner) diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 98b7b08c..443bca64 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -32,6 +32,14 @@ #define MAX_NR_CHANNELS 16 #define MAX_CHANNEL_NAME 16 +/* Code values used in 'xrdp_mm->code=' settings */ +#define XVNC_SESSION_CODE 0 +#define XRDP_SESSION_CODE 10 +#define XORG_SESSION_CODE 20 + +/* To check whether touch events has been implemented on session type 'mm' */ +#define XRDP_MM_IMPLEMENTS_TOUCH(mm) ((mm)->code != XVNC_SESSION_CODE) + struct source_info; /* lib */ diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 16c33455..26b16649 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -29,11 +29,6 @@ #include "log.h" #include "string_calls.h" -/* Code values used in 'xrdp_mm->code=' settings */ -#define XVNC_SESSION_CODE 0 -#define XRDP_SESSION_CODE 10 -#define XORG_SESSION_CODE 20 - /*****************************************************************************/ struct xrdp_wm * xrdp_wm_create(struct xrdp_process *owner, @@ -1816,9 +1811,7 @@ xrdp_wm_process_input_mouse(struct xrdp_wm *self, int device_flags, * The negative number is represented by complement. */ delta = (device_flags & WheelRotationMask) | ~WheelRotationMask; - - // XVNC session has not implemented the touch event for now - if (delta != 0 && self->mm->code != XVNC_SESSION_CODE) + if (delta != 0 && XRDP_MM_IMPLEMENTS_TOUCH(self->mm)) { // Use nature scrolling, up direction is negative. xrdp_wm_mouse_touch(self, TOUCH_TWO_FINGERS_UP, delta); @@ -1831,9 +1824,7 @@ xrdp_wm_process_input_mouse(struct xrdp_wm *self, int device_flags, else { delta = device_flags & WheelRotationMask; - - // XVNC session has not implemented the touch event for now - if (delta != 0 && self->mm->code != XVNC_SESSION_CODE) + if (delta != 0 && XRDP_MM_IMPLEMENTS_TOUCH(self->mm)) { xrdp_wm_mouse_touch(self, TOUCH_TWO_FINGERS_DOWN, delta); } @@ -1866,9 +1857,7 @@ xrdp_wm_process_input_mouse(struct xrdp_wm *self, int device_flags, * The negative number is represented by complement. */ delta = (device_flags & WheelRotationMask) | ~WheelRotationMask; - - // XVNC session has not implemented the touch event for now - if (delta != 0 && self->mm->code != XVNC_SESSION_CODE) + if (delta != 0 && XRDP_MM_IMPLEMENTS_TOUCH(self->mm)) { // Use nature scrolling, right direction is negative. xrdp_wm_mouse_touch(self, TOUCH_TWO_FINGERS_RIGHT, delta); @@ -1881,9 +1870,7 @@ xrdp_wm_process_input_mouse(struct xrdp_wm *self, int device_flags, else { delta = device_flags & WheelRotationMask; - - // XVNC session has not implemented the touch event for now - if (delta != 0 && self->mm->code != XVNC_SESSION_CODE) + if (delta != 0 && XRDP_MM_IMPLEMENTS_TOUCH(self->mm)) { xrdp_wm_mouse_touch(self, TOUCH_TWO_FINGERS_LEFT, delta); }