Skip to content

feat: add touch input support#888

Open
WeraPea wants to merge 1 commit into
mangowm:mainfrom
WeraPea:touch-pr
Open

feat: add touch input support#888
WeraPea wants to merge 1 commit into
mangowm:mainfrom
WeraPea:touch-pr

Conversation

@WeraPea
Copy link
Copy Markdown
Contributor

@WeraPea WeraPea commented May 3, 2026

Originally authored by @horriblename based on dwl-patches/touch-input: #426

Initial patch changes:

  • removed duplicate declaration of createtouch
  • touch motion events now track the surface detected at touch down, rather than whatever surface is under the finger at motion time

Subsequent fixes and improvements:

  • fix: prevent client focus loss on touch interaction with layer surfaces
  • fix: correct emulation of cursor pointer from unhandled touch events
  • opt: hide cursor on touchdown
  • fix: prevent crash when touch motion occurs over layer surfaces
  • fix: use scene node coordinates for touch motion events
  • opt: remove sloppyfocus guards from touch focus
  • opt: handle touch_cancel event
  • fix: drop events for cancelled touch points
  • fix: correct touch motion surface-local coordinate calculation

Originally authored by Ching Pei Yang (horriblename) <badnam3o.0@gmail.com>
based on dwl-patches/touch-input:
https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/touch-input/touch-input.patch

Initial patch changes:
- removed duplicate declaration of `createtouch`
- touch motion events now track the surface detected at touch down,
  rather than whatever surface is under the finger at motion time

Subsequent fixes and improvements:
- fix: prevent client focus loss on touch interaction with layer surfaces
- fix: correct emulation of cursor pointer from unhandled touch events
- opt: hide cursor on touchdown
- fix: prevent crash when touch motion occurs over layer surfaces
- fix: use scene node coordinates for touch motion events
- opt: remove sloppyfocus guards from touch focus
- opt: handle touch_cancel event
- fix: drop events for cancelled touch points
- fix: correct touch motion surface-local coordinate calculation

Co-authored-by: Ching Pei Yang <badnam3o.0@gmail.com>
@azrtareef
Copy link
Copy Markdown

is the cursor being hidden while using the touchscreen the expected behaviour?

@WeraPea
Copy link
Copy Markdown
Contributor Author

WeraPea commented May 6, 2026

is the cursor being hidden while using the touchscreen the expected behaviour?

yes

Copy link
Copy Markdown
Contributor

@max-amb max-amb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this change out locally on my machine and everything seems to be working as intended. This is on the main branch with the pr. Thank you for this 😀.

If anyone wants to test it out on NixOS you can make a fork, pull this pr into the fork and then update your flake input to your fork.

@max-amb max-amb mentioned this pull request May 10, 2026
@LSTR-261
Copy link
Copy Markdown

I noticed that after a Stylus is used, touch input is blocked until you restart mango. When i try to use the touchscreen after coming close to the screen with my stylus, libinput debug outputs: event5 - dropping events due to touch arbitration. (Lenovo Yoga 2 in 1, Nixos)

@max-amb
Copy link
Copy Markdown
Contributor

max-amb commented May 10, 2026

I think stylus support is a separate issue, to be implemented by: https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/tablet-input.

My stylus doesn't work with this touch patch, but I have a working prototype with this tablet-input patch. I wonder why your stylus works with this patch, I don't know.

@LSTR-261
Copy link
Copy Markdown

i'm on werapea's combined branch, not just the touch-pr

@max-amb
Copy link
Copy Markdown
Contributor

max-amb commented May 10, 2026

Oh I see, I don't know then sorry.

@WeraPea
Copy link
Copy Markdown
Contributor Author

WeraPea commented May 10, 2026

I noticed that after a Stylus is used, touch input is blocked until you restart mango. When i try to use the touchscreen after coming close to the screen with my stylus, libinput debug outputs: event5 - dropping events due to touch arbitration. (Lenovo Yoga 2 in 1, Nixos)

touch arbitration is handled by libinput and should only be active during stylus proximity. Compositor only receives touch cancel events on proximity in, after that any new touch events it receives are unaffected, and arbitration should stop after proximity out, so the problem lies on libinput side with how your device handles proximity events or touch arbitration in general.

@LSTR-261
Copy link
Copy Markdown

Oh, okay. Was on Plasma 6 before and there it worked fine, so I thought it may be something with wlroots (tried niri just now and there the issue reappeared)

@LSTR-261
Copy link
Copy Markdown

The issue was fixed in libinput 1.30.x/1.31.1 (nixpkgs-unstable still is on 1.29.2 so you would have to make an overlay until they merge it)

@fishman
Copy link
Copy Markdown

fishman commented May 11, 2026

The issue was fixed in libinput 1.30.x/1.31.1 (nixpkgs-unstable still is on 1.29.2 so you would have to make an overlay until they merge it)

Could it be made a compile time flag and disabled on nix until fixed?

@four-griffins
Copy link
Copy Markdown

one thing that's missing is interactions in the overview. currently touching a window in overview mode will focus the window but not exit overview mode, you still have to get a mouse out for that

@TPhakisi
Copy link
Copy Markdown

@DreamMaoMao thanks for the new update, I'll be sending a donation. Can't wait for the touch support though, a very needed feature for my line of work

@DreamMaoMao
Copy link
Copy Markdown
Collaborator

DreamMaoMao commented May 15, 2026

@DreamMaoMao thanks for the new update, I'll be sending a donation. Can't wait for the touch support though, a very needed feature for my line of work

thanks,I'll consider it, but I don't have any extra money to purchase these devices now.

@DreamMaoMao DreamMaoMao force-pushed the main branch 3 times, most recently from c009ba2 to f328c27 Compare May 20, 2026 05:07
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.

8 participants