command/focus-view: add -skip-floating

This commit is contained in:
Leon Henrik Plickat 2023-11-10 04:53:20 +01:00 committed by Isaac Freund
parent 6491310e12
commit b77b42f0d6
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 16 additions and 4 deletions

View File

@ -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.

View File

@ -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;
@ -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();