fix(desktop): use custom window controls on Linux
This commit is contained in:
1 parent
676dcdb490
commit
367d3682d2
3 files changed
+31
-5
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { shouldReserveMacTrafficLightInset, shouldShowWindowControls } from "@/composables/useWindowControls";
|
||||
|
||||
describe("window controls", () => {
|
||||
it("shows custom controls for non-macOS desktop windows", () => {
|
||||
expect(shouldShowWindowControls(false, true)).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps macOS on native traffic lights", () => {
|
||||
expect(shouldShowWindowControls(true, true)).toBe(false);
|
||||
});
|
||||
|
||||
it("does not show desktop controls in web runtime", () => {
|
||||
expect(shouldShowWindowControls(false, false)).toBe(false);
|
||||
});
|
||||
|
||||
it("reserves traffic light inset only for non-fullscreen macOS desktop windows", () => {
|
||||
expect(shouldReserveMacTrafficLightInset(true, false, true)).toBe(true);
|
||||
expect(shouldReserveMacTrafficLightInset(true, true, true)).toBe(false);
|
||||
expect(shouldReserveMacTrafficLightInset(false, false, true)).toBe(false);
|
||||
expect(shouldReserveMacTrafficLightInset(true, false, false)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,17 +1,21 @@
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
import { isTauriRuntime } from "@/lib/tauriRuntime";
|
||||
import { isMacOS, isWindows } from "@/lib/platform";
|
||||
import { isMacOS } from "@/lib/platform";
|
||||
|
||||
export function shouldReserveMacTrafficLightInset(isMac: boolean, isFullscreen: boolean, isDesktop = true): boolean {
|
||||
return isDesktop && isMac && !isFullscreen;
|
||||
}
|
||||
|
||||
export function shouldShowWindowControls(isMac: boolean, isDesktop = true): boolean {
|
||||
return isDesktop && !isMac;
|
||||
}
|
||||
|
||||
export function useWindowControls() {
|
||||
const isMaximized = ref(false);
|
||||
const isFullscreen = ref(false);
|
||||
const isMac = isMacOS();
|
||||
const isDesktop = isTauriRuntime();
|
||||
const showControls = isDesktop && isWindows();
|
||||
const showControls = shouldShowWindowControls(isMac, isDesktop);
|
||||
|
||||
let unlisten: (() => void) | null = null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user