|
|
@ -18,7 +18,7 @@ static void resource_handle_destroy(struct wl_client *client,
|
|
|
|
static const struct zwlr_layer_shell_v1_interface layer_shell_implementation;
|
|
|
|
static const struct zwlr_layer_shell_v1_interface layer_shell_implementation;
|
|
|
|
static const struct zwlr_layer_surface_v1_interface layer_surface_implementation;
|
|
|
|
static const struct zwlr_layer_surface_v1_interface layer_surface_implementation;
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_layer_client *layer_client_from_resource(
|
|
|
|
static struct wlr_layer_shell *layer_shell_from_resource(
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
assert(wl_resource_instance_of(resource, &zwlr_layer_shell_v1_interface,
|
|
|
|
assert(wl_resource_instance_of(resource, &zwlr_layer_shell_v1_interface,
|
|
|
|
&layer_shell_implementation));
|
|
|
|
&layer_shell_implementation));
|
|
|
@ -58,7 +58,7 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
if (!found) {
|
|
|
|
wl_resource_post_error(surface->client->resource,
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE,
|
|
|
|
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE,
|
|
|
|
"wrong configure serial: %u", serial);
|
|
|
|
"wrong configure serial: %u", serial);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -156,7 +156,6 @@ static void layer_surface_destroy(struct wlr_layer_surface *surface) {
|
|
|
|
layer_surface_unmap(surface);
|
|
|
|
layer_surface_unmap(surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.destroy, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.destroy, surface);
|
|
|
|
wl_resource_set_user_data(surface->resource, NULL);
|
|
|
|
wl_resource_set_user_data(surface->resource, NULL);
|
|
|
|
wl_list_remove(&surface->link);
|
|
|
|
|
|
|
|
wl_list_remove(&surface->surface_destroy_listener.link);
|
|
|
|
wl_list_remove(&surface->surface_destroy_listener.link);
|
|
|
|
wlr_surface_set_role_committed(surface->surface, NULL, NULL);
|
|
|
|
wlr_surface_set_role_committed(surface->surface, NULL, NULL);
|
|
|
|
free(surface);
|
|
|
|
free(surface);
|
|
|
@ -195,11 +194,11 @@ void wlr_layer_surface_configure(struct wlr_layer_surface *surface,
|
|
|
|
surface->server_pending.actual_height = height;
|
|
|
|
surface->server_pending.actual_height = height;
|
|
|
|
if (wlr_layer_surface_state_changed(surface)) {
|
|
|
|
if (wlr_layer_surface_state_changed(surface)) {
|
|
|
|
struct wl_display *display =
|
|
|
|
struct wl_display *display =
|
|
|
|
wl_client_get_display(surface->client->client);
|
|
|
|
wl_client_get_display(wl_resource_get_client(surface->resource));
|
|
|
|
struct wlr_layer_surface_configure *configure =
|
|
|
|
struct wlr_layer_surface_configure *configure =
|
|
|
|
calloc(1, sizeof(struct wlr_layer_surface_configure));
|
|
|
|
calloc(1, sizeof(struct wlr_layer_surface_configure));
|
|
|
|
if (configure == NULL) {
|
|
|
|
if (configure == NULL) {
|
|
|
|
wl_client_post_no_memory(surface->client->client);
|
|
|
|
wl_client_post_no_memory(wl_resource_get_client(surface->resource));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
surface->configure_next_serial = wl_display_next_serial(display);
|
|
|
|
surface->configure_next_serial = wl_display_next_serial(display);
|
|
|
@ -248,7 +247,7 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
|
|
|
|
|
|
|
|
|
|
|
if (!surface->added) {
|
|
|
|
if (!surface->added) {
|
|
|
|
surface->added = true;
|
|
|
|
surface->added = true;
|
|
|
|
wlr_signal_emit_safe(&surface->client->shell->events.new_surface,
|
|
|
|
wlr_signal_emit_safe(&surface->shell->events.new_surface,
|
|
|
|
surface);
|
|
|
|
surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
|
|
|
|
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
|
|
|
@ -274,8 +273,8 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *output_resource,
|
|
|
|
struct wl_resource *output_resource,
|
|
|
|
uint32_t layer, const char *namespace) {
|
|
|
|
uint32_t layer, const char *namespace) {
|
|
|
|
struct wlr_layer_client *client =
|
|
|
|
struct wlr_layer_shell *shell =
|
|
|
|
layer_client_from_resource(client_resource);
|
|
|
|
layer_shell_from_resource(client_resource);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_layer_surface *surface =
|
|
|
|
struct wlr_layer_surface *surface =
|
|
|
|
calloc(1, sizeof(struct wlr_layer_surface));
|
|
|
|
calloc(1, sizeof(struct wlr_layer_surface));
|
|
|
@ -284,7 +283,7 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
surface->client = client;
|
|
|
|
surface->shell = shell;
|
|
|
|
surface->surface = wlr_surface_from_resource(surface_resource);
|
|
|
|
surface->surface = wlr_surface_from_resource(surface_resource);
|
|
|
|
surface->output = wlr_output_from_resource(output_resource);
|
|
|
|
surface->output = wlr_output_from_resource(output_resource);
|
|
|
|
surface->resource = wl_resource_create(wl_client,
|
|
|
|
surface->resource = wl_resource_create(wl_client,
|
|
|
@ -322,23 +321,14 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client,
|
|
|
|
surface, surface->resource);
|
|
|
|
surface, surface->resource);
|
|
|
|
wl_resource_set_implementation(surface->resource,
|
|
|
|
wl_resource_set_implementation(surface->resource,
|
|
|
|
&layer_surface_implementation, surface, layer_surface_resource_destroy);
|
|
|
|
&layer_surface_implementation, surface, layer_surface_resource_destroy);
|
|
|
|
wl_list_insert(&client->surfaces, &surface->link);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const struct zwlr_layer_shell_v1_interface layer_shell_implementation = {
|
|
|
|
static const struct zwlr_layer_shell_v1_interface layer_shell_implementation = {
|
|
|
|
.get_layer_surface = layer_shell_handle_get_layer_surface,
|
|
|
|
.get_layer_surface = layer_shell_handle_get_layer_surface,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_layer_client_destroy(struct wl_resource *resource) {
|
|
|
|
static void client_handle_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_layer_client *client = layer_client_from_resource(resource);
|
|
|
|
wl_list_remove(wl_resource_get_link(resource));
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_layer_surface *surface, *tmp = NULL;
|
|
|
|
|
|
|
|
wl_list_for_each_safe(surface, tmp, &client->surfaces, link) {
|
|
|
|
|
|
|
|
layer_surface_destroy(surface);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&client->link);
|
|
|
|
|
|
|
|
free(client);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void layer_shell_bind(struct wl_client *wl_client, void *data,
|
|
|
|
static void layer_shell_bind(struct wl_client *wl_client, void *data,
|
|
|
@ -346,28 +336,16 @@ static void layer_shell_bind(struct wl_client *wl_client, void *data,
|
|
|
|
struct wlr_layer_shell *layer_shell = data;
|
|
|
|
struct wlr_layer_shell *layer_shell = data;
|
|
|
|
assert(wl_client && layer_shell);
|
|
|
|
assert(wl_client && layer_shell);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_layer_client *client =
|
|
|
|
struct wl_resource *resource = wl_resource_create(
|
|
|
|
calloc(1, sizeof(struct wlr_layer_client));
|
|
|
|
|
|
|
|
if (client == NULL) {
|
|
|
|
|
|
|
|
wl_client_post_no_memory(wl_client);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_init(&client->surfaces);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client->resource = wl_resource_create(
|
|
|
|
|
|
|
|
wl_client, &zwlr_layer_shell_v1_interface, version, id);
|
|
|
|
wl_client, &zwlr_layer_shell_v1_interface, version, id);
|
|
|
|
if (client->resource == NULL) {
|
|
|
|
if (resource == NULL) {
|
|
|
|
free(client);
|
|
|
|
|
|
|
|
wl_client_post_no_memory(wl_client);
|
|
|
|
wl_client_post_no_memory(wl_client);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
client->client = wl_client;
|
|
|
|
wl_resource_set_implementation(resource,
|
|
|
|
client->shell = layer_shell;
|
|
|
|
&layer_shell_implementation, layer_shell, client_handle_destroy);
|
|
|
|
|
|
|
|
wl_list_insert(&layer_shell->client_resources,
|
|
|
|
wl_resource_set_implementation(client->resource,
|
|
|
|
wl_resource_get_link(resource));
|
|
|
|
&layer_shell_implementation, client, wlr_layer_client_destroy);
|
|
|
|
|
|
|
|
wl_list_insert(&layer_shell->clients, &client->link);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
|
|
@ -383,7 +361,7 @@ struct wlr_layer_shell *wlr_layer_shell_create(struct wl_display *display) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_init(&layer_shell->clients);
|
|
|
|
wl_list_init(&layer_shell->client_resources);
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_global *wl_global = wl_global_create(display,
|
|
|
|
struct wl_global *wl_global = wl_global_create(display,
|
|
|
|
&zwlr_layer_shell_v1_interface, 1, layer_shell, layer_shell_bind);
|
|
|
|
&zwlr_layer_shell_v1_interface, 1, layer_shell, layer_shell_bind);
|
|
|
@ -405,6 +383,10 @@ void wlr_layer_shell_destroy(struct wlr_layer_shell *layer_shell) {
|
|
|
|
if (!layer_shell) {
|
|
|
|
if (!layer_shell) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wl_resource *client, *tmp;
|
|
|
|
|
|
|
|
wl_resource_for_each_safe(client, tmp, &layer_shell->client_resources) {
|
|
|
|
|
|
|
|
wl_resource_destroy(client);
|
|
|
|
|
|
|
|
}
|
|
|
|
wl_list_remove(&layer_shell->display_destroy.link);
|
|
|
|
wl_list_remove(&layer_shell->display_destroy.link);
|
|
|
|
wl_global_destroy(layer_shell->wl_global);
|
|
|
|
wl_global_destroy(layer_shell->wl_global);
|
|
|
|
free(layer_shell);
|
|
|
|
free(layer_shell);
|
|
|
|