Bug 444271

Summary: Track Mouse effect is activated only at mouse move
Product: [Plasma] kwin Reporter: Andrew Shark <ashark>
Component: effects-variousAssignee: KWin default assignee <kwin-bugs-null>
Status: CONFIRMED ---    
Severity: minor CC: nate
Priority: NOR Flags: vlad.zahorodnii: Wayland-
vlad.zahorodnii: X11+
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Andrew Shark 2021-10-23 14:15:19 UTC
In the Track Mouse effect settings there are two ways to trigger it: keyboard shortcut or holding modifier keys. The problem is with the later.

When I press and hold down modifier keys (Meta+Ctrl), the effect is not activated. I though it was completely broken. I just discovered that it is working, but after you move your mouse.

Current behavior:
Do not move you mouse.
Hold Meta+Ctrl.
Observe that the effect is not activated.
Keep holding Meta+Ctrl and move your mouse a bit.
Observe the effect activated.
Do not move mouse and release Meta+Ctrl
Observe that effect is still activated.
Move your mouse a bit.
Observe the effect deactivated.

Expected behavior:
The effect should be activated while the Meta+Ctrl are pressed (without needing to move mouse), and deactivated as long as Meta+Ctrl are released (without needing to move mouse).

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.1
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Graphics Platform: X11
Comment 1 Andrew Shark 2021-10-24 22:41:39 UTC
Looks like this is because of the subscribe function it listens is only when mouse is "changed". It is called TrackMouseEffect::slotMouseChanged():
https://invent.kde.org/plasma/kwin/-/blob/839293f98728b52525a779c260e99acf4717bb83/src/effects/trackmouse/trackmouse.cpp#L186

Probably, there should be something like TrackMouseEffect::modifierButtonsChanged().
Comment 2 Nate Graham 2021-10-25 21:46:36 UTC
Feel free to submit a patch!
Comment 3 Andrew Shark 2023-06-22 05:32:16 UTC
Some more details of current behavior.

Operating System: Arch Linux 
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Graphics Platform: Wayland

The effect activates normally (without mouse move) when pressing Ctrl + Meta (i.e. first you press and hold Ctrl, then while keep holding Ctrl, additionally press and hold Meta).
But if you do this like Meta + Ctrl (i.e. first you press and hold Meta, then while keep holding Meta, additionally press and hold Ctrl). In this case you need to move mouse to activate effect.

Regarding deactivation.
If you activated it like Ctrl + Meta (i.e. first you press and hold Ctrl, then while keep holding Ctrl, additionally press and hold Meta), then it deactivates normally, as long as you release Ctrl or Meta.
But if activated it like Meta + Ctrl (i.e. first you press and hold Meta, then while keep holding Meta, additionally press and hold Ctrl) and moved mouse, then:
- if you release Meta (and keep holding Ctrl), it deactivates normally.
- if you release Ctrl (and keep holding Meta), the effect if NOT deactivated, until you also release Meta. More of that, if you (while still keep holding Meta) press Ctrl again, it will act inverted of expected (i.e. when Ctrl + Meta both pressed -> deactivated, when only Meta pressed -> activated).
Comment 4 Andrew Shark 2023-06-22 10:34:35 UTC
Looks like the _activation_ by modifiers is triggered only at modifiers _release_, not at _press_.
For example, configure a modifiers of effect to Shift only. Then, press and hold Shift.
Expected: effect should be activate while holding.
Reality: efeect is not active. More of that, it becomes activated after you release Shift (expected: not active after release).

However, when staying at such wrong toggle state, _deactivation_ is triggered immediately at press of some another modifier (ctrl, meta or shift).
Additionally, behavior while holding Shift and when pressing/releasing (and not moving mouse - that will make it behave normal) other modifiers is odd and different (!) depending on modifier. I pressed and released ctrl to "clear" the effect state.
Shift down, Alt down [still deactive], Alt up [still deactive].
Shift down, Meta down [still deactive], Meta up [activated].
Shift down, Ctrl down [activated], Ctrl up [deactivated].