Enhance window management for macOS and Windows
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Added functionality to maximize the window on macOS and set it to fullscreen on Windows during startup. - Introduced applyStartupWindowState function to manage initial window state based on the operating system. - Updated createMainWindow to call applyStartupWindowState for improved user experience.
This commit is contained in:
parent
8e3ce20bb6
commit
d0345fd7f3
@ -227,6 +227,12 @@ export function createWindow() {
|
|||||||
setupWindowEvents()
|
setupWindowEvents()
|
||||||
attachKeyboardShortcuts(win)
|
attachKeyboardShortcuts(win)
|
||||||
setupNavigationGestures(win)
|
setupNavigationGestures(win)
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
win.maximize()
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
|
win.setFullScreen(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWindow() {
|
export function getWindow() {
|
||||||
|
|||||||
@ -89,6 +89,18 @@ function broadcastWindowState() {
|
|||||||
sendToRenderer('windowState', getWindowState())
|
sendToRenderer('windowState', getWindowState())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyStartupWindowState(window) {
|
||||||
|
if (!window) return
|
||||||
|
|
||||||
|
if (isMacOS) {
|
||||||
|
window.maximize?.()
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
|
window.setFullScreen?.(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(broadcastWindowState, 100)
|
||||||
|
}
|
||||||
|
|
||||||
function setupWindowEvents(window) {
|
function setupWindowEvents(window) {
|
||||||
// Electrobun emits resize/focus, not Electron's maximize/fullscreen events.
|
// Electrobun emits resize/focus, not Electron's maximize/fullscreen events.
|
||||||
window.on?.('resize', broadcastWindowState)
|
window.on?.('resize', broadcastWindowState)
|
||||||
@ -166,6 +178,7 @@ export async function createMainWindow(rpc) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
setupWindowEvents(mainWindow)
|
setupWindowEvents(mainWindow)
|
||||||
|
applyStartupWindowState(mainWindow)
|
||||||
|
|
||||||
Electrobun.events.on('open-url', (event) => {
|
Electrobun.events.on('open-url', (event) => {
|
||||||
const url = event?.data?.url
|
const url = event?.data?.url
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user