forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.js
More file actions
36 lines (31 loc) · 1.01 KB
/
window.js
File metadata and controls
36 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { ipcMain, Menu } from 'electron'
import { isOsx } from '../../config'
import { COMMANDS } from '../../commands'
import { zoomIn, zoomOut } from '../../windows/utils'
export const minimizeWindow = win => {
if (win) {
if (isOsx) {
Menu.sendActionToFirstResponder('performMiniaturize:')
} else {
win.minimize()
}
}
}
export const toggleAlwaysOnTop = win => {
if (win) {
ipcMain.emit('window-toggle-always-on-top', win)
}
}
export const toggleFullScreen = win => {
if (win) {
win.setFullScreen(!win.isFullScreen())
}
}
// --- Commands -------------------------------------------------------------
export const loadWindowCommands = commandManager => {
commandManager.add(COMMANDS.WINDOW_MINIMIZE, minimizeWindow)
commandManager.add(COMMANDS.WINDOW_TOGGLE_ALWAYS_ON_TOP, toggleAlwaysOnTop)
commandManager.add(COMMANDS.WINDOW_TOGGLE_FULL_SCREEN, toggleFullScreen)
commandManager.add(COMMANDS.WINDOW_ZOOM_IN, zoomIn)
commandManager.add(COMMANDS.WINDOW_ZOOM_OUT, zoomOut)
}