forked from Shinonome/dots-hyprland
Fix Overview in multi-monitor setup for toggling windows at corners
This commit is contained in:
@@ -73,18 +73,20 @@ const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widg
|
||||
}
|
||||
})
|
||||
|
||||
const Window = ({ address, at: [x, y], size: [w, h], workspace: { id, name }, class: c, title, xwayland }) => {
|
||||
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);
|
||||
if (w <= 0 || h <= 0 || (c === '' && title === '')) return null;
|
||||
if (x + w <= 0) x += (Math.floor(x / SCREEN_WIDTH) * SCREEN_WIDTH);
|
||||
else if (x < 0) { x = 0; w = x + w; }
|
||||
if (y + h <= 0) x += (Math.floor(y / SCREEN_HEIGHT) * SCREEN_HEIGHT);
|
||||
else if (y < 0) { y = 0; h = y + h; }
|
||||
|
||||
if (x >= SCREEN_WIDTH) x %= SCREEN_WIDTH;
|
||||
else if (x + w > SCREEN_WIDTH) w = SCREEN_WIDTH - x;
|
||||
if (y >= SCREEN_HEIGHT) y %= SCREEN_HEIGHT;
|
||||
else if (y + h > SCREEN_HEIGHT) h = SCREEN_HEIGHT - y;
|
||||
if (screenCoords.x != 0) x -= screenCoords.x;
|
||||
if (screenCoords.y != 0) y -= screenCoords.y;
|
||||
|
||||
if (x + w <= 0) x += (Math.floor(x / SCREEN_WIDTH) * SCREEN_WIDTH);
|
||||
else if (x < 0) { w = x + w; x = 0;}
|
||||
if (y + h <= 0) x += (Math.floor(y / SCREEN_HEIGHT) * SCREEN_HEIGHT);
|
||||
else if (y < 0) { h = y + h; y = 0;}
|
||||
|
||||
if (x + w > SCREEN_WIDTH) w = SCREEN_WIDTH - x;
|
||||
if (y + h > SCREEN_HEIGHT) h = SCREEN_HEIGHT - y;
|
||||
|
||||
// title = truncateTitle(title);
|
||||
return Widget.Button({
|
||||
@@ -221,9 +223,9 @@ const Workspace = (index) => {
|
||||
const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN;
|
||||
fixed.put(WorkspaceNumber(offset + index), 0, 0);
|
||||
}
|
||||
widget.set = (clientJson) => {
|
||||
widget.set = (clientJson, screenCoords) => {
|
||||
// if(clientMap.get(clientJson.address)) clientMap.get(clientJson.address).destroy();
|
||||
const newWindow = Window(clientJson);
|
||||
const newWindow = Window(clientJson, screenCoords);
|
||||
if (newWindow === null) return;
|
||||
// clientMap.set(clientJson.address, newWindow);
|
||||
fixed.put(newWindow,
|
||||
@@ -254,6 +256,14 @@ const arr = (s, n) => {
|
||||
const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) => Widget.Box({
|
||||
children: arr(startWorkspace, workspaces).map(Workspace),
|
||||
attribute: {
|
||||
monitorMap: [],
|
||||
getMonitorMap: (box) => {execAsync('hyprctl -j monitors').then(monitors => {
|
||||
box.attribute.monitorMap = JSON.parse(monitors).reduce((acc, item) => {
|
||||
acc[item.id] = { x: item.x, y: item.y };
|
||||
return acc;
|
||||
}, {});
|
||||
});
|
||||
},
|
||||
update: (box) => {
|
||||
const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN;
|
||||
if (!App.getWindow(windowName).visible) return;
|
||||
@@ -264,8 +274,9 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
|
||||
for (let i = 0; i < allClients.length; i++) {
|
||||
const client = allClients[i];
|
||||
if (offset + startWorkspace <= client.workspace.id && client.workspace.id <= offset + startWorkspace + workspaces) {
|
||||
const screenCoords = box.attribute.monitorMap[client.monitor];
|
||||
kids[client.workspace.id - (offset + startWorkspace)]
|
||||
.set(client);
|
||||
.set(client, screenCoords);
|
||||
}
|
||||
}
|
||||
kids.forEach(kid => kid.show());
|
||||
@@ -273,7 +284,9 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
|
||||
}).catch(print);
|
||||
}
|
||||
},
|
||||
setup: (box) => box
|
||||
setup: (box) => {
|
||||
box.attribute.getMonitorMap(box)
|
||||
box
|
||||
.hook(overviewTick, (box) => box.attribute.update(box))
|
||||
.hook(Hyprland, (box, clientAddress) => {
|
||||
box.attribute.update(box)
|
||||
@@ -285,7 +298,7 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
|
||||
.hook(App, (box, name, visible) => { // Update on open
|
||||
if (name == 'overview' && visible) box.attribute.update(box);
|
||||
})
|
||||
,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user