[WIP] Port Discord's windows title bar

This commit is contained in:
V 2023-08-06 23:58:35 +02:00
parent 26b6fb13d4
commit 0101482774
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
5 changed files with 47 additions and 2 deletions

View file

@ -73,7 +73,19 @@ ipcMain.handle(IpcEvents.FOCUS, () => {
});
ipcMain.handle(IpcEvents.CLOSE, e => {
e.sender.close();
mainWin.close();
});
ipcMain.handle(IpcEvents.MINIMIZE, e => {
mainWin.minimize();
});
ipcMain.handle(IpcEvents.MAXIMIZE, e => {
mainWin.maximize();
});
ipcMain.handle(IpcEvents.FULLSCREEN, e => {
mainWin.setFullScreen(true);
});
ipcMain.handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {

View file

@ -51,7 +51,11 @@ export const VesktopNative = {
addToDictionary: (word: string) => invoke<void>(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, word)
},
win: {
focus: () => invoke<void>(IpcEvents.FOCUS)
focus: () => invoke<void>(IpcEvents.FOCUS),
close: () => invoke<void>(IpcEvents.CLOSE),
minimize: () => invoke<void>(IpcEvents.MINIMIZE),
fullscreen: () => invoke<void>(IpcEvents.FULLSCREEN),
maximize: () => invoke<void>(IpcEvents.MAXIMIZE)
},
capturer: {
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)

View file

@ -7,3 +7,4 @@
// TODO: Possibly auto generate glob if we have more patches in the future
import "./spellCheck";
import "./platformClass";
import "./windowsTitleBar";

View file

@ -0,0 +1,25 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { addPatch } from "./shared";
addPatch({
patches: [
{
find: ".wordmarkWindows",
replacement: [
{
match: /case \i\.\i\.WINDOWS:/,
replace: 'case "WEB":'
},
...["close", "minimize", "fullscreen", "maximize"].map(op => ({
match: new RegExp(String.raw`\i\.default\.${op}\b`),
replace: `VesktopNative.win.${op}`
}))
]
}
]
});

View file

@ -16,6 +16,9 @@ export const enum IpcEvents {
RELAUNCH = "VCD_RELAUNCH",
CLOSE = "VCD_CLOSE",
FOCUS = "VCD_FOCUS",
MINIMIZE = "VCD_MINIMIZE",
FULLSCREEN = "VCD_FULLSCREEN",
MAXIMIZE = "VCD_MAXIMIZE",
SHOW_ITEM_IN_FOLDER = "VCD_SHOW_ITEM_IN_FOLDER",
GET_SETTINGS = "VCD_GET_SETTINGS",