⚡ ags(apps-window, osd): drop astal variables on ::destroy
This commit is contained in:
@@ -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) => {
|
||||
|
||||
+20
-7
@@ -7,8 +7,18 @@ 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 "";
|
||||
@@ -16,11 +26,7 @@ let osdIcon: Binding<string | undefined> = osdMode().as((mode: OSDModes) => {
|
||||
}
|
||||
});
|
||||
|
||||
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: [
|
||||
@@ -77,3 +89,4 @@ export const OSD = (mon: number) => new Widget.Window({
|
||||
]
|
||||
} as Widget.BoxProps)
|
||||
} as Widget.WindowProps);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user