mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
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>
17 lines
762 B
TypeScript
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];
|
|
}
|