()
| 64 | } |
| 65 | |
| 66 | export const load = () => { |
| 67 | // Close window when closing last tab |
| 68 | const bestWindow = () => currentExecutor().window |
| 69 | app.whenReady().then(() => { |
| 70 | ipcMain.handle("window-is-pinned", async () => { |
| 71 | return { pinned: pinned } |
| 72 | }) |
| 73 | ipcMain.handle("window-is-autoHide", async () => { |
| 74 | return { autoHide: autoHideMode } |
| 75 | }) |
| 76 | |
| 77 | ipcMain.handle("window-action", async (_, args) => { |
| 78 | const action: windowAction = args.action |
| 79 | const window = bestWindow() |
| 80 | if (!window) { |
| 81 | return |
| 82 | } |
| 83 | if (action === "maximize") { |
| 84 | bestWindow()?.maximize() |
| 85 | } else if (action === "minimize") { |
| 86 | bestWindow()?.minimize() |
| 87 | } else if (action === "left") { |
| 88 | const width = 500 |
| 89 | const windowBounds = window.getBounds() |
| 90 | const currentScreen = screen.getDisplayNearestPoint({ x: windowBounds.x, y: windowBounds.y }) |
| 91 | window.setBounds({ x: 0, y: 0, height: currentScreen.bounds.height, width: width }, true) |
| 92 | } else if (action === "right") { |
| 93 | const width = 500 |
| 94 | const windowBounds = window.getBounds() |
| 95 | const currentScreen = screen.getDisplayNearestPoint({ x: windowBounds.x, y: windowBounds.y }) |
| 96 | window.setBounds( |
| 97 | { |
| 98 | x: Math.floor(currentScreen.bounds.width - width), |
| 99 | y: 0, |
| 100 | height: currentScreen.bounds.height, |
| 101 | width: Math.floor(width), |
| 102 | }, |
| 103 | true |
| 104 | ) |
| 105 | } else if (action === "toggle-maximize") { |
| 106 | const w = bestWindow() |
| 107 | if (!w) return |
| 108 | if (!w.isMaximized()) { |
| 109 | lastSize = w.getBounds() |
| 110 | w.maximize() |
| 111 | } else { |
| 112 | if (lastSize) { |
| 113 | w.setBounds(lastSize, true) |
| 114 | } else { |
| 115 | const windowBounds = w.getBounds() |
| 116 | const currentScreen = screen.getDisplayNearestPoint({ x: windowBounds.x, y: windowBounds.y }) |
| 117 | w.setBounds( |
| 118 | { |
| 119 | // 20% padded box of the window by default if there isnt a config to rebound to. |
| 120 | x: Math.floor(currentScreen.bounds.width * 0.2), |
| 121 | y: Math.floor(currentScreen.bounds.height * 0.2), |
| 122 | height: Math.floor(currentScreen.bounds.height * 0.6), |
| 123 | width: Math.floor(currentScreen.bounds.width * 0.6), |
nothing calls this directly
no test coverage detected