neutrinolabs / xorgxrdp

Xorg drivers for xrdp
Other
428 stars 108 forks source link

Can not swap mouse button (emulate libinput input properties) #251

Open liang16 opened 1 year ago

liang16 commented 1 year ago

Is there a solution for left-handed people? thanks! cry

matt335672 commented 1 year ago

Hi @liang16

Could you add a lot more context please. What are you trying to do, and what doesn't work exactly?

liang16 commented 1 year ago

Hi @matt335672

  1. My pc is Ubuntu 22.04 x64.
  2. Change the primary mouse button on in "setting".
  3. It's work ok on direct desktop, but not work on xrdp.

图片

thinks.

matt335672 commented 1 year ago

I've had a good look into this, and it doesn't seem to be possible at the moment.

The main problem is that the xrdp mouse driver doesn't support the libinput "Left Handed Enabled" property. If I use xinput list-props on an evdev device I get this:-

Device 'spice vdagent tablet':
    Device Enabled (124):   1
    Coordinate Transformation Matrix (126): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Natural Scrolling Enabled (264):   0
    libinput Natural Scrolling Enabled Default (265):   0
    libinput Middle Emulation Enabled (266):    0
    libinput Middle Emulation Enabled Default (267):    0
    libinput Calibration Matrix (268):  1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Calibration Matrix Default (269):  1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Left Handed Enabled (270):  0
    libinput Left Handed Enabled Default (271): 0
    libinput Send Events Modes Available (247): 1, 0
    libinput Send Events Mode Enabled (248):    0, 0
    libinput Send Events Mode Enabled Default (249):    0, 0
    Device Node (250):  "/dev/input/event4"
    Device Product ID (251):    0, 0
    libinput Drag Lock Buttons (272):   
    libinput Horizontal Scroll Enabled (273):   1
    libinput High Resolution Wheel Scroll Enabled (274):    1

Toggling the GNOME control above changes libinput Left Handed Enabled to 1.

Using get_props on the xrdp mouse driver I get this:-

Device 'xrdpMouse':
    Device Enabled (113):   1
    Coordinate Transformation Matrix (115): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    Device Accel Profile (232): 0
    Device Accel Constant Deceleration (233):   1.000000
    Device Accel Adaptive Deceleration (234):   1.000000
    Device Accel Velocity Scaling (235):    10.000000

I've tried messing about with xinput set-button-map, but I can only set the first two buttons for some reason. Similarly, xmodmap has similar issues.

The same happens with the VNC backend.

The RDP protocol itself has no way to communicate the user's preference from the RDP client that I can find. So I don't think a solution at the xrdp level is right here either.

I'm going to mark this as a 'feature request'. At the moment I can't see the best way to implement this. Anyone have any suggestions?

matt335672 commented 1 year ago

As it happens, I've made some progress on this.

The issues I had with xmodmap yesterday aren't explained but they don't happen just after the X server is started. The old way of swapping buttons in the xmodmap manpage seems OK.

Create etc/X11/Xsession.d/90xrdp-gnome-set-handed with the following contents to set the X server handedness at login time from the GNOME setting:-

# -*- sh -*-
# Xsession.d script to set handedness for a GNOME XRDP session mouse
#
# This file is sourced by Xsession(5), not executed.

if [ -n "$XRDP_SESSION" ]; then
    case "`/usr/bin/dconf read \
           /org/gnome/desktop/peripherals/mouse/left-handed`" in
        true)   /usr/bin/xmodmap -e "pointer = 3 2 1" ;;
        *)      /usr/bin/xmodmap -e "pointer = 1 2 3"
    esac
fi

The required utilities are installed with sudo apt install dconf-cli x11-server-utils.

@liang16 - do you want to try this and report back?

In the longer term, we could go down the route of emulating the libinput-specific device parameters for the xorgxrdp driver. These are text strings defined by the xorg-xf86-input-libinput driver in include/libinput-properties.h. This might work - I haven't tried it yet. Disadvantage of this technique is it only works for the xorgxrdp backend.

matt335672 commented 1 year ago

@liang16 - did you manage to try this?

BruceJL commented 1 year ago

@matt335672 I've tested your above config and it works correctly, with the expected caveat that a full log-off/log-on is required to toggle the setting.

FWIW The x11-server-utils package was not found on my instance of debian stable.

matt335672 commented 1 year ago

Thanks for reporting back @BruceJL

The missing package looks like it's called x11-xserver-utils in Bullseye. My mistake!

I'll move this to a feature request on xorgxrdp.