commands: accept 'next'/'prev' output names

`move container to output`, `move workspace to output` and `focus
output` now accept 'next' and 'prev', which cycle through the enabled
outputs with wrap-around. This matches i3's behaviour of expanding
'next' into the full output list so the following output relative to
the current one is picked.

The name/direction/current resolution used by the move commands was
also duplicated inline in `focus_output`; both call sites now share a
new `output_by_direction_or_name` helper in `sway/desktop/output.c`.

Closes: #8799

i3 implementation in https://github.com/i3/i3/pull/4338
Note:
- i3 accepts multiple output arguments and `next` works as a wildcard. I
  considered that out of scope for this PR.
- i3 does not have `prev`. Accepting it in sway is natural and
  practically free complexity-wise so I added it.
This commit is contained in:
Orestis Floros 2026-04-26 08:55:33 +02:00
parent 1cbb8a440f
commit 9b81b6273f
No known key found for this signature in database
GPG key ID: A09DBD7D3222C1C3
5 changed files with 114 additions and 93 deletions

View file

@ -110,6 +110,9 @@ struct sway_output *output_by_name_or_id(const char *name_or_id);
// this includes all the outputs, including disabled ones
struct sway_output *all_output_by_name_or_id(const char *name_or_id);
struct sway_output *output_by_direction_or_name(const char *spec,
const struct sway_output *reference, double ref_lx, double ref_ly);
void output_sort_workspaces(struct sway_output *output);
void output_enable(struct sway_output *output);