fix: don't show rounded window in maximized or fullscreen mode on (#2001)

Linux, closes #1998
This commit is contained in:
Huang Xin
2025-09-09 01:32:15 +08:00
committed by GitHub
parent 79d39b2295
commit 0d8b877d73
6 changed files with 47 additions and 17 deletions
+22 -1
View File
@@ -1,6 +1,7 @@
import { getCurrentWindow } from '@tauri-apps/api/window';
import { emitTo, TauriEvent } from '@tauri-apps/api/event';
import { exit } from '@tauri-apps/plugin-process';
import { type as osType } from '@tauri-apps/plugin-os';
import { eventDispatcher } from './event';
export const tauriGetWindowLogicalPosition = async () => {
@@ -14,6 +15,20 @@ export const tauriHandleMinimize = async () => {
getCurrentWindow().minimize();
};
// workaround to reset transparent background when toggling fullscreen/maximize
const linuxWindowRestoreTransparentBg = async () => {
const currentSize = await getCurrentWindow().innerSize();
currentSize.width -= 1;
currentSize.height -= 1;
await getCurrentWindow().setSize(currentSize);
setTimeout(async () => {
const currentSize = await getCurrentWindow().innerSize();
currentSize.width += 1;
currentSize.height += 1;
await getCurrentWindow().setSize(currentSize);
}, 100);
};
export const tauriHandleToggleMaximize = async () => {
const currentWindow = getCurrentWindow();
const isFullscreen = await currentWindow.isFullscreen();
@@ -21,7 +36,10 @@ export const tauriHandleToggleMaximize = async () => {
await currentWindow.setFullscreen(false);
await currentWindow.unmaximize();
} else {
getCurrentWindow().toggleMaximize();
await currentWindow.toggleMaximize();
}
if ((await osType()) === 'linux') {
linuxWindowRestoreTransparentBg();
}
};
@@ -51,6 +69,9 @@ export const tauriHandleToggleFullScreen = async () => {
} else {
await currentWindow.setFullscreen(!isFullscreen);
}
if ((await osType()) === 'linux') {
linuxWindowRestoreTransparentBg();
}
};
export const tauriHandleSetAlwaysOnTop = async (isAlwaysOnTop: boolean) => {