Skip to content
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

1412 bspwm resize #4955

Draft
wants to merge 4 commits into
base: next
Choose a base branch
from
Draft

1412 bspwm resize #4955

wants to merge 4 commits into from

Conversation

cmprmsd
Copy link

@cmprmsd cmprmsd commented Apr 22, 2022

Trying to rebase and fix @xzfc pull request #3545

original message:
bspwm-like tiling resize

  • Two-axis tiling resize. You can drag a 24-pixel window corner (purple) to perform a two-axis resize. Also, you can press Mod and drag a large corner inside the window (one-third of the window size).
    illustration

  • Live resize: the tree is rendered during the resize process.

  • You can still press ESC to cancel resizing and revert to the old state.

  • Introduced the concept of the minimum container size. E.g. the minimum width of leaf con with 10px borders is 21px (left border + right border + at least 1px for the window itself). The minimum size is defined recursively, e.g. the minimum height of the vsplit is the sum of minimum sizes of its children. The reason for this change: the live resize made it very easy to shrink containers as small as possible, so some restraints are required.

  • Misc update: ignore the drag if i3 can't perform the resize. Suppose the user tries to resize the rightmost window to the right using Mod+RMB drag. Obliviously, i3 can't do this. Before this PR, the drag has been propagated to the application (some apps would show a context menu). After this PR, the drag would be ignored at all (and the cursor would be shown as ✕). The reasoning behind this change: the user explicitly indicated their desire to resize the window by pressing the Mod key, and probably just miss clicked to the wrong part of the window. Done in 93e96f4.

  • Bugfix in tiling_resize(): you can now resize the window with pixel border by dragging the top border.

* **Two-axis tiling resize**.  You can drag a 24-pixel window corner (purple) to perform a two-axis resize. Also, you can press Mod and drag a large corner inside the window (one-third of the window size).
  ![illustration](https://user-images.githubusercontent.com/5121426/75146543-40a7c580-56f3-11ea-9b26-e14718699323.png)

* **Live resize**: the tree is rendered during the resize process.

* You can still press **ESC to cancel** resizing and revert to the old state.

* Introduced the concept of the **minimum container size**.  E.g. the minimum width of leaf con with 10px borders is 21px (left border + right border + at least 1px for the window itself).  The minimum size is defined recursively, e.g. the minimum height of the vsplit is the sum of minimum sizes of its children.  The reason for this change: the live resize made it very easy to shrink containers as small as possible, so some restraints are required.

* ~Misc update: ignore the drag if i3 can't perform the resize.  Suppose the user tries to resize the rightmost window to the right using Mod+RMB drag.  Obliviously, i3 can't do this.  Before this PR, the drag has been propagated to the application (some apps would show a context menu).  After this PR, the drag would be ignored at all (and the cursor would be shown as ✕).  The reasoning behind this change: the user explicitly indicated their desire to resize the window by pressing the Mod key, and probably just miss clicked to the wrong part of the window.~ Done in [93e96f4](i3@93e96f4).

* Bugfix in `tiling_resize()`: you can now resize the window with pixel border by dragging the top border.
* enum border_t -> enum resize_direction_t
* resize_cursor() -> xcursor_type_for_resize_direction()
* resize_get_borders_sides(), resize_get_borders_mod() -> get_resize_direction()
* resize_find_tiling_participants_two_axes()
@cmprmsd cmprmsd mentioned this pull request Apr 22, 2022
Same fix as in this commit from 2020 that was previously mentioned in 
the PR discussion.
i3@93e96f4
/* Accumulate minimum size of the con based on child->min_size.
* We may use child->min_size only after calling render_con(child).
*
* TODO: this isn't perfect as it fails to handle some corner cases,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please investigate if the discussion in #3545 (comment) applies?

I'd rather not introduce less-than-optimal behaviour.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review!
These corner cases are not unique and new to this pr. I tried them with a upstream i3 on v 4.19.2 and there you can resize the bottom window even through the stacked titles.
image

also upstream with titlebar for the bottom tile you will see it disappear:
image

So these are not issues created by this pull request.
xzfc comment pointed to this edge case as well:
image

but as I verified it not being caused by this implementation it's fine for now.
Maybe there's some better way in the future to calculate the minimum size in the future.

The way the minimum size is calculated in this version does stop the bottom tile from moving more than one decoration through the stacked top ones. So it's at least a little improvement.

I work with this forked version for some days now and did not find any problems with it yet.

@@ -131,6 +139,33 @@ void render_con(Con *con) {
child->rect.x, child->rect.y, child->rect.width, child->rect.height);
x_raise_con(child);
render_con(child);

/* Accumulate minimum size of the con based on child->min_size.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If fixing #3544 is needed for this feature (ref: #3545 (comment)) I would also prefer to extract the necessary bug fixes in a separate PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3544 was fixed by @xzfc and has been merged upstream two years ago. I think this has already been resolved in #3949 :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment was before this PR by the same person.

@cmprmsd
Copy link
Author

cmprmsd commented Apr 25, 2022

Thanks for your comments! I'll have to look into them. I clearly am no developer but trying my best to understand how this could work out. 😅

Contributors are welcome. I guess that'll would mean inviting some people to this fork if there is anyone willing to try. :)

@orestisfl orestisfl added the stale Issue or PR has become stale and will be closed soon label Jul 21, 2023
@orestisfl orestisfl closed this Jul 21, 2023
@cmprmsd
Copy link
Author

cmprmsd commented Jul 21, 2023

I was waiting on feedback what has to be done to get this merged. I think I replied to everything.
Help 😅

@cmprmsd
Copy link
Author

cmprmsd commented Jul 21, 2023

Btw, I'm using this forked branch on 4.14 since a year now in virtual machines without any issues.
Shall I rebase on the latest master branch to get this merged?

@orestisfl orestisfl reopened this Jul 21, 2023
@orestisfl orestisfl removed the stale Issue or PR has become stale and will be closed soon label Jul 21, 2023
@orestisfl
Copy link
Member

Apologies for closing.

This branch does seem to have significant conflicts with next now though.

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

Successfully merging this pull request may close these issues.

None yet

3 participants