mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-11 07:55:34 +03:00
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com> Co-authored-by: Lucas Nogueira <lucas@tauri.studio> fixes https://github.com/tauri-apps/tauri/issues/3878
This commit is contained in:
parent
eaf0d71779
commit
62144ef3be
8
.changes/is-minimized.md
Normal file
8
.changes/is-minimized.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
"tauri": minor
|
||||
"tauri-runtime": minor
|
||||
"tauri-runtime-wry": minor
|
||||
"api": minor
|
||||
---
|
||||
|
||||
Add `is_minimized()` window method.
|
@ -1023,6 +1023,7 @@ pub enum WindowMessage {
|
||||
InnerSize(Sender<PhysicalSize<u32>>),
|
||||
OuterSize(Sender<PhysicalSize<u32>>),
|
||||
IsFullscreen(Sender<bool>),
|
||||
IsMinimized(Sender<bool>),
|
||||
IsMaximized(Sender<bool>),
|
||||
IsDecorated(Sender<bool>),
|
||||
IsResizable(Sender<bool>),
|
||||
@ -1239,6 +1240,10 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
||||
window_getter!(self, WindowMessage::IsFullscreen)
|
||||
}
|
||||
|
||||
fn is_minimized(&self) -> Result<bool> {
|
||||
window_getter!(self, WindowMessage::IsMinimized)
|
||||
}
|
||||
|
||||
fn is_maximized(&self) -> Result<bool> {
|
||||
window_getter!(self, WindowMessage::IsMaximized)
|
||||
}
|
||||
@ -2339,6 +2344,7 @@ fn handle_user_message<T: UserEvent>(
|
||||
.send(PhysicalSizeWrapper(window.outer_size()).into())
|
||||
.unwrap(),
|
||||
WindowMessage::IsFullscreen(tx) => tx.send(window.fullscreen().is_some()).unwrap(),
|
||||
WindowMessage::IsMinimized(tx) => tx.send(window.is_minimized()).unwrap(),
|
||||
WindowMessage::IsMaximized(tx) => tx.send(window.is_maximized()).unwrap(),
|
||||
WindowMessage::IsDecorated(tx) => tx.send(window.is_decorated()).unwrap(),
|
||||
WindowMessage::IsResizable(tx) => tx.send(window.is_resizable()).unwrap(),
|
||||
|
@ -522,6 +522,9 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
|
||||
/// Gets the window's current fullscreen state.
|
||||
fn is_fullscreen(&self) -> Result<bool>;
|
||||
|
||||
/// Gets the window's current minimized state.
|
||||
fn is_minimized(&self) -> Result<bool>;
|
||||
|
||||
/// Gets the window's current maximized state.
|
||||
fn is_maximized(&self) -> Result<bool>;
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -63,6 +63,7 @@ pub enum WindowManagerCmd {
|
||||
InnerSize,
|
||||
OuterSize,
|
||||
IsFullscreen,
|
||||
IsMinimized,
|
||||
IsMaximized,
|
||||
IsDecorated,
|
||||
IsResizable,
|
||||
@ -253,6 +254,7 @@ impl Cmd {
|
||||
WindowManagerCmd::InnerSize => return Ok(window.inner_size()?.into()),
|
||||
WindowManagerCmd::OuterSize => return Ok(window.outer_size()?.into()),
|
||||
WindowManagerCmd::IsFullscreen => return Ok(window.is_fullscreen()?.into()),
|
||||
WindowManagerCmd::IsMinimized => return Ok(window.is_minimized()?.into()),
|
||||
WindowManagerCmd::IsMaximized => return Ok(window.is_maximized()?.into()),
|
||||
WindowManagerCmd::IsDecorated => return Ok(window.is_decorated()?.into()),
|
||||
WindowManagerCmd::IsResizable => return Ok(window.is_resizable()?.into()),
|
||||
|
@ -359,6 +359,10 @@ impl<T: UserEvent> Dispatch<T> for MockDispatcher {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn is_minimized(&self) -> Result<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn is_maximized(&self) -> Result<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
@ -888,6 +888,11 @@ impl<R: Runtime> Window<R> {
|
||||
self.window.dispatcher.is_fullscreen().map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Gets the window's current minimized state.
|
||||
pub fn is_minimized(&self) -> crate::Result<bool> {
|
||||
self.window.dispatcher.is_minimized().map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Gets the window's current maximized state.
|
||||
pub fn is_maximized(&self) -> crate::Result<bool> {
|
||||
self.window.dispatcher.is_maximized().map_err(Into::into)
|
||||
|
@ -579,6 +579,31 @@ class WindowManager extends WebviewWindowHandle {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the window's current minimized state.
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/api/window';
|
||||
* const minimized = await appWindow.isMinimized();
|
||||
* ```
|
||||
*
|
||||
* @since 1.3.0
|
||||
* */
|
||||
async isMinimized(): Promise<boolean> {
|
||||
return invokeTauriCommand({
|
||||
__tauriModule: 'Window',
|
||||
message: {
|
||||
cmd: 'manage',
|
||||
data: {
|
||||
label: this.label,
|
||||
cmd: {
|
||||
type: 'isMinimized'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the window's current maximized state.
|
||||
* @example
|
||||
|
Loading…
Reference in New Issue
Block a user