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-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-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-11-28 00:51:28 -05:00
|
|
|
// TODO: throttle his?
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.on('get-child-position', (_, ch) => {
|
|
|
|
if (ch === mainBox) {
|
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-11-28 00:51:28 -05:00
|
|
|
export default () => {
|
2023-12-18 23:20:32 -05:00
|
|
|
const win = PopupWindow({
|
2023-11-28 00:51:28 -05:00
|
|
|
name: 'overview',
|
2023-12-08 00:01:43 -05:00
|
|
|
blur: true,
|
2023-12-18 23:20:32 -05:00
|
|
|
close_on_unfocus: 'none',
|
|
|
|
onOpen: () => {
|
|
|
|
win.attribute.set_child(Overview());
|
2023-12-23 01:14:21 -05:00
|
|
|
win.attribute.get_child().attribute.get_child().attribute.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-12-18 23:20:32 -05:00
|
|
|
return win;
|
2023-11-07 12:31:39 -05:00
|
|
|
};
|