Skip to content

Commit

Permalink
make gaps on panel widgets only for floating panels; fix a bug where…
Browse files Browse the repository at this point in the history
… windows would continuously shrink
  • Loading branch information
nclarius committed Jun 22, 2022
1 parent 7cf14cd commit 0cebed6
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 53 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.bbcode
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[h2]v7.1[/h2]
[list]\n[*] make gaps on panel widgets only for floating panels
[*] fix a bug where windows would continuously shrink
[/list]

[h1]v7.0[/h1]
[list]\n[*] improved integration with floating panels
[/list]
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v7.1
- make gaps on panel widgets only for floating panels
- fix a bug where windows would continuously shrink

# v7.0
- improved integration with floating panels

Expand Down
4 changes: 2 additions & 2 deletions README.bbcode
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Adds space around windows touching a screen edge or other window.

The size of the gap and the layouts and applications to be gapped are configurable.

Please note this script does not do any automatic tiling. Its purpose is to reshape windows that have been manually positioned with the default KWin window management system.
Please note this script does not do any automatic tiling. Its purpose is to reshape windows that have been manually positioned with the stock KWin window management system.

[b]Please make sure to install the most recent version (v7.0) and to not use Discover for installation.[/b] [b]On old Plasma versions, additional steps may be required after installation to make the configuration menu available.[/b] For more information on installation, configuration and usage as well as any requests, please visit [url=https://github.com/nclarius/tile-gaps]the GitHub page[/url].
[b]Please make sure to install the most recent version (v7.1) and to not use Discover for installation.[/b] [b]On old Plasma versions, additional steps may be required after installation to make the configuration menu available.[/b] For more information on installation, configuration and usage as well as any requests, please visit [url=https://github.com/nclarius/tile-gaps]the GitHub page[/url].

© 2021-2022 Natalie Clarius ‹[email protected]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Extension for KDE's window manager to add space around windows touching a screen

The size of the gap and the layouts and applications to be gapped are configurable.

Please note that this script does not do any automatic tiling. Its purpose is to reshape windows that have been manually positioned with the default KWin window management system.
Please note that this script does not do any automatic tiling. Its purpose is to reshape windows that have been manually positioned with the stock KWin window management system.

![screenshot](.img/screenshot.png)

Expand All @@ -18,7 +18,7 @@ Please note that this script does not do any automatic tiling. Its purpose is to

### Installation via graphical interface

**Please make sure to select the most recent version (v7.0)** in the installation process.
**Please make sure to select the most recent version (v7.1)** in the installation process.

A [bug](https://bugs.kde.org/show_bug.cgi?id=453521) in Discover causes a wrong version to be installed, so using the installation module in System Settings instead is recommended.

Expand Down
95 changes: 47 additions & 48 deletions contents/code/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,43 @@ function onAdded(client) {
// trigger applying tile gaps when client is moved or resized
function onRegeometrized(client) {
client.moveResizedChanged.connect((client) => {
// debug("move resized changed", caption(client));
debug("move resized changed", caption(client));
applyGaps(client);
});
client.clientGeometryChanged.connect((client) => {
// debug("client geometry changed", caption(client));
debug("client geometry changed", caption(client));
applyGaps(client);
});
client.frameGeometryChanged.connect((client) => {
// debug("frame geometry changed", caption(client));
debug("frame geometry changed", caption(client));
applyGaps(client)
});
client.clientFinishUserMovedResized.connect((client) => {
// debug("finish user moved resized", caption(client));
debug("finish user moved resized", caption(client));
applyGaps(client);
});
client.fullScreenChanged.connect((client) => {
// debug("fullscreen changed", caption(client));
debug("fullscreen changed", caption(client));
applyGaps(client);
});
client.clientMaximizedStateChanged.connect((client) => {
// debug("maximized changed", caption(client));
debug("maximized changed", caption(client));
applyGaps(client);
});
client.clientUnminimized.connect((client) => {
// debug("unminimized", caption(client));
debug("unminimized", caption(client));
applyGaps(client);
});
client.screenChanged.connect((client) => {
// debug("screen changed", caption(client));
debug("screen changed", caption(client));
applyGaps(client);
});
client.desktopChanged.connect((client) => {
// debug("desktop changed", caption(client));
debug("desktop changed", caption(client));
applyGaps(client);
});
client.activitiesChanged.connect((client) => {
// debug("activities changed", caption(client));
debug("activities changed", caption(client));
applyGaps(client);
});
}
Expand All @@ -141,44 +141,44 @@ onRelayouted();

function onRelayouted() {
workspace.currentDesktopChanged.connect(() => {
// debug("current desktop changed");
debug("current desktop changed");
applyGapsAll();
});
workspace.desktopPresenceChanged.connect(() => {
// debug("desktop presence changed");
debug("desktop presence changed");
applyGapsAll();
});
workspace.numberDesktopsChanged.connect(() => {
// debug("number desktops changed");
debug("number desktops changed");
applyGapsAll();
});
workspace.numberScreensChanged.connect(() => {
// debug("number screens changed");
debug("number screens changed");
applyGapsAll();
});
workspace.screenResized.connect(() => {
// debug("screen resized");
debug("screen resized");
applyGapsAll();
});
workspace.currentActivityChanged.connect(() => {
// debug("current activity changed");
debug("current activity changed");
applyGapsAll();
});
workspace.activitiesChanged.connect(() => {
// debug("activities changed");
debug("activities changed");
applyGapsAll();
});
workspace.virtualScreenSizeChanged.connect(() => {
// debug("virtual screen size changed");
debug("virtual screen size changed");
applyGapsAll();
});
workspace.virtualScreenGeometryChanged.connect(() => {
// debug("virtual screen geometry changed");
debug("virtual screen geometry changed");
applyGapsAll();
});
workspace.clientAdded.connect((client) => {
if (client.dock) {
// debug("dock added");
debug("dock added");
applyGapsAll();
}
});
Expand Down Expand Up @@ -222,11 +222,11 @@ function applyGapsArea(client) {
let pos = Object.keys(grid[edge])[i];
let coords = grid[edge][pos];
if (nearArea(win[edge], coords.closed, coords.gapped, gap[edge])) {
// debug("gap to edge", edge, pos, coords.gapped);
debug("gap to edge", edge, pos, coords.gapped);
let diff = coords.gapped - win[edge];
win.width -= diff;
win.x += diff;
// debug("new geo", geometry(win));
debug("new geo", geometry(win));
break;
}
}
Expand All @@ -237,10 +237,10 @@ function applyGapsArea(client) {
let pos = Object.keys(grid[edge])[i];
let coords = grid[edge][pos];
if (nearArea(win[edge], coords.closed, coords.gapped, gap[edge])) {
// debug("gap to edge", edge, pos, coords.gapped);
debug("gap to edge", edge, pos, coords.gapped);
let diff = coords.gapped - (win[edge] + 1);
win.width += diff;
// debug("new geo", geometry(win));
debug("new geo", geometry(win));
break;
}
}
Expand All @@ -252,11 +252,11 @@ function applyGapsArea(client) {
let pos = Object.keys(grid[edge])[i];
let coords = grid[edge][pos];
if (nearArea(win[edge], coords.closed, coords.gapped, gap[edge])) {
// debug("gap to edge", edge, pos, coords.gapped);
debug("gap to edge", edge, pos, coords.gapped);
let diff = coords.gapped - win[edge];
win.height -= diff;
win.y += diff;
// debug("new geo", geometry(win));
debug("new geo", geometry(win));
break;
}
}
Expand All @@ -268,10 +268,10 @@ function applyGapsArea(client) {
let pos = Object.keys(grid[edge])[i];
let coords = grid[edge][pos];
if (nearArea(win[edge], coords.closed, coords.gapped, gap[edge])) {
// debug("gap to edge", edge, pos, coords.gapped);
debug("gap to edge", edge, pos, coords.gapped);
let diff = coords.gapped - (win[edge] + 1);
win.height += diff;
// debug("new geo", geometry(win));
debug("new geo", geometry(win));
break;
}
}
Expand Down Expand Up @@ -454,37 +454,37 @@ function maximized(client) {

// a coordinate is close to another iff
// the difference is within the tolerance margin but non-zero

function nearArea(actual, expected_closed, expected_gapped, gap) {
// let tolerance = 2 * gap;
let tolerance = Math.min(2 * gap, 6);
return (Math.abs(actual - expected_closed) <= tolerance ||
Math.abs(actual - expected_gapped) <= tolerance) &&
actual != expected_gapped;
let tolerance = 2 * gap;
return (Math.abs(actual - expected_closed) <= tolerance
|| Math.abs(actual - expected_gapped) <= tolerance)
&& actual != expected_gapped;
}

function nearWindow(win1, win2, gap) {
// let tolerance = 2 * gap;
let tolerance = Math.min(2 * gap, 6);
return Math.abs(win1 - win2) <= tolerance &&
win1 - win2 != gap;
let tolerance = 2 * gap;
return win1 - win2 <= tolerance
&& win1 - win2 > 0
&& win1 - win2 != gap;
}

// horizontal/vertical overlap

function overlapHor(win1, win2) {
let tolerance = 2 * gap.mid;
return (win1.left <= win2.left + tolerance &&
win1.right > win2.left + tolerance) ||
(win2.left <= win1.left + tolerance &&
win2.right + tolerance > win1.left);
return (win1.left <= win2.left + tolerance
&& win1.right > win2.left + tolerance)
|| (win2.left <= win1.left + tolerance
&& win2.right + tolerance > win1.left);
}

function overlapVer(win1, win2) {
let tolerance = 2 * gap.mid;
return (win1.top <= win2.top + tolerance &&
win1.bottom > win2.top + tolerance) ||
(win2.top <= win1.top + tolerance &&
win2.bottom + tolerance > win1.top);
return (win1.top <= win2.top + tolerance
&& win1.bottom > win2.top + tolerance)
|| (win2.top <= win1.top + tolerance
&& win2.bottom + tolerance > win1.top);
}

// floored/ceiled half difference between edges
Expand Down Expand Up @@ -515,9 +515,8 @@ function halfGapU() {
// filter out irrelevant clients
function ignoreClient(client) {
return !client // null
|| ((!client.normalWindow || !client.resizeable) // not normal/resizable
&& !(client.dialog && ["plasmashell", "org.kde.plasmashell"]
.includes(String(client.resourceClass)))) // except panel popout
|| !client.normalWindow // not normal
|| !client.resizeable // not resizeable
|| client.fullScreen // fullscreen
|| (!config.includeMaximized && maximized(client)) // maximized
|| (config.excludeMode // excluded application
Expand Down
2 changes: 1 addition & 1 deletion metadata.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Comment[de]=Fügt Zwischenraum um Fenster ein, die einen Bildschirmrand oder ein
Icon=preferences-system-windows

X-KDE-PluginInfo-Name=tilegaps
X-KDE-PluginInfo-Version=7.0
X-KDE-PluginInfo-Version=7.1
X-KDE-PluginInfo-Author=Natalie Clarius
X-KDE-PluginInfo-Email[email protected]
X-KDE-PluginInfo-License=GPLv3.0
Expand Down

0 comments on commit 0cebed6

Please sign in to comment.