diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 1dfb8e6e..cf76c536 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -68,28 +68,32 @@ handle(IpcEvents.SHOW_ITEM_IN_FOLDER, (_, path) => { shell.showItemInFolder(path); }); +function getWindow(e, key?: string) { + const win = BrowserWindow.fromWebContents(e.sender) ?? mainWin; + if (!key) return win; + const popout = PopoutWindows.get(key!); + return popout ?? win; +} + handle(IpcEvents.FOCUS, () => { mainWin.show(); mainWin.setSkipTaskbar(false); }); handle(IpcEvents.CLOSE, (e, key?: string) => { - const popout = PopoutWindows.get(key!); - if (popout) return popout.close(); - - const win = BrowserWindow.fromWebContents(e.sender) ?? e.sender; - win.close(); + getWindow(e, key).close(); }); -handle(IpcEvents.MINIMIZE, e => { - mainWin.minimize(); +handle(IpcEvents.MINIMIZE, (e, key?: string) => { + getWindow(e, key).minimize(); }); -handle(IpcEvents.MAXIMIZE, e => { - if (mainWin.isMaximized()) { - mainWin.unmaximize(); +handle(IpcEvents.MAXIMIZE, (e, key?: string) => { + const win = getWindow(e, key); + if (win.isMaximized()) { + win.unmaximize(); } else { - mainWin.maximize(); + win.maximize(); } }); diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index 69884cd7..ec993c1d 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -55,8 +55,8 @@ export const VesktopNative = { win: { focus: () => invoke(IpcEvents.FOCUS), close: (key?: string) => invoke(IpcEvents.CLOSE, key), - minimize: () => invoke(IpcEvents.MINIMIZE), - maximize: () => invoke(IpcEvents.MAXIMIZE) + minimize: (key?: string) => invoke(IpcEvents.MINIMIZE, key), + maximize: (key?: string) => invoke(IpcEvents.MAXIMIZE, key) }, capturer: { getLargeThumbnail: (id: string) => invoke(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id) diff --git a/src/renderer/patches/index.ts b/src/renderer/patches/index.ts index 439d5582..2f7b8d4b 100644 --- a/src/renderer/patches/index.ts +++ b/src/renderer/patches/index.ts @@ -13,5 +13,5 @@ import "./screenShareFixes"; import "./spellCheck"; import "./windowsTitleBar"; import "./streamerMode"; -import "./nativeFocus"; +import "./windowMethods"; import "./hideDownloadAppsButton"; diff --git a/src/renderer/patches/nativeFocus.tsx b/src/renderer/patches/windowMethods.tsx similarity index 54% rename from src/renderer/patches/nativeFocus.tsx rename to src/renderer/patches/windowMethods.tsx index fe8720dd..8ffaf794 100644 --- a/src/renderer/patches/nativeFocus.tsx +++ b/src/renderer/patches/windowMethods.tsx @@ -9,13 +9,17 @@ import { addPatch } from "./shared"; addPatch({ patches: [ { - find: ".DEEP_LINK]:{", + find: ",setSystemTrayApplications", replacement: [ + ...["close", "minimize", "maximize"].map(op => ({ + match: new RegExp(String.raw`\i\.window\.${op}`), + replace: `VesktopNative.win.${op}` + })), { // TODO: Fix eslint rule // eslint-disable-next-line no-useless-escape - match: /(?<=\.DEEP_LINK.{0,200}?)\i\.\i\.focus\(\)/, - replace: "VesktopNative.win.focus()" + match: /(focus(\(\i\)){).{0,150}?\.focus\(\i,\i\)/, + replace: "$1VesktopNative.win.focus$2" } ] } diff --git a/src/renderer/patches/windowsTitleBar.tsx b/src/renderer/patches/windowsTitleBar.tsx index f5ef07c3..1b9e180d 100644 --- a/src/renderer/patches/windowsTitleBar.tsx +++ b/src/renderer/patches/windowsTitleBar.tsx @@ -19,11 +19,25 @@ if (Settings.store.customTitleBar) // eslint-disable-next-line no-useless-escape match: /case \i\.\i\.WINDOWS:/, replace: 'case "WEB":' + } + ] + }, + // Visual Refresh + { + find: '"data-windows":', + replacement: [ + { + // TODO: Fix eslint rule + // eslint-disable-next-line no-useless-escape + match: /\i===\i\.PlatformTypes\.WINDOWS/g, + replace: "true" }, - ...["close", "minimize", "maximize"].map(op => ({ - match: new RegExp(String.raw`\i\.\i\.${op}\b`), - replace: `VesktopNative.win.${op}` - })) + { + // TODO: Fix eslint rule + // eslint-disable-next-line no-useless-escape + match: /\i===\i\.PlatformTypes\.WEB/g, + replace: "false" + } ] } ]