2023-09-12 09:37:48 -04:00
|
|
|
const { Window, EventBox } = ags.Widget;
|
2023-09-12 14:42:53 -04:00
|
|
|
const { closeWindow } = ags.App;
|
|
|
|
|
2023-09-14 13:33:59 -04:00
|
|
|
// TODO: close on scroll event too?
|
2023-09-13 19:04:23 -04:00
|
|
|
export const closeAll = () => {
|
|
|
|
ags.App.windows.forEach(w => {
|
|
|
|
if (w.name != 'bar' &&
|
|
|
|
w.name != 'notifications')
|
|
|
|
ags.App.closeWindow(w.name)
|
|
|
|
});
|
|
|
|
};
|
2023-09-12 09:37:48 -04:00
|
|
|
|
|
|
|
export const Closer = Window({
|
2023-09-11 19:57:21 -04:00
|
|
|
name: 'closer',
|
|
|
|
popup: true,
|
|
|
|
layer: 'top',
|
|
|
|
anchor: 'top bottom left right',
|
|
|
|
|
2023-09-12 09:37:48 -04:00
|
|
|
child: EventBox({
|
2023-09-12 14:42:53 -04:00
|
|
|
onPrimaryClickRelease: () => closeAll(),
|
2023-09-18 17:39:10 -04:00
|
|
|
connections: [[ags.App, (box, windowName, visible) => {
|
|
|
|
if (!Array.from(ags.App.windows).some(w => w[1].visible && w[0] != 'bar' && w[0] != 'notifications' && w[0] != 'closer')) {
|
|
|
|
closeWindow('closer');
|
|
|
|
}
|
|
|
|
}]],
|
2023-09-11 19:57:21 -04:00
|
|
|
}),
|
|
|
|
});
|