Fix global shortcuts (#1904)

This commit is contained in:
Zane
2025-03-28 09:45:43 -07:00
committed by GitHub
parent 1f72044413
commit 8542114dda
2 changed files with 9 additions and 29 deletions

View File

@@ -162,12 +162,6 @@ export default function MoreMenu({
}
};
const handleVersionSelect = (version: string) => {
setOpen(false);
setShowVersions(false);
window.electron.createChatWindow(undefined, undefined, version);
};
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>

View File

@@ -224,36 +224,22 @@ const createChat = async (
});
}
// DevTools shortcut management
const registerDevToolsShortcut = (window: BrowserWindow) => {
globalShortcut.register('Alt+Command+I', () => {
window.webContents.openDevTools();
});
};
const unregisterDevToolsShortcut = () => {
globalShortcut.unregister('Alt+Command+I');
};
// Register shortcuts when window is focused
mainWindow.on('focus', () => {
registerDevToolsShortcut(mainWindow);
// Register reload shortcut
globalShortcut.register('CommandOrControl+R', () => {
// Set up local keyboard shortcuts that only work when the window is focused
mainWindow.webContents.on('before-input-event', (event, input) => {
if (input.key === 'r' && input.meta) {
mainWindow.reload();
});
});
event.preventDefault();
}
// Unregister shortcuts when window loses focus
mainWindow.on('blur', () => {
unregisterDevToolsShortcut();
globalShortcut.unregister('CommandOrControl+R');
if (input.key === 'i' && input.alt && input.meta) {
mainWindow.webContents.openDevTools();
event.preventDefault();
}
});
windowMap.set(windowId, mainWindow);
mainWindow.on('closed', () => {
windowMap.delete(windowId);
unregisterDevToolsShortcut();
goosedProcess.kill();
});
return mainWindow;