-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cursor grab no longer grabbed when mouse leave and enter #242
Copy link
Copy link
Open
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedD - easyLikely easier than most tasks hereLikely easier than most tasks hereDS - x11Affects the X11 backend, or generally free Unix platformsAffects the X11 backend, or generally free Unix platformsH - help wantedSomeone please save usSomeone please save usP - normalGreat to haveGreat to have
Description
On X11 using Xmonad window manager:
minimal program: a winit window with cursor state set to grab:
fn main() {
let mut events_loop = winit::EventsLoop::new();
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
window.set_cursor_state(winit::CursorState::Grab).unwrap();
events_loop.run_forever(|event| {
ControlFlow::Continue
});
}
issue:
I run the program. (cursor is grabbed)
I leave the window with xmonad key.
I enter the window: cursor is not longer grabbed
to solve this issue and grab the cursor again I wrote: set cursor grab on mouse entered
fn main() {
let mut events_loop = winit::EventsLoop::new();
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
window.set_cursor_state(winit::CursorState::Grab).unwrap();
events_loop.run_forever(|event| {
match event {
winit::Event::WindowEvent { event: winit::WindowEvent::MouseEntered { .. }, .. } => window.set_cursor_state(winit::CursorState::Grab).unwrap(),
_ => (),
}
ControlFlow::Continue
});
}
That didn't solve anything. But then I wrote: set cursor state to normal and then to grab on mouse entered
and it works (cursor is grabbed again):
fn main() {
let mut events_loop = winit::EventsLoop::new();
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
window.set_cursor_state(winit::CursorState::Grab).unwrap();
events_loop.run_forever(|event| {
match event {
winit::Event::WindowEvent { event: winit::WindowEvent::MouseEntered { .. }, .. } => {
window.set_cursor_state(winit::CursorState::Normal).unwrap();
window.set_cursor_state(winit::CursorState::Grab).unwrap();
},
_ => (),
}
ControlFlow::Continue
});
}
I think this is an issue and winit should grab the cursor again automatically on mouse entered.
If so I can look to make a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedD - easyLikely easier than most tasks hereLikely easier than most tasks hereDS - x11Affects the X11 backend, or generally free Unix platformsAffects the X11 backend, or generally free Unix platformsH - help wantedSomeone please save usSomeone please save usP - normalGreat to haveGreat to have