Skip to content

Commit

Permalink
edge calucation fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
GrylledCheez committed Nov 30, 2023
1 parent 239f054 commit 2693c60
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2693c60

Please sign in to comment.