Skip to content

Commit

Permalink
feat: Window::is_focused
Browse files Browse the repository at this point in the history
  • Loading branch information
henry40408 committed Aug 16, 2022
1 parent 6d8cc7e commit 4b0575c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ impl UnownedWindow {
}
}

#[inline]
pub fn is_focused(&self) -> bool {
self.is_visible()
}

pub fn request_redraw(&self) {
AppState::queue_redraw(RootWindowId(self.id()));
}
Expand Down
13 changes: 12 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,17 @@ impl Window {
self.window.set_focus()
}

/// Does window has focus?
///
/// ## Platform-specific
///
/// - **Linux / macOS:** is_focus() and is_visible() are identical.
/// - **iOS / Android:** Unsupported.
#[inline]
pub fn is_focused(&self) -> bool {
self.window.is_focused()
}

/// Sets whether the window is resizable or not.
///
/// Note that making the window unresizable doesn't exempt you from handling `Resized`, as that event can still be
Expand Down Expand Up @@ -697,7 +708,7 @@ impl Window {
self.window.is_minimized()
}

/// Gets the window's current vibility state.
/// Gets the window's current visibility state.
///
/// ## Platform-specific
///
Expand Down

0 comments on commit 4b0575c

Please sign in to comment.