Skip to content

sway/commands/move.c: negative coords move to the bottom/right edge#9058

Open
cizra wants to merge 1 commit into
swaywm:masterfrom
cizra:master
Open

sway/commands/move.c: negative coords move to the bottom/right edge#9058
cizra wants to merge 1 commit into
swaywm:masterfrom
cizra:master

Conversation

@cizra
Copy link
Copy Markdown

@cizra cizra commented Mar 6, 2026

Add a possibility to move a window to the bottom or right edge.
Sample config, tested and working:

for_window [app_id="whatever"] move position -1 ppt -1 ppt

@cizra
Copy link
Copy Markdown
Author

cizra commented Apr 9, 2026

Who do I ping to get this reviewed? Let's randomly pick @emersion as the author of a recent commit - would you know who to ping?

@emersion
Copy link
Copy Markdown
Member

emersion commented Apr 9, 2026

Is this something i3 does, or is this a new feature?

@cizra
Copy link
Copy Markdown
Author

cizra commented Apr 10, 2026

@emersion I've no idea, I haven't used i3 almost at all.
I just wanted a way to place the window in bottom right corner, independent of window size or screen resolution. I didn't find any other way to do it.

@Arnavion
Copy link
Copy Markdown

Arnavion commented Apr 27, 2026

Outputs can be placed at negative positions and a negative move position would be valid in that case, which this PR would break.

Even with all outputs at non-negative positions, someone may want to move to a negative position to position the window slightly off-screen, which this PR would break.


I just wanted a way to place the window in bottom right corner, independent of window size or screen resolution. I didn't find any other way to do it.

Parse swaymsg -t get_outputs with jq to get all the output positions and dimensions and then the math to get the bottom-right corner.

@cizra
Copy link
Copy Markdown
Author

cizra commented Apr 27, 2026

@Arnavion thanks for the insightful comments.
Currently I have this one-liner in my ~/.config/sway/config:

for_window [app_id="^$" shell="xdg_shell"] move position -1 ppt -1 ppt

How would I implement your suggestion? I would prefer not to change it to a daemon listening to events and moving windows around - it'd be an external system to manage, and it'd possibly introduce some flicker, if the window gets drawn somewhere, then moved elsewhere.

Would it be better to create a new command, movebr (for move-bottom-right) with this calculation logic?

@gwhitney
Copy link
Copy Markdown

gwhitney commented Apr 28, 2026

I, too, would like some feature very similar to this, as I have floating windows I want to place near the bottom/right of my display, and doing a round trip to an external executable to do the position computation and then back to sway with swaymsg seems much more cumbersome in addition to the drawbacks @cizra lists. After all, both Xwindows geometry specifications (-100-100) and css ('right' and 'bottom' properties) have ways of specifying offsets for the right and bottom edges of rectangles from their enclosures.

Please could a maintainer provide guidance on a design for this type of feature that would be acceptable? (And @cizra I am happy then to help with implementation if you would like.)

Personally, I would suggest that the options need to be independent for vertical and horizontal positioning; one might want to put a window in the top right or bottom left corners as well.

Therefore I would suggest that the possibility of keywords left or right before the first dimension and top or bottom before the second dimension be introduced, so that the overall syntax for this command would be

move [absolute] position [left|right] <x> [px|ppt] [top|bottom] <y> [px|ppt]

where either the keyword left or no keyword in that position at all would produce the current horizontal positioning behavior, while right would place the right edge of the window the given dimension away from the right edge of its workspace/screen, and similarly the keyword top or no keyword in that position would give the current vertical positioning behavior, while bottom would place the bottom edge of the window the given dimension away from the bottom of its workspace/screen.

Would revising this PR to implement this suggested syntax allow it to go on to further review? Or is there a different forum that would be preferable to the PR queue for proposing such a feature and having it approved for implementation? Thanks so much for guidance.

@cizra
Copy link
Copy Markdown
Author

cizra commented Apr 29, 2026

@gwhitney LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants