Fix issues preventing layer from getting allocated
Now all of the steps to get rootston a reference to the layer surface are correctly wired up.
This commit is contained in:
parent
4bc1cc49d5
commit
fcf8c6c8a2
|
@ -21,7 +21,7 @@ struct wlr_egl_surface *egl_surface;
|
||||||
struct wl_callback *frame_callback;
|
struct wl_callback *frame_callback;
|
||||||
|
|
||||||
static uint32_t output = 0;
|
static uint32_t output = 0;
|
||||||
static uint32_t layer = -1;
|
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||||
static uint32_t anchor = 0;
|
static uint32_t anchor = 0;
|
||||||
static uint32_t width = 256, height = 256;
|
static uint32_t width = 256, height = 256;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ int main(int argc, char **argv) {
|
||||||
char *namespace = "wlroots";
|
char *namespace = "wlroots";
|
||||||
bool found;
|
bool found;
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt(argc, argv, "w:h:o:"))) {
|
while ((c = getopt(argc, argv, "w:h:o:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'o':
|
case 'o':
|
||||||
output = atoi(optarg);
|
output = atoi(optarg);
|
||||||
|
@ -185,9 +185,6 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_egl_init(&egl, EGL_PLATFORM_WAYLAND_EXT, display, NULL,
|
|
||||||
WL_SHM_FORMAT_ARGB8888);
|
|
||||||
|
|
||||||
wl_surface = wl_compositor_create_surface(compositor);
|
wl_surface = wl_compositor_create_surface(compositor);
|
||||||
|
|
||||||
struct zwlr_layer_surface_v1 *layer_surface =
|
struct zwlr_layer_surface_v1 *layer_surface =
|
||||||
|
@ -195,8 +192,12 @@ int main(int argc, char **argv) {
|
||||||
wl_surface, wl_output, layer, namespace);
|
wl_surface, wl_output, layer, namespace);
|
||||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||||
// TODO: margin, interactivity, exclusive zone
|
// TODO: margin, interactivity, exclusive zone
|
||||||
|
|
||||||
wl_surface_commit(wl_surface);
|
wl_surface_commit(wl_surface);
|
||||||
|
wl_display_dispatch(display);
|
||||||
|
wl_display_roundtrip(display);
|
||||||
|
|
||||||
|
wlr_egl_init(&egl, EGL_PLATFORM_WAYLAND_EXT, display, NULL,
|
||||||
|
WL_SHM_FORMAT_ARGB8888);
|
||||||
|
|
||||||
egl_window = wl_egl_window_create(wl_surface, width, height);
|
egl_window = wl_egl_window_create(wl_surface, width, height);
|
||||||
egl_surface = wlr_egl_create_surface(&egl, egl_window);
|
egl_surface = wlr_egl_create_surface(&egl, egl_window);
|
||||||
|
|
|
@ -719,6 +719,10 @@ struct roots_desktop *desktop_create(struct roots_server *server,
|
||||||
wl_signal_add(&desktop->layer_shell->events.new_surface,
|
wl_signal_add(&desktop->layer_shell->events.new_surface,
|
||||||
&desktop->layer_shell_surface);
|
&desktop->layer_shell_surface);
|
||||||
desktop->layer_shell_surface.notify = handle_layer_shell_surface;
|
desktop->layer_shell_surface.notify = handle_layer_shell_surface;
|
||||||
|
for (size_t i = 0;
|
||||||
|
i < sizeof(desktop->layers) / sizeof(desktop->layers[0]); ++i) {
|
||||||
|
wl_list_init(&desktop->layers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WLR_HAS_XWAYLAND
|
#ifdef WLR_HAS_XWAYLAND
|
||||||
const char *cursor_theme = NULL;
|
const char *cursor_theme = NULL;
|
||||||
|
|
|
@ -14,20 +14,20 @@ static void resource_handle_destroy(struct wl_client *client,
|
||||||
wl_resource_destroy(resource);
|
wl_resource_destroy(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct zwlr_layer_shell_v1_interface layer_shell_impl;
|
static const struct zwlr_layer_shell_v1_interface layer_shell_implementation;
|
||||||
static struct zwlr_layer_surface_v1_interface layer_surface_impl;
|
static const struct zwlr_layer_surface_v1_interface layer_surface_implementation;
|
||||||
|
|
||||||
static struct wlr_layer_client *layer_client_from_resource(
|
static struct wlr_layer_client *layer_client_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_impl));
|
&layer_shell_implementation));
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wlr_layer_surface *layer_surface_from_resource(
|
static struct wlr_layer_surface *layer_surface_from_resource(
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(resource, &zwlr_layer_surface_v1_interface,
|
assert(wl_resource_instance_of(resource, &zwlr_layer_surface_v1_interface,
|
||||||
&layer_surface_impl));
|
&layer_surface_implementation));
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,11 +291,22 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client,
|
||||||
wl_client_post_no_memory(wl_client);
|
wl_client_post_no_memory(wl_client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) {
|
||||||
|
wl_resource_post_error(surface->resource,
|
||||||
|
ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER,
|
||||||
|
"Invalid layer %d", layer);
|
||||||
|
free(surface);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_list_init(&surface->configure_list);
|
||||||
|
|
||||||
wl_signal_init(&surface->events.destroy);
|
wl_signal_init(&surface->events.destroy);
|
||||||
wl_signal_add(&surface->surface->events.destroy,
|
wl_signal_add(&surface->surface->events.destroy,
|
||||||
&surface->surface_destroy_listener);
|
&surface->surface_destroy_listener);
|
||||||
surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;
|
surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;
|
||||||
|
wl_signal_init(&surface->events.map);
|
||||||
|
wl_signal_init(&surface->events.unmap);
|
||||||
|
|
||||||
wlr_surface_set_role_committed(surface->surface,
|
wlr_surface_set_role_committed(surface->surface,
|
||||||
handle_wlr_surface_committed, surface);
|
handle_wlr_surface_committed, surface);
|
||||||
|
@ -307,7 +318,7 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client,
|
||||||
wl_list_insert(&client->surfaces, &surface->link);
|
wl_list_insert(&client->surfaces, &surface->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct zwlr_layer_shell_v1_interface layer_shell_impl = {
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -347,8 +358,8 @@ static void layer_shell_bind(struct wl_client *wl_client, void *data,
|
||||||
client->client = wl_client;
|
client->client = wl_client;
|
||||||
client->shell = layer_shell;
|
client->shell = layer_shell;
|
||||||
|
|
||||||
wl_resource_set_implementation(client->resource, &layer_shell_impl, client,
|
wl_resource_set_implementation(client->resource,
|
||||||
wlr_layer_client_destroy);
|
&layer_shell_implementation, client, wlr_layer_client_destroy);
|
||||||
wl_list_insert(&layer_shell->clients, &client->link);
|
wl_list_insert(&layer_shell->clients, &client->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue