-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix layout when fullscreen #4293
Conversation
If there is more than one new window layout correctly by calculating the default size of the new windows using the information of how many of them there are in total. This helps with issue swaywm#3547 but doesn't fix it in all situations. Things now work correctly if the first layout of new windows happens after leaving fullscreen. But if for some reason an arrange_container() gets called while we are fullscreen the windows will still be incorrectly sized after saved_width/saved_height get used to restore the first window's size before going fullscreen.
This isn't quite what I had in mind. I meant setting each weighting value to 1 when the container is created then not changing them until the user resizes them. They would not sum to 1. In all places where we zero the width and height, we would make it reset the weighting to 1 instead. There would then be no reason to have the I consider the above approach to be more of a refactor than a bug fix. A fix should be merged first, then we can look into how well weighting would work and whether it's worth it (that alliteration was not intentional). |
Merging a fix first would be merging #4283. That one is a fix without changing the way the code works. But that's just uglier and it has to manipulate |
I think this is what you meant. It's indeed much simpler. I started along these lines last night and then for some reason didn't think it was going to work. In my defense it was late and I was tired :) The diff right now is probably good but the commit sequence arrives at it in a roundabout way. I'll squash/rework stuff into a cleaner history. |
06e5343
to
f36e925
Compare
I've condensed it into two commits. The first does the layout changes, the second implements the resize command based on the new layout method. So hopefully this is mergeable now. |
f36e925
to
64fb008
Compare
I've just come across a behavior that probably means normalization to the sum being 1.0 is actually needed:
The expected result would be two equally sized windows but because the existing window has a factor that's different than 1.0 the new window will not be half size and can be larger or smaller depending on the remaining factor. So the previous code is actually the one that retains current behavior while fixing bugs. |
64fb008
to
11648aa
Compare
I've pushed the normalizing solution again, as it seems needed to have correct behavior. It may still be possible to make the layout functions simpler but probably not by too much without altering behavior. |
11648aa
to
6c817ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style wise, there are several lines that:
- are well over 80 columns and could be split
- have indentation issues
- are not cleanly split across lines
Functionality wise:
- floating containers do not work. the views just render on top of each other
- if you float and re-tile a floating view a few times, it will continuously get smaller when tiled
Thanks for the review. Do you have an example of what you mean with the floating containers rendering on top of each other? I just tested with GIMP and its floating windows and everything seems to work as expected. I've pushed a fix for the issue of reducing size on going from floating to tiled. |
d4902f4
to
885c017
Compare
Float a view, split it (horizontally or vertically, doesn't matter), open another view. Instead of being split, the two views take up the full size of the floating container. Using the opacity command may help visualize it. |
885c017
to
e973ca7
Compare
Thanks. I've pushed a fix. |
A couple more issues: If you create If you have one output with |
I'll have a look at these but I don't know what the correct behavior is. This PR sizes things by a fraction of the total container and when a view is coming from somewhere else it's treated as if it's new. This will naturally be different behavior than using the width/height of existing views as the starting point to rearrange the container. So the behavior will never match current behavior in all situations. If that's wanted I did another PR that adjusted |
e973ca7
to
8b04f73
Compare
Both cases are fixed now, thanks again for looking at this. They were just missing fixes in the move command which already setts width/height to 0. So it may very well be that this approach actually does deliver the same behavior as right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few line length issues. Other than that, looks good. Can you please edit the original post and add Fixes #xxxx
for the issue(s) that this resolves?
8b04f73
to
c10e9d6
Compare
I've fixed those now. The commits already have the |
b4f15c1
to
13b0188
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Can you squash this into a single commit?
Should it really be a single commit? At least the first commit is independent and the others help explain the changes. |
I guess the first commit can remain separate, but the rest of the commits are a logical grouping. Without commits 3-8, commit 2 is not in a usable state and commits 3-8 don't make sense on there own as they are essentially just intermediary fixes for the second commit. Feel free to include as much information as you want in the commit message to explain the changes, but the commit history should be clean and logically grouped together. |
It depends on the project. Some would prefer a sequence of commits that does the work building upon each other. |
Instead of using container->width/height as both the input and output of the layout calculation have container->width_fraction/height_fraction as the share of the parent this container occupies and calculate the layout based on that. That way the container arrangement can always be recalculated even if width/height have been altered by things like fullscreen. To do this several parts are reworked: - The vertical and horizontal arrangement code is ajusted to work with fractions instead of directly with width/height - The resize code is then changed to manipulate the fractions when working on tiled containers. - Finally the places that manipulated width/height are adjusted to match. The adjusted parts are container split, swap, and the input seat code. It's possible that some parts of the code are now adjusting width and height only for those to be immediately recalculated. That's harmless and since non-tiled containers are still sized with width/height directly it may avoid breaking other corner cases. Fixes swaywm#3547 Fixes swaywm#4297
13b0188
to
a4ca232
Compare
A general rule for sway's commit history is a change log should be able to be generated from the short log. Also, I appreciate the work you are putting into this and not trying to come off rude, but please don't argue sway's conventions by saying what other project use. They are set and are not going to change. |
Thanks! |
Thanks for the patience to review it! I'll get the gaps PR ready based on this. |
This is an alternative to #4283 that's implemented using width/height fractions of the parent container. It seems to make the code cleaner, although it also required changing the resize command to match. As far as I can tell everything works fine.
Fixes #3547
Fixes #4297