Skip to content

Comments

{kwin,libinputactions}: refactor architecture, implement mouse gestures#81

Merged
taj-ny merged 94 commits intomainfrom
mouse-gestures
May 17, 2025
Merged

{kwin,libinputactions}: refactor architecture, implement mouse gestures#81
taj-ny merged 94 commits intomainfrom
mouse-gestures

Conversation

@taj-ny
Copy link
Owner

@taj-ny taj-ny commented Mar 2, 2025

One million changes in a single PR, as per usual.

Features

  • Stroke gesture
  • Mouse gestures (Plasma 6.3 required): press, wheel, stroke, swipe
  • Improved condition system based on variables
  • any:, all:, none: condition groups
  • Gesture end conditions
  • Touchpad scroll timeout (controls when 2-finger swipes end) can now be configured
  • one: action group - only executes a single action from the group, replaces Action.block_other

Changes

  • Project renamed to Input Actions, will eventually support other environments than just Plasma

Fixed bugs

  • Update actions intervals belonging to single-directional gestures of certain directions only work if negative.

Gesture conflicts

All other gestures are now cancelled when:

  • a gesture is updated, and has any action that has been executed, or has an update action that can be executed (satisfies conditions and thresholds) but hasn't been yet (the interval hadn't been reached)
  • a gesture ends, and it has an end action that can be executed

This makes it no longer necessary to resolve gesture conflicts manually. For example, if you had two of the same gestures , but one required Meta to be pressed and the other didn't, you had to set keyboard_modifiers: none on the latter one, otherwise it would always trigger.

Fixed bugs

  • Non-zero interval actions of bi-directional gestures ignore the delta of the event where the direction changes. Due to the high polling rate, this wasn't noticeable at all.

Configuration

New properties

A ton, just look through the configuration.

Changed properties

  • Gesture.type - New values (wheel, stroke), hold renamed to press but can still be used

Removed properties

  • Action.block_other - Use the one: action group instead*

Deprecated properties

Those will continue to work until v0.7.

  • Gesture.fingers - Use the fingers variable in a condition instead.
  • Gesture.keyboard_modifiers - Use the keyboard_modifiers variable in a condition instead.

@taj-ny taj-ny added this to the v0.6.0 milestone Mar 2, 2025
@taj-ny taj-ny linked an issue Mar 2, 2025 that may be closed by this pull request
@taj-ny
Copy link
Owner Author

taj-ny commented Mar 15, 2025

I updated the documentation (see first comment for added/changes properties) and example gestures. It only builds on Plasma 6.3 right now but some feedback would be nice.

Gesture.gesture_timeout and Gesture.button_timeout currently cannot be changed.

@taj-ny taj-ny linked an issue Mar 28, 2025 that may be closed by this pull request
@pallaswept
Copy link
Contributor

pallaswept commented May 12, 2025

All working great! I converted my configs to use the new keyboard conditions, also working great. Scroll gestures, drag to resize or move, alt+tab with wheel gestures, all good!

I replaced keyboard_modifiers: none on my strokes, with

      conditions:
         - !$keyboard_modifiers == meta

And that's working for my meta+drag resize, but I wasn't able to find an equivalent to none or any. I did try like the example code

      conditions:
         - $keyboard_modifiers == []

and also:

      conditions:
         - !$keyboard_modifiers one_of [ ctrl, alt, shift, meta ]

But those didn't work. I figured maybe I could use regex? But I feel like I'm doing something wrong.

By the way, I think it's awesome to have the ! negation feature, really cool.

I wanted to try $cursor_shape and it's working great! I have this gesture for ctrl+clicking links:

    - type: press
      mouse_buttons: [ left, right ]
      instant: true
      conditions:
        - $cursor_shape == pointer

      actions:
        - on: begin
          input:
            - keyboard: [ +leftctrl ]
            - mouse: [ left ]
            - keyboard: [ -leftctrl ]

I noticed that if I do this gesture slowly, so that I exceed press_timeout, it behaves as expected (sends ctrl+click and that opens the link in a new tab) but if I do it quickly, then it seems to click twice, opening the same page in two new tabs. I do still have unblock_buttons_on_timeout: false so I'm not sure what to make of that. Perhaps this action I used is a bad way to send ctrl+click?

This is really great though, wow. Conditions v2 rocks. Cheers!

@taj-ny
Copy link
Owner Author

taj-ny commented May 12, 2025

$keyboard_modifiers == [] should work now.

I noticed that if I do this gesture slowly, so that I exceed press_timeout, it behaves as expected (sends ctrl+click and that opens the link in a new tab) but if I do it quickly, then it seems to click twice, opening the same page in two new tabs. I do still have unblock_buttons_on_timeout: false so I'm not sure what to make of that. Perhaps this action I used is a bad way to send ctrl+click?

Does it work if you remove the condition? It turns out some applications set the cursor to an image which makes my code for getting the cursor shape not work at all. I don't know if I can work around it.

@pallaswept
Copy link
Contributor

$keyboard_modifiers == [] should work now.

Works!

