💥 ags: fix startup issues (and with that, errors with focusedClient bar widget)

This commit is contained in:
retrozinndev
2025-02-04 21:45:18 -03:00
parent 11f919ab1d
commit 80969071c4
21 changed files with 363 additions and 200 deletions
+49 -62
View File
@@ -9,66 +9,53 @@ import { Audio } from "../widget/bar/Audio";
import { FocusedWindow } from "../widget/bar/FocusedWindow";
//import { Media } from "../widget/bar/Media";
interface BarProps {
monitor: number;
width?: number;
height?: number;
}
export const Bar: Widget.Window = newBar({
monitor: 0
} as BarProps);
function newBar(props: BarProps): Widget.Window {
return new Widget.Window({
className: "bar",
monitor: props.monitor,
namespace: "top-bar",
anchor: Astal.WindowAnchor.TOP,
layer: Astal.Layer.TOP,
exclusivity: Astal.Exclusivity.EXCLUSIVE,
canFocus: false,
visible: true, // Recommendation: set visible to false if you don't want this window to appear on app start
heightRequest: props.height || 0,
widthRequest: props.width || Gdk.Screen.get_default()?.get_monitor_geometry(props.monitor)?.width,
hexpand: false,
vexpand: false,
child: new Widget.Box({
className: "bar-container",
child: new Widget.CenterBox({
className: "bar-centerbox",
expand: true,
export const Bar: Widget.Window = new Widget.Window({
className: "bar",
monitor: 0,
namespace: "top-bar",
anchor: Astal.WindowAnchor.TOP,
layer: Astal.Layer.TOP,
exclusivity: Astal.Exclusivity.EXCLUSIVE,
canFocus: false,
visible: true,
widthRequest: Gdk.Screen.get_default()?.get_monitor_geometry(0)?.width,
hexpand: false,
vexpand: false,
child: new Widget.Box({
className: "bar-container",
child: new Widget.CenterBox({
className: "bar-centerbox",
expand: true,
homogeneous: false,
startWidget: new Widget.Box({
className: "widgets-left",
homogeneous: false,
startWidget: new Widget.Box({
className: "widgets-left",
homogeneous: false,
halign: Gtk.Align.START,
children: [
Logo(),
Workspaces(),
FocusedWindow()
]
} as Widget.BoxProps),
centerWidget: new Widget.Box({
className: "widgets-center",
homogeneous: false,
halign: Gtk.Align.CENTER,
children: [
Clock(),
/*<Media />*/
]
} as Widget.BoxProps),
endWidget: new Widget.Box({
className: "widgets-right",
homogeneous: false,
halign: Gtk.Align.END,
children: [
Tray(),
Audio(),
CCToggle()
]
} as Widget.BoxProps)
} as Widget.CenterBoxProps)
} as Widget.BoxProps)
} as Widget.WindowProps);
}
halign: Gtk.Align.START,
children: [
Logo(),
Workspaces(),
FocusedWindow()
]
} as Widget.BoxProps),
centerWidget: new Widget.Box({
className: "widgets-center",
homogeneous: false,
halign: Gtk.Align.CENTER,
children: [
Clock(),
/*<Media />*/
]
} as Widget.BoxProps),
endWidget: new Widget.Box({
className: "widgets-right",
homogeneous: false,
halign: Gtk.Align.END,
children: [
Tray(),
Audio(),
CCToggle()
]
} as Widget.BoxProps)
} as Widget.CenterBoxProps)
} as Widget.BoxProps)
} as Widget.WindowProps);
+20 -26
View File
@@ -1,31 +1,25 @@
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
import { QuickActionsWidget } from "../widget/control-center/QuickActions";
import { QuickActions } from "../widget/control-center/QuickActions";
import { Bar } from "./Bar";
import { Tiles } from "../widget/control-center/Tiles";
export const ControlCenter: Widget.Window = CC();
export const widgetsBox: Widget.Box = new Widget.Box({
visible: true,
const monitorHeight: number = Gdk.Screen.get_default()?.get_monitor_geometry(0)?.height!;
const widgetsContainer: Widget.Box = new Widget.Box({
className: "control-center-container",
orientation: Gtk.Orientation.VERTICAL,
children: [
QuickActionsWidget()
]
} as Widget.BoxProps);
} as Widget.BoxProps,
QuickActions,
Tiles);
widgetsBox.connect("add", (_: Widget.Box, widget: Gtk.Widget) => {
widget.set_size_request(widgetsBox.get_allocated_width(), widget.get_allocated_height());
});
function CC(): Widget.Window {
return new Widget.Window({
className: "control-center",
namespace: "control-center",
canFocus: true,
exclusivity: Astal.Exclusivity.NORMAL,
anchor: Astal.WindowAnchor.RIGHT,
width_request: 450,
height_request: Gdk.Screen.get_default()?.get_monitor_geometry(0)?.height || 800,
monitor: 0,
visible: false,
child: widgetsBox
} as Widget.WindowProps);
}
export const ControlCenter: Widget.Window = new Widget.Window({
className: "control-center",
namespace: "control-center",
canFocus: true,
exclusivity: Astal.Exclusivity.NORMAL,
anchor: Astal.WindowAnchor.RIGHT,
width_request: 450,
height_request: Bar.is_visible() ? monitorHeight - Bar.get_size()[1] - 18 : 700,
monitor: 0,
visible: false
} as Widget.WindowProps, widgetsContainer);