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
view: Implement set-position and set-geometry #449
Conversation
This closes #368 btw :) |
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.
In addition to the above commands, this refactors the move and resize functions to use the setPosition and setGeometry commands. This way there is only one true way of setting position and geometry of windows.
This is very nice. There's still one place left with duplicate logic however, see the .resize
branch in Cursor.processMotion()
. I think that could be replaced with the new View.resize()
as well, though maybe it's better to hold off on that refactor for now to avoid conflicts with #399.
On a higher level, I'm curious what you use these new commands for in your workflow. With the current restriction of functioning only on the currently focused view I'm not sure how I would use them...
It's nice for positioning some windows as part of a larger setup (e.g. a terminal running |
hmm, could you elaborate a bit more on this? From a code standpoint this PR seems solid, I'm just not yet convinced that this feature is widely useful due to the restriction to always targeting the focused view. |
During my Master's thesis, I used something like this to set up my initial workspace(s) every morning: riverctl spawn "alacritty --with --some --extra --args"
sleep 0.2
riverctl move right 100
riverctl spawn "other stuff"
sleep 0.2
riverctl snap up Having set-position and set-geometry makes this process a bit nicer. |
The command `set-position x y` sets the current view's coordinates to be (x, y) relative to the current output. The view will always remain within the bounds of the current output. Any parts of the view that end up outside of the current output are silently truncated. The command `set-geometry w h` sets the geometry of a view to be `w` wide and `h` high. Any parts of the view that end up outside of the current output's bounding box are silently truncated. View truncation is applied as shown below: +-------------+ +-------------+ | output | | output | | +------+--+ ------> | +------+ | | view | | | | view | +------+------+ | +------+------+ +---------+
Hit a panic when attempting to move a view past the edge of the output in a nested session:
|
I've come around on having this feature in river. It's not really that complex and lets us unify some code paths. We should also be able to get rid of the separate resize handling in |
To add to what @ThreeFx already said, this feature could be useful for floating terminals. For example I use a floating terminal with an mpc client that can toggled with a key binding.
|
Is this feature still planned for River as I'd find it extremely useful ? |
I'm not opposed to it, though I don't have plans to implement it myself. In any case this PR is unfortunately quite out of date now. I'd recommend anyone interested on working on this to wait until I resolve the issues described in #828 to avoid conflicts and save time for both of us. |
The command
set-position x y
sets the current view's coordinates to be(x, y) relative to the current output. The view will always remain
within the bounds of the current output. Any parts of the view that end
up outside of the current output are silently truncated.
The command
set-geometry w h
sets the geometry of a view to bew
wide and
h
high. Any parts of the view that end up outside of thecurrent output's bounding box are silently truncated.
View truncation is applied as shown below:
In addition to the above commands, this refactors the
move
andresize
functions to use thesetPosition
andsetGeometry
commands. This way there is only one true way of setting position and geometry of windows.