Skip to content

Commit

Permalink
Fix window resize cursor icon on Windows (#128)
Browse files Browse the repository at this point in the history
Before this patch windows created by bevy with bevy_egui installed
would show the default cursor icon when hovering over the edges of the
window, although a resize cursor icon should be shown instead.
  • Loading branch information
chronicl authored Nov 13, 2022
1 parent c906611 commit fbcd126
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ pub fn process_output(
#[cfg(feature = "manage_clipboard")] mut egui_clipboard: ResMut<crate::EguiClipboard>,
mut windows: Option<ResMut<Windows>>,
mut event: EventWriter<RequestRedraw>,
#[cfg(windows)] mut last_cursor_icon: Local<HashMap<WindowId, egui::CursorIcon>>,
) {
for (window_id, ctx) in egui_context.ctx.iter_mut() {
let full_output = ctx.end_frame();
Expand All @@ -378,10 +379,23 @@ pub fn process_output(

if let Some(ref mut windows) = windows {
if let Some(window) = windows.get_mut(*window_id) {
window.set_cursor_icon(
egui_to_winit_cursor_icon(platform_output.cursor_icon)
.unwrap_or(bevy::window::CursorIcon::Default),
);
let mut set_icon = || {
window.set_cursor_icon(
egui_to_winit_cursor_icon(platform_output.cursor_icon)
.unwrap_or(bevy::window::CursorIcon::Default),
)
};

#[cfg(windows)]
{
let last_cursor_icon = last_cursor_icon.entry(*window_id).or_default();
if *last_cursor_icon != platform_output.cursor_icon {
set_icon();
*last_cursor_icon = platform_output.cursor_icon;
}
}
#[cfg(not(windows))]
set_icon();
}
}

Expand Down

0 comments on commit fbcd126

Please sign in to comment.