Skip to content

Commit

Permalink
add focus window
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 committed Oct 20, 2023
1 parent fb81257 commit ccb0f71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
1 change: 1 addition & 0 deletions src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub(crate) enum UpdateMessage {
SetWindowTitle {
title: String,
},
FocusWindow,
SetImeAllowed {
allowed: bool,
},
Expand Down
5 changes: 5 additions & 0 deletions src/window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ccb0f71

Please sign in to comment.