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

35 lines
791 B
JavaScript

import { App, Widget } from '../../imports.js';
const { Window, EventBox } = Widget;
const ALWAYS_OPEN = [
'closer',
'bar',
'notifications',
];
// TODO: close on scroll event too?
export const closeAll = () => {
App.windows.forEach(w => {
if (!ALWAYS_OPEN.some(window => window === w.name))
App.closeWindow(w.name)
});
App.closeWindow('closer');
};
export const Closer = Window({
name: 'closer',
popup: true,
layer: 'top',
anchor: [ 'top', 'bottom', 'left', 'right' ],
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]))) {
App.closeWindow('closer');
}
}]],
}),
});