aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Ovelleiro Corral <mail@pablo.tools>2023-03-23 11:56:56 +0100
committerIsaac Freund <mail@isaacfreund.com>2023-03-25 14:32:31 +0100
commitb3698150708bec276454c0ff7c707d9dab446b1e (patch)
tree29d8e46789b4789c336b0fa0dc2ade2d1ee4031d
parente207a0e03a33a17cee40d4b2cecaef011293b38c (diff)
downloadriver-b3698150708bec276454c0ff7c707d9dab446b1e.tar.gz
river-b3698150708bec276454c0ff7c707d9dab446b1e.tar.xz
command/send-to-output: add -current-tags flag
-rw-r--r--doc/riverctl.1.scd5
-rw-r--r--river/command/output.zig17
2 files changed, 18 insertions, 4 deletions
diff --git a/doc/riverctl.1.scd b/doc/riverctl.1.scd
index 8e23619..7218a6c 100644
--- a/doc/riverctl.1.scd
+++ b/doc/riverctl.1.scd
@@ -50,10 +50,13 @@ over the Wayland protocol.
Snap the focused view to the specified screen edge. The view will
be set to floating.
-*send-to-output* *next*|*previous*|*up*|*right*|*down*|*left*|_name_
+*send-to-output* [*-current-tags*] *next*|*previous*|*up*|*right*|*down*|*left*|_name_
Send the focused view to the next or previous output, the closest
output in any direction or to an output by name.
+ - *-current-tags*: Assign the currently focused tags of the destination
+ output to the view.
+
*spawn* _shell_command_
Run _shell_command_ using `/bin/sh -c _shell_command_`. Note that
*spawn* only takes a single argument. To spawn a command taking
diff --git a/river/command/output.zig b/river/command/output.zig
index 64d021e..f2b973c 100644
--- a/river/command/output.zig
+++ b/river/command/output.zig
@@ -17,8 +17,8 @@
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;
-
const wlr = @import("wlroots");
+const flags = @import("flags");
const server = &@import("../main.zig").server;
@@ -52,7 +52,13 @@ pub fn sendToOutput(
_: *?[]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 = "current-tags", .kind = .boolean },
+ }).parse(args[1..]) catch {
+ return error.InvalidOption;
+ };
+ if (result.args.len < 1) return Error.NotEnoughArguments;
+ if (result.args.len > 1) return Error.TooManyArguments;
// If the noop output is focused, there is nowhere to send the view
if (seat.focused_output == null) {
@@ -61,10 +67,15 @@ pub fn sendToOutput(
}
if (seat.focused == .view) {
- const destination_output = (try getOutput(seat, args[1])) orelse return;
+ const destination_output = (try getOutput(seat, result.args[0])) orelse return;
// If the view is already on destination_output, do nothing
if (seat.focused.view.pending.output == destination_output) return;
+
+ if (result.flags.@"current-tags") {
+ seat.focused.view.pending.tags = destination_output.pending.tags;
+ }
+
seat.focused.view.setPendingOutput(destination_output);
server.root.applyPending();