Skip to content

Commit

Permalink
command/focus-view: add -skip-floating
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon-Plickat authored and ifreund committed Mar 22, 2024
1 parent 6491310 commit b77b42f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion doc/riverctl.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ necessarily disjunct), an analogy to workspaces.
Focus the next or previous output, the closest output in any direction
or an output by name.

*focus-view* *next*|*previous*|*up*|*down*|*left*|*right*
*focus-view* [*-skip-floating*] *next*|*previous*|*up*|*down*|*left*|*right*
Focus the next or previous view in the stack or the closest view in
any direction.

- *-skip-floating*: Skip floating views, only focusing tiled ones.

*move* *up*|*down*|*left*|*right* _delta_
Move the focused view in the specified direction by _delta_ logical
pixels. The view will be set to floating.
Expand Down
16 changes: 13 additions & 3 deletions river/command/view_operations.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
const std = @import("std");
const assert = std.debug.assert;
const wlr = @import("wlroots");
const flags = @import("flags");

const server = &@import("../main.zig").server;

Expand All @@ -34,10 +35,19 @@ pub fn focusView(
args: []const [:0]const u8,
_: *?[]const u8,
) Error!void {
if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments;
const result = flags.parser([:0]const u8, &.{
.{ .name = "skip-floating", .kind = .boolean },
}).parse(args[1..]) catch {
return error.InvalidValue;
};
if (result.args.len < 1) return Error.NotEnoughArguments;
if (result.args.len > 1) return Error.TooManyArguments;

if (try getTarget(seat, args[1], .all)) |target| {
if (try getTarget(
seat,
result.args[0],
if (result.flags.@"skip-floating") .skip_float else .all,
)) |target| {
assert(!target.pending.fullscreen);
seat.focus(target);
server.root.applyPending();
Expand Down

0 comments on commit b77b42f

Please sign in to comment.