aboutsummaryrefslogtreecommitdiff
path: root/src/window.rs
diff options
context:
space:
mode:
authorTuomas Siipola <siiptuo@kapsi.fi>2017-02-22 22:46:08 +0200
committerJoe Wilm <jwilm@users.noreply.github.com>2017-02-22 14:49:29 -0800
commit3cc27a4d767a87c617b5213810dfce254bac1131 (patch)
tree097880f8bdac7e9a38014a18f1560c32cc38bd39 /src/window.rs
parent7bb49fabfa0d2686e4e74c1c11362d6b6aade1ca (diff)
downloadalacritty-3cc27a4d767a87c617b5213810dfce254bac1131.tar.gz
alacritty-3cc27a4d767a87c617b5213810dfce254bac1131.zip
Set cursor only when its visibility changes
Diffstat (limited to 'src/window.rs')
-rw-r--r--src/window.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/window.rs b/src/window.rs
index b90c242d..fa751352 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -53,6 +53,7 @@ type Result<T> = ::std::result::Result<T, Error>;
/// Wraps the underlying windowing library to provide a stable API in Alacritty
pub struct Window {
glutin_window: glutin::Window,
+ cursor_visible: bool,
}
/// Threadsafe APIs for the window
@@ -218,6 +219,7 @@ impl Window {
Ok(Window {
glutin_window: window,
+ cursor_visible: true,
})
}
@@ -290,10 +292,12 @@ impl Window {
}
/// Set cursor visible
- #[inline]
- pub fn set_cursor_visible(&self, show: bool) {
- self.glutin_window.set_cursor(if show { glutin::MouseCursor::Default }
- else { glutin::MouseCursor::NoneCursor });
+ pub fn set_cursor_visible(&mut self, visible: bool) {
+ if visible != self.cursor_visible {
+ self.cursor_visible = visible;
+ self.glutin_window.set_cursor(if visible { glutin::MouseCursor::Default }
+ else { glutin::MouseCursor::NoneCursor });
+ }
}
}