2023-10-31 08:32:40 -04:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
|
|
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
|
|
|
import { Box, Overlay } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-09-19 23:24:46 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
import PopupWindow from '../misc/popup.js';
|
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 12:31:39 -05:00
|
|
|
function update(box, highlight) {
|
2023-10-20 23:11:21 -04:00
|
|
|
getWorkspaces(box);
|
|
|
|
updateWorkspaces(box);
|
|
|
|
updateClients(box);
|
2023-11-07 12:31:39 -05:00
|
|
|
updateCurrentWorkspace(box, highlight);
|
2023-10-12 19:37:26 -04:00
|
|
|
}
|
2023-10-02 12:06:35 -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-07 12:31:39 -05:00
|
|
|
export default () => {
|
|
|
|
const highlighter = Highlighter();
|
|
|
|
|
|
|
|
const mainBox = Box({
|
2023-11-07 13:00:29 -05:00
|
|
|
// do this for scss hierarchy
|
2023-11-07 12:31:39 -05:00
|
|
|
className: '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-07 12:31:39 -05:00
|
|
|
children: [
|
|
|
|
Box({
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
WorkspaceRow('normal', 0),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
Box({
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
WorkspaceRow('special', 0),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
connections: [[Hyprland, self => {
|
|
|
|
if (!App.getWindow('overview').visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
update(self, highlighter);
|
|
|
|
}]],
|
|
|
|
properties: [
|
|
|
|
['workspaces'],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const window = PopupWindow({
|
|
|
|
name: 'overview',
|
|
|
|
closeOnUnfocus: 'none',
|
|
|
|
onOpen: () => update(mainBox, highlighter),
|
|
|
|
|
|
|
|
child: Overlay({
|
2023-11-07 13:00:29 -05:00
|
|
|
overlays: [highlighter, mainBox],
|
2023-11-07 12:31:39 -05:00
|
|
|
|
2023-11-07 13:00:29 -05:00
|
|
|
child: Box({
|
|
|
|
className: 'overview',
|
|
|
|
css: `
|
|
|
|
min-height: ${mainBox.get_allocated_height()}px;
|
|
|
|
min-width: ${mainBox.get_allocated_width()}px;
|
|
|
|
`,
|
|
|
|
}),
|
|
|
|
// TODO: throttle his?
|
|
|
|
connections: [['get-child-position', (self, ch) => {
|
|
|
|
if (ch === mainBox) {
|
|
|
|
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-10-30 22:00:46 -04:00
|
|
|
}),
|
2023-10-08 00:43:35 -04:00
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
});
|
|
|
|
return window;
|
|
|
|
};
|