diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-15 17:59:46 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-15 17:59:46 +0200 |
| commit | 2283ee78b57b4cd1f78d4c409b6d113cecbefac9 (patch) | |
| tree | 4e80c8f3b49992f56aa64025fae51ae7347f68f8 /src/command.zig | |
| parent | a6eeb5bbba35da70d225dfabb31265bc19e2bda8 (diff) | |
| download | river-2283ee78b57b4cd1f78d4c409b6d113cecbefac9.tar.gz river-2283ee78b57b4cd1f78d4c409b6d113cecbefac9.tar.xz | |
Track the focused output of seats
Diffstat (limited to 'src/command.zig')
| -rw-r--r-- | src/command.zig | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/command.zig b/src/command.zig index 347a1d7..1062d4a 100644 --- a/src/command.zig +++ b/src/command.zig @@ -24,7 +24,7 @@ pub fn exitCompositor(seat: *Seat, arg: Arg) void { /// Focus either the next or the previous visible view, depending on the bool /// passed. fn focusNextPrevView(seat: *Seat, next: bool) void { - const output = seat.input_manager.server.root.focusedOutput(); + const output = seat.focused_output; if (seat.focused_view) |current_focus| { // If there is a currently focused view, focus the next visible view in the stack. const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus); @@ -66,27 +66,25 @@ pub fn focusPrevView(seat: *Seat, arg: Arg) void { /// Modify the number of master views pub fn modifyMasterCount(seat: *Seat, arg: Arg) void { const delta = arg.int; - const root = &seat.input_manager.server.root; - const output = root.focusedOutput(); + const output = seat.focused_output; output.master_count = @intCast( u32, std.math.max(0, @intCast(i32, output.master_count) + delta), ); - root.arrange(); + seat.input_manager.server.root.arrange(); } /// Modify the percent of the width of the screen that the master views occupy. pub fn modifyMasterFactor(seat: *Seat, arg: Arg) void { const delta = arg.float; - const root = &seat.input_manager.server.root; - const output = root.focusedOutput(); + const output = seat.focused_output; const new_master_factor = std.math.min( std.math.max(output.master_factor + delta, 0.05), 0.95, ); if (new_master_factor != output.master_factor) { output.master_factor = new_master_factor; - root.arrange(); + seat.input_manager.server.root.arrange(); } } @@ -94,13 +92,12 @@ pub fn modifyMasterFactor(seat: *Seat, arg: Arg) void { /// TODO: if the top of the stack is focused, bump the next visible view. pub fn zoom(seat: *Seat, arg: Arg) void { if (seat.focused_view) |current_focus| { - const root = &seat.input_manager.server.root; - const output = root.focusedOutput(); + const output = seat.focused_output; const node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus); if (node != output.views.first) { output.views.remove(node); output.views.push(node); - root.arrange(); + seat.input_manager.server.root.arrange(); } } } @@ -108,21 +105,18 @@ pub fn zoom(seat: *Seat, arg: Arg) void { /// Switch focus to the passed tags. pub fn focusTags(seat: *Seat, arg: Arg) void { const tags = arg.uint; - const root = &seat.input_manager.server.root; - const output = root.focusedOutput(); - output.pending_focused_tags = tags; - root.arrange(); + seat.focused_output.pending_focused_tags = tags; + seat.input_manager.server.root.arrange(); } /// Toggle focus of the passsed tags. pub fn toggleTags(seat: *Seat, arg: Arg) void { const tags = arg.uint; - const root = &seat.input_manager.server.root; - const output = root.focusedOutput(); + const output = seat.focused_output; const new_focused_tags = output.current_focused_tags ^ tags; if (new_focused_tags != 0) { output.pending_focused_tags = new_focused_tags; - root.arrange(); + seat.input_manager.server.root.arrange(); } } |
