Implemented focus_window (#1944)
This commit is contained in:
parent
91591c4e94
commit
b371b406d5
10 changed files with 107 additions and 0 deletions
|
|
@ -685,6 +685,20 @@ impl Window {
|
|||
pub fn theme(&self) -> Theme {
|
||||
self.window_state.lock().current_theme
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn focus_window(&self) {
|
||||
let window = self.window.clone();
|
||||
let window_flags = self.window_state.lock().window_flags();
|
||||
|
||||
let is_visible = window_flags.contains(WindowFlags::VISIBLE);
|
||||
let is_minimized = window_flags.contains(WindowFlags::MINIMIZED);
|
||||
let is_foreground = window.0 == unsafe { winuser::GetForegroundWindow() };
|
||||
|
||||
if is_visible && !is_minimized && !is_foreground {
|
||||
unsafe { force_window_active(window.0) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Window {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue