diff --git a/src/action.rs b/src/action.rs index 13529016..a08ae9e9 100644 --- a/src/action.rs +++ b/src/action.rs @@ -150,6 +150,10 @@ pub fn set_window_title(title: String) { add_update_message(UpdateMessage::SetWindowTitle { title }); } +pub fn focus_window() { + add_update_message(UpdateMessage::FocusWindow); +} + pub fn set_ime_allowed(allowed: bool) { add_update_message(UpdateMessage::SetImeAllowed { allowed }); } diff --git a/src/update.rs b/src/update.rs index 4d024e0e..53521a22 100644 --- a/src/update.rs +++ b/src/update.rs @@ -114,6 +114,7 @@ pub(crate) enum UpdateMessage { SetWindowTitle { title: String, }, + FocusWindow, SetImeAllowed { allowed: bool, }, diff --git a/src/window_handle.rs b/src/window_handle.rs index 165011e2..4ffa04ea 100644 --- a/src/window_handle.rs +++ b/src/window_handle.rs @@ -611,6 +611,11 @@ impl WindowHandle { let _ = window.drag_window(); } } + UpdateMessage::FocusWindow => { + if let Some(window) = self.window.as_ref() { + window.focus_window(); + } + } UpdateMessage::DragResizeWindow(direction) => { if let Some(window) = self.window.as_ref() { let _ = window.drag_resize_window(direction);