From 42079b4b84507ea3afa839cf872dfae30a4cd280 Mon Sep 17 00:00:00 2001 From: 4gray Date: Fri, 24 Feb 2023 15:36:24 +0100 Subject: [PATCH] refactor: revert some changes related to custom-titlebar lib --- electron/api.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/electron/api.ts b/electron/api.ts index 554420611..502d0511f 100644 --- a/electron/api.ts +++ b/electron/api.ts @@ -245,6 +245,8 @@ export class Api { .on(EPG_FORCE_FETCH, (event, arg) => this.workerWindow.webContents.send(EPG_FORCE_FETCH, arg) ); + + this.setTitleBarListeners(); } /** @@ -326,6 +328,30 @@ export class Api { }); } + /** + * Set default listeners for custom-titlebar + */ + setTitleBarListeners() { + ipcMain.on('window-minimize', function (event) { + BrowserWindow.fromWebContents(event.sender).minimize(); + }); + + ipcMain.on('window-maximize', function (event) { + const window = BrowserWindow.fromWebContents(event.sender); + window.isMaximized() ? window.unmaximize() : window.maximize(); + }); + + ipcMain.on('window-close', function (event) { + BrowserWindow.fromWebContents(event.sender).close(); + }); + + ipcMain.on('window-is-maximized', function (event) { + event.returnValue = BrowserWindow.fromWebContents( + event.sender + ).isMaximized(); + }); + } + /** * Fetches the playlist from the given url and triggers the update operation * @param id id of the playlist to update