Merge branch 'xvar/fix-window-moving-bug' into 'master'

Voxygen: Fixed weird window movement caused by moving the window with the cursor grabbed (#588)

See merge request veloren/veloren!1088
This commit is contained in:
Marcel 2020-06-17 17:47:33 +00:00
commit d2f8372447
2 changed files with 11 additions and 0 deletions

View File

@ -2123,6 +2123,12 @@ impl Hud {
self.force_ungrab = !state;
true
},
WinEvent::Moved(_) => {
// Prevent the cursor from being grabbed while the window is being moved as this
// causes the window to move erratically
self.show.want_grab = false;
true
},
_ => false,
};

View File

@ -162,6 +162,8 @@ pub enum Event {
Close,
/// The window has been resized.
Resize(Vec2<u32>),
/// The window has been moved.
Moved(Vec2<u32>),
/// A key has been typed that corresponds to a specific character.
Char(char),
/// The cursor has been panned across the screen while grabbed.
@ -552,6 +554,9 @@ impl Window {
renderer.on_resize().unwrap();
events.push(Event::Resize(Vec2::new(width as u32, height as u32)));
},
glutin::WindowEvent::Moved(glutin::dpi::LogicalPosition { x, y }) => {
events.push(Event::Moved(Vec2::new(x as u32, y as u32)))
},
glutin::WindowEvent::ReceivedCharacter(c) => events.push(Event::Char(c)),
glutin::WindowEvent::MouseInput { button, state, .. } => {
if let (true, Some(game_inputs)) = (