Skip to content

Commit

Permalink
remove gaps from between tiles
Browse files Browse the repository at this point in the history
fixes #42
  • Loading branch information
GrylledCheez committed May 26, 2023
1 parent 5a1d88a commit 4cc5951
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ function moveApp(app, loc) {
_log(`moveApp) isNotUltrawide: ${isNotUltrawide}`);

var colCount = config.cols === 2 || (config.ultrawideOnly && isNotUltrawide) ? 2 : config.cols;
space.parts = splitScreenWidth(space.width, colCount);
_log(`space: ${JSON.stringify(space)}`);
if (loc.col >= colCount)
loc.col = 1;
var colWidth = Math.floor(space.width / colCount);

var colWidth = space.parts[loc.col].partialWidth;
var rowHeight = Math.floor(space.height / 2);

let x = loc.col * colWidth + space.x;
let x = space.parts[loc.col].partialOffset + space.x;
let y = loc.row * rowHeight + space.y;
let w = loc.width * colWidth;
let w = colWidth;
let h = loc.height * rowHeight;

if (!config.useMaximize) {
Expand Down Expand Up @@ -1115,6 +1118,23 @@ function getCurrentMonitor() {
return monitorProvider.get_current_monitor();
}

/**
* @param {number} screenWidth - screen width
* @param {number} colCount - number of cols to split into
*/
function splitScreenWidth(screenWidth, colCount) {
var partSize = Math.floor(screenWidth / colCount);
var leftover = screenWidth % colCount;

var parts = new Array(colCount).fill(partSize).map(function (size, index) {
return {
partialWidth: size + (index < leftover ? 1 : 0),
partialOffset: index * partSize + Math.min(index, leftover)
};
});
return parts;
}

/**
*
*/
Expand Down

0 comments on commit 4cc5951

Please sign in to comment.