Fix Visual Refresh titlebar (#1104)
Some checks failed
test / test (push) Failing after 5m35s

This commit is contained in:
Sqaaakoi 2025-04-05 02:44:47 +13:00 committed by GitHub
parent 765ffc0b57
commit c42c1b7bbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 52 additions and 22 deletions

View file

@ -7,7 +7,17 @@
if (process.platform === "linux") import("./venmic");
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 { open, readFile } from "fs/promises";
import { release } from "os";
@ -68,28 +78,29 @@ handle(IpcEvents.SHOW_ITEM_IN_FOLDER, (_, path) => {
shell.showItemInFolder(path);
});
function getWindow(e: IpcMainInvokeEvent, key?: string) {
return key ? PopoutWindows.get(key)! : (BrowserWindow.fromWebContents(e.sender) ?? mainWin);
}
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();
}
});

View file

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

View file

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

View file

@ -9,13 +9,18 @@ import { addPatch } from "./shared";
addPatch({
patches: [
{
find: ".DEEP_LINK]:{",
find: ",setSystemTrayApplications",
replacement: [
{
// eslint-disable-next-line no-useless-escape
match: /\i\.window\.(close|minimize|maximize)/,
replace: `VesktopNative.win.$1`
},
{
// 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"
}
]
}

View file

@ -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"
}
]
}
]