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

Allow resize in both direcitons on Meta+Right click #860

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

russelltg
Copy link

@russelltg russelltg commented Sep 13, 2024

Closes #858

This is just an initial implementation, it seems to work alright but I'm unfamiliar with this codebase so may have done something in a silly way.

@russelltg
Copy link
Author

russelltg commented Sep 13, 2024

Quick demo:

2024-09-13.02-33-27.mp4

@russelltg
Copy link
Author

Definitely has a some bugs with more windows on screen that I'll have to figure out

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

This is just an initial implementation, it seems to work alright but I'm unfamiliar with this codebase so may have done something in a silly way.

Seems sensible, I also thought about how to fix this already, so here are some thoughts. Your implementation is quite close to how I envision this being solved, I would appreciate it, should you continue working on this.

@@ -94,6 +94,7 @@ impl PointerTarget<State> for ResizeForkTarget {
location.as_global(),
node,
left_up_idx,
None,
Copy link
Member

Choose a reason for hiding this comment

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

Preferably these would also gain the option to do more complex grabs at corners, but I guess we can leave this for now.

node: NodeId,
output: WeakOutput,
left_up_idx: usize,
parent_left_up_idx: Option<usize>,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of splitting this in parent and node/, I would prefer, if we separately determine the left_idx and left_node and the up_idx and the up_node. (And have both be an Option, though the grab should obviously never be created with both being None.)

Copy link
Author

Choose a reason for hiding this comment

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

The *_node values would be instances of something like enum ResizeDest { Node, NodeParent }?

Copy link
Author

Choose a reason for hiding this comment

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

Okay, looking at your other comment about having to walk up the tree until finding a split of the correct orientation, this needs to be a ResizeDest(usize) meaning how many times we need to walk towards the root?

Copy link
Author

Choose a reason for hiding this comment

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

Okay, looking at your other comment about having to walk up the tree until finding a split of the correct orientation, this needs to be a ResizeDest(usize) meaning how many times we need to walk towards the root?

Copy link
Member

@Drakulix Drakulix Sep 18, 2024

Choose a reason for hiding this comment

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

The *_node values would be instances of something like enum ResizeDest { Node, NodeParent }?

No just NodeIds. You don't need to know how far you have walked, if you just mark the nodes we do the resize operations on. (Both of them, one for each axis.)

orientation, sizes, ..
}) = parent.map(|p| tree.get_mut(&p).unwrap().data_mut())
{
if *orientation == child_orientation {
Copy link
Member

Choose a reason for hiding this comment

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

This can happen, we simply have to walk up the tree in a while-loop and select the next parent to check for it's orientation, until we potentially get None (which will happen if there isn't any edge in the other direction as we hit the workspace/output border).

Fixes pop-os#858

This is just an initial implementation, it seems to work alright but I'm unfamilar with this codebase so may have done something in a silly way.
Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

This seems pretty spot on what I had in mind! Just a couple of nitpicks. :)

Also please remember to remove the draft-status, once you want me to test this and eventually merge.

@@ -2463,41 +2463,74 @@ impl TilingLayout {
edges
}

// Returns (left_node_idx, up_node_idx)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should just create a struct definition for the return type at this point, so we can name these fields.

@@ -83,6 +83,10 @@ impl PointerTarget<State> for ResizeForkTarget {
data.common.event_loop_handle.insert_idle(move |state| {
let pointer = seat.get_pointer().unwrap();
let location = pointer.current_location();
let (left_node_idx, right_node_idx) = match orientation {
Copy link
Member

Choose a reason for hiding this comment

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

left and right? Shouldn't this be left and up?

@russelltg russelltg marked this pull request as ready for review September 24, 2024 22:11
@russelltg
Copy link
Author

Just realized I swapped the resize grab directions, will fix tomorrow

@russelltg
Copy link
Author

russelltg commented Oct 9, 2024

Ok, upon further review I don't think I regressed the grab--this snippet is from master (and it's the same on this branch)

I think this branch is ready for testing/review.

In my opinion the tiling "grab by hovering in the middle" is kinda strange as cosmic also allows you to drag the edges of the window...definitely a reason why I much prefer the Meta+Right click resize.

2024-10-08.21-29-46.mp4

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.

Feature Request: Meta+Right click resize in two directions at once
2 participants