mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'alt-tab-cursor' into 'master'
Show cursor when unfocussing the window Closes #141 and #137 See merge request veloren/veloren!262
This commit is contained in:
commit
22af8cb9d5
@ -713,9 +713,6 @@ impl Hud {
|
||||
}
|
||||
WinEvent::InputUpdate(GameInput::ToggleCursor, true) if !self.typing() => {
|
||||
self.force_ungrab = !self.force_ungrab;
|
||||
if self.force_ungrab {
|
||||
global_state.window.grab_cursor(false);
|
||||
}
|
||||
true
|
||||
}
|
||||
_ if !self.show.ui => false,
|
||||
@ -786,15 +783,17 @@ impl Hud {
|
||||
// Else the player is typing in chat
|
||||
WinEvent::InputUpdate(_key, _) => self.typing(),
|
||||
WinEvent::Char(_) => self.typing(),
|
||||
WinEvent::Focused(state) => {
|
||||
self.force_ungrab = !state;
|
||||
true
|
||||
}
|
||||
|
||||
_ => false,
|
||||
};
|
||||
// Handle cursor grab.
|
||||
if !self.force_ungrab {
|
||||
if cursor_grabbed != self.show.want_grab {
|
||||
global_state.window.grab_cursor(self.show.want_grab);
|
||||
}
|
||||
}
|
||||
global_state
|
||||
.window
|
||||
.grab_cursor(!self.force_ungrab && self.show.want_grab);
|
||||
|
||||
handled
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ pub enum Event {
|
||||
ViewDistanceChanged(u32),
|
||||
/// Game settings have changed.
|
||||
SettingsChanged,
|
||||
/// The window is (un)focused
|
||||
Focused(bool),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
||||
@ -225,7 +227,10 @@ impl Window {
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
glutin::WindowEvent::Focused(new_focus) => *focused = new_focus,
|
||||
glutin::WindowEvent::Focused(state) => {
|
||||
*focused = state;
|
||||
events.push(Event::Focused(state));
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
glutin::Event::DeviceEvent { event, .. } => match event {
|
||||
|
Loading…
Reference in New Issue
Block a user