Output: reinitialize output_status, cleanup

If a output is removed and added back without being destroyed this must
be reinitialized.

This commit also cleans up the Root.applyPending() calls related to
output hotplug and adds some more logging.
This commit is contained in:
Isaac Freund 2023-03-14 11:39:10 +01:00
parent 0355b654af
commit dd542b5284
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 13 additions and 7 deletions

View File

@ -381,15 +381,13 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", output);
util.gpa.destroy(node);
server.root.applyPending();
}
fn handleEnable(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
const self = @fieldParentPtr(Self, "enable", listener);
// Add the output to root.outputs and the output layout if it has not
// already been added.
if (wlr_output.enabled) server.root.addOutput(self);
// We can't assert the current state of normal_content/locked_content
// here as this output may be newly created.
if (wlr_output.enabled) {
@ -409,6 +407,10 @@ fn handleEnable(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) vo
// Disabling and re-enabling an output always blanks it.
self.lock_render_state = .blanked;
}
// Add the output to root.outputs and the output layout if it has not
// already been added.
if (wlr_output.enabled) server.root.addOutput(self);
}
fn handleMode(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {

View File

@ -295,8 +295,7 @@ pub fn removeOutput(root: *Self, output: *Output) void {
}
output.status.deinit();
root.applyPending();
output.status.init();
}
/// Add the output to self.outputs and the output layout if it has not
@ -338,8 +337,9 @@ pub fn addOutput(root: *Self, output: *Output) void {
seat.focusOutput(output);
}
}
root.applyPending();
}
root.applyPending();
}
/// Trigger asynchronous application of pending state for all outputs and views.
@ -546,6 +546,8 @@ fn commitTransaction(root: *Self) void {
assert(root.inflight_layout_demands == 0);
assert(root.inflight_configures == 0);
std.log.scoped(.transaction).debug("commiting transaction", .{});
{
var it = root.hidden.inflight.focus_stack.safeIterator(.forward);
while (it.next()) |view| {
@ -656,6 +658,8 @@ fn handleManagerApply(
const self = @fieldParentPtr(Self, "manager_apply", listener);
defer config.destroy();
std.log.scoped(.output_manager).info("applying output configuration", .{});
self.processOutputConfig(config, .apply);
// Send the config that was actually applied