press tab to lock mouse (no workie on X11)

This commit is contained in:
Quaternions 2023-08-29 18:02:05 -07:00
parent 65eb229961
commit 036c056de0

View File

@ -350,6 +350,24 @@ fn main() {
ElementState::Pressed => controls|=CONTROL_MOVEDOWN, ElementState::Pressed => controls|=CONTROL_MOVEDOWN,
ElementState::Released => controls&=!CONTROL_MOVEDOWN, ElementState::Released => controls&=!CONTROL_MOVEDOWN,
} }
(k,VirtualKeyCode::Tab) => match k {
ElementState::Pressed => {
let window = surface.object().unwrap().downcast_ref::<Window>().unwrap();
let garb = window.set_cursor_grab(winit::window::CursorGrabMode::None);
match garb {
Err(err) => println!("set_cursor_grab error: {}",err),
_ => (),
}
}
ElementState::Released => {
let window = surface.object().unwrap().downcast_ref::<Window>().unwrap();
let garb = window.set_cursor_grab(winit::window::CursorGrabMode::Locked);
match garb {
Err(err) => println!("set_cursor_grab error: {}",err),
_ => (),
}
}
}
_ => (), _ => (),
} }
} }