Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
fixed some bugs with insertion and added support for inverting insert…
Browse files Browse the repository at this point in the history
…ion order when autotiling
  • Loading branch information
zeroxoneafour committed Mar 20, 2023
1 parent 74154f7 commit 51b9cb2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
Binary file modified autotile.kwinscript
Binary file not shown.
33 changes: 25 additions & 8 deletions res/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
</item>
<item>
<widget class="QComboBox" name="kcfg_Borders">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Changes where borders are or aren't&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
Expand Down Expand Up @@ -92,14 +95,28 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_Debug">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Spams your user journal&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Debug Mode</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="kcfg_InvertInsertion">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Invert the side that windows are inserted into&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Invert insertion</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_Debug">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Spams your user journal&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Debug Mode</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion res/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<entry name="TileDialogs" type="bool"><default>false</default></entry>
<entry name="Debug" type="bool"><default>false</default></entry>
<entry name="Borders" type="int"><default>1</default></entry>
<entry name="RetileWindow" type="string"><default>Meta+Shift+Space</default></entry>
<entry name="InvertInsertion" type="bool"><default>false</default></entry>
</group>
</kcfg>
10 changes: 9 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let useWhitelist;
let blacklist;
let tileDialogs;
let borders;
let invertInsertion;
let blacklistCache;

function printDebug(str, isError) {
Expand All @@ -19,12 +20,14 @@ let updateConfig = function() {
blacklist = readConfig("Blacklist", "krunner,yakuake").split(',').map(x => x.trim());
tileDialogs = readConfig("TileDialogs", false);
borders = readConfig("Borders", 1);
invertInsertion = readConfig("InvertInsertion", false);
blacklistCache = new Set();
printDebug("Config Updated", false)
printDebug("useWhitelist == " + useWhitelist, false);
printDebug("blacklist == " + blacklist, false);
printDebug("tileDialogs == " + tileDialogs, false);
printDebug("borders == " + borders, false);
printDebug("invertInsertion == " + invertInsertion, false);
}

updateConfig();
Expand Down Expand Up @@ -220,7 +223,12 @@ function tileClient(client) {
}
// check if there is only one window and the tile is binary-splittable
if (t_windows.length != 0 && t.tiles.length == 2) {
targetTile = t.tiles[0];
// if the insertion order is inverted, windows will be pushed to the back instead of the front
if (invertInsertion) {
targetTile = t.tiles[1];
} else {
targetTile = t.tiles[0];
}
break mainloop;
}
stackNext = stackNext.concat(t.tiles);
Expand Down
13 changes: 9 additions & 4 deletions src/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ let insertAbove = function() {
return;
}
printDebug("Inserting " + client.resourceClass + " above", false);
let oldTile = client.tile;
untileClient(client);
client.wasTiled = true;
if (windowsOnDesktop(tile, client.desktop).length != 0) {
Expand All @@ -85,7 +86,8 @@ let insertAbove = function() {
// if tile has no children then don't tile
if (tile == undefined) {
printDebug("Could not insert " + client.resourceClass, false);
tileClient(client);
// now inserts client back into its old tile instead of retiling
putClientInTile(client, oldTile);
}
putClientInTile(client, tile);
}
Expand Down Expand Up @@ -160,6 +162,7 @@ let insertBelow = function() {
return;
}
printDebug("Inserting " + client.resourceClass + " below", false);
let oldTile = client.tile;
untileClient(client);
client.wasTiled = true;
if (windowsOnDesktop(tile, client.desktop).length != 0) {
Expand All @@ -168,7 +171,7 @@ let insertBelow = function() {
// if tile has no children then don't tile
if (tile == undefined) {
printDebug("Could not insert " + client.resourceClass, false);
tileClient(client);
putClientInTile(client, oldTile);
}
putClientInTile(client, tile);
}
Expand Down Expand Up @@ -243,6 +246,7 @@ let insertLeft = function() {
return;
}
printDebug("Inserting " + client.resourceClass + " left", false);
let oldTile = client.tile;
untileClient(client);
client.wasTiled = true;
if (windowsOnDesktop(tile, client.desktop).length != 0) {
Expand All @@ -251,7 +255,7 @@ let insertLeft = function() {
// if tile has no children then don't tile
if (tile == undefined) {
printDebug("Could not insert " + client.resourceClass, false);
tileClient(client);
putClientInTile(client, oldTile);
}
putClientInTile(client, tile);
}
Expand Down Expand Up @@ -326,6 +330,7 @@ let insertRight = function() {
return;
}
printDebug("Inserting " + client.resourceClass + " right", false);
let oldTile = client.tile;
untileClient(client);
client.wasTiled = true;
if (windowsOnDesktop(tile, client.desktop).length != 0) {
Expand All @@ -334,7 +339,7 @@ let insertRight = function() {
// if tile has no children then don't tile
if (tile == undefined) {
printDebug("Could not insert " + client.resourceClass, false);
tileClient(client);
putClientInTile(client, oldTile);
}
putClientInTile(client, tile);
}
Expand Down

0 comments on commit 51b9cb2

Please sign in to comment.