fix: tray icon path for Flatpak and titlebar double-click maximize
- Fix Flatpak tray icon path (com.blitzfc.qbz, not com.blitzkriegfc.qbz) - Fix titlebar double-click: prevent JS handler from firing on native drag regions, which caused double toggleMaximize (maximize then immediate restore) - Improve tray click handlers to properly detect minimized state
This commit is contained in:
2 files changed
+21
-6
No files matched your search
+15
-5
@@ -25,7 +25,7 @@ fn load_tray_icon() -> Image<'static> {
|
|||||||
// This works better with StatusNotifierItem/libayatana-appindicator
|
// This works better with StatusNotifierItem/libayatana-appindicator
|
||||||
if is_flatpak() {
|
if is_flatpak() {
|
||||||
let icon_path =
|
let icon_path =
|
||||||
PathBuf::from("/app/share/icons/hicolor/32x32/apps/com.blitzkriegfc.qbz.png");
|
PathBuf::from("/app/share/icons/hicolor/32x32/apps/com.blitzfc.qbz.png");
|
||||||
if icon_path.exists() {
|
if icon_path.exists() {
|
||||||
log::info!("Flatpak detected, loading tray icon from: {:?}", icon_path);
|
log::info!("Flatpak detected, loading tray icon from: {:?}", icon_path);
|
||||||
if let Ok(icon_data) = std::fs::read(&icon_path) {
|
if let Ok(icon_data) = std::fs::read(&icon_path) {
|
||||||
@@ -135,22 +135,32 @@ pub fn init_tray(app: &AppHandle) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
log::info!("Tray icon left-click");
|
log::info!("Tray icon left-click");
|
||||||
let app = tray.app_handle();
|
let app = tray.app_handle();
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
if window.is_visible().unwrap_or(true) {
|
let is_visible = window.is_visible().unwrap_or(true);
|
||||||
|
let is_minimized = window.is_minimized().unwrap_or(false);
|
||||||
|
|
||||||
|
if is_visible && !is_minimized {
|
||||||
let _ = window.hide();
|
let _ = window.hide();
|
||||||
} else {
|
} else {
|
||||||
let _ = window.show();
|
let _ = window.show();
|
||||||
let _ = window.unminimize();
|
if is_minimized {
|
||||||
|
let _ = window.unminimize();
|
||||||
|
}
|
||||||
let _ = window.set_focus();
|
let _ = window.set_focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Double click always shows and focuses
|
// Double click always brings window to front
|
||||||
TrayIconEvent::DoubleClick { .. } => {
|
TrayIconEvent::DoubleClick { .. } => {
|
||||||
log::info!("Tray icon double-click");
|
log::info!("Tray icon double-click");
|
||||||
let app = tray.app_handle();
|
let app = tray.app_handle();
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
|
// Ensure window is visible first
|
||||||
let _ = window.show();
|
let _ = window.show();
|
||||||
let _ = window.unminimize();
|
// Unminimize if minimized
|
||||||
|
if window.is_minimized().unwrap_or(false) {
|
||||||
|
let _ = window.unminimize();
|
||||||
|
}
|
||||||
|
// Always bring to front and focus
|
||||||
let _ = window.set_focus();
|
let _ = window.set_focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleDoubleClick(e: MouseEvent) {
|
async function handleDoubleClick(e: MouseEvent) {
|
||||||
// Don't toggle maximize when double-clicking the search input
|
// Don't toggle maximize when double-clicking the search input or window controls
|
||||||
if ((e.target as HTMLElement)?.closest('.titlebar-search')) return;
|
if ((e.target as HTMLElement)?.closest('.titlebar-search')) return;
|
||||||
|
if ((e.target as HTMLElement)?.closest('.window-controls')) return;
|
||||||
|
// Don't toggle if the native drag region already handles it
|
||||||
|
// (data-tauri-drag-region natively double-clicks to toggle maximize)
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
if (target?.hasAttribute('data-tauri-drag-region')) return;
|
||||||
await appWindow?.toggleMaximize();
|
await appWindow?.toggleMaximize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user