nixos-configs/devices/wim/config/ags/js/bar/fullscreen.js

87 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-11-16 00:48:50 -05:00
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
import { Box, EventBox, Revealer, Window } from 'resource:///com/github/Aylur/ags/widget.js';
2023-12-18 18:00:30 -05:00
/** @param {import('types/variable.js').Variable} variable */
const BarCloser = (variable) => Window({
2023-11-16 00:48:50 -05:00
name: 'bar-closer',
visible: false,
anchor: ['top', 'bottom', 'left', 'right'],
layer: 'overlay',
2023-11-16 00:48:50 -05:00
child: EventBox({
2023-12-18 18:00:30 -05:00
on_hover: (self) => {
2023-11-16 00:48:50 -05:00
variable.value = false;
2023-12-18 18:00:30 -05:00
// @ts-expect-error
2023-11-16 00:48:50 -05:00
self.get_parent().visible = false;
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'padding: 1px',
}),
}),
});
2023-12-18 18:00:30 -05:00
/** @param {import('types/widgets/revealer').RevealerProps} props */
export default (props) => {
2023-11-16 00:48:50 -05:00
const Revealed = Variable(true);
const barCloser = BarCloser(Revealed);
return Box({
css: 'min-height: 1px',
hexpand: true,
vertical: true,
setup: (self) => {
const checkCurrentWsFsState = () => {
const workspace = Hyprland.getWorkspace(
Hyprland.active.workspace.id,
);
if (workspace) {
Revealed.value = !workspace['hasfullscreen'];
}
};
/**
* @param {import('types/widgets/box').default} _
* @param {boolean} fullscreen
*/
const checkGlobalFsState = (_, fullscreen) => {
Revealed.value = !fullscreen;
};
self
.hook(Hyprland.active, checkCurrentWsFsState)
.hook(Hyprland, checkGlobalFsState, 'fullscreen');
},
2023-11-16 00:48:50 -05:00
children: [
Revealer({
...props,
2023-11-16 00:48:50 -05:00
transition: 'slide_down',
2023-12-18 18:00:30 -05:00
reveal_child: true,
2023-11-16 00:48:50 -05:00
binds: [['revealChild', Revealed, 'value']],
}),
2023-11-16 00:48:50 -05:00
Revealer({
binds: [['revealChild', Revealed, 'value', (v) => !v]],
2023-11-16 00:48:50 -05:00
child: EventBox({
2023-12-18 18:00:30 -05:00
on_hover: () => {
2023-11-16 00:48:50 -05:00
barCloser.visible = true;
Revealed.value = true;
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'min-height: 5px;',
}),
}),
}),
2023-11-16 00:48:50 -05:00
],
});
};