From cee41e925dc0a9d7460806c9f8386512b207edf3 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 19 May 2020 22:59:50 +0200 Subject: Implement command execution through riverctl --- src/command/close.zig | 30 ++++++++++++++++++++ src/command/close_view.zig | 30 -------------------- src/command/exit.zig | 26 +++++++++++++++++ src/command/exit_compositor.zig | 26 ----------------- src/command/focus.zig | 54 ++++++++++++++++++++++++++++++++++++ src/command/focus_all_tags.zig | 25 +++++++++++++++++ src/command/focus_output.zig | 2 +- src/command/focus_tag.zig | 26 +++++++++++++++++ src/command/focus_tags.zig | 28 ------------------- src/command/focus_view.zig | 54 ------------------------------------ src/command/mod_master_count.zig | 34 +++++++++++++++++++++++ src/command/mod_master_factor.zig | 37 ++++++++++++++++++++++++ src/command/mode.zig | 2 +- src/command/modify_master_count.zig | 34 ----------------------- src/command/modify_master_factor.zig | 37 ------------------------ src/command/send_to_output.zig | 2 +- src/command/set_view_tags.zig | 32 --------------------- src/command/spawn.zig | 2 +- src/command/tag_view.zig | 32 +++++++++++++++++++++ src/command/tag_view_all_tags.zig | 31 +++++++++++++++++++++ src/command/toggle_float.zig | 2 +- src/command/toggle_tag_focus.zig | 32 +++++++++++++++++++++ src/command/toggle_tags.zig | 32 --------------------- src/command/toggle_view_tag.zig | 33 ++++++++++++++++++++++ src/command/toggle_view_tags.zig | 33 ---------------------- src/command/zoom.zig | 2 +- 26 files changed, 366 insertions(+), 312 deletions(-) create mode 100644 src/command/close.zig delete mode 100644 src/command/close_view.zig create mode 100644 src/command/exit.zig delete mode 100644 src/command/exit_compositor.zig create mode 100644 src/command/focus.zig create mode 100644 src/command/focus_all_tags.zig create mode 100644 src/command/focus_tag.zig delete mode 100644 src/command/focus_tags.zig delete mode 100644 src/command/focus_view.zig create mode 100644 src/command/mod_master_count.zig create mode 100644 src/command/mod_master_factor.zig delete mode 100644 src/command/modify_master_count.zig delete mode 100644 src/command/modify_master_factor.zig delete mode 100644 src/command/set_view_tags.zig create mode 100644 src/command/tag_view.zig create mode 100644 src/command/tag_view_all_tags.zig create mode 100644 src/command/toggle_tag_focus.zig delete mode 100644 src/command/toggle_tags.zig create mode 100644 src/command/toggle_view_tag.zig delete mode 100644 src/command/toggle_view_tags.zig (limited to 'src/command') diff --git a/src/command/close.zig b/src/command/close.zig new file mode 100644 index 0000000..c5be01c --- /dev/null +++ b/src/command/close.zig @@ -0,0 +1,30 @@ +// 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 . + +const c = @import("../c.zig"); + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// Close the focused view, if any. +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. + view.close(); + } +} diff --git a/src/command/close_view.zig b/src/command/close_view.zig deleted file mode 100644 index 7bee0b6..0000000 --- a/src/command/close_view.zig +++ /dev/null @@ -1,30 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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 { - if (seat.focused_view) |view| { - // Note: we don't call arrange() here as it will be called - // automatically when the view is unmapped. - view.close(); - } -} diff --git a/src/command/exit.zig b/src/command/exit.zig new file mode 100644 index 0000000..799b12c --- /dev/null +++ b/src/command/exit.zig @@ -0,0 +1,26 @@ +// 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 . + +const c = @import("../c.zig"); + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// Exit the compositor, terminating the wayland session. +pub fn exit(seat: *Seat, arg: Arg) void { + c.wl_display_terminate(seat.input_manager.server.wl_display); +} diff --git a/src/command/exit_compositor.zig b/src/command/exit_compositor.zig deleted file mode 100644 index 7736452..0000000 --- a/src/command/exit_compositor.zig +++ /dev/null @@ -1,26 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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 { - c.wl_display_terminate(seat.input_manager.server.wl_display); -} diff --git a/src/command/focus.zig b/src/command/focus.zig new file mode 100644 index 0000000..930a36c --- /dev/null +++ b/src/command/focus.zig @@ -0,0 +1,54 @@ +// 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 . + +const c = @import("../c.zig"); + +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 focus(seat: *Seat, arg: Arg) void { + const direction = arg.direction; + 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); + var it = switch (direction) { + .Next => ViewStack(View).iterator(focused_node, output.current_focused_tags), + .Prev => ViewStack(View).reverseIterator(focused_node, output.current_focused_tags), + }; + + // Skip past the focused node + _ = it.next(); + // Focus the next visible node if there is one + if (it.next()) |node| { + seat.focus(&node.view); + return; + } + } + + // There is either no currently focused view or the last visible view in the + // stack is focused and we need to wrap. + var it = switch (direction) { + .Next => ViewStack(View).iterator(output.views.first, output.current_focused_tags), + .Prev => ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags), + }; + seat.focus(if (it.next()) |node| &node.view else null); +} 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 . + +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_tag.zig b/src/command/focus_tag.zig new file mode 100644 index 0000000..edb3292 --- /dev/null +++ b/src/command/focus_tag.zig @@ -0,0 +1,26 @@ +// 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 . + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// 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/focus_tags.zig b/src/command/focus_tags.zig deleted file mode 100644 index aa29b7c..0000000 --- a/src/command/focus_tags.zig +++ /dev/null @@ -1,28 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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; - seat.focused_output.pending_focused_tags = tags; - seat.input_manager.server.root.arrange(); -} diff --git a/src/command/focus_view.zig b/src/command/focus_view.zig deleted file mode 100644 index 225fa5e..0000000 --- a/src/command/focus_view.zig +++ /dev/null @@ -1,54 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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 { - const direction = arg.direction; - 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); - var it = switch (direction) { - .Next => ViewStack(View).iterator(focused_node, output.current_focused_tags), - .Prev => ViewStack(View).reverseIterator(focused_node, output.current_focused_tags), - }; - - // Skip past the focused node - _ = it.next(); - // Focus the next visible node if there is one - if (it.next()) |node| { - seat.focus(&node.view); - return; - } - } - - // There is either no currently focused view or the last visible view in the - // stack is focused and we need to wrap. - var it = switch (direction) { - .Next => ViewStack(View).iterator(output.views.first, output.current_focused_tags), - .Prev => ViewStack(View).reverseIterator(output.views.last, output.current_focused_tags), - }; - seat.focus(if (it.next()) |node| &node.view else null); -} diff --git a/src/command/mod_master_count.zig b/src/command/mod_master_count.zig new file mode 100644 index 0000000..bd2fde0 --- /dev/null +++ b/src/command/mod_master_count.zig @@ -0,0 +1,34 @@ +// 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 . + +const std = @import("std"); + +const c = @import("../c.zig"); + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// Modify the number of master views +pub fn modMasterCount(seat: *Seat, arg: Arg) void { + const delta = arg.int; + const output = seat.focused_output; + output.master_count = @intCast( + u32, + std.math.max(0, @intCast(i32, output.master_count) + delta), + ); + seat.input_manager.server.root.arrange(); +} diff --git a/src/command/mod_master_factor.zig b/src/command/mod_master_factor.zig new file mode 100644 index 0000000..2e2a73c --- /dev/null +++ b/src/command/mod_master_factor.zig @@ -0,0 +1,37 @@ +// 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 . + +const std = @import("std"); + +const c = @import("../c.zig"); + +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 modMasterFactor(seat: *Seat, arg: Arg) void { + const delta = arg.float; + 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; + seat.input_manager.server.root.arrange(); + } +} 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 . -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/modify_master_count.zig b/src/command/modify_master_count.zig deleted file mode 100644 index c7a5ac1..0000000 --- a/src/command/modify_master_count.zig +++ /dev/null @@ -1,34 +0,0 @@ -// 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 . - -const std = @import("std"); - -const c = @import("../c.zig"); - -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 { - const delta = arg.int; - const output = seat.focused_output; - output.master_count = @intCast( - u32, - std.math.max(0, @intCast(i32, output.master_count) + delta), - ); - seat.input_manager.server.root.arrange(); -} diff --git a/src/command/modify_master_factor.zig b/src/command/modify_master_factor.zig deleted file mode 100644 index b2af06f..0000000 --- a/src/command/modify_master_factor.zig +++ /dev/null @@ -1,37 +0,0 @@ -// 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 . - -const std = @import("std"); - -const c = @import("../c.zig"); - -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 { - const delta = arg.float; - 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; - seat.input_manager.server.root.arrange(); - } -} 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/set_view_tags.zig b/src/command/set_view_tags.zig deleted file mode 100644 index 562d311..0000000 --- a/src/command/set_view_tags.zig +++ /dev/null @@ -1,32 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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; - if (seat.focused_view) |view| { - if (view.current_tags != tags) { - view.pending_tags = tags; - seat.input_manager.server.root.arrange(); - } - } -} 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/tag_view.zig b/src/command/tag_view.zig new file mode 100644 index 0000000..fd74285 --- /dev/null +++ b/src/command/tag_view.zig @@ -0,0 +1,32 @@ +// 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 . + +const c = @import("../c.zig"); + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// 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; + seat.input_manager.server.root.arrange(); + } + } +} 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 . + +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_tag_focus.zig b/src/command/toggle_tag_focus.zig new file mode 100644 index 0000000..8a1a707 --- /dev/null +++ b/src/command/toggle_tag_focus.zig @@ -0,0 +1,32 @@ +// 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 . + +const c = @import("../c.zig"); + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// Toggle focus of the passsed tags. +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) { + output.pending_focused_tags = new_focused_tags; + seat.input_manager.server.root.arrange(); + } +} diff --git a/src/command/toggle_tags.zig b/src/command/toggle_tags.zig deleted file mode 100644 index 2d9f86e..0000000 --- a/src/command/toggle_tags.zig +++ /dev/null @@ -1,32 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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; - 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; - seat.input_manager.server.root.arrange(); - } -} diff --git a/src/command/toggle_view_tag.zig b/src/command/toggle_view_tag.zig new file mode 100644 index 0000000..fa869b5 --- /dev/null +++ b/src/command/toggle_view_tag.zig @@ -0,0 +1,33 @@ +// 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 . + +const c = @import("../c.zig"); + +const Arg = @import("../Command.zig").Arg; +const Seat = @import("../Seat.zig"); + +/// 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) { + view.pending_tags = new_tags; + seat.input_manager.server.root.arrange(); + } + } +} diff --git a/src/command/toggle_view_tags.zig b/src/command/toggle_view_tags.zig deleted file mode 100644 index 2f5ba3e..0000000 --- a/src/command/toggle_view_tags.zig +++ /dev/null @@ -1,33 +0,0 @@ -// 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 . - -const c = @import("../c.zig"); - -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; - if (seat.focused_view) |view| { - const new_tags = view.current_tags ^ tags; - if (new_tags != 0) { - view.pending_tags = new_tags; - seat.input_manager.server.root.arrange(); - } - } -} 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; -- cgit v1.2.3