Does it work if you remove the condition? It turns out some applications set the cursor to an image which makes my code for getting the cursor shape not work at all. I don't know if I can work around it.

No change. It still fires twice if I'm too quick. So far I'm just using it in firefox and the cursor shape detection does seem to be working well there.

@taj-ny
Copy link
Owner Author

taj-ny commented May 12, 2025

No change. It still fires twice if I'm too quick

Should be fixed.

So far I'm just using it in firefox and the cursor shape detection does seem to be working well there.

I should update my system more often, GTK now supports the cursor shape protocol so it'll work. Still doesn't work in Easy Effects for some reason though.

@pallaswept
Copy link
Contributor

Works great! I just noticed that you also got YAML anchors working, nice one.

I am not sure if it is possible yet, or perhaps my syntax sucks, but I was trying to see if variables can be used in a command actions like command: notify-send test $window_under_name? I was hoping to use kdotool to control the Window under the gesture (so for eg I can close a window other than the active window with a gesture)

It seems very 'snappy' (fast, responsive) since these last few updates, I don't know if that was expected?

Just loving it mate, thank you so much

@taj-ny
Copy link
Owner Author

taj-ny commented May 13, 2025

I just noticed that you also got YAML anchors working

I didn't do anything, I probably just didn't use them correctly the first time.

I am not sure if it is possible yet, or perhaps my syntax sucks, but I was trying to see if variables can be used in a command actions like command: notify-send test $window_under_name? I was hoping to use kdotool to control the Window under the gesture (so for eg I can close a window other than the active window with a gesture)

Will be possible in the next version (after v0.6). I don't want to delay this even more.

Edit: What you can do is activate the window by pressing left mouse button on it first.

It seems very 'snappy' (fast, responsive) since these last few updates, I don't know if that was expected?

I didn't do anything that would improve speed, in fact I added a few more layers input events must go through and made it so that motion gesture activation is attempted on every motion event. There's a ton of CPU time to be saved, in the future I'll add dynamic event compression that will automatically adjust itself based on the active gestures.

@taj-ny
Copy link
Owner Author

taj-ny commented May 13, 2025

I changed my mind. command: kdotool windowclose $window_under_id should work now.

@pallaswept
Copy link
Contributor

Amazing! Thank you!!!

I also do not want to cause any more delay so I will shut up now 😁 I have plenty to keep me busy for a while.

@scar45
Copy link

scar45 commented May 14, 2025

With a fresh build of 0.6.0, I have been trying to get stroke mouse gestures to work, but having difficulty with the format of the YAML. I have tried many iterations, but just can't find success. Here is an example that is wrong, but one of many I've tried:

    - type: stroke
      - 'AFoA62QJZAA='
        mouse_buttons: [ right ]

        actions:
          - on: end_cancel
          plasma_shortcut: kwin,Maximize Window

I can record the gesture using the settings dialog without issue (in this case, /, or diagonal up-right), but I am unsure of the correct YAML structure. I have checked the (new) docs, and I realize this is very new functionality, but again, hoping you can advise with an example for a proper stroke gesture.

Regardless, this utility is a life-saver, as I am trying to move to Wayland, and have extreme muscle memory (and preference) for gestures as I used Easystroke prior. Thanks much!

@taj-ny
Copy link
Owner Author

taj-ny commented May 14, 2025

With a fresh build of 0.6.0, I have been trying to get stroke mouse gestures to work, but having difficulty with the format of the YAML. I have tried many iterations, but just can't find success. Here is an example that is wrong, but one of many I've tried:

    - type: stroke
      - 'AFoA62QJZAA='
        mouse_buttons: [ right ]

        actions:
          - on: end_cancel
          plasma_shortcut: kwin,Maximize Window

I can record the gesture using the settings dialog without issue (in this case, /, or diagonal up-right), but I am unsure of the correct YAML structure. I have checked the (new) docs, and I realize this is very new functionality, but again, hoping you can advise with an example for a proper stroke gesture.

Regardless, this utility is a life-saver, as I am trying to move to Wayland, and have extreme muscle memory (and preference) for gestures as I used Easystroke prior. Thanks much!

mouse:
  gestures:
    - type: stroke
      strokes: 'AFoA62QJZAA='
      mouse_buttons: [ right ]

      actions:
        - on: end
          plasma_shortcut: kwin,Window Maximize # "Maximize Window" is not a shortcut

https://github.com/InputActions/docs/blob/v0.6.0/example_gestures.md

Stroke gestures only support on: end actions as stated in https://github.com/InputActions/docs/blob/v0.6.0/index.md. Using anything else will result in unexpected behavior.

@taj-ny
Copy link
Owner Author

taj-ny commented May 17, 2025

Thanks for testing.

@taj-ny taj-ny marked this pull request as ready for review May 17, 2025 10:05
@taj-ny taj-ny merged commit 9236271 into main May 17, 2025
8 of 10 checks passed
This was referenced May 17, 2025
@taj-ny taj-ny deleted the mouse-gestures branch May 17, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When a gesture begins, all other gestures should be cancelled Mouse gestures Stroke gesture

3 participants