Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* ship udev rule to add MOUSE_WHEEL_CLICK_COUNT to our uinput devices
* make wheel multiplier configurable via XPRA_MOUSE_WHEEL_CLICK_MULTIPLIER env var
* log uinput button name

git-svn-id: https://xpra.org/svn/Xpra/trunk@16652 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 7, 2017
1 parent 3612da6 commit b26c8bb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions rpmbuild/xpra.spec
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ rm -rf $RPM_BUILD_ROOT
%{_prefix}/lib/systemd/system/xpra.service
%{_prefix}/lib/systemd/system/xpra.socket
%{_prefix}/lib/cups/backend/xpraforwarder
%{_prefix}/lib/udev/rules.d/71-xpra-virtual-pointer.rules
%config(noreplace) %{_sysconfdir}/sysconfig/xpra
%config %{_prefix}/lib/tmpfiles.d/xpra.conf
%config %{_prefix}/lib/sysusers.d/xpra.conf
Expand Down Expand Up @@ -722,6 +723,7 @@ else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
/bin/systemctl restart xpra.socket >/dev/null 2>&1 || :
fi
udevadm control --reload-rules && udevadm trigger || :
%endif

%post common-client
Expand Down
9 changes: 7 additions & 2 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def is_RH():

x11_ENABLED = DEFAULT and not WIN32 and not OSX
xinput_ENABLED = x11_ENABLED
uinput_ENABLED = x11_ENABLED
dbus_ENABLED = DEFAULT and x11_ENABLED and not (OSX or WIN32)
gtk_x11_ENABLED = DEFAULT and not WIN32 and not OSX
gtk2_ENABLED = DEFAULT and client_ENABLED and not PYTHON3
Expand Down Expand Up @@ -215,7 +216,7 @@ def is_RH():
"csc_libyuv",
"bencode", "cython_bencode", "vsock", "mdns",
"clipboard",
"server", "client", "dbus", "x11", "xinput", "sd_listen",
"server", "client", "dbus", "x11", "xinput", "uinput", "sd_listen",
"gtk_x11", "service",
"gtk2", "gtk3", "example",
"html5", "minify", "html5_gzip", "html5_brotli",
Expand Down Expand Up @@ -1483,7 +1484,9 @@ def copytodir(src, dst_dir, chmod=0o644):
if any(x.find("xpra_Xdummy")>=0 for x in (xvfb_command or [])) or Xdummy_wrapper_ENABLED is True:
copytodir("scripts/xpra_Xdummy", "bin", chmod=0o755)
#install xorg*.conf, cuda.conf and nvenc.keys:
etc_xpra_files = ["xorg.conf", "xorg-uinput.conf"]
etc_xpra_files = ["xorg.conf"]
if uinput_ENABLED:
etc_xpra_files.append("xorg-uinput.conf")
if nvenc_ENABLED:
etc_xpra_files += ["cuda.conf", "nvenc.keys"]
for x in etc_xpra_files:
Expand Down Expand Up @@ -1535,6 +1538,8 @@ def copytodir(src, dst_dir, chmod=0o644):
#not supported by all distros, but doesn't hurt to install them anyway:
for x in ("tmpfiles.d", "sysusers.d"):
add_data_files("lib/%s" % x, ["%s/xpra.conf" % x])
if uinput_ENABLED:
add_data_files("lib/udev/rules.d/", ["udev/rules.d/71-xpra-virtual-pointer.rules"])

#gentoo does weird things, calls --no-compile with build *and* install
#then expects to find the cython modules!? ie:
Expand Down
3 changes: 3 additions & 0 deletions src/udev/rules.d/71-xpra-virtual-pointer.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# allow xpra to use fine grained scrolling

ACTION=="add|change", ATTRS{name}=="Xpra Virtual Pointer", ENV{MOUSE_WHEEL_CLICK_ANGLE}="1", ENV{MOUSE_WHEEL_CLICK_COUNT}="360"
19 changes: 16 additions & 3 deletions src/xpra/x11/x11_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

MAX_CONCURRENT_CONNECTIONS = envint("XPRA_MAX_CONCURRENT_CONNECTIONS", 20)
ALWAYS_NOTIFY_MOTION = envbool("XPRA_ALWAYS_NOTIFY_MOTION", False)
MOUSE_WHEEL_CLICK_MULTIPLIER = envint("XPRA_MOUSE_WHEEL_CLICK_MULTIPLIER", 30)


class XTestPointerDevice(object):
Expand Down Expand Up @@ -100,14 +101,26 @@ def move_pointer(self, screen_no, x, y, *_args):

def click(self, button, pressed, *_args):
import uinput
BUTTON_STR = {
uinput.BTN_LEFT : "BTN_LEFT",
uinput.BTN_RIGHT : "BTN_RIGHT",
uinput.BTN_MIDDLE : "BTN_MIDDLE",
uinput.BTN_SIDE : "BTN_SIDE",
uinput.BTN_EXTRA : "BTN_EXTRA",
uinput.REL_WHEEL : "REL_WHEEL",
}
#this multiplier is based on the values defined in 71-xpra-virtual-pointer.rules as:
#MOUSE_WHEEL_CLICK_COUNT=360
#MOUSE_WHEEL_CLICK_ANGLE=1
mult = MOUSE_WHEEL_CLICK_MULTIPLIER
if button==4:
ubutton = uinput.REL_WHEEL
val = 1
val = 1*mult
if pressed: #only send one event
return
elif button==5:
ubutton = uinput.REL_WHEEL
val = -1
val = -1*mult
if pressed: #only send one event
return
else:
Expand All @@ -120,7 +133,7 @@ def click(self, button, pressed, *_args):
}.get(button)
val = bool(pressed)
if ubutton:
mouselog("UInput.click(%i, %s) uinput button=%#x, %#x, value=%s", button, pressed, ubutton[0], ubutton[1], val)
mouselog("UInput.click(%i, %s) uinput button=%s (%#x), %#x, value=%s", button, pressed, BUTTON_STR.get(ubutton), ubutton[0], ubutton[1], val)
self.device.emit(ubutton, val)
else:
mouselog("UInput.click(%i, %s) uinput button not found - using XTest", button, pressed)
Expand Down

0 comments on commit b26c8bb

Please sign in to comment.