Skip to content

Commit 34a1526

Browse files
committed
fix(mac): remove global zoom globalShortcut bindings to stop intercepting Cmd+=/Cmd+-; rely on View menu roles
1 parent e6190b2 commit 34a1526

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

src/main/window.ts

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -23,69 +23,6 @@ type WINDOW_ID = "main" | "panel" | "setup"
2323

2424
export const WINDOWS = new Map<WINDOW_ID, BrowserWindow>()
2525

26-
// Helper function to add zoom functionality to any window
27-
function addZoomHandling(win: BrowserWindow) {
28-
const { globalShortcut } = require('electron');
29-
30-
// Zoom implementation using setZoomFactor for reliable results
31-
const zoomIn = () => {
32-
const currentFactor = win.webContents.getZoomFactor();
33-
const newFactor = Math.min(currentFactor * 1.2, 5.0); // Max 5x zoom
34-
win.webContents.setZoomFactor(newFactor);
35-
};
36-
37-
const zoomOut = () => {
38-
const currentFactor = win.webContents.getZoomFactor();
39-
const newFactor = Math.max(currentFactor / 1.2, 0.25); // Min 0.25x zoom
40-
win.webContents.setZoomFactor(newFactor);
41-
};
42-
43-
const zoomReset = () => {
44-
win.webContents.setZoomFactor(1.0);
45-
};
46-
47-
// Register global shortcuts when window gains focus
48-
win.on('focus', () => {
49-
try {
50-
// Unregister first to avoid conflicts
51-
globalShortcut.unregister('CommandOrControl+=');
52-
globalShortcut.unregister('CommandOrControl+-');
53-
globalShortcut.unregister('CommandOrControl+0');
54-
55-
// Register zoom shortcuts
56-
globalShortcut.register('CommandOrControl+=', () => {
57-
if (win.isFocused()) {
58-
zoomIn();
59-
}
60-
});
61-
62-
globalShortcut.register('CommandOrControl+-', () => {
63-
if (win.isFocused()) {
64-
zoomOut();
65-
}
66-
});
67-
68-
globalShortcut.register('CommandOrControl+0', () => {
69-
if (win.isFocused()) {
70-
zoomReset();
71-
}
72-
});
73-
} catch (error) {
74-
console.error('Error registering zoom shortcuts:', error);
75-
}
76-
});
77-
78-
// Unregister shortcuts when window loses focus
79-
win.on('blur', () => {
80-
try {
81-
globalShortcut.unregister('CommandOrControl+=');
82-
globalShortcut.unregister('CommandOrControl+-');
83-
globalShortcut.unregister('CommandOrControl+0');
84-
} catch (error) {
85-
console.error('Error unregistering zoom shortcuts:', error);
86-
}
87-
});
88-
}
8926

9027
function createBaseWindow({
9128
id,
@@ -114,8 +51,6 @@ function createBaseWindow({
11451

11552
WINDOWS.set(id, win)
11653

117-
// Add zoom handling to all windows
118-
addZoomHandling(win)
11954

12055
if (showWhenReady) {
12156
win.on("ready-to-show", () => {
@@ -260,8 +195,6 @@ export function createPanelWindow() {
260195
getRendererHandlers<RendererHandlers>(win.webContents).stopRecording.send()
261196
})
262197

263-
// Note: Zoom handling is now handled by addZoomHandling() function above
264-
// Removed duplicate zoom handler to prevent conflicts
265198

266199
makePanel(win)
267200

0 commit comments

Comments
 (0)