Root: migrate {all,active}_outputs to wl.list

As discussed with ifreund on irc. This avoids extra allocation in case
of all_outputs and confusion in case of active_outputs (because with the
Output embedded in the Node, i thought its value was copied instead of
its pointer).
This commit is contained in:
tiosgz
2023-08-06 13:36:33 +00:00
parent 8966f95e72
commit 4726a6b0f1
8 changed files with 88 additions and 85 deletions

View File

@ -138,10 +138,8 @@ fn handleLockSurfacesTimeout(manager: *LockManager) c_int {
manager.state = .waiting_for_blank;
{
var it = server.root.active_outputs.first;
while (it) |node| : (it = node.next) {
const output = &node.data;
var it = server.root.active_outputs.iterator(.forward);
while (it.next()) |output| {
output.normal_content.node.setEnabled(false);
output.locked_content.node.setEnabled(true);
}
@ -157,9 +155,8 @@ pub fn maybeLock(manager: *LockManager) void {
var all_outputs_blanked = true;
var all_outputs_rendered_lock_surface = true;
{
var it = server.root.active_outputs.first;
while (it) |node| : (it = node.next) {
const output = &node.data;
var it = server.root.active_outputs.iterator(.forward);
while (it.next()) |output| {
switch (output.lock_render_state) {
.pending_unlock, .unlocked, .pending_blank, .pending_lock_surface => {
all_outputs_blanked = false;
@ -205,10 +202,8 @@ fn handleUnlock(listener: *wl.Listener(void)) void {
log.info("session unlocked", .{});
{
var it = server.root.active_outputs.first;
while (it) |node| : (it = node.next) {
const output = &node.data;
var it = server.root.active_outputs.iterator(.forward);
while (it.next()) |output| {
assert(!output.normal_content.node.enabled);
output.normal_content.node.setEnabled(true);