Root: rename field outputs to active_outputs
Although this list only including active outputs was already documented, making this explicit in its name reduces confusion and debugging overhead.
This commit is contained in:
parent
bbd21c1637
commit
57186fced3
@ -258,7 +258,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void {
|
|||||||
self.xcursor_manager = try wlr.XcursorManager.create(theme, size);
|
self.xcursor_manager = try wlr.XcursorManager.create(theme, size);
|
||||||
|
|
||||||
// For each output, ensure a theme of the proper scale is loaded
|
// For each output, ensure a theme of the proper scale is loaded
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.active_outputs.first;
|
||||||
while (it) |node| : (it = node.next) {
|
while (it) |node| : (it = node.next) {
|
||||||
const wlr_output = node.data.wlr_output;
|
const wlr_output = node.data.wlr_output;
|
||||||
self.xcursor_manager.load(wlr_output.scale) catch
|
self.xcursor_manager.load(wlr_output.scale) catch
|
||||||
|
@ -69,7 +69,7 @@ pub fn create(client: *wl.Client, version: u32, id: u32, output: *Output, namesp
|
|||||||
/// Returns true if the given namespace is already in use on the given output
|
/// Returns true if the given namespace is already in use on the given output
|
||||||
/// or on another output by a different client.
|
/// or on another output by a different client.
|
||||||
fn namespaceInUse(namespace: []const u8, output: *Output, client: *wl.Client) bool {
|
fn namespaceInUse(namespace: []const u8, output: *Output, client: *wl.Client) bool {
|
||||||
var output_it = server.root.outputs.first;
|
var output_it = server.root.active_outputs.first;
|
||||||
while (output_it) |output_node| : (output_it = output_node.next) {
|
while (output_it) |output_node| : (output_it = output_node.next) {
|
||||||
var layout_it = output_node.data.layouts.first;
|
var layout_it = output_node.data.layouts.first;
|
||||||
if (output_node.data.wlr_output == output.wlr_output) {
|
if (output_node.data.wlr_output == output.wlr_output) {
|
||||||
|
@ -138,7 +138,7 @@ fn handleLockSurfacesTimeout(manager: *LockManager) c_int {
|
|||||||
manager.state = .waiting_for_blank;
|
manager.state = .waiting_for_blank;
|
||||||
|
|
||||||
{
|
{
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.active_outputs.first;
|
||||||
while (it) |node| : (it = node.next) {
|
while (it) |node| : (it = node.next) {
|
||||||
const output = &node.data;
|
const output = &node.data;
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ pub fn maybeLock(manager: *LockManager) void {
|
|||||||
var all_outputs_blanked = true;
|
var all_outputs_blanked = true;
|
||||||
var all_outputs_rendered_lock_surface = true;
|
var all_outputs_rendered_lock_surface = true;
|
||||||
{
|
{
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.active_outputs.first;
|
||||||
while (it) |node| : (it = node.next) {
|
while (it) |node| : (it = node.next) {
|
||||||
const output = &node.data;
|
const output = &node.data;
|
||||||
switch (output.lock_render_state) {
|
switch (output.lock_render_state) {
|
||||||
@ -205,7 +205,7 @@ fn handleUnlock(listener: *wl.Listener(void)) void {
|
|||||||
log.info("session unlocked", .{});
|
log.info("session unlocked", .{});
|
||||||
|
|
||||||
{
|
{
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.active_outputs.first;
|
||||||
while (it) |node| : (it = node.next) {
|
while (it) |node| : (it = node.next) {
|
||||||
const output = &node.data;
|
const output = &node.data;
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
|||||||
log.debug("output '{s}' destroyed", .{output.wlr_output.name});
|
log.debug("output '{s}' destroyed", .{output.wlr_output.name});
|
||||||
|
|
||||||
// Remove the destroyed output from root if it wasn't already removed
|
// Remove the destroyed output from root if it wasn't already removed
|
||||||
server.root.removeOutput(output);
|
server.root.deactivateOutput(output);
|
||||||
|
|
||||||
assert(output.pending.focus_stack.empty());
|
assert(output.pending.focus_stack.empty());
|
||||||
assert(output.pending.wm_stack.empty());
|
assert(output.pending.wm_stack.empty());
|
||||||
@ -412,9 +412,9 @@ fn handleEnable(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) vo
|
|||||||
self.locked_content.node.setEnabled(true);
|
self.locked_content.node.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the output to root.outputs and the output layout if it has not
|
// Add the output to root.active_outputs and the output layout if it has not
|
||||||
// already been added.
|
// already been added.
|
||||||
if (wlr_output.enabled) server.root.addOutput(self);
|
if (wlr_output.enabled) server.root.activateOutput(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleMode(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
fn handleMode(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
|
||||||
|
@ -107,7 +107,7 @@ all_outputs: std.TailQueue(*Output) = .{},
|
|||||||
|
|
||||||
/// A list of all active outputs (any one that can be interacted with, even if
|
/// A list of all active outputs (any one that can be interacted with, even if
|
||||||
/// it's turned off by dpms)
|
/// it's turned off by dpms)
|
||||||
outputs: std.TailQueue(Output) = .{},
|
active_outputs: std.TailQueue(Output) = .{},
|
||||||
|
|
||||||
/// Number of layout demands before sending configures to clients.
|
/// Number of layout demands before sending configures to clients.
|
||||||
inflight_layout_demands: u32 = 0,
|
inflight_layout_demands: u32 = 0,
|
||||||
@ -256,19 +256,19 @@ fn handleNewOutput(_: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the output from root.outputs and evacuate views if it is a member of
|
/// Remove the output from root.active_outputs and evacuate views if it is a
|
||||||
/// the list. The node is not freed
|
/// member of the list. The node is not freed
|
||||||
pub fn removeOutput(root: *Self, output: *Output) void {
|
pub fn deactivateOutput(root: *Self, output: *Output) void {
|
||||||
{
|
{
|
||||||
const node = @fieldParentPtr(std.TailQueue(Output).Node, "data", output);
|
const node = @fieldParentPtr(std.TailQueue(Output).Node, "data", output);
|
||||||
|
|
||||||
// If the node has already been removed, do nothing
|
// If the node has already been removed, do nothing
|
||||||
var output_it = root.outputs.first;
|
var output_it = root.active_outputs.first;
|
||||||
while (output_it) |n| : (output_it = n.next) {
|
while (output_it) |n| : (output_it = n.next) {
|
||||||
if (n == node) break;
|
if (n == node) break;
|
||||||
} else return;
|
} else return;
|
||||||
|
|
||||||
root.outputs.remove(node);
|
root.active_outputs.remove(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output.inflight.layout_demand) |layout_demand| {
|
if (output.inflight.layout_demand) |layout_demand| {
|
||||||
@ -290,7 +290,7 @@ pub fn removeOutput(root: *Self, output: *Output) void {
|
|||||||
}
|
}
|
||||||
// Use the first output in the list as fallback. If the last real output
|
// Use the first output in the list as fallback. If the last real output
|
||||||
// is being removed, store the views in Root.fallback.
|
// is being removed, store the views in Root.fallback.
|
||||||
const fallback_output = if (root.outputs.first) |node| &node.data else null;
|
const fallback_output = if (root.active_outputs.first) |node| &node.data else null;
|
||||||
if (fallback_output) |fallback| {
|
if (fallback_output) |fallback| {
|
||||||
var it = output.pending.focus_stack.safeIterator(.reverse);
|
var it = output.pending.focus_stack.safeIterator(.reverse);
|
||||||
while (it.next()) |view| view.setPendingOutput(fallback);
|
while (it.next()) |view| view.setPendingOutput(fallback);
|
||||||
@ -329,16 +329,16 @@ pub fn removeOutput(root: *Self, output: *Output) void {
|
|||||||
output.status.init();
|
output.status.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add the output to root.outputs and the output layout if it has not
|
/// Add the output to root.active_outputs and the output layout if it has not
|
||||||
/// already been added.
|
/// already been added.
|
||||||
pub fn addOutput(root: *Self, output: *Output) void {
|
pub fn activateOutput(root: *Self, output: *Output) void {
|
||||||
const node = @fieldParentPtr(std.TailQueue(Output).Node, "data", output);
|
const node = @fieldParentPtr(std.TailQueue(Output).Node, "data", output);
|
||||||
|
|
||||||
// If we have already added the output, do nothing and return
|
// If we have already added the output, do nothing and return
|
||||||
var output_it = root.outputs.first;
|
var output_it = root.active_outputs.first;
|
||||||
while (output_it) |n| : (output_it = n.next) if (n == node) return;
|
while (output_it) |n| : (output_it = n.next) if (n == node) return;
|
||||||
|
|
||||||
root.outputs.append(node);
|
root.active_outputs.append(node);
|
||||||
|
|
||||||
// This arranges outputs from left-to-right in the order they appear. The
|
// This arranges outputs from left-to-right in the order they appear. The
|
||||||
// wlr-output-management protocol may be used to modify this arrangement.
|
// wlr-output-management protocol may be used to modify this arrangement.
|
||||||
@ -350,7 +350,7 @@ pub fn addOutput(root: *Self, output: *Output) void {
|
|||||||
output.tree.node.setPosition(layout_output.x, layout_output.y);
|
output.tree.node.setPosition(layout_output.x, layout_output.y);
|
||||||
|
|
||||||
// If we previously had no outputs, move all views to the new output and focus it.
|
// If we previously had no outputs, move all views to the new output and focus it.
|
||||||
if (root.outputs.len == 1) {
|
if (root.active_outputs.len == 1) {
|
||||||
output.pending.tags = root.fallback.tags;
|
output.pending.tags = root.fallback.tags;
|
||||||
{
|
{
|
||||||
var it = root.fallback.pending.focus_stack.safeIterator(.reverse);
|
var it = root.fallback.pending.focus_stack.safeIterator(.reverse);
|
||||||
@ -411,7 +411,7 @@ pub fn applyPending(root: *Self) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var output_it = root.outputs.first;
|
var output_it = root.active_outputs.first;
|
||||||
while (output_it) |node| : (output_it = node.next) {
|
while (output_it) |node| : (output_it = node.next) {
|
||||||
const output = &node.data;
|
const output = &node.data;
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ pub fn applyPending(root: *Self) void {
|
|||||||
{
|
{
|
||||||
// Layout demands can't be sent until after the inflight stacks of
|
// Layout demands can't be sent until after the inflight stacks of
|
||||||
// all outputs have been updated.
|
// all outputs have been updated.
|
||||||
var output_it = root.outputs.first;
|
var output_it = root.active_outputs.first;
|
||||||
while (output_it) |node| : (output_it = node.next) {
|
while (output_it) |node| : (output_it = node.next) {
|
||||||
const output = &node.data;
|
const output = &node.data;
|
||||||
assert(output.inflight.layout_demand == null);
|
assert(output.inflight.layout_demand == null);
|
||||||
@ -538,7 +538,7 @@ fn sendConfigures(root: *Self) void {
|
|||||||
assert(root.inflight_configures == 0);
|
assert(root.inflight_configures == 0);
|
||||||
|
|
||||||
// Iterate over all views of all outputs
|
// Iterate over all views of all outputs
|
||||||
var output_it = root.outputs.first;
|
var output_it = root.active_outputs.first;
|
||||||
while (output_it) |output_node| : (output_it = output_node.next) {
|
while (output_it) |output_node| : (output_it = output_node.next) {
|
||||||
const output = &output_node.data;
|
const output = &output_node.data;
|
||||||
|
|
||||||
@ -614,7 +614,7 @@ fn commitTransaction(root: *Self) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var output_it = root.outputs.first;
|
var output_it = root.active_outputs.first;
|
||||||
while (output_it) |output_node| : (output_it = output_node.next) {
|
while (output_it) |output_node| : (output_it = output_node.next) {
|
||||||
const output = &output_node.data;
|
const output = &output_node.data;
|
||||||
|
|
||||||
@ -770,7 +770,7 @@ fn processOutputConfig(
|
|||||||
output.updateBackgroundRect();
|
output.updateBackgroundRect();
|
||||||
output.arrangeLayers();
|
output.arrangeLayers();
|
||||||
} else {
|
} else {
|
||||||
self.removeOutput(output);
|
self.deactivateOutput(output);
|
||||||
self.output_layout.remove(output.wlr_output);
|
self.output_layout.remove(output.wlr_output);
|
||||||
output.tree.node.setEnabled(false);
|
output.tree.node.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ pub fn focusOutput(
|
|||||||
|
|
||||||
// If the fallback pseudo-output is focused, there are no other outputs to switch to
|
// If the fallback pseudo-output is focused, there are no other outputs to switch to
|
||||||
if (seat.focused_output == null) {
|
if (seat.focused_output == null) {
|
||||||
assert(server.root.outputs.len == 0);
|
assert(server.root.active_outputs.len == 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ pub fn sendToOutput(
|
|||||||
|
|
||||||
// If the fallback pseudo-output is focused, there is nowhere to send the view
|
// If the fallback pseudo-output is focused, there is nowhere to send the view
|
||||||
if (seat.focused_output == null) {
|
if (seat.focused_output == null) {
|
||||||
assert(server.root.outputs.len == 0);
|
assert(server.root.active_outputs.len == 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +89,8 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output {
|
|||||||
// Return the next/prev output in the list if there is one, else wrap
|
// Return 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.?);
|
const focused_node = @fieldParentPtr(std.TailQueue(Output).Node, "data", seat.focused_output.?);
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
.next => if (focused_node.next) |node| &node.data else &server.root.outputs.first.?.data,
|
.next => if (focused_node.next) |node| &node.data else &server.root.active_outputs.first.?.data,
|
||||||
.previous => if (focused_node.prev) |node| &node.data else &server.root.outputs.last.?.data,
|
.previous => if (focused_node.prev) |node| &node.data else &server.root.active_outputs.last.?.data,
|
||||||
};
|
};
|
||||||
} else if (std.meta.stringToEnum(wlr.OutputLayout.Direction, str)) |direction| { // Spacial direction
|
} else if (std.meta.stringToEnum(wlr.OutputLayout.Direction, str)) |direction| { // Spacial direction
|
||||||
var focus_box: wlr.Box = undefined;
|
var focus_box: wlr.Box = undefined;
|
||||||
@ -106,7 +106,7 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output {
|
|||||||
return @intToPtr(*Output, wlr_output.data);
|
return @intToPtr(*Output, wlr_output.data);
|
||||||
} else {
|
} else {
|
||||||
// Check if an output matches by name
|
// Check if an output matches by name
|
||||||
var it = server.root.outputs.first;
|
var it = server.root.active_outputs.first;
|
||||||
while (it) |node| : (it = node.next) {
|
while (it) |node| : (it = node.next) {
|
||||||
if (mem.eql(u8, mem.span(node.data.wlr_output.name), str)) {
|
if (mem.eql(u8, mem.span(node.data.wlr_output.name), str)) {
|
||||||
return &node.data;
|
return &node.data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user