Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mouse movement events through Sway IPC #8542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Zai-Kun
Copy link

@Zai-Kun Zai-Kun commented Jan 23, 2025

This patch lets you track your cursor's position through Sway ipc. You can subscribe to the 'cursor_movement' event and listen to cursor movements as they happen.
Checkout the demo on this reddit post: https://www.reddit.com/r/swaywm/comments/1i7zu4u/a_sway_patch_that_lets_you_listen_for_mouse/

@emersion
Copy link
Member

Thanks for the patch! However, I'm not sure the Sway IPC is a good way to implement this. The Sway IPC is mostly for low-volume, low-frequency data. Wayland is better suited for relaying stuff such as input events.

Can you tell more about your use-case? Why do you need the cursor position?

@poach3r
Copy link

poach3r commented Jan 26, 2025

Thanks for the patch! However, I'm not sure the Sway IPC is a good way to implement this. The Sway IPC is mostly for low-volume, low-frequency data. Wayland is better suited for relaying stuff such as input events.

Can you tell more about your use-case? Why do you need the cursor position?

Having access to cursor position gives users the ability to create mouse position dependent programs such as global menus in a similar vein to Windows 11, Awesome, Openbox, etc. This is my primary use case, however I can imagine it being used for adding other features such as hot corners.

@kennylevinsen
Copy link
Member

What aspect of this "global menu" requires global mouse tracking? I cannot off the top of my head think of a menu in Windows, Awesome or Openbox that requires global, focus free mouse tracking.

@poach3r
Copy link

poach3r commented Jan 26, 2025

By "global menu" I mean a menu which appears at the position of your mouse when right clicking on your desktop which gives you various options. This includes one in Openbox.

@kennylevinsen
Copy link
Member

Context menus on right click on the background can already be implemented using wlr_layer_shell to make a fullscreen background surface. That surface will have regular mouse focus behavior and can observe right clicks on it, and in turn give you a surface to actually attach the context menu popups to.

@Zai-Kun
Copy link
Author

Zai-Kun commented Jan 27, 2025

Wayland is better suited for relaying stuff such as input events.

But, there is no inbuilt way to achieve this in wayland as far as I know. You can get the current mouse position through wlr-layer-shell protocol however, you can't "track" your mouse as it moves around without taking the focus which is not what I want for my use case. I've tried several things but nothing worked so I decided to make this patch in the end.

Can you tell more about your use-case? Why do you need the cursor position?

I wanted to create a tool that would generate heat maps of your mouse movements and a "desktop mate" like oneko that followed your cursor around (using wlr-layer-shell to display it).

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

Successfully merging this pull request may close these issues.

4 participants