Skip to content

Commit 20be0c3

Browse files
committed
Fix Linux window controls, menus, and shortcuts
- Move titleBarStyle: Overlay to runtime macOS-only code (was breaking GTK window controls) - Build Linux menus from scratch instead of patching Menu::default() - Add toPlatformShortcut() to convert ⌘⇧P → Ctrl+Shift+P on Linux - Implement show_in_finder and open_in_editor for Linux via xdg-open - Platform-aware labels ("Show in Finder" → "Show in file manager") - Hide macOS-only menu items (Quick Look, Get Info) on Linux New files: key-capture.test.ts, docs/specs/linux-ui-foundations.md
1 parent b6e80f6 commit 20be0c3

10 files changed

Lines changed: 589 additions & 45 deletions

File tree

apps/desktop/src-tauri/src/commands/ui.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::ignore_poison::IgnorePoison;
22
use crate::menu::{MenuState, build_context_menu, build_tab_context_menu};
3-
#[cfg(target_os = "macos")]
3+
#[cfg(any(target_os = "macos", target_os = "linux"))]
44
use std::process::Command;
55
use tauri::menu::ContextMenu;
66
use tauri::{AppHandle, Emitter, Manager, Runtime, Window};
@@ -101,9 +101,22 @@ pub fn show_in_finder(path: String) -> Result<(), String> {
101101
}
102102

103103
#[tauri::command]
104-
#[cfg(not(target_os = "macos"))]
104+
#[cfg(target_os = "linux")]
105+
pub fn show_in_finder(path: String) -> Result<(), String> {
106+
let parent = std::path::Path::new(&path)
107+
.parent()
108+
.unwrap_or(std::path::Path::new("/"));
109+
Command::new("xdg-open")
110+
.arg(parent)
111+
.spawn()
112+
.map_err(|e| e.to_string())?;
113+
Ok(())
114+
}
115+
116+
#[tauri::command]
117+
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
105118
pub fn show_in_finder(_path: String) -> Result<(), String> {
106-
Err("Show in Finder is only available on macOS".to_string())
119+
Err("Show in file manager is not available on this platform".to_string())
107120
}
108121

109122
/// Copy text to clipboard
@@ -170,9 +183,16 @@ pub fn open_in_editor(path: String) -> Result<(), String> {
170183
}
171184

172185
#[tauri::command]
173-
#[cfg(not(target_os = "macos"))]
186+
#[cfg(target_os = "linux")]
187+
pub fn open_in_editor(path: String) -> Result<(), String> {
188+
Command::new("xdg-open").arg(&path).spawn().map_err(|e| e.to_string())?;
189+
Ok(())
190+
}
191+
192+
#[tauri::command]
193+
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
174194
pub fn open_in_editor(_path: String) -> Result<(), String> {
175-
Err("Open in editor is only available on macOS".to_string())
195+
Err("Open in editor is not available on this platform".to_string())
176196
}
177197

178198
/// Shows a native context menu for a tab (fire-and-forget).
@@ -223,13 +243,13 @@ pub fn execute_menu_action<R: Runtime>(app: &AppHandle<R>, id: &str) {
223243
let _ = app.opener().open_path(&context.path, None::<&str>);
224244
}
225245
crate::menu::EDIT_ID => {
226-
#[cfg(target_os = "macos")]
246+
#[cfg(any(target_os = "macos", target_os = "linux"))]
227247
{
228248
let _ = open_in_editor(context.path);
229249
}
230250
}
231251
crate::menu::SHOW_IN_FINDER_ID => {
232-
#[cfg(target_os = "macos")]
252+
#[cfg(any(target_os = "macos", target_os = "linux"))]
233253
{
234254
let _ = show_in_finder(context.path);
235255
}

apps/desktop/src-tauri/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,15 @@ pub fn run() {
285285
let _ = window.set_title(&title);
286286
}
287287

288+
// Apply macOS overlay title bar at runtime (titleBarStyle removed from tauri.conf.json
289+
// because "Overlay" hides the native title bar on Linux/GTK, breaking window controls).
290+
// trafficLightPosition stays in JSON since it's macOS-only and ignored on other platforms.
291+
#[cfg(target_os = "macos")]
292+
if let Some(window) = app.get_webview_window("main") {
293+
use tauri::TitleBarStyle;
294+
let _ = window.set_title_bar_style(TitleBarStyle::Overlay);
295+
}
296+
288297
// Initialize pane state store for MCP context tools
289298
app.manage(mcp::PaneStateStore::new());
290299

0 commit comments

Comments
 (0)