Skip to content

Touch input#612

Open
zharsing wants to merge 4 commits into
trip-zip:mainfrom
zharsing:touch-input
Open

Touch input#612
zharsing wants to merge 4 commits into
trip-zip:mainfrom
zharsing:touch-input

Conversation

@zharsing

Copy link
Copy Markdown

Description

Basic implementation of touch and pen support (wlr_touch, wlr_tablet, wlr_tablet_tool)

Test Plan

Manual testing

Checklist

  • Lua libraries (lua/awful/, lua/gears/, lua/wibox/, lua/naughty/) are not modified — if a bug surfaces in Lua, the fix belongs in C
❯ git diff lua/awful/input.lua
diff --git a/lua/awful/input.lua b/lua/awful/input.lua
index cc851bf..3a87478 100644
--- a/lua/awful/input.lua
+++ b/lua/awful/input.lua
@@ -37,6 +37,7 @@ local state = {
     accel_profile = nil,            -- "flat", "adaptive"
     accel_speed = 0.0,              -- -1.0 to 1.0
     tap_button_map = nil,           -- "lrm", "lmr"
+    output = nil,           -- "lrm", "lmr"
 
     -- Keyboard settings
     keyboard_repeat_rate = 25,      -- repeats per second
@@ -67,6 +68,7 @@ local property_types = {
     send_events_mode = "string",
     accel_profile = "string",
     accel_speed = "number",
+    output = "string",
     tap_button_map = "string",
     keyboard_repeat_rate = "int",
     keyboard_repeat_delay = "int",
@@ -97,6 +99,7 @@ local pointer_settings = {
     accel_profile = true,
     accel_speed = true,
     tap_button_map = true,
+    output = true,
 }
  • Tests pass (make test-unit && make test-integration)
--- FAIL: test-floating-layout.lua (0.62s)
    Log output:
    [nested-inhibitor] outer compositor did not advertise the shortcut inhibitor protocol; host will intercept Mod4 combos
    W: ./lua/awful/mouse/init.lua:379: invalid cursor left_ptr
    2026-06-11 23:58:27 W: awesome: `awful.layout.layouts` was set before `request::default_layouts` could be called. Please use `awful.layout.append_default_layouts` to  avoid this problem
    [0.043] Failed to set locale with LANG: en_GB.UTF-8
    [0.043] Failed to set locale with LANG: en_GB.UTF-8
    [0.042] Failed to set locale with LANG: en_GB.UTF-8
    [0.134] [0.132] Could not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.SpawnCould not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
    .ChildExited: Process org.freedesktop.systemd1 exited with status 1
    [0.130] Could not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
    [0.050] Failed to set locale with LANG: en_GB.UTF-8
    [0.123] Could not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
    Error: running function for step 4/7 (@3): ...ng/projects/github/somewm/tests/test-floating-layout.lua:90: BUG: new client in floating layout was forced to workarea size 1282x722 (workarea 1280x720)
    stack traceback:
    	[C]: in function 'assert'
    	...ng/projects/github/somewm/tests/test-floating-layout.lua:90: in function <...ng/projects/github/somewm/tests/test-floating-layout.lua:81>
    	[C]: in function 'xpcall'
    	/home/zharsing/projects/github/somewm/tests/_runner.lua:160: in function </home/zharsing/projects/github/somewm/tests/_runner.lua:151>
    	[C]: in function 'xpcall'
    	./lua/gears/protected_call.lua:41: in function 'protected_call'
    	./lua/gears/timer.lua:286: in function <./lua/gears/timer.lua:284>!
    NOTE: there were 4 clients left after the test.
    [0.308] [0.311] Could not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.SpawnCould not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
    .ChildExited: Process org.freedesktop.systemd1 exited with status 1
    [0.306] Could not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
    [0.192] Could not move child process into a systemd scope: [Errno 5] Failed to call StartTransientUnit: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
    [0.195] [glfw error 65544]: Wayland: fatal display error: Connection reset by peer
    [0.309] [0.310] [glfw error 65544]: Wayland: fatal display error: Broken pipe
    [glfw error 65544]: Wayland: fatal display error: Broken pipe
    [0.313] [glfw error 65544]: Wayland: fatal display error: Broken pipe
    ```

@JimmyCozza

JimmyCozza commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Thanks for this PR @zharsing

Does this address #524 fully?

I don't have my touchscreen laptop set up quite yet so I'll review the code the best I can until I get a chance to actually physically run the branch

@zharsing

Copy link
Copy Markdown
Author

Hi Jimmy,

Thanks for the review, indeed, this does not address the issue in full.

What does this address then?

The PR covers basic 'plumbing', touch and tablet (pen) input device handling with wlroots and event forwarding to capable clients. Also introduces the output property in awful.input.rules to associate input devices with their relevant output devices to map the coordinate spaces.

Whats missing then?

The PR does not cover 'mouse emulation'; translation of touch events to standard pointer/cursor (mouse) movements and/or actions (buttons), gestures, .. etc.

My Background

I use keyboard for the most and TrackPoint with 3 buttons as my pointer device for the majority of the time. I use the touch for navigating 2D document spaces (Xournal++, PDF viewers, browsers) which are typically designed to work with native touch events.

(All I see of SomeWM is a slim bar which I would not try to touch anyway.. :)

My Setup

I have a ThinkPad with Wacom Touch and Pen and a Samsung Android tablet with touch and pen. I connected them together via vkms -> Sunshine -> Artemis to have the tablet function as an external display over WiFi.

History

In the first commit, I have pretty much just 'hacked' it together to make it work SomeHOW; while in the following commit reviewed the device life cycle management, added output mapping for multi screen setup and cleaned up the event handlers to remove unnecessary calls.

Current State

The touch event handling works with clients actually implementing touch handling. The device life cycle is managed, input-to-output mapping is implemented, event handlers hooked.

Going Forward

In order to implement mouse emulation or any cursor interaction, the only place to look (I believe) is the event handlers in input.c:712-892 range of the second commit.

Considering my habits, I am not necessarily the best person to decide what to actually implement, although I'm happy to work on improving this feature.

I would really appreciate 'some' input on what to actually add. While I do have a couple of ideas, I don't really have the capacity to think it through properly, to contemplate what kind of behaviour others might expect.

The Catch

Having the touch controlling the mouse may not always be desirable since its a different category of events. Especially true when working with multiple screens, you don't always want to warp the cursor over to the other, sort of allowing simultaneous access. Right now, I can open 2 instances of Xournal++ - laptop and tablet - and draw on both simultaneously without any interference while the mouse cursor or the focus is not going anywhere from where I left it. The same is true for touch navigation. Its a pretty good feature for me, the emulation must be optional.

By The Way

While I'm writing this response and contemplating the architecture I can't help but think of a third party utility which might just do the remapping of the touch events better than I can ever imagine. Previously, SomeWM did not report touch capability to the seat, yet now it does. I'm not sure, but I have a wild guess about capturing and redelivering translated events might be a thing already implemented somewhere else?

Vision

If I was to go really hardcore on the touch handling, I'd probably want to have highly configurable emulation per input device per output per client.. etc. Such a feature requires very careful design as it can bring about serious latency with high frequency events.

@zharsing zharsing mentioned this pull request Jun 13, 2026
3 tasks
@sicelo

sicelo commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Thanks so much!

Regarding the mouse emulation, I would just recommend following sway. Anyway, that discussion probably belongs in #524.

Comment thread lua/awful/input.lua Outdated
correction of typo

Co-authored-by: Sicelo <sicelo@users.noreply.github.com>
@sicelo

sicelo commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Heh, so I built and tested this on the device mentioned in #524. I can't click anywhere (I guess due to the lacking mouse emulation). Can't bring up menu, etc. However, I can indeed see touch working if I open foot (touch scrolling works) or xournalpp (i can scroll page up and down).

Unfortunately at least for my device, the mouse emulation appears to be necessary. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants