mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-23 13:45:09 +00:00
ipc: add window key to minimize and maximize methods
This commit is contained in:
parent
da5d0f8f19
commit
fa610acb0d
2 changed files with 17 additions and 13 deletions
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue