Skip to content

Commit 01468a0

Browse files
authored
fix: fix macos full window (#1254)
* fix: fix macos full window * fix: format
1 parent f99e4f6 commit 01468a0

File tree

1 file changed

+19
-1
lines changed
  • src/main/presenter/windowPresenter

1 file changed

+19
-1
lines changed

src/main/presenter/windowPresenter/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ export class WindowPresenter implements IWindowPresenter {
8383

8484
const parentWindow = BrowserWindow.fromWebContents(event.sender)
8585
if (!parentWindow || parentWindow.isDestroyed()) return
86+
// On macOS fullscreen, suppress tooltip overlay to keep system traffic lights reachable
87+
if (process.platform === 'darwin' && parentWindow.isFullScreen()) {
88+
return
89+
}
8690

8791
const overlay = this.getOrCreateTooltipOverlay(parentWindow)
8892
if (!overlay) return
@@ -858,6 +862,8 @@ export class WindowPresenter implements IWindowPresenter {
858862
// 窗口进入全屏
859863
shellWindow.on('enter-full-screen', () => {
860864
console.log(`Window ${windowId} entered fullscreen.`)
865+
// Destroy tooltip overlay while fullscreen so it never blocks system traffic lights
866+
this.destroyTooltipOverlay(windowId)
861867
if (!shellWindow.isDestroyed()) {
862868
shellWindow.webContents.send(WINDOW_EVENTS.WINDOW_ENTER_FULL_SCREEN)
863869
eventBus.sendToMain(WINDOW_EVENTS.WINDOW_ENTER_FULL_SCREEN, windowId)
@@ -874,6 +880,8 @@ export class WindowPresenter implements IWindowPresenter {
874880
// 窗口退出全屏
875881
shellWindow.on('leave-full-screen', () => {
876882
console.log(`Window ${windowId} left fullscreen.`)
883+
// Recreate tooltip overlay after exiting fullscreen for normal behavior
884+
this.getOrCreateTooltipOverlay(shellWindow)
877885
if (!shellWindow.isDestroyed()) {
878886
shellWindow.webContents.send(WINDOW_EVENTS.WINDOW_LEAVE_FULL_SCREEN)
879887
eventBus.sendToMain(WINDOW_EVENTS.WINDOW_LEAVE_FULL_SCREEN, windowId)
@@ -994,7 +1002,10 @@ export class WindowPresenter implements IWindowPresenter {
9941002
shellWindow.webContents.once('did-finish-load', () => {
9951003
if (shellWindow.isDestroyed()) return
9961004
shellWindow.webContents.send('shell-window:type', windowType)
997-
this.getOrCreateTooltipOverlay(shellWindow)
1005+
// Avoid pre-creating overlay if window already in fullscreen on macOS
1006+
if (!(process.platform === 'darwin' && shellWindow.isFullScreen())) {
1007+
this.getOrCreateTooltipOverlay(shellWindow)
1008+
}
9981009
})
9991010

10001011
// --- 处理初始标签页创建或激活 ---
@@ -1068,6 +1079,8 @@ export class WindowPresenter implements IWindowPresenter {
10681079

10691080
private getOrCreateTooltipOverlay(parentWindow: BrowserWindow): BrowserWindow | null {
10701081
if (parentWindow.isDestroyed()) return null
1082+
// Do not create overlay on macOS fullscreen; it hides traffic lights
1083+
if (process.platform === 'darwin' && parentWindow.isFullScreen()) return null
10711084

10721085
const existing = this.tooltipOverlayWindows.get(parentWindow.id)
10731086
if (existing && !existing.isDestroyed()) {
@@ -1103,6 +1116,11 @@ export class WindowPresenter implements IWindowPresenter {
11031116
}
11041117
})
11051118

1119+
if (process.platform === 'darwin') {
1120+
overlay.setHiddenInMissionControl(true)
1121+
// Keep overlay off fullscreen spaces to avoid covering macOS traffic lights
1122+
overlay.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: false })
1123+
}
11061124
overlay.setIgnoreMouseEvents(true, { forward: true })
11071125

11081126
const syncOnMoved = () => {

0 commit comments

Comments
 (0)