desktop tray: card as tall as its content, card and menu open from the tray icon's edge (never over the taskbar); menu permission files
This commit is contained in:
parent
6782ac6078
commit
da7ca48ab4
17 changed files with 185 additions and 26 deletions
|
|
@ -67,19 +67,20 @@ fn tray(app: &tauri::App) -> tauri::Result<()> {
|
|||
.on_tray_icon_event(|t, e| {
|
||||
let TrayIconEvent::Click { button, button_state: MouseButtonState::Up, rect, position, .. } = e else { return };
|
||||
let app = t.app_handle();
|
||||
// both open from the icon's rectangle (not the click point): their edge sits next to the icon, above a
|
||||
// bottom taskbar, so nothing starts inside the taskbar
|
||||
let scale = app.get_webview_window(policy::MAIN).and_then(|w| w.scale_factor().ok()).unwrap_or(1.0);
|
||||
let p = rect.position.to_physical::<f64>(scale);
|
||||
let s = rect.size.to_physical::<f64>(scale);
|
||||
let icon = if s.width > 0.0 && s.height > 0.0 { card::Rect { x: p.x, y: p.y, w: s.width, h: s.height } } else { card::Rect { x: position.x, y: position.y, w: 1.0, h: 1.0 } };
|
||||
match button {
|
||||
// right click: the menu panels at the click point
|
||||
MouseButton::Right => menu_panel::open_root(app, position.x, position.y),
|
||||
// left click: the tray card next to the icon
|
||||
MouseButton::Right => menu_panel::open_root(app, menu_panel::Anchor::Tray { x: icon.x, y: icon.y, w: icon.w, h: icon.h }),
|
||||
MouseButton::Left => {
|
||||
if app.get_webview_window(card::LABEL).is_none() {
|
||||
show_main(app);
|
||||
return;
|
||||
}
|
||||
let scale = app.get_webview_window(policy::MAIN).and_then(|w| w.scale_factor().ok()).unwrap_or(1.0);
|
||||
let p = rect.position.to_physical::<f64>(scale);
|
||||
let s = rect.size.to_physical::<f64>(scale);
|
||||
card::toggle(app, card::Rect { x: p.x, y: p.y, w: s.width, h: s.height });
|
||||
card::toggle(app, icon);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue