Skip to content

Commit 07ff78c

Browse files
authored
feat(tray): add TrayIcon::rect method (#9615)
1 parent f1badb9 commit 07ff78c

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

.changes/tray-icon-rect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": "minor:feat"
3+
---
4+
5+
Add `TrayIcon::rect` method to retrieve the tray icon rectangle

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri-build/src/manifest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn check(config: &Config, manifest: &mut Manifest) -> Result<()> {
6565
if deps.is_empty() {
6666
if let Some(alias) = &metadata.alias {
6767
deps = find_dependency(manifest, alias, metadata.kind);
68-
name = alias.clone();
68+
name.clone_from(alias)
6969
}
7070
}
7171

core/tauri-runtime-wry/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4136,8 +4136,10 @@ fn calculate_window_center_position(
41364136
{
41374137
use tao::platform::windows::MonitorHandleExtWindows;
41384138
use windows::Win32::Graphics::Gdi::{GetMonitorInfoW, HMONITOR, MONITORINFO};
4139-
let mut monitor_info = MONITORINFO::default();
4140-
monitor_info.cbSize = std::mem::size_of::<MONITORINFO>() as u32;
4139+
let mut monitor_info = MONITORINFO {
4140+
cbSize: std::mem::size_of::<MONITORINFO>() as u32,
4141+
..Default::default()
4142+
};
41414143
let status = unsafe { GetMonitorInfoW(HMONITOR(target_monitor.hmonitor()), &mut monitor_info) };
41424144
if status.into() {
41434145
let available_width = monitor_info.rcWork.right - monitor_info.rcWork.left;

core/tauri/src/async_runtime.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl GlobalRuntime {
4242
}
4343
}
4444

45-
fn spawn<F: Future>(&self, task: F) -> JoinHandle<F::Output>
45+
fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
4646
where
4747
F: Future + Send + 'static,
4848
F::Output: Send + 'static,
@@ -96,7 +96,7 @@ impl Runtime {
9696
}
9797

9898
/// Spawns a future onto the runtime.
99-
pub fn spawn<F: Future>(&self, task: F) -> JoinHandle<F::Output>
99+
pub fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
100100
where
101101
F: Future + Send + 'static,
102102
F::Output: Send + 'static,
@@ -189,7 +189,7 @@ impl RuntimeHandle {
189189
}
190190

191191
/// Spawns a future onto the runtime.
192-
pub fn spawn<F: Future>(&self, task: F) -> JoinHandle<F::Output>
192+
pub fn spawn<F>(&self, task: F) -> JoinHandle<F::Output>
193193
where
194194
F: Future + Send + 'static,
195195
F::Output: Send + 'static,

core/tauri/src/tray/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,20 @@ impl<R: Runtime> TrayIcon<R> {
421421
.set_show_menu_on_left_click(enable))?;
422422
Ok(())
423423
}
424+
425+
/// Get tray icon rect.
426+
///
427+
/// ## Platform-specific:
428+
///
429+
/// - **Linux**: Unsupported, always returns `None`.
430+
pub fn rect(&self) -> crate::Result<Option<crate::Rect>> {
431+
run_item_main_thread!(self, |self_: Self| self_.inner.rect().map(|rect| {
432+
Rect {
433+
position: rect.position.into(),
434+
size: rect.size.into(),
435+
}
436+
}))
437+
}
424438
}
425439

426440
impl<R: Runtime> Resource for TrayIcon<R> {

0 commit comments

Comments
 (0)