Skip to content

Commit 98f48b0

Browse files
remove the manual menu invoke on macos tray click
1 parent f26e6e8 commit 98f48b0

2 files changed

Lines changed: 28 additions & 36 deletions

File tree

src-tauri/src/tray.rs

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -147,45 +147,35 @@ pub async fn setup_tray(app: &AppHandle) -> Result<(), Error> {
147147
.show_menu_on_left_click(false)
148148
.on_tray_icon_event(|icon, event| {
149149
store_tray_click_position(icon.app_handle(), &event);
150-
match event {
151-
#[cfg(target_os = "macos")]
152-
TrayIconEvent::Click {
153-
button: MouseButton::Right,
154-
button_state: MouseButtonState::Up,
155-
..
156-
} => {
157-
let _ = icon.show_menu();
158-
}
159-
TrayIconEvent::Click {
160-
button: MouseButton::Left,
161-
button_state: MouseButtonState::Up,
162-
..
163-
} => {
164-
let app = icon.app_handle();
165-
let any_visible = [NEW_UI_WINDOW_ID, OLD_UI_WINDOW_ID].iter().any(|id| {
166-
app.get_webview_window(id)
167-
.and_then(|w| w.is_visible().ok())
168-
.unwrap_or(false)
169-
});
170-
if any_visible {
171-
hide_visible_windows(app);
172-
} else {
173-
#[cfg(not(target_os = "linux"))]
174-
{
175-
let has_locations = tauri::async_runtime::block_on(
176-
crate::window_manager::has_non_service_locations(),
177-
);
178-
if has_locations {
179-
show_new_ui_window_near_tray(app);
180-
} else {
181-
let _ = WindowManager::open_full_view(app);
182-
}
150+
if let TrayIconEvent::Click {
151+
button: MouseButton::Left,
152+
button_state: MouseButtonState::Up,
153+
..
154+
} = event
155+
{
156+
let app = icon.app_handle();
157+
let any_visible = [NEW_UI_WINDOW_ID, OLD_UI_WINDOW_ID].iter().any(|id| {
158+
app.get_webview_window(id)
159+
.and_then(|w| w.is_visible().ok())
160+
.unwrap_or(false)
161+
});
162+
if any_visible {
163+
hide_visible_windows(app);
164+
} else {
165+
#[cfg(not(target_os = "linux"))]
166+
{
167+
let has_locations = tauri::async_runtime::block_on(
168+
crate::window_manager::has_non_service_locations(),
169+
);
170+
if has_locations {
171+
show_new_ui_window_near_tray(app);
172+
} else {
173+
let _ = WindowManager::open_full_view(app);
183174
}
184-
#[cfg(target_os = "linux")]
185-
show_new_ui_window_near_tray(app);
186175
}
176+
#[cfg(target_os = "linux")]
177+
show_main_window(app);
187178
}
188-
_ => {}
189179
}
190180
})
191181
.on_menu_event(handle_tray_menu_event)

src-tauri/src/window_manager/macos.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(deprecated)]
2+
13
use tauri::{AppHandle, LogicalPosition, Manager, Monitor, PhysicalSize, Position, WebviewWindow};
24

35
#[cfg(target_os = "macos")]

0 commit comments

Comments
 (0)