Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce gaps between windows. #36

Open
lukaszkieronski opened this issue Mar 20, 2023 · 3 comments
Open

Introduce gaps between windows. #36

lukaszkieronski opened this issue Mar 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@lukaszkieronski
Copy link

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
Copy link
Author

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]
}

@lucmos lucmos added the enhancement New feature or request label Oct 11, 2023
@mtvx
Copy link

mtvx commented Sep 11, 2024

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.

@dxh0w1k
Copy link

dxh0w1k commented Nov 12, 2024

Any idea how you might modify this to enable the gap between windows, but not between windows & the edge of the screen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants