overview: fix bug for multimonitor (#212, #221)

This commit is contained in:
end-4 2024-02-02 21:14:44 +07:00
parent b6b061b172
commit 13f634fffa

View file

@ -75,15 +75,20 @@ const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widg
const Window = ({ address, at: [x, y], size: [w, h], workspace: { id, name }, class: c, title, xwayland }) => {
const revealInfoCondition = (Math.min(w, h) * OVERVIEW_SCALE > 70);
if (c === '' && title === '') return null;
if (w <= 0 || h <= 0) return null;
if (x + w > SCREEN_WIDTH) w = SCREEN_WIDTH - x;
if (y + h > SCREEN_HEIGHT) h = SCREEN_HEIGHT - y;
if (x < 0) w = x + w; // We only have to handle w/h. Pos determined at put()
if (y < 0) h = y + h; // We only have to handle w/h. Pos determined at put()
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;
// title = truncateTitle(title);
return Widget.Button({
attribute: { x, y },
className: 'overview-tasks-window',
hpack: 'center',
vpack: 'center',
@ -222,8 +227,8 @@ const Workspace = (index) => {
if (newWindow === null) return;
// clientMap.set(clientJson.address, newWindow);
fixed.put(newWindow,
Math.max(0, clientJson.at[0] * OVERVIEW_SCALE),
Math.max(0, clientJson.at[1] * OVERVIEW_SCALE)
Math.max(0, newWindow.attribute.x * OVERVIEW_SCALE),
Math.max(0, newWindow.attribute.y * OVERVIEW_SCALE)
);
};
// widget.unset = (clientAddress) => {