Bug 485394 - Touchpad function button toggle to off / on
Summary: Touchpad function button toggle to off / on
Status: RESOLVED UPSTREAM
Alias: None
Product: plasmashell
Classification: Plasma
Component: Touchpad (other bugs)
Version First Reported In: 6.0.3
Platform: Neon Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-11 18:00 UTC by tchiot.ludo
Modified: 2024-12-27 17:50 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Video of the bug (661.12 KB, video/webm)
2024-04-11 18:00 UTC, tchiot.ludo
Details
shortcut declared with function key (5.06 KB, image/png)
2024-04-11 21:36 UTC, tchiot.ludo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tchiot.ludo 2024-04-11 18:00:58 UTC
Created attachment 168405 [details]
Video of the bug

SUMMARY
Using the native keyboard function to toggle the touchpad is activating to off and directly on  

STEPS TO REPRODUCE
1. Press the touchpad function button toggle
2. see the Touchpad off and without any action Touchpad on 

See video attached for more information 
No log appear on the syslog file

SOFTWARE/OS VERSIONS
Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.7.0
Kernel Version: 6.5.0-27-generic (64-bit)
Graphics Platform: Wayland
Processors: 16 × 13th Gen Intel® Core™ i7-1360P
Memory: 31,1 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: LG Electronics
Product Name: 16Z90R-G.AD78F
System Version: 0.1
Comment 1 tchiot.ludo 2024-04-11 18:06:54 UTC
Just discover that trying to use the "Function + Touchpad Toggle" as a custom shortcut, Plasma will detect it as "Control, Touchpad Toggle". 
Using a custom global shortcut (without using this function touch) works as expected
Comment 2 Nate Graham 2024-04-11 21:30:43 UTC
If you set a custom keyboard shortcut for the "Touchpad Toggle" action in System Settings > Keyboard > Shortcuts > Touchpad, and then trigger that shortcut by pressing its shortcut once, does the same problem happen? Or does it correctly toggle on or off as expected?
Comment 3 tchiot.ludo 2024-04-11 21:36:39 UTC
Created attachment 168406 [details]
shortcut declared with function key
Comment 4 tchiot.ludo 2024-04-11 21:39:03 UTC
With a custom global shortcut, it works well. 

I try to setup a global shortcut with that function key, the shortcut shown is "Control, Touchpad Toggle" and not a simple "Touchpad Toggle" (see screenshot), maybe related?
Comment 5 Nate Graham 2024-04-11 21:42:16 UTC
Ok, then what's happening here is that when you press the "toggle touchpad" key on your keyboard, it's sending two key events rather than one. So the first event toggles it, and then second one toggles it again. Obviously, this isn't going to work! :D

The problem is either in your keyboard's hardware, or else in a deeper part of the stack, maybe Libinput or the kernel. Not in KDE code. So I'd recommend following up with the Libinput folks to start with. Maybe it's their bug or they can debounce these events. 

https://gitlab.freedesktop.org/libinput/libinput/-/issues/

Good luck!
Comment 6 tchiot.ludo 2024-04-11 21:48:04 UTC
Are you sure? 
The button on the same laptop is working well on ubuntu 23.10 with cinammon or gnome shell
Comment 7 Nate Graham 2024-04-11 21:56:59 UTC
Pretty sure. Maybe in GNOME and Cinnamon they debounce rapidly repeated toggle touchpad events themselves to workaround this bug? Or maybe it's a recent kernel regression that's affecting the kernel version you're using but not the kernel version that's in Ubuntu 23.10. Either way if setting a different key for this action works, then I have difficulty seeing how it could be anything else.
Comment 8 tchiot.ludo 2024-04-11 22:05:13 UTC
I tested with that command 

$ xev | awk /keysym/'{sub(/\),/,""); print $7}'
Super_L
Control_L
NoSymbol
NoSymbol
Control_L
Super_L
XF86TouchpadToggle
XF86TouchpadToggle


All of these events for a single touch press and release ^^

You should be right so, thanks for your help
Comment 9 Werner Sembach [TUXEDO] 2024-12-27 17:45:07 UTC
(In reply to tchiot.ludo from comment #8)
> I tested with that command 
> 
> $ xev | awk /keysym/'{sub(/\),/,""); print $7}'
> Super_L
> Control_L
> NoSymbol
> NoSymbol
> Control_L
> Super_L
> XF86TouchpadToggle
> XF86TouchpadToggle
> 
> 
> All of these events for a single touch press and release ^^
> 
> You should be right so, thanks for your help

Sliding in here: I suspect you are using tuxedo-drivers?

If Yes what you are seeing is:
- Left Meta key down (from firmware)
- Left CTRL key down (from firmware)
- Zenkaku/Hangaku key down (from firmware)
- Zenkaku/Hangaku key up (from firmware)
- Left CTRL key up (from firmware)
- Left Meta key up (from firmware)
- F21 key up (from driver)
- F21 key up (from driver)

The Zenkaku/Hangaku key (https://en.wikipedia.org/wiki/Language_input_keys#Half-width/Full-width/Kanji) is not one physically present on ANSI and ISO keyboards. The firmware sends the 3 key combo Meta+CTRL+Zenkaku/Hangaku upon pressing FN + Touchpad toggle. The driver listens to this 3 key combo and additionally sends a virtual F21 keypress which is bound to touchpad toggle by X11 and Xwayland.

This worked fine in the past but now it seems that KDE has implemented the Meta+CTRL+Zenkaku/Hangaku key combo as well, causing the double touchpad toggle (Does someone have a reference at hand when this happened? A bugtracker ticket or a commit?).

I'm writing here and all of this because I want to search for a clean solution, maybe someone who already has a good idea reads this as I'm still at the beginning of my research.
Comment 10 Werner Sembach [TUXEDO] 2024-12-27 17:50:18 UTC
(In reply to Werner Sembach [TUXEDO] from comment #9)
> - F21 key up (from driver)
> - F21 key up (from driver)

copy past error correction:
- F21 key down (from driver)
- F21 key up (from driver)