refactor(ags overview): restructure window func to have easy refs
This commit is contained in:
parent
3b65abac7e
commit
8307198659
2 changed files with 47 additions and 41 deletions
|
@ -16,18 +16,17 @@ export const Highlighter = () => Box({
|
|||
css: DEFAULT_STYLE,
|
||||
});
|
||||
|
||||
export const updateCurrentWorkspace = self => {
|
||||
self = self.get_parent().get_children()[1];
|
||||
export const updateCurrentWorkspace = (main, highlighter) => {
|
||||
const currentId = Hyprland.active.workspace.id;
|
||||
const row = Math.floor((currentId - 1) / VARS.WORKSPACE_PER_ROW);
|
||||
|
||||
const rowObject = self.get_parent().get_children()[0].children[0].children[row];
|
||||
const rowObject = main.children[0].children[row];
|
||||
const workspaces = rowObject.child.centerWidget.child.get_children().filter(w => w.revealChild);
|
||||
|
||||
const height = row * (VARS.SCREEN.Y * VARS.SCALE + 17);
|
||||
const currentIndex = workspaces.findIndex(w => w._id == currentId);
|
||||
|
||||
self.setCss(`
|
||||
highlighter.setCss(`
|
||||
${DEFAULT_STYLE}
|
||||
margin-left: ${9 + currentIndex * (VARS.SCREEN.X * VARS.SCALE + 34)}px;
|
||||
margin-top: ${9 + height}px;
|
||||
|
|
|
@ -9,26 +9,19 @@ import { Highlighter, updateCurrentWorkspace } from './current-workspace.js';
|
|||
import { updateClients } from './clients.js';
|
||||
|
||||
|
||||
function update(box) {
|
||||
function update(box, highlight) {
|
||||
getWorkspaces(box);
|
||||
updateWorkspaces(box);
|
||||
updateClients(box);
|
||||
updateCurrentWorkspace(box);
|
||||
updateCurrentWorkspace(box, highlight);
|
||||
}
|
||||
|
||||
// FIXME: can't drag in workspaces that are before the highlight
|
||||
// TODO: have a 'page' for each monitor, arrows on both sides to loop through
|
||||
export default () => PopupWindow({
|
||||
name: 'overview',
|
||||
closeOnUnfocus: 'none',
|
||||
onOpen: child => update(child.child),
|
||||
export default () => {
|
||||
const highlighter = Highlighter();
|
||||
|
||||
child: Overlay({
|
||||
// FIXME: see if we can get rid of this timeout
|
||||
setup: self => timeout(1, () => self.pass_through = true),
|
||||
|
||||
overlays: [Highlighter()],
|
||||
child: Box({
|
||||
const mainBox = Box({
|
||||
className: 'overview',
|
||||
vertical: true,
|
||||
children: [
|
||||
|
@ -49,12 +42,26 @@ export default () => PopupWindow({
|
|||
if (!App.getWindow('overview').visible)
|
||||
return;
|
||||
|
||||
update(self);
|
||||
update(self, highlighter);
|
||||
}]],
|
||||
properties: [
|
||||
['workspaces'],
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
const window = PopupWindow({
|
||||
name: 'overview',
|
||||
closeOnUnfocus: 'none',
|
||||
onOpen: () => update(mainBox, highlighter),
|
||||
|
||||
child: Overlay({
|
||||
// FIXME: see if we can get rid of this timeout
|
||||
setup: self => timeout(1, () => self.pass_through = true),
|
||||
|
||||
overlays: [highlighter],
|
||||
child: mainBox,
|
||||
}),
|
||||
|
||||
});
|
||||
});
|
||||
return window;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue