Implement variable single-window ratio

This commit is contained in:
Ben Buhse 2026-03-19 14:25:25 -05:00
commit 63f5fc1bcd
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
6 changed files with 20 additions and 10 deletions

View file

@ -299,7 +299,8 @@ Full command reference:
| `toggle_fullscreen` | | Toggle fullscreen on focused window | | `toggle_fullscreen` | | Toggle fullscreen on focused window |
| `close_window` | | Close the focused window | | `close_window` | | Close the focused window |
| `exit_river` | | Exit the river session | | `exit_river` | | Exit the river session |
| `change_ratio` | float | Adjust primary/stack ratio on current output | | `change_primary_ratio` | float | Adjust primary/stack ratio on current output |
| `change_single_window_ratio` | float | Adjust single-window ratio on current output |
| `increment_primary_count`| | Add a window to the primary side | | `increment_primary_count`| | Add a window to the primary side |
| `decrement_primary_count`| | Remove a window from the primary side | | `decrement_primary_count`| | Remove a window from the primary side |
| `move_up` | pixels | Move floating window up | | `move_up` | pixels | Move floating window up |

View file

@ -2,6 +2,7 @@
These are in rough order of my priority, though no promises I do them in this order. These are in rough order of my priority, though no promises I do them in this order.
- [ ] Allow single-window ratio config PER output name
- [ ] Fix mouse resizing - [ ] Fix mouse resizing
- [ ] Add gap support - [ ] Add gap support
- [ ] Support window tag/order caching between WM restarts (within a river session) - [ ] Support window tag/order caching between WM restarts (within a river session)

View file

@ -72,8 +72,8 @@ keybinds {
// Float/unfloat the currently-focused window // Float/unfloat the currently-focused window
toggle_float Mod4+Shift F toggle_float Mod4+Shift F
// Change the primary ratio of the current output // Change the primary ratio of the current output
change_ratio Mod4 H 0.05 change_primary_ratio Mod4 H 0.05
change_ratio Mod4 L -0.05 change_primary_ratio Mod4 L -0.05
// Change the number of windows in the primary side // Change the number of windows in the primary side
increment_primary_count Mod4 I increment_primary_count Mod4 I
decrement_primary_count Mod4 D decrement_primary_count Mod4 D

View file

@ -309,9 +309,12 @@ can typically be found at _/usr/include/xkbcommon/xkbcommon-keysyms.h_.
*exit_river* *exit_river*
Exit the river session. Exit the river session.
*change_ratio* _modifiers_ _keysym_ _float_ *change_primary_ratio* _modifiers_ _keysym_ _float_
Adjust the primary/stack ratio on the current output. Adjust the primary/stack ratio on the current output.
*change_single_window_ratio* _modifiers_ _keysym_ _float_
Adjust the single-window ratio on the current output.
*increment_primary_count*, *decrement_primary_count* *increment_primary_count*, *decrement_primary_count*
Add/remove a window from the primary side. Add/remove a window from the primary side.

View file

@ -15,7 +15,9 @@ pub const Command = union(enum) {
zoom, zoom,
toggle_float, toggle_float,
// Changes the ratio on the focused output only // Changes the ratio on the focused output only
change_ratio: f32, change_primary_ratio: f32,
// Changes the ratio on the focused output only
change_single_window_ratio: f32,
// Changes the primary count on the focus output only // Changes the primary count on the focus output only
increment_primary_count, increment_primary_count,
decrement_primary_count, decrement_primary_count,
@ -65,7 +67,8 @@ pub const Command = union(enum) {
.send_to_prev_output, .send_to_prev_output,
.zoom, .zoom,
.toggle_float, .toggle_float,
.change_ratio, .change_primary_ratio,
.change_single_window_ratio,
.increment_primary_count, .increment_primary_count,
.decrement_primary_count, .decrement_primary_count,
.reload_config, .reload_config,
@ -202,10 +205,12 @@ const XkbBinding = struct {
window.pending_manage.floating = !window.floating; window.pending_manage.floating = !window.floating;
context.wm.river_window_manager_v1.manageDirty(); context.wm.river_window_manager_v1.manageDirty();
}, },
.change_ratio => |diff| { inline .change_primary_ratio, .change_single_window_ratio => |diff, cmd| {
const seat = first_seat orelse return; const seat = first_seat orelse return;
const output = seat.focused_output orelse return; const output = seat.focused_output orelse return;
output.pending_manage.primary_ratio = output.primary_ratio + diff; // Get rid of the "change_" from the start of the command name
const field_name = @tagName(cmd)[7..];
@field(output.pending_manage, field_name) = @field(output, field_name) + diff;
context.wm.river_window_manager_v1.manageDirty(); context.wm.river_window_manager_v1.manageDirty();
}, },
.increment_primary_count => { .increment_primary_count => {

View file

@ -118,7 +118,7 @@ pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
} }
break :sw .{ .spawn = split_exec }; break :sw .{ .spawn = split_exec };
}, },
.change_ratio => { inline .change_primary_ratio, .change_single_window_ratio => |cmd| {
const diff_str = utils.stripQuotes(node.arg(parser, 2) orelse { const diff_str = utils.stripQuotes(node.arg(parser, 2) orelse {
logWarnMissingNodeArg(name, "diff"); logWarnMissingNodeArg(name, "diff");
continue; continue;
@ -127,7 +127,7 @@ pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
logWarnInvalidNodeArg(name, diff_str); logWarnInvalidNodeArg(name, diff_str);
continue; continue;
}; };
break :sw .{ .change_ratio = diff }; break :sw @unionInit(XkbBindings.Command, @tagName(cmd), diff);
}, },
inline .focus_next_window, inline .focus_next_window,
.focus_prev_window, .focus_prev_window,