2023-11-21 01:29:46 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
2023-10-31 08:32:40 -04:00
|
|
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-30 19:49:08 -05:00
|
|
|
import { Box, Overlay, Window } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-09-19 23:24:46 -04:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.ts';
|
|
|
|
import { Highlighter, updateCurrentWorkspace } from './current-workspace.ts';
|
|
|
|
import { updateClients } from './clients.ts';
|
2023-09-19 23:24:46 -04:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
// Types
|
2024-01-13 23:38:31 -05:00
|
|
|
import AgsBox from 'types/widgets/box.ts';
|
|
|
|
import AgsOverlay from 'types/widgets/overlay.ts';
|
2024-01-13 11:15:08 -05:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
|
2023-11-07 10:56:12 -05:00
|
|
|
// TODO: have a 'page' for each monitor, arrows on both sides to loop through
|
2023-11-28 00:51:28 -05:00
|
|
|
export const Overview = () => {
|
2023-11-07 12:31:39 -05:00
|
|
|
const highlighter = Highlighter();
|
|
|
|
|
|
|
|
const mainBox = Box({
|
2023-11-21 01:29:46 -05:00
|
|
|
// Do this for scss hierarchy
|
2023-12-23 01:14:21 -05:00
|
|
|
class_name: 'overview',
|
2023-11-07 13:00:29 -05:00
|
|
|
css: 'all: unset',
|
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
vertical: true,
|
2023-11-07 13:00:29 -05:00
|
|
|
vpack: 'center',
|
|
|
|
hpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-23 01:14:21 -05:00
|
|
|
attribute: {
|
|
|
|
workspaces: [],
|
|
|
|
|
|
|
|
update: () => {
|
|
|
|
getWorkspaces(mainBox);
|
|
|
|
updateWorkspaces(mainBox);
|
|
|
|
updateClients(mainBox);
|
|
|
|
updateCurrentWorkspace(mainBox, highlighter);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
children: [
|
|
|
|
Box({
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
WorkspaceRow('normal', 0),
|
|
|
|
],
|
|
|
|
}),
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
Box({
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
WorkspaceRow('special', 0),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.hook(Hyprland, () => {
|
2023-12-23 01:14:21 -05:00
|
|
|
if (!App.getWindow('overview')?.visible) {
|
2023-12-17 00:01:58 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-15 09:20:41 -05:00
|
|
|
self.attribute.update();
|
2023-12-17 00:01:58 -05:00
|
|
|
});
|
|
|
|
},
|
2023-11-07 12:31:39 -05:00
|
|
|
});
|
|
|
|
|
2023-11-28 00:51:28 -05:00
|
|
|
const widget = Overlay({
|
|
|
|
overlays: [highlighter, mainBox],
|
|
|
|
|
2023-12-23 01:14:21 -05:00
|
|
|
attribute: {
|
|
|
|
get_child: () => mainBox,
|
2023-12-30 19:49:08 -05:00
|
|
|
closing: false,
|
2023-12-23 01:14:21 -05:00
|
|
|
},
|
|
|
|
|
2023-12-30 19:49:08 -05:00
|
|
|
// Make size of overlay big enough for content
|
2023-11-28 00:51:28 -05:00
|
|
|
child: Box({
|
2023-12-23 01:14:21 -05:00
|
|
|
class_name: 'overview',
|
2023-11-28 00:51:28 -05:00
|
|
|
css: `
|
|
|
|
min-height: ${mainBox.get_allocated_height()}px;
|
|
|
|
min-width: ${mainBox.get_allocated_width()}px;
|
|
|
|
`,
|
|
|
|
}),
|
2023-11-07 12:31:39 -05:00
|
|
|
|
2023-12-27 16:14:14 -05:00
|
|
|
// TODO: throttle this?
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.on('get-child-position', (_, ch) => {
|
2023-12-30 19:49:08 -05:00
|
|
|
if (ch === mainBox && !self.attribute.closing) {
|
2024-01-13 11:15:08 -05:00
|
|
|
(self.child as AgsBox).setCss(`
|
2023-12-17 00:01:58 -05:00
|
|
|
transition: min-height 0.2s ease, min-width 0.2s ease;
|
|
|
|
min-height: ${mainBox.get_allocated_height()}px;
|
|
|
|
min-width: ${mainBox.get_allocated_width()}px;
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-11-28 00:51:28 -05:00
|
|
|
});
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-28 00:51:28 -05:00
|
|
|
return widget;
|
|
|
|
};
|
2023-10-08 00:43:35 -04:00
|
|
|
|
2023-12-30 19:49:08 -05:00
|
|
|
// FIXME: can't use PopupWindow because this is an overlay already
|
2023-11-28 00:51:28 -05:00
|
|
|
export default () => {
|
2023-12-30 19:49:08 -05:00
|
|
|
const transition_duration = 800;
|
|
|
|
const win = Window({
|
2023-11-28 00:51:28 -05:00
|
|
|
name: 'overview',
|
2023-12-30 19:49:08 -05:00
|
|
|
visible: false,
|
|
|
|
|
|
|
|
// Needs this to have space
|
|
|
|
// allocated at the start
|
|
|
|
child: Box({
|
|
|
|
css: `
|
|
|
|
min-height: 1px;
|
|
|
|
min-width: 1px;
|
|
|
|
padding: 1px;
|
|
|
|
`,
|
|
|
|
}),
|
|
|
|
|
|
|
|
attribute: { close_on_unfocus: 'none' },
|
|
|
|
|
|
|
|
setup: (self) => {
|
2024-01-02 16:47:06 -05:00
|
|
|
const name = 'overview';
|
|
|
|
|
2023-12-30 19:49:08 -05:00
|
|
|
Hyprland.sendMessage('[[BATCH]] ' +
|
2024-01-02 16:47:06 -05:00
|
|
|
`keyword layerrule ignorealpha[0.97],${name}; ` +
|
|
|
|
`keyword layerrule blur,${name}`);
|
2023-12-30 19:49:08 -05:00
|
|
|
|
|
|
|
self.hook(App, (_, currentName, isOpen) => {
|
|
|
|
if (currentName === self.name) {
|
|
|
|
if (isOpen) {
|
|
|
|
self.child = Overview();
|
|
|
|
self.show_all();
|
2024-01-15 09:20:41 -05:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
(self.child as AgsOverlay)
|
|
|
|
.attribute.get_child().attribute.update();
|
2023-12-30 19:49:08 -05:00
|
|
|
}
|
|
|
|
else {
|
2024-01-13 11:15:08 -05:00
|
|
|
(self.child as AgsOverlay).attribute.closing = true;
|
2024-01-15 09:20:41 -05:00
|
|
|
|
|
|
|
((self.child as AgsOverlay)
|
|
|
|
.child as AgsBox).css = `
|
|
|
|
min-height: 1px;
|
|
|
|
min-width: 1px;
|
|
|
|
transition: all
|
|
|
|
${transition_duration - 10}ms ease;
|
|
|
|
`;
|
2023-12-30 19:49:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2023-11-28 00:51:28 -05:00
|
|
|
},
|
2023-11-07 12:31:39 -05:00
|
|
|
});
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-18 23:20:32 -05:00
|
|
|
return win;
|
2023-11-07 12:31:39 -05:00
|
|
|
};
|