aboutsummaryrefslogtreecommitdiff
path: root/src/command
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-05-19 22:59:50 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-05-19 22:59:50 +0200
commitcee41e925dc0a9d7460806c9f8386512b207edf3 (patch)
tree75799b00cf703d4196864a261e01ff8ec53699f2 /src/command
parent569308d91b7d6ea19a283a3db4a612f9e5d881d7 (diff)
downloadriver-cee41e925dc0a9d7460806c9f8386512b207edf3.tar.gz
river-cee41e925dc0a9d7460806c9f8386512b207edf3.tar.xz
Implement command execution through riverctl
Diffstat (limited to 'src/command')
-rw-r--r--src/command/close.zig (renamed from src/command/close_view.zig)4
-rw-r--r--src/command/exit.zig (renamed from src/command/exit_compositor.zig)4
-rw-r--r--src/command/focus.zig (renamed from src/command/focus_view.zig)4
-rw-r--r--src/command/focus_all_tags.zig25
-rw-r--r--src/command/focus_output.zig2
-rw-r--r--src/command/focus_tag.zig (renamed from src/command/focus_tags.zig)10
-rw-r--r--src/command/mod_master_count.zig (renamed from src/command/modify_master_count.zig)4
-rw-r--r--src/command/mod_master_factor.zig (renamed from src/command/modify_master_factor.zig)4
-rw-r--r--src/command/mode.zig2
-rw-r--r--src/command/send_to_output.zig2
-rw-r--r--src/command/spawn.zig2
-rw-r--r--src/command/tag_view.zig (renamed from src/command/set_view_tags.zig)8
-rw-r--r--src/command/tag_view_all_tags.zig31
-rw-r--r--src/command/toggle_float.zig2
-rw-r--r--src/command/toggle_tag_focus.zig (renamed from src/command/toggle_tags.zig)6
-rw-r--r--src/command/toggle_view_tag.zig (renamed from src/command/toggle_view_tags.zig)8
-rw-r--r--src/command/zoom.zig2
17 files changed, 87 insertions, 33 deletions
diff --git a/src/command/close_view.zig b/src/command/close.zig
index 7bee0b6..c5be01c 100644
--- a/src/command/close_view.zig
+++ b/src/command/close.zig
@@ -17,11 +17,11 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Close the focused view, if any.
-pub fn close_view(seat: *Seat, arg: Arg) void {
+pub fn close(seat: *Seat, arg: Arg) void {
if (seat.focused_view) |view| {
// Note: we don't call arrange() here as it will be called
// automatically when the view is unmapped.
diff --git a/src/command/exit_compositor.zig b/src/command/exit.zig
index 7736452..799b12c 100644
--- a/src/command/exit_compositor.zig
+++ b/src/command/exit.zig
@@ -17,10 +17,10 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Exit the compositor, terminating the wayland session.
-pub fn exitCompositor(seat: *Seat, arg: Arg) void {
+pub fn exit(seat: *Seat, arg: Arg) void {
c.wl_display_terminate(seat.input_manager.server.wl_display);
}
diff --git a/src/command/focus_view.zig b/src/command/focus.zig
index 225fa5e..930a36c 100644
--- a/src/command/focus_view.zig
+++ b/src/command/focus.zig
@@ -17,14 +17,14 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
const View = @import("../View.zig");
const ViewStack = @import("../view_stack.zig").ViewStack;
/// Focus either the next or the previous visible view, depending on the enum
/// passed. Does nothing if there are 1 or 0 views in the stack.
-pub fn focusView(seat: *Seat, arg: Arg) void {
+pub fn focus(seat: *Seat, arg: Arg) void {
const direction = arg.direction;
const output = seat.focused_output;
if (seat.focused_view) |current_focus| {
diff --git a/src/command/focus_all_tags.zig b/src/command/focus_all_tags.zig
new file mode 100644
index 0000000..d2eef88
--- /dev/null
+++ b/src/command/focus_all_tags.zig
@@ -0,0 +1,25 @@
+// This file is part of river, a dynamic tiling wayland compositor.
+//
+// Copyright 2020 Isaac Freund
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+const Arg = @import("../Command.zig").Arg;
+const Seat = @import("../Seat.zig");
+
+/// Set focus to all tags
+pub fn focusAllTags(seat: *Seat, arg: Arg) void {
+ seat.focused_output.pending_focused_tags = 0xFFFFFFFF;
+ seat.input_manager.server.root.arrange();
+}
diff --git a/src/command/focus_output.zig b/src/command/focus_output.zig
index 5140943..02b7999 100644
--- a/src/command/focus_output.zig
+++ b/src/command/focus_output.zig
@@ -19,7 +19,7 @@ const std = @import("std");
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Output = @import("../Output.zig");
const Seat = @import("../Seat.zig");
diff --git a/src/command/focus_tags.zig b/src/command/focus_tag.zig
index aa29b7c..edb3292 100644
--- a/src/command/focus_tags.zig
+++ b/src/command/focus_tag.zig
@@ -15,14 +15,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-const c = @import("../c.zig");
-
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
-/// Switch focus to the passed tags.
-pub fn focusTags(seat: *Seat, arg: Arg) void {
- const tags = arg.uint;
+/// Switch focus to the passed tag.
+pub fn focusTag(seat: *Seat, arg: Arg) void {
+ const tags = @as(u32, 1) << @intCast(u5, arg.uint - 1);
seat.focused_output.pending_focused_tags = tags;
seat.input_manager.server.root.arrange();
}
diff --git a/src/command/modify_master_count.zig b/src/command/mod_master_count.zig
index c7a5ac1..bd2fde0 100644
--- a/src/command/modify_master_count.zig
+++ b/src/command/mod_master_count.zig
@@ -19,11 +19,11 @@ const std = @import("std");
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Modify the number of master views
-pub fn modifyMasterCount(seat: *Seat, arg: Arg) void {
+pub fn modMasterCount(seat: *Seat, arg: Arg) void {
const delta = arg.int;
const output = seat.focused_output;
output.master_count = @intCast(
diff --git a/src/command/modify_master_factor.zig b/src/command/mod_master_factor.zig
index b2af06f..2e2a73c 100644
--- a/src/command/modify_master_factor.zig
+++ b/src/command/mod_master_factor.zig
@@ -19,11 +19,11 @@ const std = @import("std");
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Modify the percent of the width of the screen that the master views occupy.
-pub fn modifyMasterFactor(seat: *Seat, arg: Arg) void {
+pub fn modMasterFactor(seat: *Seat, arg: Arg) void {
const delta = arg.float;
const output = seat.focused_output;
const new_master_factor = std.math.min(
diff --git a/src/command/mode.zig b/src/command/mode.zig
index cf0d709..706533c 100644
--- a/src/command/mode.zig
+++ b/src/command/mode.zig
@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Switch to the given mode
diff --git a/src/command/send_to_output.zig b/src/command/send_to_output.zig
index f0658ca..7e0bbbf 100644
--- a/src/command/send_to_output.zig
+++ b/src/command/send_to_output.zig
@@ -19,7 +19,7 @@ const std = @import("std");
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Output = @import("../Output.zig");
const Seat = @import("../Seat.zig");
diff --git a/src/command/spawn.zig b/src/command/spawn.zig
index 53566fa..61aedab 100644
--- a/src/command/spawn.zig
+++ b/src/command/spawn.zig
@@ -19,7 +19,7 @@ const std = @import("std");
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Log = @import("../log.zig").Log;
const Seat = @import("../Seat.zig");
diff --git a/src/command/set_view_tags.zig b/src/command/tag_view.zig
index 562d311..fd74285 100644
--- a/src/command/set_view_tags.zig
+++ b/src/command/tag_view.zig
@@ -17,12 +17,12 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
-/// Set the tags of the focused view.
-pub fn setViewTags(seat: *Seat, arg: Arg) void {
- const tags = arg.uint;
+/// Set the tag of the focused view.
+pub fn tagView(seat: *Seat, arg: Arg) void {
+ const tags = @as(u32, 1) << @intCast(u5, arg.uint - 1);
if (seat.focused_view) |view| {
if (view.current_tags != tags) {
view.pending_tags = tags;
diff --git a/src/command/tag_view_all_tags.zig b/src/command/tag_view_all_tags.zig
new file mode 100644
index 0000000..1b93233
--- /dev/null
+++ b/src/command/tag_view_all_tags.zig
@@ -0,0 +1,31 @@
+// This file is part of river, a dynamic tiling wayland compositor.
+//
+// Copyright 2020 Isaac Freund
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+const c = @import("../c.zig");
+
+const Arg = @import("../Command.zig").Arg;
+const Seat = @import("../Seat.zig");
+
+/// Tag the focused view with all tags.
+pub fn tagViewAllTags(seat: *Seat, arg: Arg) void {
+ if (seat.focused_view) |view| {
+ if (view.current_tags != 0xFFFFFFFF) {
+ view.pending_tags = 0xFFFFFFFF;
+ seat.input_manager.server.root.arrange();
+ }
+ }
+}
diff --git a/src/command/toggle_float.zig b/src/command/toggle_float.zig
index 27e3186..e890d73 100644
--- a/src/command/toggle_float.zig
+++ b/src/command/toggle_float.zig
@@ -17,7 +17,7 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Make the focused view float or stop floating, depending on its current
diff --git a/src/command/toggle_tags.zig b/src/command/toggle_tag_focus.zig
index 2d9f86e..8a1a707 100644
--- a/src/command/toggle_tags.zig
+++ b/src/command/toggle_tag_focus.zig
@@ -17,12 +17,12 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
/// Toggle focus of the passsed tags.
-pub fn toggleTags(seat: *Seat, arg: Arg) void {
- const tags = arg.uint;
+pub fn toggleTagFocus(seat: *Seat, arg: Arg) void {
+ const tags = @as(u32, 1) << @intCast(u5, arg.uint - 1);
const output = seat.focused_output;
const new_focused_tags = output.current_focused_tags ^ tags;
if (new_focused_tags != 0) {
diff --git a/src/command/toggle_view_tags.zig b/src/command/toggle_view_tag.zig
index 2f5ba3e..fa869b5 100644
--- a/src/command/toggle_view_tags.zig
+++ b/src/command/toggle_view_tag.zig
@@ -17,12 +17,12 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
-/// Toggle the passed tags of the focused view
-pub fn toggleViewTags(seat: *Seat, arg: Arg) void {
- const tags = arg.uint;
+/// Toggle the passed tag of the focused view
+pub fn toggleViewTag(seat: *Seat, arg: Arg) void {
+ const tags = @as(u32, 1) << @intCast(u5, arg.uint - 1);
if (seat.focused_view) |view| {
const new_tags = view.current_tags ^ tags;
if (new_tags != 0) {
diff --git a/src/command/zoom.zig b/src/command/zoom.zig
index b1f7ba6..b603a69 100644
--- a/src/command/zoom.zig
+++ b/src/command/zoom.zig
@@ -17,7 +17,7 @@
const c = @import("../c.zig");
-const Arg = @import("../command.zig").Arg;
+const Arg = @import("../Command.zig").Arg;
const Seat = @import("../Seat.zig");
const View = @import("../View.zig");
const ViewStack = @import("../view_stack.zig").ViewStack;