From 8283dd30e2b1b272049739cc4735b9b0d7614884 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 ++++++++++++++++---------------- metadata.json | 2 +- 2 files changed, 17 insertions(+), 17 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); diff --git a/metadata.json b/metadata.json index 3db8a33..693a229 100644 --- a/metadata.json +++ b/metadata.json @@ -9,5 +9,5 @@ "43", "44" ], - "version": 16 + "version": 17 }