Файли
openidea/src/platform/platformInfo.ts
T
Piettro CastroтаClaude Opus 5.5 ec5302d838 fix(linux): draw GTK's CSD shadow on frameless windows under Wayland
tao makes frameless Wayland windows client-side decorated (an empty GTK
title bar, so the compositor adds no frame) but leaves them undecorated,
so GTK draws no shadow or resize margin and dark windows blend into
whatever is behind them. Decorating the window after build keeps that
empty title bar: GTK adds the theme's shadow and resize edges, nothing
else. Applies to project windows and the Settings window; X11 is
unchanged (decorating there would bring back the WM frame).

- Detect Wayland from GDK's backend (tao's own test), not env vars.
- Measure windows by GTK's content size, which excludes the shadow
  margin, so remembered geometry and Settings placement don't grow.
- Skip the in-page resize handles on Wayland; GTK provides the edges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 00:14:14 -05:00

52 рядки
1.7 KiB
TypeScript

import { create } from "zustand";
import { commands, isTauri } from "@/platform/ipc";
interface PlatformInfo {
/** `macos` | `windows` | `linux` | `web`. */
os: string;
version: string | null;
/** Native traffic lights overlay the title bar (Tauri, macOS, Overlay style). */
overlayTitleBar: boolean;
/** Frameless window: the title bar draws the main menu and caption buttons (Tauri, Windows and Linux). */
framelessTitleBar: boolean;
/** Linux on a Wayland display: GTK draws the frameless windows' shadow and resize edges. */
wayland: boolean;
}
/** OS from the user agent (before the backend answers, or in a browser). "darwin" must not read as Windows. */
export function guessOs(): "macos" | "windows" | "linux" | "web" {
if (typeof navigator === "undefined") return "web";
const ua = navigator.userAgent;
if (/Mac|darwin/i.test(ua)) return "macos";
if (/Windows|Win32|Win64/i.test(ua)) return "windows";
if (/Linux/i.test(ua)) return "linux";
return "web";
}
export const usePlatform = create<PlatformInfo>(() => {
const os = guessOs();
return {
os,
version: null,
overlayTitleBar: isTauri() && os === "macos",
framelessTitleBar: isTauri() && (os === "windows" || os === "linux"),
wayland: false,
};
});
export async function loadPlatformInfo() {
if (!isTauri()) return;
try {
const info = await commands.appInfo();
usePlatform.setState({
os: info.platform,
version: info.version,
overlayTitleBar: info.platform === "macos",
framelessTitleBar: info.platform === "windows" || info.platform === "linux",
wayland: info.wayland,
});
} catch {
/* keep the user-agent guess */
}
}