diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index e0255a6caf3..691aaf50ee1 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -429,7 +429,7 @@ impl State { self.egui_input.modifiers.alt = alt; self.egui_input.modifiers.ctrl = ctrl; self.egui_input.modifiers.shift = shift; - self.egui_input.modifiers.mac_cmd = super_; + self.egui_input.modifiers.mac_cmd = cfg!(target_os = "macos") && super_; self.egui_input.modifiers.command = if cfg!(target_os = "macos") { super_ } else { @@ -841,16 +841,11 @@ impl State { if let Some(ime) = ime { let pixels_per_point = pixels_per_point(&self.egui_ctx, window); - let ime_rect_px = ime.rect * pixels_per_point; - let mut need_set_ime_cursor_area = true; - - // On Wayland of Linux, repaints every frame Issue : See https://github.com/emilk/egui/pull/4254 - if self.egui_ctx.os() == egui::os::OperatingSystem::Nix { - need_set_ime_cursor_area = self.ime_rect_px != Some(ime_rect_px) - && self.egui_ctx.input(|i| !i.events.is_empty()); - } - - if need_set_ime_cursor_area { + let ime_rect_px = pixels_per_point * ime.rect; + if self.ime_rect_px != Some(ime_rect_px) + || self.egui_ctx.input(|i| !i.events.is_empty()) + { + self.ime_rect_px = Some(ime_rect_px); crate::profile_scope!("set_ime_cursor_area"); window.set_ime_cursor_area( winit::dpi::PhysicalPosition { @@ -862,10 +857,6 @@ impl State { height: ime_rect_px.height(), }, ); - - self.ime_rect_px = Some(ime_rect_px); - } else { - self.ime_rect_px = None; } } else { self.ime_rect_px = None; @@ -986,7 +977,6 @@ pub fn update_viewport_info( } viewport_info.fullscreen = Some(window.fullscreen().is_some()); - viewport_info.decorations = Some(window.is_decorated()); viewport_info.focused = Some(window.has_focus()); } @@ -1331,20 +1321,10 @@ fn process_viewport_command( match command { ViewportCommand::Close => { - info.close_requested_on(); - info.close_cancelable_off(); info.events.push(egui::ViewportEvent::Close); } ViewportCommand::CancelClose => { // Need to be handled elsewhere - info.close_requested_off(); - if let Some(position) = info - .events - .iter() - .position(|x| *x == egui::ViewportEvent::Close) - { - info.events.remove(position); - } } ViewportCommand::StartDrag => { // If `is_viewport_focused` is not checked on x11 the input will be permanently taken until the app is killed! @@ -1401,10 +1381,7 @@ fn process_viewport_command( ViewportCommand::Title(title) => { window.set_title(&title); } - ViewportCommand::Transparent(v) => { - window.set_transparent(v); - info.transparent = Some(v); - } + ViewportCommand::Transparent(v) => window.set_transparent(v), ViewportCommand::Visible(v) => window.set_visible(v), ViewportCommand::OuterPosition(pos) => { window.set_outer_position(PhysicalPosition::new( @@ -1458,10 +1435,7 @@ fn process_viewport_command( ViewportCommand::Fullscreen(v) => { window.set_fullscreen(v.then_some(winit::window::Fullscreen::Borderless(None))); } - ViewportCommand::Decorations(v) => { - window.set_decorations(v); - info.decorations = Some(v); - } + ViewportCommand::Decorations(v) => window.set_decorations(v), ViewportCommand::WindowLevel(l) => window.set_window_level(match l { egui::viewport::WindowLevel::AlwaysOnBottom => WindowLevel::AlwaysOnBottom, egui::viewport::WindowLevel::AlwaysOnTop => WindowLevel::AlwaysOnTop, @@ -1471,11 +1445,13 @@ fn process_viewport_command( let winit_icon = icon.and_then(|icon| to_winit_icon(&icon)); window.set_window_icon(winit_icon); } - ViewportCommand::IMERect(ime_rect) => { - let ime_rect_px = ime_rect * pixels_per_point; + ViewportCommand::IMERect(rect) => { window.set_ime_cursor_area( - PhysicalPosition::new(ime_rect_px.min.x, ime_rect_px.min.y), - PhysicalSize::new(ime_rect_px.width(), ime_rect_px.height()), + PhysicalPosition::new(pixels_per_point * rect.min.x, pixels_per_point * rect.min.y), + PhysicalSize::new( + pixels_per_point * rect.size().x, + pixels_per_point * rect.size().y, + ), ); } ViewportCommand::IMEAllowed(v) => window.set_ime_allowed(v),