kwin-scripts / kwin-tiling

Tiling script for kwin
GNU General Public License v2.0
1.1k stars 68 forks source link

Option to maximize when there is only one window #235

Open deleterium opened 3 years ago

deleterium commented 3 years ago

Hi! I know there is no big difference when the window is maximized or just resized to entire screen. But of course there is a difference in some applications. Some users may prefer to use the window maximized when there is only one!

My case is that I use another script for kwin named hide-titles ( https://github.com/bahamondev/hide-titles ). That script hides the title bar only when the window is maximized, but that script didn't work with this project...

I'm not pro in programming, but I solved this issue creating couple of lines, that add new config. I set it manually in kwinrc (I don't have knowledge to edit the .ui files and their control logic). So I just let the code here to make easier to implement this enhancement!


diff --git a/contents/code/tiling.js b/contents/code/tiling.js
index de5c117..36f66fc 100644
--- a/contents/code/tiling.js
+++ b/contents/code/tiling.js
@@ -50,6 +50,7 @@ function Tiling(layoutType, desktop, screen) {
         this.userActive = true;

         var gapSize = KWin.readConfig("gapSize", 0);  /* stick to old gaps config by default */
+        this.maximizeWhenOnlyOne = KWin.readConfig("maximizeWhenOnlyOne", false);
         this.windowsGapSizeHeight = KWin.readConfig("windowsGapSizeHeight", gapSize);
         this.windowsGapSizeWidth = KWin.readConfig("windowsGapSizeWidth", gapSize);
         this.screenGapSizeLeft = KWin.readConfig("screenGapSizeLeft", 0);
@@ -344,6 +345,10 @@ Tiling.prototype._updateAllTiles = function() {
         // Set the position/size of all tiles
         if (this.active == true && this.userActive == true) {
             this.resizeScreen();
+            if (this.layout.tiles.length == 1 && this.maximizeWhenOnlyOne == true) {
+                this.tiles[0].clients[0].setMaximize(true, true);
+                    return;
+            }
             for (var i = 0; i < this.layout.tiles.length; i++) {
                 var newRect = this.layout.tiles[i].rectangle;
                 if (! newRect) {
´´´
faho commented 3 years ago

setMaximize doesn't appear to be a thing according to the docs, and as far as I know there never was a way to set maximize state from scripts.

deleterium commented 3 years ago

I know it is strange, but I found setMaximize inside the code, file tilelist.js line 222 --- client.setMaximize(true, true); and it just works!

faho commented 3 years ago

Oh, jesus, so the docs are now outright incomplete? Lovely.

laloch commented 3 years ago

Oh, jesus, so the docs are now outright incomplete? Lovely.

My fault. I've added setMaximize to KWin back in 2019, but I completely forgot about the API docs.

santiago-webdev commented 3 years ago

I guess this belongs here since it's related and I didn't wanted to create another issue: If you select the option to maximize window, it makes it wider and larger just to fit on the screen, but it's not really a "maximized" window per se, so the window doesn't make the panel adaptive opacity work and it doesn't apply the effect. I tried to read the code base, but I didn't really find a way to do this from the script itself since I don't know js, I was thinking about making a qdbus call to really make it maximized, but as I said, I'm not able to fix it, so I'll leave my concern here