From 84aca672964e29b5b4503b7da7bc34fc395f08ab Mon Sep 17 00:00:00 2001 From: Elaina Martineau Date: Mon, 8 Jul 2019 12:13:55 -0600 Subject: Change mouse cursor when hovering over the message bar --- alacritty_terminal/src/window.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'alacritty_terminal/src/window.rs') diff --git a/alacritty_terminal/src/window.rs b/alacritty_terminal/src/window.rs index d4c673ba..0292cab9 100644 --- a/alacritty_terminal/src/window.rs +++ b/alacritty_terminal/src/window.rs @@ -61,6 +61,9 @@ pub struct Window { windowed_context: glutin::WindowedContext, mouse_visible: bool, + /// Keep track of the current mouse cursor to avoid unnecessarily changing it + current_mouse_cursor: MouseCursor, + /// Whether or not the window is the focused window. pub is_focused: bool, } @@ -164,8 +167,13 @@ impl Window { // Set OpenGL symbol loader. This call MUST be after window.make_current on windows. gl::load_with(|symbol| windowed_context.get_proc_address(symbol) as *const _); - let window = - Window { event_loop, windowed_context, mouse_visible: true, is_focused: false }; + let window = Window { + event_loop, + current_mouse_cursor: MouseCursor::Default, + windowed_context, + mouse_visible: true, + is_focused: false, + }; window.run_os_extensions(); @@ -239,8 +247,11 @@ impl Window { } #[inline] - pub fn set_mouse_cursor(&self, cursor: MouseCursor) { - self.window().set_cursor(cursor); + pub fn set_mouse_cursor(&mut self, cursor: MouseCursor) { + if cursor != self.current_mouse_cursor { + self.current_mouse_cursor = cursor; + self.window().set_cursor(cursor); + } } /// Set mouse cursor visible -- cgit