This commit is contained in:
end-4
2024-02-05 23:38:56 +07:00
parent 12dd964980
commit 4465d9b58d
@@ -77,15 +77,15 @@ const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widg
const Window = ({ address, at: [x, y], size: [w, h], workspace: { id, name }, class: c, title, xwayland }, screenCoords) => { const Window = ({ address, at: [x, y], size: [w, h], workspace: { id, name }, class: c, title, xwayland }, screenCoords) => {
const revealInfoCondition = (Math.min(w, h) * OVERVIEW_SCALE > 70); const revealInfoCondition = (Math.min(w, h) * OVERVIEW_SCALE > 70);
if (w <= 0 || h <= 0 || (c === '' && title === '')) return null; if (w <= 0 || h <= 0 || (c === '' && title === '')) return null;
// Non-primary monitors
if (screenCoords.x != 0) x -= screenCoords.x; if (screenCoords.x != 0) x -= screenCoords.x;
if (screenCoords.y != 0) y -= screenCoords.y; if (screenCoords.y != 0) y -= screenCoords.y;
// Other offscreen adjustments
if (x + w <= 0) x += (Math.floor(x / SCREEN_WIDTH) * SCREEN_WIDTH); if (x + w <= 0) x += (Math.floor(x / SCREEN_WIDTH) * SCREEN_WIDTH);
else if (x < 0) { w = x + w; x = 0; } else if (x < 0) { w = x + w; x = 0; }
if (y + h <= 0) x += (Math.floor(y / SCREEN_HEIGHT) * SCREEN_HEIGHT); if (y + h <= 0) x += (Math.floor(y / SCREEN_HEIGHT) * SCREEN_HEIGHT);
else if (y < 0) { h = y + h; y = 0; } else if (y < 0) { h = y + h; y = 0; }
// Truncate if offscreen
if (x + w > SCREEN_WIDTH) w = SCREEN_WIDTH - x; if (x + w > SCREEN_WIDTH) w = SCREEN_WIDTH - x;
if (y + h > SCREEN_HEIGHT) h = SCREEN_HEIGHT - y; if (y + h > SCREEN_HEIGHT) h = SCREEN_HEIGHT - y;
@@ -260,7 +260,8 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
children: arr(startWorkspace, workspaces).map(Workspace), children: arr(startWorkspace, workspaces).map(Workspace),
attribute: { attribute: {
monitorMap: [], monitorMap: [],
getMonitorMap: (box) => {execAsync('hyprctl -j monitors').then(monitors => { getMonitorMap: (box) => {
execAsync('hyprctl -j monitors').then(monitors => {
box.attribute.monitorMap = JSON.parse(monitors).reduce((acc, item) => { box.attribute.monitorMap = JSON.parse(monitors).reduce((acc, item) => {
acc[item.id] = { x: item.x, y: item.y }; acc[item.id] = { x: item.x, y: item.y };
return acc; return acc;
@@ -281,7 +282,6 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
const screenCoords = box.attribute.monitorMap[client.monitor]; const screenCoords = box.attribute.monitorMap[client.monitor];
kids[client.workspace.id - (offset + startWorkspace)] kids[client.workspace.id - (offset + startWorkspace)]
?.set(client, screenCoords); ?.set(client, screenCoords);
} }
} }
kids.forEach(kid => kid.show()); kids.forEach(kid => kid.show());
@@ -290,7 +290,7 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
} }
}, },
setup: (box) => { setup: (box) => {
box.attribute.getMonitorMap(box) box.attribute.getMonitorMap(box);
box box
.hook(overviewTick, (box) => box.attribute.update(box)) .hook(overviewTick, (box) => box.attribute.update(box))
.hook(Hyprland, (box, clientAddress) => { .hook(Hyprland, (box, clientAddress) => {