diff --git a/crates/eframe/CHANGELOG.md b/crates/eframe/CHANGELOG.md index 32375fad..8ec57b66 100644 --- a/crates/eframe/CHANGELOG.md +++ b/crates/eframe/CHANGELOG.md @@ -10,7 +10,9 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C #### Desktop/Native: * `eframe::run_native` now returns a `Result` ([#2433](https://github.com/emilk/egui/pull/2433)). +* Fixed window position persistence for Windows ([#2583](https://github.com/emilk/egui/issues/2583)). * Update to `winit` 0.28, adding support for mac trackpad zoom ([#2654](https://github.com/emilk/egui/pull/2654)). +* Fix bug where the cursor could get stuck using the wrong icon. #### Web: * Prevent ctrl-P/cmd-P from opening the print dialog ([#2598](https://github.com/emilk/egui/pull/2598)). diff --git a/crates/egui-winit/CHANGELOG.md b/crates/egui-winit/CHANGELOG.md index e3cf1a26..06233538 100644 --- a/crates/egui-winit/CHANGELOG.md +++ b/crates/egui-winit/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to the `egui-winit` integration will be noted in this file. * Fixed window position persistence for Windows ([#2583](https://github.com/emilk/egui/issues/2583)). * Update to `winit` 0.28, adding support for mac trackpad zoom ([#2654](https://github.com/emilk/egui/pull/2654)). * Remove the `screen_reader` feature. Use the `accesskit` feature flag instead ([#2669](https://github.com/emilk/egui/pull/2669)). +* Fix bug where the cursor could get stuck using the wrong icon. ## 0.20.1 - 2022-12-11 diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 05b0cf8a..4a7c9ee9 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -59,7 +59,7 @@ pub struct State { egui_input: egui::RawInput, pointer_pos_in_points: Option, any_pointer_button_down: bool, - current_cursor_icon: egui::CursorIcon, + current_cursor_icon: Option, /// What egui uses. current_pixels_per_point: f32, @@ -99,7 +99,7 @@ impl State { egui_input, pointer_pos_in_points: None, any_pointer_button_down: false, - current_cursor_icon: egui::CursorIcon::Default, + current_cursor_icon: None, current_pixels_per_point: 1.0, clipboard: clipboard::Clipboard::new(wayland_display), @@ -654,22 +654,25 @@ impl State { } fn set_cursor_icon(&mut self, window: &winit::window::Window, cursor_icon: egui::CursorIcon) { - // Prevent flickering near frame boundary when Windows OS tries to control cursor icon for window resizing. - // On other platforms: just early-out to save CPU. - if self.current_cursor_icon == cursor_icon { + if self.current_cursor_icon == Some(cursor_icon) { + // Prevent flickering near frame boundary when Windows OS tries to control cursor icon for window resizing. + // On other platforms: just early-out to save CPU. return; } - self.current_cursor_icon = cursor_icon; - if let Some(cursor_icon) = translate_cursor(cursor_icon) { - window.set_cursor_visible(true); + let is_pointer_in_window = self.pointer_pos_in_points.is_some(); + if is_pointer_in_window { + self.current_cursor_icon = Some(cursor_icon); - let is_pointer_in_window = self.pointer_pos_in_points.is_some(); - if is_pointer_in_window { - window.set_cursor_icon(cursor_icon); + if let Some(winit_cursor_icon) = translate_cursor(cursor_icon) { + window.set_cursor_visible(true); + window.set_cursor_icon(winit_cursor_icon); + } else { + window.set_cursor_visible(false); } } else { - window.set_cursor_visible(false); + // Remember to set the cursor again once the cursor returns to the screen: + self.current_cursor_icon = None; } } }