Close layer surfaces on output destroy
This commit is contained in:
parent
fb1414a052
commit
0557d9df9d
@ -58,18 +58,18 @@ pub const LayerSurface = struct {
|
||||
|
||||
fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const layer_surface = @fieldParentPtr(LayerSurface, "listen_destroy", listener.?);
|
||||
const output = layer_surface.output;
|
||||
|
||||
Log.Debug.log("Layer surface '{}' destroyed", .{layer_surface.wlr_layer_surface.namespace});
|
||||
|
||||
const node = @fieldParentPtr(std.TailQueue(LayerSurface).Node, "data", layer_surface);
|
||||
layer_surface.output.layers[@intCast(usize, @enumToInt(layer_surface.layer))].remove(node);
|
||||
layer_surface.output.root.server.allocator.destroy(node);
|
||||
|
||||
layer_surface.output.arrangeLayers();
|
||||
|
||||
// Remove listeners active the entire lifetime of the layer surface
|
||||
c.wl_list_remove(&layer_surface.listen_destroy);
|
||||
c.wl_list_remove(&layer_surface.listen_map);
|
||||
c.wl_list_remove(&layer_surface.listen_unmap);
|
||||
c.wl_list_remove(&layer_surface.listen_destroy.link);
|
||||
c.wl_list_remove(&layer_surface.listen_map.link);
|
||||
c.wl_list_remove(&layer_surface.listen_unmap.link);
|
||||
|
||||
const node = @fieldParentPtr(std.TailQueue(LayerSurface).Node, "data", layer_surface);
|
||||
output.layers[@intCast(usize, @enumToInt(layer_surface.layer))].remove(node);
|
||||
output.root.server.allocator.destroy(node);
|
||||
}
|
||||
|
||||
fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
@ -101,6 +101,8 @@ pub const LayerSurface = struct {
|
||||
// remove listeners only active while the layer surface is mapped
|
||||
c.wl_list_remove(&layer_surface.listen_commit.link);
|
||||
c.wl_list_remove(&layer_surface.listen_new_popup.link);
|
||||
|
||||
layer_surface.output.arrangeLayers();
|
||||
}
|
||||
|
||||
fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
|
@ -379,6 +379,8 @@ pub const Output = struct {
|
||||
const destroyed_output = @fieldParentPtr(Output, "listen_destroy", listener.?);
|
||||
const root = destroyed_output.root;
|
||||
|
||||
Log.Debug.log("Output {} destroyed", .{destroyed_output.wlr_output.name});
|
||||
|
||||
// Use the first output in the list that is not the one being destroyed.
|
||||
// If there is no other real output, use the noop output.
|
||||
var output_it = root.outputs.first;
|
||||
@ -395,6 +397,21 @@ pub const Output = struct {
|
||||
node.view.output = fallback_output;
|
||||
}
|
||||
|
||||
// Close all layer surfaces on the destroyed output
|
||||
for (destroyed_output.layers) |*layer, layer_idx| {
|
||||
while (layer.pop()) |node| {
|
||||
const layer_surface = &node.data;
|
||||
c.wlr_layer_surface_v1_close(layer_surface.wlr_layer_surface);
|
||||
// We need to move the closing layer surface to the noop output
|
||||
// since it is not immediately destoryed. This just a request
|
||||
// to close which will trigger unmap and destroy events in
|
||||
// response, and the LayerSurface needs a valid output to
|
||||
// handle them.
|
||||
root.noop_output.layers[layer_idx].prepend(node);
|
||||
layer_surface.output = &root.noop_output;
|
||||
}
|
||||
}
|
||||
|
||||
// If any seat has the destroyed output focused, focus the fallback one
|
||||
var seat_it = root.server.input_manager.seats.first;
|
||||
while (seat_it) |seat_node| : (seat_it = seat_node.next) {
|
||||
|
@ -131,6 +131,7 @@ pub const Server = struct {
|
||||
fn handleNewOutput(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const server = @fieldParentPtr(Server, "listen_new_output", listener.?);
|
||||
const wlr_output = @ptrCast(*c.wlr_output, @alignCast(@alignOf(*c.wlr_output), data));
|
||||
Log.Debug.log("New output {}", .{wlr_output.name});
|
||||
server.root.addOutput(wlr_output);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user