Fix Visual Refresh titlebar (#1104)

This commit is contained in:
Sqaaakoi
2025-04-05 02:44:47 +13:00
committed by GitHub
parent 765ffc0b57
commit c42c1b7bbd
5 changed files with 52 additions and 22 deletions

View File

@@ -7,7 +7,17 @@
if (process.platform === "linux") import("./venmic"); if (process.platform === "linux") import("./venmic");
import { execFile } from "child_process"; import { execFile } from "child_process";
import { app, BrowserWindow, clipboard, dialog, nativeImage, RelaunchOptions, session, shell } from "electron"; import {
app,
BrowserWindow,
clipboard,
dialog,
IpcMainInvokeEvent,
nativeImage,
RelaunchOptions,
session,
shell
} from "electron";
import { mkdirSync, readFileSync, watch } from "fs"; import { mkdirSync, readFileSync, watch } from "fs";
import { open, readFile } from "fs/promises"; import { open, readFile } from "fs/promises";
import { release } from "os"; import { release } from "os";
@@ -68,28 +78,29 @@ handle(IpcEvents.SHOW_ITEM_IN_FOLDER, (_, path) => {
shell.showItemInFolder(path); shell.showItemInFolder(path);
}); });
function getWindow(e: IpcMainInvokeEvent, key?: string) {
return key ? PopoutWindows.get(key)! : (BrowserWindow.fromWebContents(e.sender) ?? mainWin);
}
handle(IpcEvents.FOCUS, () => { handle(IpcEvents.FOCUS, () => {
mainWin.show(); mainWin.show();
mainWin.setSkipTaskbar(false); mainWin.setSkipTaskbar(false);
}); });
handle(IpcEvents.CLOSE, (e, key?: string) => { handle(IpcEvents.CLOSE, (e, key?: string) => {
const popout = PopoutWindows.get(key!); getWindow(e, key).close();
if (popout) return popout.close();
const win = BrowserWindow.fromWebContents(e.sender) ?? e.sender;
win.close();
}); });
handle(IpcEvents.MINIMIZE, e => { handle(IpcEvents.MINIMIZE, (e, key?: string) => {
mainWin.minimize(); getWindow(e, key).minimize();
}); });
handle(IpcEvents.MAXIMIZE, e => { handle(IpcEvents.MAXIMIZE, (e, key?: string) => {
if (mainWin.isMaximized()) { const win = getWindow(e, key);
mainWin.unmaximize(); if (win.isMaximized()) {
win.unmaximize();
} else { } else {
mainWin.maximize(); win.maximize();
} }
}); });

View File

@@ -55,8 +55,8 @@ export const VesktopNative = {
win: { win: {
focus: () => invoke<void>(IpcEvents.FOCUS), focus: () => invoke<void>(IpcEvents.FOCUS),
close: (key?: string) => invoke<void>(IpcEvents.CLOSE, key), close: (key?: string) => invoke<void>(IpcEvents.CLOSE, key),
minimize: () => invoke<void>(IpcEvents.MINIMIZE), minimize: (key?: string) => invoke<void>(IpcEvents.MINIMIZE, key),
maximize: () => invoke<void>(IpcEvents.MAXIMIZE) maximize: (key?: string) => invoke<void>(IpcEvents.MAXIMIZE, key)
}, },
capturer: { capturer: {
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id) getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)

View File

@@ -14,5 +14,5 @@ import "./screenShareFixes";
import "./spellCheck"; import "./spellCheck";
import "./windowsTitleBar"; import "./windowsTitleBar";
import "./streamerMode"; import "./streamerMode";
import "./nativeFocus"; import "./windowMethods";
import "./hideDownloadAppsButton"; import "./hideDownloadAppsButton";

View File

@@ -9,13 +9,18 @@ import { addPatch } from "./shared";
addPatch({ addPatch({
patches: [ patches: [
{ {
find: ".DEEP_LINK]:{", find: ",setSystemTrayApplications",
replacement: [ replacement: [
{
// eslint-disable-next-line no-useless-escape
match: /\i\.window\.(close|minimize|maximize)/,
replace: `VesktopNative.win.$1`
},
{ {
// TODO: Fix eslint rule // TODO: Fix eslint rule
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
match: /(?<=\.DEEP_LINK.{0,200}?)\i\.\i\.focus\(\)/, match: /(focus(\(\i\)){).{0,150}?\.focus\(\i,\i\)/,
replace: "VesktopNative.win.focus()" replace: "$1VesktopNative.win.focus$2"
} }
] ]
} }

View File

@@ -19,11 +19,25 @@ if (Settings.store.customTitleBar)
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
match: /case \i\.\i\.WINDOWS:/, match: /case \i\.\i\.WINDOWS:/,
replace: 'case "WEB":' replace: 'case "WEB":'
}
]
}, },
...["close", "minimize", "maximize"].map(op => ({ // Visual Refresh
match: new RegExp(String.raw`\i\.\i\.${op}\b`), {
replace: `VesktopNative.win.${op}` find: '"data-windows":',
})) replacement: [
{
// TODO: Fix eslint rule
// eslint-disable-next-line no-useless-escape
match: /\i===\i\.PlatformTypes\.WINDOWS/g,
replace: "true"
},
{
// TODO: Fix eslint rule
// eslint-disable-next-line no-useless-escape
match: /\i===\i\.PlatformTypes\.WEB/g,
replace: "false"
}
] ]
} }
] ]