From 2693c60724cb50c6a68a854b95358f584f0cfe58 Mon Sep 17 00:00:00 2001 From: GrylledCheez <68041324+GrylledCheez@users.noreply.github.com> Date: Thu, 30 Nov 2023 09:47:59 -1000 Subject: [PATCH] edge calucation fixed --- extension.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/extension.js b/extension.js index 8c94b21..0df0e3b 100644 --- a/extension.js +++ b/extension.js @@ -171,8 +171,8 @@ function moveApp(app, loc) { var colWidth = Math.floor(monitor.width / colCount); var rowHeight = Math.floor(monitor.height / rowCount); - let x = loc.col * colWidth + monitor.x; - let y = loc.row * rowHeight + monitor.y; + let x = loc.col * colWidth + monitor.leftEdge; + let y = loc.row * rowHeight + monitor.topEdge; let w = loc.width * colWidth; let h = loc.height * rowHeight; @@ -799,26 +799,26 @@ function checkIfNearGrid(app) { _log(`checkIfNearGrid) keys - ctrl:${ctrlPressed} superPressed:${superPressed}`); _log(`checkIfNearGrid) monitor - x:${monitor.x} y:${monitor.y} w:${monitor.width} h:${monitor.height}`); _log(`checkIfNearGrid) window - x:${window.x} y:${window.y} w:${window.width} h:${window.height}`); - var c = Math.floor((mouseX - monitor.x) / colWidth); - var r = Math.floor((mouseY - monitor.y) / rowHeight); + var c = Math.floor((mouseX - monitor.leftEdge) / colWidth); + var r = Math.floor((mouseY - monitor.topEdge) / rowHeight); c = Math.max(0, Math.min(c, colCount - 1)); r = Math.max(0, Math.min(r, rowCount - 1)); - var gridX = c * colWidth + monitor.x; - var inGrid = mouseX > gridX && mouseX < gridX + colWidth; - var centerOfGrid = mouseX > Math.floor(gridX + colWidth / 3) && mouseX < Math.floor(gridX + (2 * colWidth / 3)); - var topRow = mouseY < monitor.y + rowHeight; - var bottomRow = mouseY > monitor.y + monitor.height - rowHeight; - var nearTop = isClose(mouseY, monitor.y) || mouseY < monitor.y; - var nearBottom = isClose(mouseY, monitor.y + monitor.height) || mouseY > monitor.y + monitor.height; - var nearLeft = isClose(mouseX, monitor.x) || mouseX < monitor.x; - var nearRight = isClose(mouseX, monitor.rightEdge) || mouseX > monitor.rightEdge; - - var centerOfScreenH = monitor.x + Math.floor(monitor.width / 2); + var gridX = c * colWidth + monitor.leftEdge; + var inGrid = mouseX >= gridX && mouseX <= gridX + colWidth; + var centerOfGrid = mouseX >= Math.floor(gridX + colWidth / 3) && mouseX <= Math.floor(gridX + (2 * colWidth / 3)); + var topRow = mouseY <= monitor.topEdge + rowHeight; + var bottomRow = mouseY >= monitor.bottomEdge - rowHeight; + var nearTop = isClose(mouseY, monitor.topEdge) || mouseY <= monitor.topEdge; + var nearBottom = isClose(mouseY, monitor.bottomEdge) || mouseY >= monitor.bottomEdge; + var nearLeft = isClose(mouseX, monitor.leftEdge) || mouseX <= monitor.leftEdge; + var nearRight = isClose(mouseX, monitor.rightEdge) || mouseX >= monitor.rightEdge; + + var centerOfScreenH = monitor.leftEdge + Math.floor(monitor.width / 2); var columnWidthFraction = Math.floor(colWidth / 3); var nearCenterH = mouseX > centerOfScreenH - (columnWidthFraction / 2) && mouseX < centerOfScreenH + (columnWidthFraction / 2); - var centerOfScreenV = monitor.y + Math.floor(monitor.height / 2); + var centerOfScreenV = monitor.topEdge + Math.floor(monitor.height / 2); var rowHeightFraction = Math.floor(rowHeight / 3); var nearCenterV = mouseY > centerOfScreenV - (rowHeightFraction / 2) && mouseY < centerOfScreenV + (rowHeightFraction / 2);