attach-mode: code/documentation style tweaks
This commit is contained in:
parent
6a71fc65b0
commit
69a51cadb4
@ -347,7 +347,7 @@ matches everything while _\*\*_ and the empty string are invalid.
|
|||||||
|
|
||||||
## CONFIGURATION
|
## CONFIGURATION
|
||||||
|
|
||||||
*attach-mode* *top*|*bottom*|*after <N>*
|
*default-attach-mode* *top*|*bottom*|*after <N>*
|
||||||
Set the attach mode to be used by all outputs by default.
|
Set the attach mode to be used by all outputs by default.
|
||||||
|
|
||||||
Possible values:
|
Possible values:
|
||||||
@ -355,8 +355,8 @@ matches everything while _\*\*_ and the empty string are invalid.
|
|||||||
- bottom: Appends the newly spawned view at the bottom of the stack.
|
- bottom: Appends the newly spawned view at the bottom of the stack.
|
||||||
- after <N>: Inserts the newly spawned view after N views in the stack.
|
- after <N>: Inserts the newly spawned view after N views in the stack.
|
||||||
|
|
||||||
*default-attach-mode* *top*|*bottom*|*after <N>*
|
Note that the deprecated *attach-mode* command is aliased to
|
||||||
Alias to attach-mode.
|
*default-attach-mode* for backwards compatibility.
|
||||||
|
|
||||||
*output-attach-mode* *top*|*bottom*|*after <N>*
|
*output-attach-mode* *top*|*bottom*|*after <N>*
|
||||||
Set the attach mode of the currently focused output, overriding the value of
|
Set the attach mode of the currently focused output, overriding the value of
|
||||||
|
@ -32,9 +32,9 @@ const RuleList = @import("rule_list.zig").RuleList;
|
|||||||
const View = @import("View.zig");
|
const View = @import("View.zig");
|
||||||
|
|
||||||
pub const AttachMode = union(enum) {
|
pub const AttachMode = union(enum) {
|
||||||
top: void,
|
top,
|
||||||
bottom: void,
|
bottom,
|
||||||
after: usize,
|
after: u32,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const FocusFollowsCursorMode = enum {
|
pub const FocusFollowsCursorMode = enum {
|
||||||
|
@ -36,7 +36,7 @@ const LockSurface = @import("LockSurface.zig");
|
|||||||
const OutputStatus = @import("OutputStatus.zig");
|
const OutputStatus = @import("OutputStatus.zig");
|
||||||
const SceneNodeData = @import("SceneNodeData.zig");
|
const SceneNodeData = @import("SceneNodeData.zig");
|
||||||
const View = @import("View.zig");
|
const View = @import("View.zig");
|
||||||
const AttachMode = @import("Config.zig").AttachMode;
|
const Config = @import("Config.zig");
|
||||||
|
|
||||||
const log = std.log.scoped(.output);
|
const log = std.log.scoped(.output);
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ current: struct {
|
|||||||
/// Remembered version of tags (from last run)
|
/// Remembered version of tags (from last run)
|
||||||
previous_tags: u32 = 1 << 0,
|
previous_tags: u32 = 1 << 0,
|
||||||
|
|
||||||
attach_mode: ?AttachMode = null,
|
attach_mode: ?Config.AttachMode = null,
|
||||||
|
|
||||||
/// List of all layouts
|
/// List of all layouts
|
||||||
layouts: std.TailQueue(Layout) = .{},
|
layouts: std.TailQueue(Layout) = .{},
|
||||||
@ -612,6 +612,6 @@ pub fn layoutNamespace(self: Self) []const u8 {
|
|||||||
return self.layout_namespace orelse server.config.default_layout_namespace;
|
return self.layout_namespace orelse server.config.default_layout_namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attachMode(self: Self) AttachMode {
|
pub fn attachMode(self: Self) Config.AttachMode {
|
||||||
return self.attach_mode orelse server.config.default_attach_mode;
|
return self.attach_mode orelse server.config.default_attach_mode;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ const SceneNodeData = @import("SceneNodeData.zig");
|
|||||||
const Seat = @import("Seat.zig");
|
const Seat = @import("Seat.zig");
|
||||||
const XdgToplevel = @import("XdgToplevel.zig");
|
const XdgToplevel = @import("XdgToplevel.zig");
|
||||||
const XwaylandView = @import("XwaylandView.zig");
|
const XwaylandView = @import("XwaylandView.zig");
|
||||||
const PendingState = @import("Output.zig").PendingState;
|
|
||||||
|
|
||||||
const log = std.log.scoped(.view);
|
const log = std.log.scoped(.view);
|
||||||
|
|
||||||
@ -422,7 +421,7 @@ pub fn setPendingOutput(view: *Self, output: *Output) void {
|
|||||||
switch (output.attachMode()) {
|
switch (output.attachMode()) {
|
||||||
.top => output.pending.wm_stack.prepend(view),
|
.top => output.pending.wm_stack.prepend(view),
|
||||||
.bottom => output.pending.wm_stack.append(view),
|
.bottom => output.pending.wm_stack.append(view),
|
||||||
.after => |n| view.attach_after(&output.pending, n),
|
.after => |n| view.attachAfter(&output.pending, n),
|
||||||
}
|
}
|
||||||
output.pending.focus_stack.prepend(view);
|
output.pending.focus_stack.prepend(view);
|
||||||
|
|
||||||
@ -478,15 +477,16 @@ pub fn applyConstraints(self: *Self, box: *wlr.Box) void {
|
|||||||
box.height = math.clamp(box.height, self.constraints.min_height, self.constraints.max_height);
|
box.height = math.clamp(box.height, self.constraints.min_height, self.constraints.max_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attach current view after n Views on the pending wm_stack
|
/// Attach after n visible, not-floating views in the pending wm_stack
|
||||||
pub fn attach_after(view: *Self, pending_state: *PendingState, n: usize) void {
|
pub fn attachAfter(view: *Self, pending_state: *Output.PendingState, n: usize) void {
|
||||||
var nvisible: u32 = 0;
|
var visible: u32 = 0;
|
||||||
var it = pending_state.wm_stack.iterator(.forward);
|
var it = pending_state.wm_stack.iterator(.forward);
|
||||||
|
|
||||||
while (it.next()) |cur_view| {
|
while (it.next()) |other| {
|
||||||
if (nvisible >= n) break;
|
if (visible >= n) break;
|
||||||
if (!cur_view.pending.float // ignore floating views
|
if (!other.pending.float and other.pending.tags & pending_state.tags != 0) {
|
||||||
and cur_view.pending.tags & pending_state.tags != 0) nvisible += 1;
|
visible += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it.current.prev.?.insert(&view.pending_wm_stack_link);
|
it.current.prev.?.insert(&view.pending_wm_stack_link);
|
||||||
@ -549,7 +549,7 @@ pub fn map(view: *Self) !void {
|
|||||||
switch (server.config.default_attach_mode) {
|
switch (server.config.default_attach_mode) {
|
||||||
.top => server.root.fallback_pending.wm_stack.prepend(view),
|
.top => server.root.fallback_pending.wm_stack.prepend(view),
|
||||||
.bottom => server.root.fallback_pending.wm_stack.append(view),
|
.bottom => server.root.fallback_pending.wm_stack.append(view),
|
||||||
.after => |n| view.attach_after(&server.root.fallback_pending, n),
|
.after => |n| view.attachAfter(&server.root.fallback_pending, n),
|
||||||
}
|
}
|
||||||
server.root.fallback_pending.focus_stack.prepend(view);
|
server.root.fallback_pending.focus_stack.prepend(view);
|
||||||
|
|
||||||
|
@ -16,26 +16,31 @@
|
|||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
|
const meta = std.meta;
|
||||||
|
|
||||||
const server = &@import("../main.zig").server;
|
const server = &@import("../main.zig").server;
|
||||||
|
|
||||||
const Error = @import("../command.zig").Error;
|
const Error = @import("../command.zig").Error;
|
||||||
const Seat = @import("../Seat.zig");
|
const Seat = @import("../Seat.zig");
|
||||||
const AttachMode = @import("../Config.zig").AttachMode;
|
const Config = @import("../Config.zig");
|
||||||
|
|
||||||
fn parseAttachMode(args: []const [:0]const u8) Error!AttachMode {
|
fn parseAttachMode(args: []const [:0]const u8) Error!Config.AttachMode {
|
||||||
if (args.len < 2) return Error.NotEnoughArguments;
|
if (args.len < 2) return Error.NotEnoughArguments;
|
||||||
|
|
||||||
if (mem.eql(u8, "top", args[1])) {
|
const tag = meta.stringToEnum(meta.Tag(Config.AttachMode), args[1]) orelse return Error.UnknownOption;
|
||||||
return if (args.len > 2) Error.TooManyArguments else .top;
|
switch (tag) {
|
||||||
} else if (mem.eql(u8, "bottom", args[1])) {
|
inline .top, .bottom => |mode| {
|
||||||
return if (args.len > 2) Error.TooManyArguments else .bottom;
|
if (args.len > 2) return Error.TooManyArguments;
|
||||||
} else if (mem.eql(u8, "after", args[1])) {
|
|
||||||
if (args.len < 3) return Error.NotEnoughArguments;
|
return mode;
|
||||||
if (args.len > 3) return Error.TooManyArguments;
|
},
|
||||||
return .{ .after = try std.fmt.parseInt(usize, args[2], 10) };
|
.after => {
|
||||||
|
if (args.len < 3) return Error.NotEnoughArguments;
|
||||||
|
if (args.len > 3) return Error.TooManyArguments;
|
||||||
|
|
||||||
|
return .{ .after = try std.fmt.parseInt(u32, args[2], 10) };
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return Error.UnknownOption;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outputAttachMode(
|
pub fn outputAttachMode(
|
||||||
|
Loading…
Reference in New Issue
Block a user