summaryrefslogtreecommitdiff
path: root/src/window.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-08-04 16:18:24 +1200
committerBen Bridle <bridle.benjamin@gmail.com>2024-08-04 16:18:24 +1200
commitc141d8fe8bb9115ccb953ed6ea5b0b04bc828125 (patch)
tree01a9967c607a75141a915d340185b2952a08e9f8 /src/window.rs
parente85f41bdf72b31f6d9224cb0d9f71986cc12a15e (diff)
downloadphosphor-c141d8fe8bb9115ccb953ed6ea5b0b04bc828125.zip
Unify is_cursor_visible and cursor_icon callbacks
It makes sense to handle all cursor icon state at once.
Diffstat (limited to 'src/window.rs')
-rw-r--r--src/window.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/window.rs b/src/window.rs
index b280a36..1b602c8 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -15,7 +15,7 @@ pub struct Window {
#[allow(dead_code)] context: softbuffer::Context,
render_request: RenderRequest,
previous_cursor_position: Option<Point>,
- previous_cursor_icon: CursorIcon,
+ previous_cursor: Option<CursorIcon>,
previous_title: String,
}
@@ -57,7 +57,7 @@ impl Window {
context,
render_request: RenderRequest::REDRAW,
previous_cursor_position: None,
- previous_cursor_icon: CursorIcon::Default,
+ previous_cursor: Some(CursorIcon::Default),
previous_title: String::new(),
}
}
@@ -74,11 +74,14 @@ impl Window {
}
}
- pub fn update_cursor_icon(&mut self) {
- let icon = self.controller.cursor_icon().unwrap_or(CursorIcon::Default);
- if icon != self.previous_cursor_icon {
- self.window.set_cursor_icon(icon);
- self.previous_cursor_icon = icon;
+ pub fn update_cursor(&mut self) {
+ let cursor = self.controller.cursor();
+ if cursor != self.previous_cursor {
+ self.window.set_cursor_visible(cursor.is_some());
+ if let Some(icon) = cursor {
+ self.window.set_cursor_icon(icon);
+ }
+ self.previous_cursor = cursor;
}
}
@@ -132,10 +135,6 @@ impl Window {
}
}
- pub fn update_cursor_visible(&mut self) {
- self.window.set_cursor_visible(self.controller.is_cursor_visible());
- }
-
/// Resize the frame buffer and screen surface to the new size of the window.
pub fn resize_buffer_and_surface(&mut self, physical_dimensions: Dimensions) {
if let Some((width, height)) = dim_to_nonzero_size(physical_dimensions) {