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:
Amr Bashir 2023-01-19 23:39:04 +02:00 committed by GitHub
parent de782504ab
commit 809162fbd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 83 additions and 11 deletions

View file

@ -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 {