mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-25 11:43:06 +03:00
feat(tray): add TrayIcon::rect
method (#9615)
This commit is contained in:
parent
f1badb9fb3
commit
07ff78c2de
5
.changes/tray-icon-rect.md
Normal file
5
.changes/tray-icon-rect.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": "minor:feat"
|
||||
---
|
||||
|
||||
Add `TrayIcon::rect` method to retrieve the tray icon rectangle
|
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -1765,7 +1765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.52.5",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4077,9 +4077,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tray-icon"
|
||||
version = "0.13.0"
|
||||
version = "0.13.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8713f74e697917aa794800289e15bce534fc91450312ab2d3edf5b8907f7301a"
|
||||
checksum = "39240037d755a1832e752d64f99078c3b0b21c09a71c12405070c75ef4e7cd3c"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"core-graphics",
|
||||
|
@ -65,7 +65,7 @@ pub fn check(config: &Config, manifest: &mut Manifest) -> Result<()> {
|
||||
if deps.is_empty() {
|
||||
if let Some(alias) = &metadata.alias {
|
||||
deps = find_dependency(manifest, alias, metadata.kind);
|
||||
name = alias.clone();
|
||||
name.clone_from(alias)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4136,8 +4136,10 @@ fn calculate_window_center_position(
|
||||
{
|
||||
use tao::platform::windows::MonitorHandleExtWindows;
|
||||
use windows::Win32::Graphics::Gdi::{GetMonitorInfoW, HMONITOR, MONITORINFO};
|
||||
let mut monitor_info = MONITORINFO::default();
|
||||
monitor_info.cbSize = std::mem::size_of::<MONITORINFO>() as u32;
|
||||
let mut monitor_info = MONITORINFO {
|
||||
cbSize: std::mem::size_of::<MONITORINFO>() as u32,
|
||||
..Default::default()
|
||||
};
|
||||
let status = unsafe { GetMonitorInfoW(HMONITOR(target_monitor.hmonitor()), &mut monitor_info) };
|
||||
if status.into() {
|
||||
let available_width = monitor_info.rcWork.right - monitor_info.rcWork.left;
|
||||
|
@ -42,7 +42,7 @@ impl GlobalRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn<F: Future>(&self, task: F) -> JoinHandle<F::Output>
|
||||
fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
|
||||
where
|
||||
F: Future + Send + 'static,
|
||||
F::Output: Send + 'static,
|
||||
@ -96,7 +96,7 @@ impl Runtime {
|
||||
}
|
||||
|
||||
/// Spawns a future onto the runtime.
|
||||
pub fn spawn<F: Future>(&self, task: F) -> JoinHandle<F::Output>
|
||||
pub fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
|
||||
where
|
||||
F: Future + Send + 'static,
|
||||
F::Output: Send + 'static,
|
||||
@ -189,7 +189,7 @@ impl RuntimeHandle {
|
||||
}
|
||||
|
||||
/// Spawns a future onto the runtime.
|
||||
pub fn spawn<F: Future>(&self, task: F) -> JoinHandle<F::Output>
|
||||
pub fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
|
||||
where
|
||||
F: Future + Send + 'static,
|
||||
F::Output: Send + 'static,
|
||||
|
@ -421,6 +421,20 @@ impl<R: Runtime> TrayIcon<R> {
|
||||
.set_show_menu_on_left_click(enable))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get tray icon rect.
|
||||
///
|
||||
/// ## Platform-specific:
|
||||
///
|
||||
/// - **Linux**: Unsupported, always returns `None`.
|
||||
pub fn rect(&self) -> crate::Result<Option<crate::Rect>> {
|
||||
run_item_main_thread!(self, |self_: Self| self_.inner.rect().map(|rect| {
|
||||
Rect {
|
||||
position: rect.position.into(),
|
||||
size: rect.size.into(),
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Runtime> Resource for TrayIcon<R> {
|
||||
|
Loading…
Reference in New Issue
Block a user