diff options
Diffstat (limited to 'src/command')
| -rw-r--r-- | src/command/close.zig | 37 | ||||
| -rw-r--r-- | src/command/declare_mode.zig | 51 | ||||
| -rw-r--r-- | src/command/enter_mode.zig | 43 | ||||
| -rw-r--r-- | src/command/exit.zig | 34 | ||||
| -rw-r--r-- | src/command/focus.zig | 67 | ||||
| -rw-r--r-- | src/command/focus_all_tags.zig | 32 | ||||
| -rw-r--r-- | src/command/focus_output.zig | 54 | ||||
| -rw-r--r-- | src/command/focus_tag.zig | 37 | ||||
| -rw-r--r-- | src/command/layout.zig | 37 | ||||
| -rw-r--r-- | src/command/map.zig | 110 | ||||
| -rw-r--r-- | src/command/mod_master_count.zig | 42 | ||||
| -rw-r--r-- | src/command/mod_master_factor.zig | 45 | ||||
| -rw-r--r-- | src/command/send_to_output.zig | 62 | ||||
| -rw-r--r-- | src/command/spawn.zig | 47 | ||||
| -rw-r--r-- | src/command/tag_view.zig | 43 | ||||
| -rw-r--r-- | src/command/tag_view_all_tags.zig | 38 | ||||
| -rw-r--r-- | src/command/toggle_float.zig | 38 | ||||
| -rw-r--r-- | src/command/toggle_tag_focus.zig | 43 | ||||
| -rw-r--r-- | src/command/toggle_view_tag.zig | 44 | ||||
| -rw-r--r-- | src/command/zoom.zig | 54 |
20 files changed, 0 insertions, 958 deletions
diff --git a/src/command/close.zig b/src/command/close.zig deleted file mode 100644 index 04b2dcd..0000000 --- a/src/command/close.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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Close the focused view, if any. -pub fn close( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!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/declare_mode.zig b/src/command/declare_mode.zig deleted file mode 100644 index 943ede8..0000000 --- a/src/command/declare_mode.zig +++ /dev/null @@ -1,51 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Mapping = @import("../Mapping.zig"); -const Seat = @import("../Seat.zig"); - -/// Declare a new keymap mode -pub fn declareMode( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const config = &seat.input_manager.server.config; - const new_mode_name = args[1]; - - if (config.mode_to_id.get(new_mode_name) != null) { - failure_message.* = try std.fmt.allocPrint( - allocator, - "mode '{}' already exists and cannot be re-declared", - .{new_mode_name}, - ); - return Error.CommandFailed; - } - - try config.mode_to_id.putNoClobber(new_mode_name, config.modes.items.len); - errdefer _ = config.mode_to_id.remove(new_mode_name); - try config.modes.append(std.ArrayList(Mapping).init(allocator)); -} diff --git a/src/command/enter_mode.zig b/src/command/enter_mode.zig deleted file mode 100644 index 8c7e3e4..0000000 --- a/src/command/enter_mode.zig +++ /dev/null @@ -1,43 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Switch to the given mode -pub fn enterMode( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const config = seat.input_manager.server.config; - const target_mode = args[1]; - seat.mode_id = config.mode_to_id.getValue(target_mode) orelse { - failure_message.* = try std.fmt.allocPrint( - allocator, - "cannot enter non-existant mode '{}'", - .{target_mode}, - ); - return Error.CommandFailed; - }; -} diff --git a/src/command/exit.zig b/src/command/exit.zig deleted file mode 100644 index a21e4f3..0000000 --- a/src/command/exit.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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Exit the compositor, terminating the wayland session. -pub fn exit( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len > 1) return Error.TooManyArguments; - c.wl_display_terminate(seat.input_manager.server.wl_display); -} diff --git a/src/command/focus.zig b/src/command/focus.zig deleted file mode 100644 index 0e2c9e0..0000000 --- a/src/command/focus.zig +++ /dev/null @@ -1,67 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Direction = @import("../command.zig").Direction; -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( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const direction = try Direction.parse(args[1]); - 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 deleted file mode 100644 index 28e001d..0000000 --- a/src/command/focus_all_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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Set focus to all tags -pub fn focusAllTags( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!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 deleted file mode 100644 index b11664f..0000000 --- a/src/command/focus_output.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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Direction = @import("../command.zig").Direction; -const Output = @import("../Output.zig"); -const Seat = @import("../Seat.zig"); - -/// Focus either the next or the previous output, depending on the bool passed. -/// Does nothing if there is only one output. -pub fn focusOutput( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const direction = try Direction.parse(args[1]); - const root = &seat.input_manager.server.root; - // If the noop output is focused, there are no other outputs to switch to - if (seat.focused_output == &root.noop_output) { - std.debug.assert(root.outputs.len == 0); - return; - } - - // Focus the next/prev output in the list if there is one, else wrap - const focused_node = @fieldParentPtr(std.TailQueue(Output).Node, "data", seat.focused_output); - seat.focused_output = switch (direction) { - .Next => if (focused_node.next) |node| &node.data else &root.outputs.first.?.data, - .Prev => if (focused_node.prev) |node| &node.data else &root.outputs.last.?.data, - }; - - seat.focus(null); -} diff --git a/src/command/focus_tag.zig b/src/command/focus_tag.zig deleted file mode 100644 index 8f69e6e..0000000 --- a/src/command/focus_tag.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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Switch focus to the passed tag. -pub fn focusTag( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const tag = try std.fmt.parseInt(u32, args[1], 10); - const tags = @as(u32, 1) << @intCast(u5, tag - 1); - seat.focused_output.pending_focused_tags = tags; - seat.input_manager.server.root.arrange(); -} diff --git a/src/command/layout.zig b/src/command/layout.zig deleted file mode 100644 index 4a21050..0000000 --- a/src/command/layout.zig +++ /dev/null @@ -1,37 +0,0 @@ -// This file is part of river, a dynamic tiling wayland compositor. -// -// Copyright 2020 Leon Henrik Plickat -// -// 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 std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -pub fn layout( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - seat.focused_output.layout = seat.focused_output.getLayoutByName(args[1]); - seat.focused_output.arrangeViews(); - seat.input_manager.server.root.startTransaction(); -} diff --git a/src/command/map.zig b/src/command/map.zig deleted file mode 100644 index 90c0b33..0000000 --- a/src/command/map.zig +++ /dev/null @@ -1,110 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Mapping = @import("../Mapping.zig"); -const Seat = @import("../Seat.zig"); - -const modifier_names = [_]struct { - name: []const u8, - modifier: u32, -}{ - .{ .name = "Shift", .modifier = c.WLR_MODIFIER_SHIFT }, - .{ .name = "Lock", .modifier = c.WLR_MODIFIER_CAPS }, - .{ .name = "Control", .modifier = c.WLR_MODIFIER_CTRL }, - .{ .name = "Mod1", .modifier = c.WLR_MODIFIER_ALT }, - .{ .name = "Mod2", .modifier = c.WLR_MODIFIER_MOD2 }, - .{ .name = "Mod3", .modifier = c.WLR_MODIFIER_MOD3 }, - .{ .name = "Mod4", .modifier = c.WLR_MODIFIER_LOGO }, - .{ .name = "Mod5", .modifier = c.WLR_MODIFIER_MOD5 }, -}; - -/// Create a new mapping for a given mode -/// -/// Example: -/// map normal Mod4|Shift Return spawn alacritty -pub fn map( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 4) return Error.NotEnoughArguments; - - // Parse the mode - const config = seat.input_manager.server.config; - const target_mode = args[1]; - const mode_id = config.mode_to_id.getValue(target_mode) orelse { - failure_message.* = try std.fmt.allocPrint( - allocator, - "cannot add mapping to non-existant mode '{}p'", - .{target_mode}, - ); - return Error.CommandFailed; - }; - - // Parse the modifiers - var it = std.mem.split(args[2], "|"); - var modifiers: u32 = 0; - while (it.next()) |mod_name| { - for (modifier_names) |def| { - if (std.mem.eql(u8, def.name, mod_name)) { - modifiers |= def.modifier; - break; - } - } else { - failure_message.* = try std.fmt.allocPrint( - allocator, - "invalid modifier '{}'", - .{mod_name}, - ); - return Error.CommandFailed; - } - } - - // Parse the keysym - const keysym_name = try std.cstr.addNullByte(allocator, args[3]); - defer allocator.free(keysym_name); - const keysym = c.xkb_keysym_from_name(keysym_name, .XKB_KEYSYM_CASE_INSENSITIVE); - if (keysym == c.XKB_KEY_NoSymbol) { - failure_message.* = try std.fmt.allocPrint( - allocator, - "invalid keysym '{}'", - .{args[3]}, - ); - return Error.CommandFailed; - } - - // Check if the mapping already exists - const mode_mappings = &config.modes.items[mode_id]; - for (mode_mappings.items) |existant_mapping| { - if (existant_mapping.modifiers == modifiers and existant_mapping.keysym == keysym) { - failure_message.* = try std.fmt.allocPrint( - allocator, - "a mapping for modifiers '{}' and keysym '{}' already exists", - .{ args[2], args[3] }, - ); - return Error.CommandFailed; - } - } - - try mode_mappings.append(try Mapping.init(allocator, keysym, modifiers, args[4..])); -} diff --git a/src/command/mod_master_count.zig b/src/command/mod_master_count.zig deleted file mode 100644 index 38a379e..0000000 --- a/src/command/mod_master_count.zig +++ /dev/null @@ -1,42 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Modify the number of master views -pub fn modMasterCount( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const delta = try std.fmt.parseInt(i32, args[1], 10); - 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 deleted file mode 100644 index ec8065a..0000000 --- a/src/command/mod_master_factor.zig +++ /dev/null @@ -1,45 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Modify the percent of the width of the screen that the master views occupy. -pub fn modMasterFactor( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const delta = try std.fmt.parseFloat(f64, args[1]); - 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 deleted file mode 100644 index de92f6f..0000000 --- a/src/command/send_to_output.zig +++ /dev/null @@ -1,62 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Direction = @import("../command.zig").Direction; -const Output = @import("../Output.zig"); -const Seat = @import("../Seat.zig"); - -/// Send the focused view to the the next or the previous output, depending on -/// the bool passed. Does nothing if there is only one output. -pub fn sendToOutput( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const direction = try Direction.parse(args[1]); - const root = &seat.input_manager.server.root; - - if (seat.focused_view) |view| { - // If the noop output is focused, there is nowhere to send the view - if (view.output == &root.noop_output) { - std.debug.assert(root.outputs.len == 0); - return; - } - - // Send to the next/preg output in the list if there is one, else wrap - const current_node = @fieldParentPtr(std.TailQueue(Output).Node, "data", view.output); - const destination_output = switch (direction) { - .Next => if (current_node.next) |node| &node.data else &root.outputs.first.?.data, - .Prev => if (current_node.prev) |node| &node.data else &root.outputs.last.?.data, - }; - - // Move the view to the target output - view.sendToOutput(destination_output); - - // Handle the change and focus whatever's next in the focus stack - root.arrange(); - seat.focus(null); - } -} diff --git a/src/command/spawn.zig b/src/command/spawn.zig deleted file mode 100644 index 880483a..0000000 --- a/src/command/spawn.zig +++ /dev/null @@ -1,47 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Spawn a program. -pub fn spawn( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - - const cmd = try std.mem.join(allocator, " ", args[1..]); - defer allocator.free(cmd); - - const child_args = [_][]const u8{ "/bin/sh", "-c", cmd }; - const child = try std.ChildProcess.init(&child_args, allocator); - defer child.deinit(); - - std.ChildProcess.spawn(child) catch |err| { - failure_message.* = try std.fmt.allocPrint( - allocator, - "failed to spawn {}: {}.", - .{ cmd, err }, - ); - return Error.CommandFailed; - }; -} diff --git a/src/command/tag_view.zig b/src/command/tag_view.zig deleted file mode 100644 index 735481d..0000000 --- a/src/command/tag_view.zig +++ /dev/null @@ -1,43 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Set the tag of the focused view. -pub fn tagView( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const tag = try std.fmt.parseInt(u32, args[1], 10); - const tags = @as(u32, 1) << @intCast(u5, tag - 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 deleted file mode 100644 index 2d187f3..0000000 --- a/src/command/tag_view_all_tags.zig +++ /dev/null @@ -1,38 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Tag the focused view with all tags. -pub fn tagViewAllTags( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!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 deleted file mode 100644 index 25655e8..0000000 --- a/src/command/toggle_float.zig +++ /dev/null @@ -1,38 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Make the focused view float or stop floating, depending on its current -/// state. -pub fn toggleFloat( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len > 1) return Error.TooManyArguments; - if (seat.focused_view) |view| { - view.setFloating(!view.floating); - view.output.root.arrange(); - } -} diff --git a/src/command/toggle_tag_focus.zig b/src/command/toggle_tag_focus.zig deleted file mode 100644 index 09761c7..0000000 --- a/src/command/toggle_tag_focus.zig +++ /dev/null @@ -1,43 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Toggle focus of the passsed tags. -pub fn toggleTagFocus( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const tag = try std.fmt.parseInt(u32, args[1], 10); - const tags = @as(u32, 1) << @intCast(u5, tag - 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_view_tag.zig b/src/command/toggle_view_tag.zig deleted file mode 100644 index 469a750..0000000 --- a/src/command/toggle_view_tag.zig +++ /dev/null @@ -1,44 +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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); - -/// Toggle the passed tag of the focused view -pub fn toggleViewTag( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len < 2) return Error.NotEnoughArguments; - if (args.len > 2) return Error.TooManyArguments; - - const tag = try std.fmt.parseInt(u32, args[1], 10); - const tags = @as(u32, 1) << @intCast(u5, tag - 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/zoom.zig b/src/command/zoom.zig deleted file mode 100644 index 59156ab..0000000 --- a/src/command/zoom.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 <https://www.gnu.org/licenses/>. - -const std = @import("std"); - -const c = @import("../c.zig"); - -const Error = @import("../command.zig").Error; -const Seat = @import("../Seat.zig"); -const View = @import("../View.zig"); -const ViewStack = @import("../view_stack.zig").ViewStack; - -/// Bump the focused view to the top of the stack. If the view on the top of -/// the stack is focused, bump the second view to the top. -pub fn zoom( - allocator: *std.mem.Allocator, - seat: *Seat, - args: []const []const u8, - failure_message: *[]const u8, -) Error!void { - if (args.len > 1) return Error.TooManyArguments; - - if (seat.focused_view) |current_focus| { - const output = seat.focused_output; - const focused_node = @fieldParentPtr(ViewStack(View).Node, "view", current_focus); - - var it = ViewStack(View).iterator(output.views.first, output.current_focused_tags); - const zoom_node = if (focused_node == it.next()) - if (it.next()) |second| second else null - else - focused_node; - - if (zoom_node) |to_bump| { - output.views.remove(to_bump); - output.views.push(to_bump); - seat.input_manager.server.root.arrange(); - seat.focus(&to_bump.view); - } - } -} |
