Add Window::is_minimized
Co-authored-by: Kirill Chibisov <contact@kchibisov.com> Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
This commit is contained in:
parent
de782504ab
commit
809162fbd0
12 changed files with 83 additions and 11 deletions
|
|
@ -24,9 +24,10 @@ use windows_sys::{
|
|||
Input::KeyboardAndMouse::GetActiveWindow,
|
||||
WindowsAndMessaging::{
|
||||
ClipCursor, GetClientRect, GetClipCursor, GetSystemMetrics, GetWindowRect,
|
||||
ShowCursor, IDC_APPSTARTING, IDC_ARROW, IDC_CROSS, IDC_HAND, IDC_HELP, IDC_IBEAM,
|
||||
IDC_NO, IDC_SIZEALL, IDC_SIZENESW, IDC_SIZENS, IDC_SIZENWSE, IDC_SIZEWE, IDC_WAIT,
|
||||
SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN,
|
||||
IsIconic, ShowCursor, IDC_APPSTARTING, IDC_ARROW, IDC_CROSS, IDC_HAND, IDC_HELP,
|
||||
IDC_IBEAM, IDC_NO, IDC_SIZEALL, IDC_SIZENESW, IDC_SIZENS, IDC_SIZENWSE, IDC_SIZEWE,
|
||||
IDC_WAIT, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN,
|
||||
SM_YVIRTUALSCREEN,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -135,6 +136,10 @@ pub fn is_focused(window: HWND) -> bool {
|
|||
window == unsafe { GetActiveWindow() }
|
||||
}
|
||||
|
||||
pub fn is_minimized(window: HWND) -> bool {
|
||||
unsafe { IsIconic(window) != false.into() }
|
||||
}
|
||||
|
||||
pub fn get_instance_handle() -> HINSTANCE {
|
||||
// Gets the instance handle by taking the address of the
|
||||
// pseudo-variable created by the microsoft linker:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ use windows_sys::Win32::{
|
|||
},
|
||||
WindowsAndMessaging::{
|
||||
CreateWindowExW, FlashWindowEx, GetClientRect, GetCursorPos, GetForegroundWindow,
|
||||
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW, IsIconic,
|
||||
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW,
|
||||
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
||||
SetCursorPos, SetForegroundWindow, SetWindowDisplayAffinity, SetWindowPlacement,
|
||||
SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO,
|
||||
|
|
@ -462,7 +462,7 @@ impl Window {
|
|||
let window = self.window.clone();
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
let is_minimized = self.is_minimized();
|
||||
let is_minimized = util::is_minimized(self.hwnd());
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
let _ = &window;
|
||||
|
|
@ -475,6 +475,11 @@ impl Window {
|
|||
});
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_minimized(&self) -> Option<bool> {
|
||||
Some(util::is_minimized(self.hwnd()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
let window = self.window.clone();
|
||||
|
|
@ -494,11 +499,6 @@ impl Window {
|
|||
window_state.window_flags.contains(WindowFlags::MAXIMIZED)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_minimized(&self) -> bool {
|
||||
unsafe { IsIconic(self.hwnd()) == 1 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
let window_state = self.window_state_lock();
|
||||
|
|
@ -810,7 +810,7 @@ impl Window {
|
|||
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_minimized = util::is_minimized(self.hwnd());
|
||||
let is_foreground = window.0 == unsafe { GetForegroundWindow() };
|
||||
|
||||
if is_visible && !is_minimized && !is_foreground {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue