forked from Shinonome/dots-hyprland
fix focus mode ws
This commit is contained in:
@@ -19,9 +19,10 @@ const WS_TAKEN_WIDTH_MULTIPLIER = 1.4;
|
|||||||
// Font size = workspace id
|
// Font size = workspace id
|
||||||
const WorkspaceContents = (count = 10) => {
|
const WorkspaceContents = (count = 10) => {
|
||||||
return DrawingArea({
|
return DrawingArea({
|
||||||
className: 'menu-decel',
|
className: 'element-decel',
|
||||||
// css: `transition: 300ms cubic-bezier(0.1, 1, 0, 1);`,
|
// css: `transition: 300ms cubic-bezier(0.1, 1, 0, 1);`,
|
||||||
attribute: {
|
attribute: {
|
||||||
|
lastImmediateActiveWs: 0,
|
||||||
immediateActiveWs: 0,
|
immediateActiveWs: 0,
|
||||||
initialized: false,
|
initialized: false,
|
||||||
workspaceMask: 0,
|
workspaceMask: 0,
|
||||||
@@ -52,6 +53,7 @@ const WorkspaceContents = (count = 10) => {
|
|||||||
.hook(Hyprland.active.workspace, (self) => {
|
.hook(Hyprland.active.workspace, (self) => {
|
||||||
const newActiveWs = (Hyprland.active.workspace.id - 1) % count + 1;
|
const newActiveWs = (Hyprland.active.workspace.id - 1) % count + 1;
|
||||||
self.setCss(`font-size: ${newActiveWs}px;`);
|
self.setCss(`font-size: ${newActiveWs}px;`);
|
||||||
|
self.attribute.lastImmediateActiveWs = self.attribute.immediateActiveWs;
|
||||||
self.attribute.immediateActiveWs = newActiveWs;
|
self.attribute.immediateActiveWs = newActiveWs;
|
||||||
const previousGroup = self.attribute.workspaceGroup;
|
const previousGroup = self.attribute.workspaceGroup;
|
||||||
const currentGroup = Math.floor((Hyprland.active.workspace.id - 1) / count);
|
const currentGroup = Math.floor((Hyprland.active.workspace.id - 1) / count);
|
||||||
@@ -82,16 +84,29 @@ const WorkspaceContents = (count = 10) => {
|
|||||||
|
|
||||||
const widgetStyleContext = area.get_style_context();
|
const widgetStyleContext = area.get_style_context();
|
||||||
const activeWs = widgetStyleContext.get_property('font-size', Gtk.StateFlags.NORMAL);
|
const activeWs = widgetStyleContext.get_property('font-size', Gtk.StateFlags.NORMAL);
|
||||||
|
const lastImmediateActiveWs = area.attribute.lastImmediateActiveWs;
|
||||||
const immediateActiveWs = area.attribute.immediateActiveWs;
|
const immediateActiveWs = area.attribute.immediateActiveWs;
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
area.set_size_request(workspaceDiameter * WS_TAKEN_WIDTH_MULTIPLIER * (count - 1) + activeWorkspaceWidth, -1);
|
area.set_size_request(workspaceDiameter * WS_TAKEN_WIDTH_MULTIPLIER * (count - 1) + activeWorkspaceWidth, -1);
|
||||||
for (let i = 1; i <= count; i++) {
|
for (let i = 1; i <= count; i++) {
|
||||||
if (i == immediateActiveWs) continue;
|
if (i == immediateActiveWs) continue;
|
||||||
if (area.attribute.workspaceMask & (1 << i))
|
let colors = {};
|
||||||
cr.setSourceRGBA(occupiedbg.red, occupiedbg.green, occupiedbg.blue, occupiedbg.alpha);
|
if (area.attribute.workspaceMask & (1 << i)) colors = occupiedbg;
|
||||||
else
|
else colors = wsbg;
|
||||||
cr.setSourceRGBA(wsbg.red, wsbg.green, wsbg.blue, wsbg.alpha);
|
|
||||||
|
// if ((i == immediateActiveWs + 1 && immediateActiveWs < activeWs) ||
|
||||||
|
// (i == immediateActiveWs + 1 && immediateActiveWs < activeWs)) {
|
||||||
|
// const widthPercentage = (i == immediateActiveWs - 1) ?
|
||||||
|
// 1 - (immediateActiveWs - activeWs) :
|
||||||
|
// activeWs - immediateActiveWs;
|
||||||
|
// cr.setSourceRGBA(colors.red * widthPercentage + activebg.red * (1 - widthPercentage),
|
||||||
|
// colors.green * widthPercentage + activebg.green * (1 - widthPercentage),
|
||||||
|
// colors.blue * widthPercentage + activebg.blue * (1 - widthPercentage),
|
||||||
|
// colors.alpha);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
cr.setSourceRGBA(colors.red, colors.green, colors.blue, colors.alpha)
|
||||||
|
|
||||||
const centerX = (i <= activeWs) ?
|
const centerX = (i <= activeWs) ?
|
||||||
(-workspaceRadius + (workspaceDiameter * WS_TAKEN_WIDTH_MULTIPLIER * i))
|
(-workspaceRadius + (workspaceDiameter * WS_TAKEN_WIDTH_MULTIPLIER * i))
|
||||||
@@ -115,7 +130,7 @@ const WorkspaceContents = (count = 10) => {
|
|||||||
const leftX = rightX - wsWidth;
|
const leftX = rightX - wsWidth;
|
||||||
cr.rectangle(leftX, height / 2 - workspaceRadius, wsWidth, workspaceDiameter);
|
cr.rectangle(leftX, height / 2 - workspaceRadius, wsWidth, workspaceDiameter);
|
||||||
cr.fill();
|
cr.fill();
|
||||||
cr.arc(rightX, height / 2, workspaceRadius, 0, Math.PI * 2);
|
cr.arc(leftX, height / 2, workspaceRadius, 0, Math.PI * 2);
|
||||||
cr.fill();
|
cr.fill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user