Implement keybinding modes
This commit is contained in:
parent
3832601333
commit
3fe1edbe3e
@ -22,6 +22,8 @@ const std = @import("std");
|
|||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
const command = @import("command.zig");
|
const command = @import("command.zig");
|
||||||
|
|
||||||
|
const Log = @import("log.zig").Log;
|
||||||
|
const Mode = @import("Mode.zig");
|
||||||
const Server = @import("Server.zig");
|
const Server = @import("Server.zig");
|
||||||
|
|
||||||
/// Width of borders in pixels
|
/// Width of borders in pixels
|
||||||
@ -33,15 +35,8 @@ view_padding: u32,
|
|||||||
/// Amount of padding arount the outer edge of the layout in pixels
|
/// Amount of padding arount the outer edge of the layout in pixels
|
||||||
outer_padding: u32,
|
outer_padding: u32,
|
||||||
|
|
||||||
const Keybind = struct {
|
/// All user-defined keybinding modes
|
||||||
keysym: c.xkb_keysym_t,
|
modes: std.ArrayList(Mode),
|
||||||
modifiers: u32,
|
|
||||||
command: command.Command,
|
|
||||||
arg: command.Arg,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// All user-defined keybindings
|
|
||||||
keybinds: std.ArrayList(Keybind),
|
|
||||||
|
|
||||||
/// List of app_ids which will be started floating
|
/// List of app_ids which will be started floating
|
||||||
float_filter: std.ArrayList([*:0]const u8),
|
float_filter: std.ArrayList([*:0]const u8),
|
||||||
@ -51,13 +46,16 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
self.view_padding = 8;
|
self.view_padding = 8;
|
||||||
self.outer_padding = 8;
|
self.outer_padding = 8;
|
||||||
|
|
||||||
self.keybinds = std.ArrayList(Keybind).init(allocator);
|
self.modes = std.ArrayList(Mode).init(allocator);
|
||||||
|
try self.modes.append(try Mode.init("normal", allocator));
|
||||||
|
|
||||||
self.float_filter = std.ArrayList([*:0]const u8).init(allocator);
|
self.float_filter = std.ArrayList([*:0]const u8).init(allocator);
|
||||||
|
|
||||||
|
const normal = &self.modes.items[0];
|
||||||
const mod = c.WLR_MODIFIER_LOGO;
|
const mod = c.WLR_MODIFIER_LOGO;
|
||||||
|
|
||||||
// Mod+Shift+Return to start an instance of alacritty
|
// Mod+Shift+Return to start an instance of alacritty
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_Return,
|
.keysym = c.XKB_KEY_Return,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.spawn,
|
.command = command.spawn,
|
||||||
@ -65,7 +63,7 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+Q to close the focused view
|
// Mod+Q to close the focused view
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_q,
|
.keysym = c.XKB_KEY_q,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.close_view,
|
.command = command.close_view,
|
||||||
@ -73,7 +71,7 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+E to exit river
|
// Mod+E to exit river
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_e,
|
.keysym = c.XKB_KEY_e,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.exitCompositor,
|
.command = command.exitCompositor,
|
||||||
@ -81,15 +79,13 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+J and Mod+K to focus the next/previous view in the layout stack
|
// Mod+J and Mod+K to focus the next/previous view in the layout stack
|
||||||
try self.keybinds.append(
|
try normal.keybinds.append(.{
|
||||||
Keybind{
|
|
||||||
.keysym = c.XKB_KEY_j,
|
.keysym = c.XKB_KEY_j,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.focusView,
|
.command = command.focusView,
|
||||||
.arg = .{ .direction = .Next },
|
.arg = .{ .direction = .Next },
|
||||||
},
|
});
|
||||||
);
|
try normal.keybinds.append(.{
|
||||||
try self.keybinds.append(Keybind{
|
|
||||||
.keysym = c.XKB_KEY_k,
|
.keysym = c.XKB_KEY_k,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.focusView,
|
.command = command.focusView,
|
||||||
@ -98,7 +94,7 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
|
|
||||||
// Mod+Return to bump the focused view to the top of the layout stack,
|
// Mod+Return to bump the focused view to the top of the layout stack,
|
||||||
// making it the new master
|
// making it the new master
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_Return,
|
.keysym = c.XKB_KEY_Return,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.zoom,
|
.command = command.zoom,
|
||||||
@ -106,13 +102,13 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+H and Mod+L to increase/decrease the width of the master column
|
// Mod+H and Mod+L to increase/decrease the width of the master column
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_h,
|
.keysym = c.XKB_KEY_h,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.modifyMasterFactor,
|
.command = command.modifyMasterFactor,
|
||||||
.arg = .{ .float = 0.05 },
|
.arg = .{ .float = 0.05 },
|
||||||
});
|
});
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_l,
|
.keysym = c.XKB_KEY_l,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.modifyMasterFactor,
|
.command = command.modifyMasterFactor,
|
||||||
@ -121,13 +117,13 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
|
|
||||||
// Mod+Shift+H and Mod+Shift+L to increment/decrement the number of
|
// Mod+Shift+H and Mod+Shift+L to increment/decrement the number of
|
||||||
// master views in the layout
|
// master views in the layout
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_h,
|
.keysym = c.XKB_KEY_h,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.modifyMasterCount,
|
.command = command.modifyMasterCount,
|
||||||
.arg = .{ .int = 1 },
|
.arg = .{ .int = 1 },
|
||||||
});
|
});
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_l,
|
.keysym = c.XKB_KEY_l,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.modifyMasterCount,
|
.command = command.modifyMasterCount,
|
||||||
@ -137,28 +133,28 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
comptime var i = 0;
|
comptime var i = 0;
|
||||||
inline while (i < 9) : (i += 1) {
|
inline while (i < 9) : (i += 1) {
|
||||||
// Mod+[1-9] to focus tag [1-9]
|
// Mod+[1-9] to focus tag [1-9]
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_1 + i,
|
.keysym = c.XKB_KEY_1 + i,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.focusTags,
|
.command = command.focusTags,
|
||||||
.arg = .{ .uint = 1 << i },
|
.arg = .{ .uint = 1 << i },
|
||||||
});
|
});
|
||||||
// Mod+Shift+[1-9] to tag focused view with tag [1-9]
|
// Mod+Shift+[1-9] to tag focused view with tag [1-9]
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_1 + i,
|
.keysym = c.XKB_KEY_1 + i,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.setViewTags,
|
.command = command.setViewTags,
|
||||||
.arg = .{ .uint = 1 << i },
|
.arg = .{ .uint = 1 << i },
|
||||||
});
|
});
|
||||||
// Mod+Ctrl+[1-9] to toggle focus of tag [1-9]
|
// Mod+Ctrl+[1-9] to toggle focus of tag [1-9]
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_1 + i,
|
.keysym = c.XKB_KEY_1 + i,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_CTRL,
|
.modifiers = mod | c.WLR_MODIFIER_CTRL,
|
||||||
.command = command.toggleTags,
|
.command = command.toggleTags,
|
||||||
.arg = .{ .uint = 1 << i },
|
.arg = .{ .uint = 1 << i },
|
||||||
});
|
});
|
||||||
// Mod+Shift+Ctrl+[1-9] to toggle tag [1-9] of focused view
|
// Mod+Shift+Ctrl+[1-9] to toggle tag [1-9] of focused view
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_1 + i,
|
.keysym = c.XKB_KEY_1 + i,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_CTRL | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_CTRL | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.toggleViewTags,
|
.command = command.toggleViewTags,
|
||||||
@ -167,7 +163,7 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mod+0 to focus all tags
|
// Mod+0 to focus all tags
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_0,
|
.keysym = c.XKB_KEY_0,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.focusTags,
|
.command = command.focusTags,
|
||||||
@ -175,7 +171,7 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+Shift+0 to tag focused view with all tags
|
// Mod+Shift+0 to tag focused view with all tags
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_0,
|
.keysym = c.XKB_KEY_0,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.setViewTags,
|
.command = command.setViewTags,
|
||||||
@ -183,13 +179,13 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+Period and Mod+Comma to focus the next/previous output
|
// Mod+Period and Mod+Comma to focus the next/previous output
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_period,
|
.keysym = c.XKB_KEY_period,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.focusOutput,
|
.command = command.focusOutput,
|
||||||
.arg = .{ .direction = .Next },
|
.arg = .{ .direction = .Next },
|
||||||
});
|
});
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_comma,
|
.keysym = c.XKB_KEY_comma,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.focusOutput,
|
.command = command.focusOutput,
|
||||||
@ -198,13 +194,13 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
|
|
||||||
// Mod+Shift+Period/Comma to send the focused view to the the
|
// Mod+Shift+Period/Comma to send the focused view to the the
|
||||||
// next/previous output
|
// next/previous output
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_period,
|
.keysym = c.XKB_KEY_period,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.sendToOutput,
|
.command = command.sendToOutput,
|
||||||
.arg = .{ .direction = .Next },
|
.arg = .{ .direction = .Next },
|
||||||
});
|
});
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_comma,
|
.keysym = c.XKB_KEY_comma,
|
||||||
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
.modifiers = mod | c.WLR_MODIFIER_SHIFT,
|
||||||
.command = command.sendToOutput,
|
.command = command.sendToOutput,
|
||||||
@ -212,12 +208,40 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mod+Space to toggle float
|
// Mod+Space to toggle float
|
||||||
try self.keybinds.append(Keybind{
|
try normal.keybinds.append(.{
|
||||||
.keysym = c.XKB_KEY_space,
|
.keysym = c.XKB_KEY_space,
|
||||||
.modifiers = mod,
|
.modifiers = mod,
|
||||||
.command = command.toggleFloat,
|
.command = command.toggleFloat,
|
||||||
.arg = .{ .none = {} },
|
.arg = .{ .none = {} },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mod+F11 to enter passthrough mode
|
||||||
|
try normal.keybinds.append(.{
|
||||||
|
.keysym = c.XKB_KEY_F11,
|
||||||
|
.modifiers = mod,
|
||||||
|
.command = command.mode,
|
||||||
|
.arg = .{ .str = "passthrough" },
|
||||||
|
});
|
||||||
|
|
||||||
|
try self.modes.append(try Mode.init("passthrough", allocator));
|
||||||
|
|
||||||
|
// Mod+F11 to return to normal mode
|
||||||
|
try self.modes.items[1].keybinds.append(.{
|
||||||
|
.keysym = c.XKB_KEY_F11,
|
||||||
|
.modifiers = mod,
|
||||||
|
.command = command.mode,
|
||||||
|
.arg = .{ .str = "normal" },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Float views with app_id "float"
|
||||||
try self.float_filter.append("float");
|
try self.float_filter.append("float");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getMode(self: Self, name: []const u8) *Mode {
|
||||||
|
for (self.modes.items) |*mode|
|
||||||
|
if (std.mem.eql(u8, mode.name, name)) return mode;
|
||||||
|
Log.Error.log("Mode '{}' does not exist, entering normal mode", .{name});
|
||||||
|
for (self.modes.items) |*mode|
|
||||||
|
if (std.mem.eql(u8, mode.name, "normal")) return mode;
|
||||||
|
unreachable;
|
||||||
|
}
|
||||||
|
24
src/Keybind.zig
Normal file
24
src/Keybind.zig
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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 command = @import("command.zig");
|
||||||
|
|
||||||
|
keysym: c.xkb_keysym_t,
|
||||||
|
modifiers: u32,
|
||||||
|
command: command.Command,
|
||||||
|
arg: command.Arg,
|
42
src/Mode.zig
Normal file
42
src/Mode.zig
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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 Self = @This();
|
||||||
|
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const Keybind = @import("Keybind.zig");
|
||||||
|
|
||||||
|
/// The name of the mode
|
||||||
|
name: []const u8,
|
||||||
|
|
||||||
|
/// The list of active keybindings for this mode
|
||||||
|
keybinds: std.ArrayList(Keybind),
|
||||||
|
|
||||||
|
pub fn init(name: []const u8, allocator: *std.mem.Allocator) !Self {
|
||||||
|
const owned_name = try std.mem.dupe(allocator, u8, name);
|
||||||
|
return Self{
|
||||||
|
.name = owned_name,
|
||||||
|
.keybinds = std.ArrayList(Keybind).init(allocator),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: Self) void {
|
||||||
|
const allocator = self.keybinds.allocator;
|
||||||
|
allocator.free(self.name);
|
||||||
|
self.keybinds.deinit();
|
||||||
|
}
|
@ -25,6 +25,7 @@ const Cursor = @import("Cursor.zig");
|
|||||||
const InputManager = @import("InputManager.zig");
|
const InputManager = @import("InputManager.zig");
|
||||||
const Keyboard = @import("Keyboard.zig");
|
const Keyboard = @import("Keyboard.zig");
|
||||||
const LayerSurface = @import("LayerSurface.zig");
|
const LayerSurface = @import("LayerSurface.zig");
|
||||||
|
const Mode = @import("Mode.zig");
|
||||||
const Output = @import("Output.zig");
|
const Output = @import("Output.zig");
|
||||||
const View = @import("View.zig");
|
const View = @import("View.zig");
|
||||||
const ViewStack = @import("view_stack.zig").ViewStack;
|
const ViewStack = @import("view_stack.zig").ViewStack;
|
||||||
@ -44,6 +45,9 @@ cursor: Cursor,
|
|||||||
/// Mulitple keyboards are handled separately
|
/// Mulitple keyboards are handled separately
|
||||||
keyboards: std.TailQueue(Keyboard),
|
keyboards: std.TailQueue(Keyboard),
|
||||||
|
|
||||||
|
/// Current keybind mode
|
||||||
|
mode: *Mode,
|
||||||
|
|
||||||
/// Currently focused output, may be the noop output if no
|
/// Currently focused output, may be the noop output if no
|
||||||
focused_output: *Output,
|
focused_output: *Output,
|
||||||
|
|
||||||
@ -72,6 +76,8 @@ pub fn init(self: *Self, input_manager: *InputManager, name: []const u8) !void {
|
|||||||
|
|
||||||
self.keyboards = std.TailQueue(Keyboard).init();
|
self.keyboards = std.TailQueue(Keyboard).init();
|
||||||
|
|
||||||
|
self.mode = input_manager.server.config.getMode("normal");
|
||||||
|
|
||||||
self.focused_output = &self.input_manager.server.root.noop_output;
|
self.focused_output = &self.input_manager.server.root.noop_output;
|
||||||
|
|
||||||
self.focused_view = null;
|
self.focused_view = null;
|
||||||
@ -243,7 +249,7 @@ pub fn handleViewUnmap(self: *Self, view: *View) void {
|
|||||||
/// Handle any user-defined keybinding for the passed keysym and modifiers
|
/// Handle any user-defined keybinding for the passed keysym and modifiers
|
||||||
/// Returns true if the key was handled
|
/// Returns true if the key was handled
|
||||||
pub fn handleKeybinding(self: *Self, keysym: c.xkb_keysym_t, modifiers: u32) bool {
|
pub fn handleKeybinding(self: *Self, keysym: c.xkb_keysym_t, modifiers: u32) bool {
|
||||||
for (self.input_manager.server.config.keybinds.items) |keybind| {
|
for (self.mode.keybinds.items) |keybind| {
|
||||||
if (modifiers == keybind.modifiers and keysym == keybind.keysym) {
|
if (modifiers == keybind.modifiers and keysym == keybind.keysym) {
|
||||||
// Execute the bound command
|
// Execute the bound command
|
||||||
keybind.command(self, keybind.arg);
|
keybind.command(self, keybind.arg);
|
||||||
|
@ -115,11 +115,11 @@ pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
|||||||
c.wl_signal_add(&self.wlr_xwayland.events.new_surface, &self.listen_new_xwayland_surface);
|
c.wl_signal_add(&self.wlr_xwayland.events.new_surface, &self.listen_new_xwayland_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try self.config.init(self.allocator);
|
||||||
try self.decoration_manager.init(self);
|
try self.decoration_manager.init(self);
|
||||||
try self.root.init(self);
|
try self.root.init(self);
|
||||||
// Must be called after root is initialized
|
// Must be called after root is initialized
|
||||||
try self.input_manager.init(self);
|
try self.input_manager.init(self);
|
||||||
try self.config.init(self.allocator);
|
|
||||||
|
|
||||||
// These all free themselves when the wl_display is destroyed
|
// These all free themselves when the wl_display is destroyed
|
||||||
_ = c.wlr_data_device_manager_create(self.wl_display) orelse
|
_ = c.wlr_data_device_manager_create(self.wl_display) orelse
|
||||||
|
@ -38,12 +38,13 @@ pub usingnamespace @import("command/exit_compositor.zig");
|
|||||||
pub usingnamespace @import("command/focus_output.zig");
|
pub usingnamespace @import("command/focus_output.zig");
|
||||||
pub usingnamespace @import("command/focus_tags.zig");
|
pub usingnamespace @import("command/focus_tags.zig");
|
||||||
pub usingnamespace @import("command/focus_view.zig");
|
pub usingnamespace @import("command/focus_view.zig");
|
||||||
|
pub usingnamespace @import("command/mode.zig");
|
||||||
pub usingnamespace @import("command/modify_master_count.zig");
|
pub usingnamespace @import("command/modify_master_count.zig");
|
||||||
pub usingnamespace @import("command/modify_master_factor.zig");
|
pub usingnamespace @import("command/modify_master_factor.zig");
|
||||||
pub usingnamespace @import("command/send_to_output.zig");
|
pub usingnamespace @import("command/send_to_output.zig");
|
||||||
pub usingnamespace @import("command/set_view_tags.zig");
|
pub usingnamespace @import("command/set_view_tags.zig");
|
||||||
pub usingnamespace @import("command/spawn.zig");
|
pub usingnamespace @import("command/spawn.zig");
|
||||||
|
pub usingnamespace @import("command/toggle_float.zig");
|
||||||
pub usingnamespace @import("command/toggle_tags.zig");
|
pub usingnamespace @import("command/toggle_tags.zig");
|
||||||
pub usingnamespace @import("command/toggle_view_tags.zig");
|
pub usingnamespace @import("command/toggle_view_tags.zig");
|
||||||
pub usingnamespace @import("command/zoom.zig");
|
pub usingnamespace @import("command/zoom.zig");
|
||||||
pub usingnamespace @import("command/toggle_float.zig");
|
|
||||||
|
26
src/command/mode.zig
Normal file
26
src/command/mode.zig
Normal file
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
const Arg = @import("../command.zig").Arg;
|
||||||
|
const Seat = @import("../Seat.zig");
|
||||||
|
|
||||||
|
/// Switch to the given mode
|
||||||
|
pub fn mode(seat: *Seat, arg: Arg) void {
|
||||||
|
const mode_name = arg.str;
|
||||||
|
const config = seat.input_manager.server.config;
|
||||||
|
seat.mode = config.getMode(mode_name);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user