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) => {
|
const WorkspaceContents = (count = 10) => {
|
||||||
return DrawingArea({
|
return DrawingArea({
|
||||||
properties: [
|
properties: [
|
||||||
|
['initialized', false],
|
||||||
['workspaceMask', 0],
|
['workspaceMask', 0],
|
||||||
],
|
['updateMask', (self) => {
|
||||||
css: `transition: 500ms cubic-bezier(0.1, 1, 0, 1);`,
|
if(self._initialized) return; // We only need this to run once
|
||||||
setup: (area) => area
|
console.log('update dayo')
|
||||||
.hook(Hyprland.active.workspace, (area) =>
|
|
||||||
area.setCss(`font-size: ${Hyprland.active.workspace.id}px;`)
|
|
||||||
)
|
|
||||||
.hook(Hyprland, (area) => {
|
|
||||||
const workspaces = Hyprland.workspaces;
|
const workspaces = Hyprland.workspaces;
|
||||||
let workspaceMask = 0;
|
let workspaceMask = 0;
|
||||||
for (let i = 0; i < workspaces.length; i++) {
|
for (let i = 0; i < workspaces.length; i++) {
|
||||||
@@ -34,8 +31,23 @@ const WorkspaceContents = (count = 10) => {
|
|||||||
workspaceMask |= (1 << ws.id);
|
workspaceMask |= (1 << ws.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
area._workspaceMask = workspaceMask;
|
self._workspaceMask = workspaceMask;
|
||||||
}, 'notify::workspaces')
|
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) => {
|
.on('draw', Lang.bind(area, (area, cr) => {
|
||||||
const allocation = area.get_allocation();
|
const allocation = area.get_allocation();
|
||||||
const { width, height } = allocation;
|
const { width, height } = allocation;
|
||||||
@@ -121,8 +133,8 @@ const WorkspaceContents = (count = 10) => {
|
|||||||
cr.setSourceRGBA(activefg.red, activefg.green, activefg.blue, activefg.alpha);
|
cr.setSourceRGBA(activefg.red, activefg.green, activefg.blue, activefg.alpha);
|
||||||
cr.arc(activeWsCenterX, activeWsCenterY, indicatorRadius * 0.2, 0, 2 * Math.PI);
|
cr.arc(activeWsCenterX, activeWsCenterY, indicatorRadius * 0.2, 0, 2 * Math.PI);
|
||||||
cr.fill();
|
cr.fill();
|
||||||
}))
|
}));
|
||||||
,
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user