diff --git a/devices/wim/config/ags/js/overview/current-workspace.js b/devices/wim/config/ags/js/overview/current-workspace.js index ab898132..7fd1fb3d 100644 --- a/devices/wim/config/ags/js/overview/current-workspace.js +++ b/devices/wim/config/ags/js/overview/current-workspace.js @@ -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; diff --git a/devices/wim/config/ags/js/overview/main.js b/devices/wim/config/ags/js/overview/main.js index 7a5edfdd..12035e6c 100644 --- a/devices/wim/config/ags/js/overview/main.js +++ b/devices/wim/config/ags/js/overview/main.js @@ -9,52 +9,59 @@ 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), + const mainBox = Box({ + className: 'overview', + vertical: true, + children: [ + Box({ + vertical: true, + children: [ + WorkspaceRow('normal', 0), + ], + }), + Box({ + vertical: true, + children: [ + WorkspaceRow('special', 0), + ], + }), + ], + connections: [[Hyprland, self => { + if (!App.getWindow('overview').visible) + return; - overlays: [Highlighter()], - child: Box({ - className: 'overview', - vertical: true, - 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'], + ], + }); - update(self); - }]], - 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; +};