-
Notifications
You must be signed in to change notification settings - Fork 120
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
Wayland: mouse moves to 0, 0 no matter where you move it to when using abs cords #396
Comments
Hi, Could you please try again with the current main branch? I fixed a few Wayland issues recently. Also, can you tell me more about your environment? You say that you are using sway with Wayland. Which feature are you using to do that? |
I cloned the main repo using [package]
name = "lol"
version = "0.1.0"
edition = "2024"
[dependencies]
enigo = { path = "/tmp/enigo", features = ["wayland"] } That did not solve the issue but introduced another issue. A weird one at that. It doesn't take effect until i switch my workspace. Please see the attached video: recorded_video.mp4After tinkering around with the source code I bit, I discovered that changing the arguments in the vp.motion_absolute(
time,
x,
y,
u32::MAX, // TODO: Check what would be the correct value here
u32::MAX, // TODO: Check what would be the correct value here
); function from u32:MAX to my width and height of the screen somehow fished the first issue. recorded_video.mp4About the question earlier, mouse button clicks seem to work just fine. |
Also, before, writing text using |
Nice find, now we need to find out how to get the correct screen dimensions dynamically Regarding your videos, I don't understand what I am seeing in them. Maybe it is because I never used sway, but I can't tell when you change workspaces and if it is intentional or not. I also don't get what enigo is supposed to do. Is it executing the same code as before (i.e it is just supposed to move the mouse)? |
I'm sorry for not being clear. What I wanted to show was, that no matter how long I keep the program running nothing happens, not until I switch my workspace. The code used is the same as before: use enigo::{
Enigo, Mouse, Settings,
Coordinate::Abs
};
fn main() {
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.move_mouse(500, 500, Abs).unwrap();
} Focus on my mouse pointer; it suddenly moves when I switch a workspace, and then the program exits. Now, another weird part about it is, that it only happens when I move to a workspace with a window, and not with an empty one. recorded_video.mp4Those numbers at the top indicate my workspaces. 3rd workspace is where I was running the program 2nd workspace is where I had another terminal open. As you can see, when I switch to an empty workspace, workspace 4 for example, nothing happens. But when I do the same with a workspace with a window on it, my cursor moves and the program exists. I hope that explained it. |
On sway, the roundtrip never finished until e.g the workspace was switched. The move_mouse and scroll functions would not finish otherwise. Changing this to flush fixes the issue (see enigo-rs#396 for more details)
No problem, I understand it now. I have a suspicion why the program does not terminate unless the workspace is switched. Could you please try out the fix from #398? You should be able to just change your Cargo.toml to include enigo = { git = "https://github.com/pentamassiv/enigo.git", branch = "wayland_sway_roundtrip", features = ["wayland"] } I haven't tested it myself yet, but it should fix the issue of the program not terminating. It might still only successfully simulate the mouse move after you change workspaces. Please let me know what happens :-) |
Unfortunately, that did not seem to fix the issue :( |
What happened? Is the program still not terminating before switching workspaces? Then it must be waiting for a previous Wayland message. That makes sense, as the changes I recently merged were touching the initialization of the connection. Could you please change your Cargo.toml file to this: [package]
name = "lol"
version = "0.1.0"
edition = "2024"
[dependencies]
enigo = { git = "https://github.com/pentamassiv/enigo.git", branch = "wayland_sway_roundtrip", features = ["wayland"] }
env_logger = "0.11" and please change your code to this: use enigo::{
Enigo, Mouse, Settings,
Coordinate::Abs
};
fn main() {
env_logger::try_init().ok();
let mut enigo = Enigo::new(&Settings::default()).unwrap();
enigo.move_mouse(100 200, Abs).unwrap();
} Please start the program by running |
Yes, the problem persists. Here is the interrupted one: |
Awesome, thank you. I now know what the issue is. The code gets stuck here. We are waiting for the compositor to send an event, but it never comes until for example the workspace gets switched. I know how to fix this, but I will only have the time to work on it starting mid march because I have exams coming up that I need to prepare for. |
Perfect! Goodluck with your exams :) |
Describe the bug
Pretty much as the title says. No matter what x,y cords you set, it just moves to 0, 0. However, relative seems to work.
To Reproduce
Expected behavior
Mouse cursor should move to the defined x,y cords.
Environment (please complete the following information):
Additional context
None
recorded_video.mp4
The text was updated successfully, but these errors were encountered: