Add keybinds to cycle between outputs
This commit is contained in:
parent
f33b1fa3e8
commit
8a326541f6
@ -2,6 +2,7 @@ const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
|
||||
const Log = @import("log.zig").Log;
|
||||
const Output = @import("output.zig").Output;
|
||||
const Seat = @import("seat.zig").Seat;
|
||||
const View = @import("view.zig").View;
|
||||
const ViewStack = @import("view_stack.zig").ViewStack;
|
||||
@ -63,6 +64,36 @@ pub fn focusPrevView(seat: *Seat, arg: Arg) void {
|
||||
focusNextPrevView(seat, false);
|
||||
}
|
||||
|
||||
/// Focus either the next or the previous output, depending on the bool passed.
|
||||
fn focusNextPrevOutput(seat: *Seat, next: bool) void {
|
||||
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;
|
||||
}
|
||||
|
||||
const focused_node = @fieldParentPtr(std.TailQueue(Output).Node, "data", seat.focused_output);
|
||||
seat.focused_output = if (if (next) focused_node.next else focused_node.prev) |output_node|
|
||||
// Focus the next/prev output in the list if there is one
|
||||
&output_node.data
|
||||
else if (next) &root.outputs.first.?.data else &root.outputs.last.?.data;
|
||||
|
||||
seat.focus(null);
|
||||
}
|
||||
|
||||
/// Focus the next output, wrapping if needed. Does nothing if there is
|
||||
/// only one output.
|
||||
pub fn focusNextOutput(seat: *Seat, arg: Arg) void {
|
||||
focusNextPrevOutput(seat, true);
|
||||
}
|
||||
|
||||
/// Focus the previous output, wrapping if needed. Does nothing if there is
|
||||
/// only one output.
|
||||
pub fn focusPrevOutput(seat: *Seat, arg: Arg) void {
|
||||
focusNextPrevOutput(seat, false);
|
||||
}
|
||||
|
||||
/// Modify the number of master views
|
||||
pub fn modifyMasterCount(seat: *Seat, arg: Arg) void {
|
||||
const delta = arg.int;
|
||||
|
@ -96,5 +96,9 @@ pub const Config = struct {
|
||||
|
||||
// Mod+Shift+0 to tag focused view with all tags
|
||||
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_0, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 0xFFFFFFFF } });
|
||||
|
||||
// Mod+Period and Mod+Comma to focus the next/previous output
|
||||
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_period, .modifiers = mod, .command = command.focusNextOutput, .arg = .{ .none = {} } });
|
||||
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_comma, .modifiers = mod, .command = command.focusPrevOutput, .arg = .{ .none = {} } });
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user