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
|
|
|
|
2023-09-23 18:41:05 -04:00
|
|
|
import { WorkspaceRow, getWorkspaces, updateWorkspaces } from './workspaces.js';
|
2023-10-30 22:00:46 -04:00
|
|
|
import { Highlighter, updateCurrentWorkspace } from './current-workspace.js';
|
2023-09-23 18:41:05 -04:00
|
|
|
import { updateClients } from './clients.js';
|
2023-09-19 23:24:46 -04: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;
|
|
|
|
}
|
|
|
|
|
2023-12-23 01:14:21 -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) {
|
2023-12-23 01:14:21 -05:00
|
|
|
// @ts-expect-error
|
2023-12-17 00:01:58 -05:00
|
|
|
self.child.setCss(`
|
|
|
|
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) => {
|
|
|
|
Hyprland.sendMessage('[[BATCH]] ' +
|
|
|
|
`keyword layerrule ignorealpha[0.97],${self.name}; ` +
|
|
|
|
`keyword layerrule blur,${self.name}
|
|
|
|
`);
|
|
|
|
|
|
|
|
self.hook(App, (_, currentName, isOpen) => {
|
|
|
|
if (currentName === self.name) {
|
|
|
|
if (isOpen) {
|
|
|
|
self.child = Overview();
|
|
|
|
self.show_all();
|
|
|
|
// @ts-expect-error
|
|
|
|
self.child.attribute.get_child().attribute.update();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// @ts-expect-error
|
|
|
|
self.child.attribute.closing = true;
|
|
|
|
// @ts-expect-error
|
|
|
|
self.child.child.css = `
|
|
|
|
min-height: 1px;
|
|
|
|
min-width: 1px;
|
|
|
|
transition: all
|
|
|
|
${transition_duration - 10}ms ease;
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
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
|
|
|
};
|