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-10-31 08:32:40 -04:00
|
|
|
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-28 00:51:28 -05: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-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-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-21 01:29:46 -05:00
|
|
|
|
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
|
|
|
|
|
|
|
connections: [[Hyprland, (self) => {
|
|
|
|
if (!App.getWindow('overview').visible) {
|
2023-11-07 12:31:39 -05:00
|
|
|
return;
|
2023-11-21 01:29:46 -05:00
|
|
|
}
|
2023-11-07 12:31:39 -05:00
|
|
|
|
2023-11-28 00:51:28 -05:00
|
|
|
self.update();
|
2023-11-07 12:31:39 -05:00
|
|
|
}]],
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-07 12:31:39 -05:00
|
|
|
properties: [
|
|
|
|
['workspaces'],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2023-11-28 00:51:28 -05:00
|
|
|
mainBox.update = () => {
|
|
|
|
getWorkspaces(mainBox);
|
|
|
|
updateWorkspaces(mainBox);
|
|
|
|
updateClients(mainBox);
|
|
|
|
updateCurrentWorkspace(mainBox, highlighter);
|
|
|
|
};
|
|
|
|
|
|
|
|
const widget = Overlay({
|
|
|
|
overlays: [highlighter, mainBox],
|
|
|
|
|
|
|
|
child: Box({
|
|
|
|
className: 'overview',
|
|
|
|
css: `
|
|
|
|
min-height: ${mainBox.get_allocated_height()}px;
|
|
|
|
min-width: ${mainBox.get_allocated_width()}px;
|
|
|
|
`,
|
|
|
|
}),
|
2023-11-07 12:31:39 -05:00
|
|
|
|
2023-11-28 00:51:28 -05:00
|
|
|
// 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;
|
2023-11-07 13:00:29 -05:00
|
|
|
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
|
|
|
widget.getChild = () => mainBox;
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
};
|
2023-10-08 00:43:35 -04:00
|
|
|
|
2023-11-28 00:51:28 -05:00
|
|
|
export default () => {
|
|
|
|
const window = PopupWindow({
|
|
|
|
name: 'overview',
|
2023-12-08 00:01:43 -05:00
|
|
|
blur: true,
|
2023-11-28 00:51:28 -05:00
|
|
|
closeOnUnfocus: 'none',
|
2023-12-12 15:11:00 -05:00
|
|
|
onOpen: (win) => {
|
|
|
|
win.setChild(Overview());
|
|
|
|
win.getChild().getChild().update();
|
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-11-07 12:31:39 -05:00
|
|
|
return window;
|
|
|
|
};
|