mirror of
https://github.com/aaddrick/claude-desktop-debian.git
synced 2026-05-17 08:36:35 +03:00
fix: enable Alt menu toggle and Ctrl+Q quit on Linux
Two changes for quit accessibility on Linux: 1. Fix Alt menu bar toggle in 'auto' mode (the default). The show event handler and setApplicationMenu interceptor were force-hiding the menu bar on every event, overriding autoHideMenuBar's native Alt toggle. Now only 'hidden' mode force-hides; 'auto' lets Electron handle the toggle natively. 2. Register Ctrl+Q as a global shortcut to quit. The upstream menu has a CmdOrCtrl+Q accelerator but Electron doesn't fire menu accelerators when the menu bar is hidden on Linux. The global shortcut ensures Ctrl+Q always works, using the same API as Ctrl+Alt+Space (works under XWayland). Together these give GNOME and other DE users two ways to quit without needing a tray icon: Alt → File → Quit, or Ctrl+Q. Fixes #321 Co-Authored-By: Claude <claude@anthropic.com>
This commit is contained in:
@@ -132,12 +132,14 @@ Module.prototype.require = function(id) {
|
||||
this.webContents.insertCSS(LINUX_CSS).catch(() => {});
|
||||
});
|
||||
|
||||
// Ensure menu bar stays hidden on show events
|
||||
this.on('show', () => {
|
||||
if (MENU_BAR_MODE !== 'visible') {
|
||||
// In 'hidden' mode, suppress Alt toggle by re-hiding
|
||||
// on every show event. In 'auto' mode, let
|
||||
// autoHideMenuBar handle the toggle natively.
|
||||
if (MENU_BAR_MODE === 'hidden') {
|
||||
this.on('show', () => {
|
||||
this.setMenuBarVisibility(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!popup) {
|
||||
// Directly set child view bounds to match content size.
|
||||
@@ -301,12 +303,15 @@ Module.prototype.require = function(id) {
|
||||
}
|
||||
}
|
||||
|
||||
// Intercept Menu.setApplicationMenu to hide menu bar on Linux
|
||||
// Intercept Menu.setApplicationMenu to hide menu bar on Linux.
|
||||
// In 'hidden' mode, force-hide after every menu update.
|
||||
// In 'auto' mode, only hide initially (autoHideMenuBar handles
|
||||
// Alt toggle — re-hiding here would break that). Fixes: #321
|
||||
const originalSetAppMenu = OriginalMenu.setApplicationMenu.bind(OriginalMenu);
|
||||
patchedSetApplicationMenu = function(menu) {
|
||||
console.log('[Frame Fix] Intercepting setApplicationMenu');
|
||||
originalSetAppMenu(menu);
|
||||
if (process.platform === 'linux' && MENU_BAR_MODE !== 'visible') {
|
||||
if (process.platform === 'linux' && MENU_BAR_MODE === 'hidden') {
|
||||
for (const win of PatchedBrowserWindow.getAllWindows()) {
|
||||
if (win.isDestroyed()) continue;
|
||||
win.setMenuBarVisibility(false);
|
||||
@@ -315,6 +320,29 @@ Module.prototype.require = function(id) {
|
||||
}
|
||||
};
|
||||
|
||||
// Register Ctrl+Q as a global shortcut to quit the app.
|
||||
// The upstream menu has CmdOrCtrl+Q but Electron doesn't fire
|
||||
// menu accelerators when the menu bar is hidden/auto-hide on
|
||||
// Linux. This ensures Ctrl+Q always works. Fixes: #321
|
||||
const registerQuitShortcut = () => {
|
||||
try {
|
||||
if (!result.globalShortcut.isRegistered('CommandOrControl+Q')) {
|
||||
result.globalShortcut.register('CommandOrControl+Q', () => {
|
||||
console.log('[Frame Fix] Ctrl+Q pressed, quitting');
|
||||
result.app.quit();
|
||||
});
|
||||
console.log('[Frame Fix] Ctrl+Q quit shortcut registered');
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[Frame Fix] Failed to register Ctrl+Q shortcut:', e.message);
|
||||
}
|
||||
};
|
||||
if (result.app.isReady()) {
|
||||
registerQuitShortcut();
|
||||
} else {
|
||||
result.app.once('ready', registerQuitShortcut);
|
||||
}
|
||||
|
||||
console.log('[Frame Fix] Patches built successfully');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user