UltrawideWindows icon indicating copy to clipboard operation
UltrawideWindows copied to clipboard

Introduce gaps between windows.

Open lukaszkieronski opened this issue 3 years ago • 3 comments

I really love your script, but in my case I had to introduce small gaps between windows. Here is a patched function. It would be nice if this feature is configurable.

function newSlotPosition(workspace, client, numberXslots, numberYslots, x, y, xSlotToFill, ySlotToFill) {
    var maxArea = workspace.clientArea(KWin.MaximizeArea, client);

    var newX = maxArea.x + Math.round(maxArea.width / numberXslots * x) + 8;
    var newY = maxArea.y + Math.round(maxArea.height / numberYslots * y) + 8;

    var gapX = x + xSlotToFill < numberXslots ? 8 : 0;
    var gapY = y + ySlotToFill < numberYslots ? 8 : 0;

    // Width and height is calculated by finding where the window should end and subtracting where it should start
    var clientWidth = Math.round(maxArea.width / numberXslots * (x + xSlotToFill)) - (newX - maxArea.x) - 8 + gapX;
    var clientHeight = Math.round(maxArea.height / numberYslots * (y + ySlotToFill)) - (newY - maxArea.y) - 8 + gapY;

    return [newX, newY, clientWidth, clientHeight]
}

lukaszkieronski avatar Mar 20 '23 23:03 lukaszkieronski

gapSize as a parameter, just to get rid of magic numbers in code

function newSlotPosition(workspace, client, numberXslots, numberYslots, x, y, xSlotToFill, ySlotToFill) {
    var gapSize = 8;

    var maxArea = workspace.clientArea(KWin.MaximizeArea, client);

    var newX = maxArea.x + Math.round(maxArea.width / numberXslots * x) + gapSize;
    var newY = maxArea.y + Math.round(maxArea.height / numberYslots * y) + gapSize;

    var gapX = x + xSlotToFill < numberXslots ? gapSize : 0;
    var gapY = y + ySlotToFill < numberYslots ? gapSize : 0;

    // Width and height is calculated by finding where the window should end and subtracting where it should start
    var clientWidth = Math.round(maxArea.width / numberXslots * (x + xSlotToFill)) - (newX - maxArea.x) - gapSize + gapX;
    var clientHeight = Math.round(maxArea.height / numberYslots * (y + ySlotToFill)) - (newY - maxArea.y) - gapSize + gapY;

    return [newX, newY, clientWidth, clientHeight]
}

lukaszkieronski avatar Mar 20 '23 23:03 lukaszkieronski

There's https://github.com/nclarius/tile-gaps which works together with this (well enough). However, the project there seems somewhat dead (last release 2 years ago) and it's lacking Plasma 6 (and Wayland, at least in my experience) support.

mtvx avatar Sep 11 '24 05:09 mtvx