ags(apps-window, osd): drop astal variables on ::destroy

This commit is contained in:
retrozinndev
2025-05-11 22:24:18 -03:00
parent b1eef4285f
commit 89fe8c36b3
2 changed files with 79 additions and 65 deletions
+1
View File
@@ -117,6 +117,7 @@ export const AppsWindow = (mon: number): (Widget.Window) => {
marginTop: 64,
onDestroy: () => {
searchSubscription?.();
searchString.drop();
flowboxConnections.map(id => flowbox.disconnect(id));
},
onKeyPressEvent: (_, event: Gdk.Event) => {
+22 -9
View File
@@ -7,20 +7,26 @@ export enum OSDModes {
BRIGHTNESS
}
let osdMode: Variable<OSDModes> = new Variable<OSDModes>(OSDModes.SINK);
let osdIcon: Binding<string | undefined> = osdMode().as((mode: OSDModes) => {
let osdMode: (Variable<OSDModes>|null);
let osdIcon: (Binding<string | undefined>|null);
export function setOSDMode(newMode: OSDModes): void {
if(!osdMode) return;
osdMode.set(newMode);
}
export const OSD = (mon: number) => {
osdMode = new Variable<OSDModes>(OSDModes.SINK);
osdIcon = osdMode().as((mode: OSDModes) => {
switch(mode) {
case OSDModes.SINK: return "󰕾";
case OSDModes.BRIGHTNESS: return "󰃠";
default: return "󱧣";
}
});
});
export function setOSDMode(newMode: OSDModes): void {
osdMode.set(newMode);
}
export const OSD = (mon: number) => new Widget.Window({
return new Widget.Window({
namespace: "osd",
layer: Astal.Layer.OVERLAY,
anchor: Astal.WindowAnchor.BOTTOM,
@@ -29,6 +35,12 @@ export const OSD = (mon: number) => new Widget.Window({
focusOnClick: false,
clickThrough: true,
monitor: mon,
onDestroy: () => {
osdMode?.drop();
osdMode = null;
osdIcon = null;
},
child: new Widget.Box({
className: "osd",
children: [
@@ -76,4 +88,5 @@ export const OSD = (mon: number) => new Widget.Window({
} as Widget.BoxProps)
]
} as Widget.BoxProps)
} as Widget.WindowProps);
} as Widget.WindowProps);
}