diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 45a8ec5..b8923a2 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -299,7 +299,8 @@ Full command reference: | `toggle_fullscreen` | | Toggle fullscreen on focused window | | `close_window` | | Close the focused window | | `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 | | `decrement_primary_count`| | Remove a window from the primary side | | `move_up` | pixels | Move floating window up | diff --git a/docs/TODO.md b/docs/TODO.md index e1bae66..2535476 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -2,6 +2,7 @@ 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 - [ ] Add gap support - [ ] Support window tag/order caching between WM restarts (within a river session) diff --git a/examples/config.kdl b/examples/config.kdl index 84d702f..639d42d 100644 --- a/examples/config.kdl +++ b/examples/config.kdl @@ -72,8 +72,8 @@ keybinds { // Float/unfloat the currently-focused window toggle_float Mod4+Shift F // Change the primary ratio of the current output - change_ratio Mod4 H 0.05 - change_ratio Mod4 L -0.05 + change_primary_ratio Mod4 H 0.05 + change_primary_ratio Mod4 L -0.05 // Change the number of windows in the primary side increment_primary_count Mod4 I decrement_primary_count Mod4 D diff --git a/man/beansprout.5.scd b/man/beansprout.5.scd index a02dbf6..84acf1f 100644 --- a/man/beansprout.5.scd +++ b/man/beansprout.5.scd @@ -309,9 +309,12 @@ can typically be found at _/usr/include/xkbcommon/xkbcommon-keysyms.h_. *exit_river* Exit the river session. -*change_ratio* _modifiers_ _keysym_ _float_ +*change_primary_ratio* _modifiers_ _keysym_ _float_ 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* Add/remove a window from the primary side. diff --git a/src/XkbBindings.zig b/src/XkbBindings.zig index e644e50..347502c 100644 --- a/src/XkbBindings.zig +++ b/src/XkbBindings.zig @@ -15,7 +15,9 @@ pub const Command = union(enum) { zoom, toggle_float, // 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 increment_primary_count, decrement_primary_count, @@ -65,7 +67,8 @@ pub const Command = union(enum) { .send_to_prev_output, .zoom, .toggle_float, - .change_ratio, + .change_primary_ratio, + .change_single_window_ratio, .increment_primary_count, .decrement_primary_count, .reload_config, @@ -202,10 +205,12 @@ const XkbBinding = struct { window.pending_manage.floating = !window.floating; 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 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(); }, .increment_primary_count => { diff --git a/src/config/keybind.zig b/src/config/keybind.zig index 1f8372f..6c51a99 100644 --- a/src/config/keybind.zig +++ b/src/config/keybind.zig @@ -118,7 +118,7 @@ pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void { } 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 { logWarnMissingNodeArg(name, "diff"); continue; @@ -127,7 +127,7 @@ pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void { logWarnInvalidNodeArg(name, diff_str); continue; }; - break :sw .{ .change_ratio = diff }; + break :sw @unionInit(XkbBindings.Command, @tagName(cmd), diff); }, inline .focus_next_window, .focus_prev_window,