mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Set cursor only when its visibility changes
This commit is contained in:
parent
7bb49fabfa
commit
3cc27a4d76
3 changed files with 11 additions and 7 deletions
|
@ -231,8 +231,8 @@ impl Display {
|
||||||
self.tx.clone()
|
self.tx.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window(&self) -> &Window {
|
pub fn window(&mut self) -> &mut Window {
|
||||||
&self.window
|
&mut self.window
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process pending resize events
|
/// Process pending resize events
|
||||||
|
|
|
@ -261,7 +261,7 @@ impl<N: Notify> Processor<N> {
|
||||||
pub fn process_events<'a>(
|
pub fn process_events<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
term: &'a FairMutex<Term>,
|
term: &'a FairMutex<Term>,
|
||||||
window: &Window
|
window: &mut Window
|
||||||
) -> MutexGuard<'a, Term> {
|
) -> MutexGuard<'a, Term> {
|
||||||
// Terminal is lazily initialized the first time an event is returned
|
// Terminal is lazily initialized the first time an event is returned
|
||||||
// from the blocking WaitEventsIterator. Otherwise, the pty reader would
|
// from the blocking WaitEventsIterator. Otherwise, the pty reader would
|
||||||
|
|
|
@ -53,6 +53,7 @@ type Result<T> = ::std::result::Result<T, Error>;
|
||||||
/// Wraps the underlying windowing library to provide a stable API in Alacritty
|
/// Wraps the underlying windowing library to provide a stable API in Alacritty
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
glutin_window: glutin::Window,
|
glutin_window: glutin::Window,
|
||||||
|
cursor_visible: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Threadsafe APIs for the window
|
/// Threadsafe APIs for the window
|
||||||
|
@ -218,6 +219,7 @@ impl Window {
|
||||||
|
|
||||||
Ok(Window {
|
Ok(Window {
|
||||||
glutin_window: window,
|
glutin_window: window,
|
||||||
|
cursor_visible: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,10 +292,12 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set cursor visible
|
/// Set cursor visible
|
||||||
#[inline]
|
pub fn set_cursor_visible(&mut self, visible: bool) {
|
||||||
pub fn set_cursor_visible(&self, show: bool) {
|
if visible != self.cursor_visible {
|
||||||
self.glutin_window.set_cursor(if show { glutin::MouseCursor::Default }
|
self.cursor_visible = visible;
|
||||||
else { glutin::MouseCursor::NoneCursor });
|
self.glutin_window.set_cursor(if visible { glutin::MouseCursor::Default }
|
||||||
|
else { glutin::MouseCursor::NoneCursor });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue