Improve handling of layer surface output assignment

This commit is contained in:
Isaac Freund 2020-04-15 13:38:36 +02:00
parent b02f660475
commit 5bbfcab60e
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 20 additions and 12 deletions

View file

@ -58,6 +58,7 @@ pub const Output = struct {
self.root = root; self.root = root;
self.wlr_output = wlr_output; self.wlr_output = wlr_output;
wlr_output.data = self;
for (self.layers) |*layer| { for (self.layers) |*layer| {
layer.* = std.TailQueue(LayerSurface).init(); layer.* = std.TailQueue(LayerSurface).init();

View file

@ -172,20 +172,27 @@ pub const Server = struct {
}, },
); );
// TODO: this is insufficent for multi output support // If the new layer surface does not have an output assigned to it, use the
// first output or close the surface if none are available.
if (wlr_layer_surface.output == null) {
if (server.root.outputs.first) |node| { if (server.root.outputs.first) |node| {
const output = &node.data; const output = &node.data;
if (wlr_layer_surface.output == null) { Log.Debug.log(
"New layer surface had null output, assigning it to output {}",
.{output.wlr_output.name},
);
wlr_layer_surface.output = output.wlr_output; wlr_layer_surface.output = output.wlr_output;
}
output.addLayerSurface(wlr_layer_surface) catch unreachable;
} else { } else {
Log.Error.log( Log.Error.log(
"No output available for layer surface '{}' autoassign", "No output available for layer surface '{}'",
.{wlr_layer_surface.namespace}, .{wlr_layer_surface.namespace},
); );
c.wlr_layer_surface_v1_close(wlr_layer_surface); c.wlr_layer_surface_v1_close(wlr_layer_surface);
return;
} }
} }
const output = @ptrCast(*Output, @alignCast(@alignOf(*Output), wlr_layer_surface.output.*.data));
output.addLayerSurface(wlr_layer_surface) catch unreachable;
}
}; };