Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit f12330d

Browse files
committed
fix: Ctrl/Cmd+W in windows opened to be non-kui does nothing
if the client is using Kui to show a random web page, Kui's main menu.ts still intercepts Ctrl/Cmd+w as a request to close a Kui tab.
1 parent f66d4f9 commit f12330d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

packages/core/src/main/menu.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Menu, MenuItemConstructorOptions } from 'electron'
2121

2222
import open from './open'
2323
import tellRendererToExecute from './tell'
24+
import ISubwindowPrefs from '../models/SubwindowPrefs'
2425
import loadClientNotebooksMenuDefinition from './load'
2526
import { openNotebook, clientNotebooksDefinitionToElectron } from './notebooks'
2627
import { isOfflineClient, isReadOnlyClient } from '..'
@@ -43,7 +44,16 @@ const newSplit = () => tellRendererToExecute('split')
4344
* tell the current window to close the current tab
4445
*
4546
*/
46-
const closeTab = () => tellRendererToExecute('tab close -A')
47+
const closeTab = (
48+
_: import('electron').MenuItem,
49+
browserWindow: import('electron').BrowserWindow & { subwindow: ISubwindowPrefs }
50+
) => {
51+
if (browserWindow.subwindow && browserWindow.subwindow._notAKuiWindow) {
52+
browserWindow.close()
53+
} else {
54+
tellRendererToExecute('tab close -A')
55+
}
56+
}
4757

4858
const isDarwin = process.platform === 'darwin'
4959
const closeAccelerator = isDarwin ? 'Command+W' : 'Control+Shift+W'

packages/core/src/main/spawn-electron.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,18 @@ export async function createWindow(
222222
position
223223
)
224224

225+
// if we are opening a random URL, then we cannot use a
226+
// frameless window; otherwise, it is unlikely the window will
227+
// be moveable
228+
if (typeof executeThisArgvPlease === 'string') {
229+
delete opts.frame
230+
delete opts.titleBarStyle
231+
if (!subwindowPrefs) {
232+
subwindowPrefs = {}
233+
}
234+
subwindowPrefs._notAKuiWindow = true
235+
}
236+
225237
// if user ups zoom level, reloads, we're stuck at a higher zoom
226238
// see https://github.com/electron/electron/issues/10572
227239
// note that this requires show: false above

packages/core/src/models/SubwindowPrefs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ interface SubwindowPrefs {
3333
/** Use this as the initial title for the first tab */
3434
initialTabTitle?: string
3535

36+
/** Internal: this is not a Kui window */
37+
_notAKuiWindow?: boolean
38+
3639
quietExecCommand?: boolean
3740
position?: () => Promise<{ x: number; y: number }>
3841
bringYourOwnWindow?: () => void

0 commit comments

Comments
 (0)