Files
openidea/src/workbench/windowButtons.ts
T
Bert Verhelstandbertyhell 77e6679701 feat(ui): the frameless title bar follows the desktop's window button layout (#3817)
On Linux the frameless title bar reads the desktop's button layout (GTK decoration layout / GNOME button-layout) and places close, minimize and maximize on the left or right in that order; auxiliary windows such as Settings follow it. Other platforms and the default layout are unchanged. Verified on Ubuntu GNOME (Wayland) with left and right layouts.

Closes #3794

Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
2026-11-17 03:45:50 +08:00

17 lines
762 B
TypeScript

import type { WindowButton, WindowButtonLayout } from "@/platform/ipc";
export type Side = "left" | "right";
/** A dialog keeps its close button even where the layout leaves close out, on the side the buttons go. */
function closeSide(layout: WindowButtonLayout): Side {
if (layout.left.includes("close")) return "left";
if (layout.right.includes("close") || layout.right.length > 0) return "right";
return layout.left.length > 0 ? "left" : "right";
}
/** The caption buttons on one side of a frameless title bar, left to right. Dialogs only have close. */
export function captionButtons(layout: WindowButtonLayout, side: Side, dialog = false): WindowButton[] {
if (dialog) return closeSide(layout) === side ? ["close"] : [];
return layout[side];
}