lingtjien/Grid-Tiling-Kwin

Rearranging windows after closing one window

Closed this issue · 4 comments

Hi Ling,

I've come across a behavior in Plumb for Windows which is a less feature-rich tiling solution, but it does this one thing right which is missing from Grid-Tiling, and it's the behaviour I didn't think I'd need until I experienced it. I'll explain it below. Also excuse me for using non-technical language such as window and screen.

I open 5 windows in one screen that has 3 columns x 2 rows configuration.

+---+---+---+
| 1 | 2 |   |
+---+---+ 5 +
| 3 | 4 |   |
+---+---+---+

I then close window number 4.

+---+---+---+
| 1 |   |   |
+---+ 2 + 5 +
| 3 |   |   |
+---+---+---+

Expected:

+-----+-----+
|  1  |  2  |
+-----+-----+
|  3  |  5  |
+-----+-----+

Neither refreshing or moving windows around doesn't help in achieving the expected result. Only switching to another workspace and back from what I've tried. What do you think?

Best Regards,
Andrei

You set a grid of 3x2, so what you observe is the correct behavior when you go from

+---+---+---+
| 1 | 2 |   |
+---+---+ 5 +
| 3 | 4 |   |
+---+---+---+

to

+---+---+---+
| 1 |   |   |
+---+ 2 + 5 +
| 3 |   |   |
+---+---+---+

So you're already in a "correct state" at this point, so a refresh won't do anything (or at least it shouldn't). If you now want to go to this state, what you technically want; is to move client 5 to the column left of it

+-----+-----+
|  1  |  2  |
+-----+-----+
|  3  |  5  |
+-----+-----+

So you need to focus client 5 and use the global shortcut Grid-Tiling: Move/Swap Left to move this client into the column left of it, which will make column 3 empty and remove it. (If this action would violate minSpace then it will swap the columns 2 and 3 instead of moving the client inside column 3 into column 2)

Would you accept a pull request with an opt-in configuration "Keep tiles equally split among columns and rows"?

I kindly consider this correct behavior less useful to me. The automatic tiling functionality is the essence of tiling scripts so it's better if we have to rely less on manual commands. Splitting equally would be useful to my case because it doesn't clutter up the content and it makes it most readable.

So that if you have 9x3, you never end up in

+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |
+ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 +
|   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+

but always in

+-----------+-----------+-----------+
|     1     |     2     |     3     |
|           |           |           |
+-----------+-----------+-----------+
|     4     |     5     |     6     |
|           |           |           |
+-----------+-----------+-----------+
|     7     |     8     |     9     |
|           |           |           |
+-----------+-----------+-----------+

I understand how this would not be intuitive and might cause the user to lose track of which tile is which. But a strategy could be made to only move one tile at most.
I understand the reason that someone wants 9x3 is to have it spread out more over columns than rows as you might have a super-ultrawide monitor. But that is not the most usual case.

What do you think?

Best Regards!

There are two extreme ways to go about solving this and then there is the whole spectrum in between.

  1. On one end of the spectrum you have no automatic tiling at all and the script would always add new columns (or rows) and then the user would have to rearrange them, themselves to come to their desired result.

  2. On the other end you have full enforced automatic tiling which would always enforce clients in a certain arrangement.

They both have pros and cons, the main ones in my opinion. That the first one requires a lot of user input to come to ones desired arrangement, but the second one makes the user less flexible or even prevents their desired arrangement.

The problem with always enforcing a square arrangement is that this removes a lot of flexibility and may be undesirable for people that have setups where they desire a non square arrangement, such as wide screen monitors. So making something that would automatically always square up the arrangement would take away that flexibility from those users.

Currently the script already tries to keep the arrangement as "square" as possible, but only when adding new clients, so not on removing clients. My idea behind this was that, this way I suggest a square arrangement, but the user is still free to move clients around into their desired arrangement. This reduces user input for people that want a square arrangement, but still keeps the flexibility for people that don't.

There are also people that prefer new clients to always be added as a new column, so even this squaring of only the new clients is opinionated.

With all that having been said, I do think that a global shortcut that attempts to arrange the clients as square as possible should be doable, but I don't think always enforcing this is the way to go?

Also, if you have set a 9x3 grid size and you open 9 clients, it should automatically arrange them like this

+-----------+-----------+-----------+
|     1     |     2     |     5     |
|           |           |           |
+-----------+-----------+-----------+
|     3     |     4     |     6     |
|           |           |           |
+-----------+-----------+-----------+
|     7     |     8     |     9     |
|           |           |           |
+-----------+-----------+-----------+

Closing for now, perhaps in the future when I have to do some rewriting for Wayland, I'll take another look at this and implement a few different default placing algorithms