forked from Shinonome/dots-hyprland
workspace widget: even faster
This commit is contained in:
@@ -16,14 +16,11 @@ const dummyOccupiedWs = Box({ className: 'bar-ws bar-ws-occupied' }); // Not sho
|
||||
const WorkspaceContents = (count = 10) => {
|
||||
return DrawingArea({
|
||||
properties: [
|
||||
['initialized', false],
|
||||
['workspaceMask', 0],
|
||||
],
|
||||
css: `transition: 500ms cubic-bezier(0.1, 1, 0, 1);`,
|
||||
setup: (area) => area
|
||||
.hook(Hyprland.active.workspace, (area) =>
|
||||
area.setCss(`font-size: ${Hyprland.active.workspace.id}px;`)
|
||||
)
|
||||
.hook(Hyprland, (area) => {
|
||||
['updateMask', (self) => {
|
||||
if(self._initialized) return; // We only need this to run once
|
||||
console.log('update dayo')
|
||||
const workspaces = Hyprland.workspaces;
|
||||
let workspaceMask = 0;
|
||||
for (let i = 0; i < workspaces.length; i++) {
|
||||
@@ -34,8 +31,23 @@ const WorkspaceContents = (count = 10) => {
|
||||
workspaceMask |= (1 << ws.id);
|
||||
}
|
||||
}
|
||||
area._workspaceMask = workspaceMask;
|
||||
}, 'notify::workspaces')
|
||||
self._workspaceMask = workspaceMask;
|
||||
self._initialized = true;
|
||||
}],
|
||||
['toggleMask', (self, occupied, name) => {
|
||||
if (occupied) self._workspaceMask |= (1 << parseInt(name));
|
||||
else self._workspaceMask &= ~(1 << parseInt(name));
|
||||
}]
|
||||
],
|
||||
css: `transition: 90ms cubic-bezier(0.1, 1, 0, 1);`,
|
||||
setup: (area) => {
|
||||
area
|
||||
.hook(Hyprland.active.workspace, (area) =>
|
||||
area.setCss(`font-size: ${Hyprland.active.workspace.id}px;`)
|
||||
)
|
||||
.hook(Hyprland, (self) => self._updateMask(self), 'notify::workspaces')
|
||||
.hook(Hyprland, (self, name) => self._toggleMask(self, true, name), 'workspace-added')
|
||||
.hook(Hyprland, (self, name) => self._toggleMask(self, false, name), 'workspace-removed')
|
||||
.on('draw', Lang.bind(area, (area, cr) => {
|
||||
const allocation = area.get_allocation();
|
||||
const { width, height } = allocation;
|
||||
@@ -121,8 +133,8 @@ const WorkspaceContents = (count = 10) => {
|
||||
cr.setSourceRGBA(activefg.red, activefg.green, activefg.blue, activefg.alpha);
|
||||
cr.arc(activeWsCenterX, activeWsCenterY, indicatorRadius * 0.2, 0, 2 * Math.PI);
|
||||
cr.fill();
|
||||
}))
|
||||
,
|
||||
}));
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user