output: Add struct members for layer shell

This commit is contained in:
Moon Sungjoon 2024-07-22 20:26:17 +09:00 committed by Sungjoon Moon
parent 956b308d9e
commit c82ec0585b
2 changed files with 30 additions and 12 deletions

View file

@ -235,6 +235,11 @@ output_destroy(struct cg_output *output)
wl_list_remove(&output->frame.link);
wl_list_remove(&output->link);
wlr_scene_node_destroy(&output->layers.shell_background->node);
wlr_scene_node_destroy(&output->layers.shell_bottom->node);
wlr_scene_node_destroy(&output->layers.shell_top->node);
wlr_scene_node_destroy(&output->layers.shell_overlay->node);
output_layout_remove(output);
free(output);
@ -255,6 +260,18 @@ handle_output_destroy(struct wl_listener *listener, void *data)
output_destroy(output);
}
static struct wlr_scene_tree *
create_layer_for_output(struct cg_output *output)
{
struct cg_server *server = output->server;
struct wlr_scene_tree *layer = wlr_scene_tree_create(&server->scene->tree);
if (layer == NULL) {
return NULL;
}
layer->node.data = output->wlr_output;
return layer;
}
void
handle_new_output(struct wl_listener *listener, void *data)
{
@ -320,9 +337,10 @@ handle_new_output(struct wl_listener *listener, void *data)
output_disable(next);
}
for (size_t i = 0; i < sizeof(output->layers) / sizeof(output->layers[0]); i++) {
wl_list_init(&output->layers[i]);
}
output->layers.shell_background = create_layer_for_output(output);
output->layers.shell_bottom = create_layer_for_output(output);
output->layers.shell_top = create_layer_for_output(output);
output->layers.shell_overlay = create_layer_for_output(output);
if (!wlr_xcursor_manager_load(server->seat->xcursor_manager, wlr_output->scale)) {
wlr_log(WLR_ERROR, "Cannot load XCursor theme for output '%s' with scale %f", wlr_output->name,

View file

@ -7,14 +7,6 @@
#include "server.h"
#include "view.h"
/* There exist currently four layers:
* - ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
* - ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM
* - ZWLR_LAYER_SHELL_V1_LAYER_TOP
* - ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY
*/
#define NUM_LAYERS 4
struct cg_output {
struct cg_server *server;
struct wlr_output *wlr_output;
@ -25,8 +17,16 @@ struct cg_output {
struct wl_listener destroy;
struct wl_listener frame;
struct {
struct wlr_scene_tree *shell_background;
struct wlr_scene_tree *shell_bottom;
struct wlr_scene_tree *shell_top;
struct wlr_scene_tree *shell_overlay;
} layers;
struct wlr_box usable_area;
struct wl_list link; // cg_server::outputs
struct wl_list layers[NUM_LAYERS]; // cg_layer_surface::link
};
void handle_output_manager_apply(struct wl_listener *listener, void *data);