mirror of https://github.com/jiahaog/Nativefier
Added hooks for minimize, toggle-maximize and close, in the main process, and exposed same named emitted events through the window object. This makes it easy to integreate inline window control buttons, for when not having a window frame
This commit is contained in:
parent
45d7981761
commit
1618775096
|
@ -150,6 +150,22 @@ export async function createMainWindow(
|
|||
mainWindow.show();
|
||||
});
|
||||
|
||||
ipcMain.on('window-minimize', () => {
|
||||
mainWindow.minimize();
|
||||
});
|
||||
|
||||
ipcMain.on('window-toggle-maximize', () => {
|
||||
if (mainWindow.isMaximized()) {
|
||||
mainWindow.restore();
|
||||
} else {
|
||||
mainWindow.maximize();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('window-close', () => {
|
||||
mainWindow.close();
|
||||
})
|
||||
|
||||
setupSessionInteraction(mainWindow);
|
||||
setupSessionPermissionHandler(mainWindow);
|
||||
|
||||
|
|
|
@ -62,6 +62,12 @@ function setNotificationCallback(
|
|||
window.Notification = newNotify;
|
||||
}
|
||||
|
||||
function exposeWindowControls() {
|
||||
(<any>window).minimize = () => ipcRenderer.send('window-minimize');
|
||||
(<any>window).toggleMaximize = () => ipcRenderer.send('window-toggle-maximize');
|
||||
(<any>window).close = () => ipcRenderer.send('window-close');
|
||||
}
|
||||
|
||||
async function getDisplayMedia(
|
||||
sourceId: number | string,
|
||||
): Promise<MediaStream> {
|
||||
|
@ -327,6 +333,8 @@ function notifyNotificationClick(): void {
|
|||
setNotificationCallback(notifyNotificationCreate, notifyNotificationClick);
|
||||
setDisplayMediaPromise();
|
||||
|
||||
exposeWindowControls();
|
||||
|
||||
ipcRenderer.on('params', (event, message: string) => {
|
||||
log.debug('ipcRenderer.params', { event, message });
|
||||
const appArgs: unknown = JSON.parse(message) as OutputOptions;
|
||||
|
|
Loading…
Reference in New Issue