nixos-configs/hosts/wim/config/ags/js/misc/closer.js

36 lines
791 B
JavaScript
Raw Normal View History

import { App, Widget } from '../../imports.js';
const { Window, EventBox } = Widget;
const ALWAYS_OPEN = [
'closer',
'bar',
'notifications',
];
2023-09-14 13:33:59 -04:00
// TODO: close on scroll event too?
export const closeAll = () => {
App.windows.forEach(w => {
if (!ALWAYS_OPEN.some(window => window === w.name))
2023-10-14 13:54:45 -04:00
App.closeWindow(w.name)
});
2023-10-14 13:54:45 -04:00
App.closeWindow('closer');
};
export const Closer = Window({
2023-09-11 19:57:21 -04:00
name: 'closer',
popup: true,
layer: 'top',
2023-10-07 21:02:23 -04:00
anchor: [ 'top', 'bottom', 'left', 'right' ],
2023-09-11 19:57:21 -04:00
child: EventBox({
onPrimaryClickRelease: () => closeAll(),
connections: [[App, (_b, _w, _v) => {
if (!Array.from(App.windows).some(w => w[1].visible &&
!ALWAYS_OPEN.some(window => window === w[0]))) {
2023-10-14 13:54:45 -04:00
App.closeWindow('closer');
}
}]],
2023-09-11 19:57:21 -04:00
}),
});