Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Option to maximize when there is only one window #235

Open
deleterium opened this issue Dec 27, 2020 · 5 comments
Open

Option to maximize when there is only one window #235

deleterium opened this issue Dec 27, 2020 · 5 comments
Labels

Comments

@deleterium
Copy link

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

faho commented Dec 27, 2020

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.

@faho faho closed this as completed Dec 27, 2020
@faho faho added the upstream label Dec 27, 2020
@deleterium
Copy link
Author

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

faho commented Dec 27, 2020

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

@faho faho reopened this Dec 27, 2020
@laloch
Copy link
Contributor

laloch commented Feb 5, 2021

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.

@santiagogonzalez-dev

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants