Print error if wlr-layer-shell is not supported

This commit is contained in:
Midgard 2022-09-08 13:44:14 +02:00
parent ac272a754e
commit 28f821f1e0
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -116,18 +116,19 @@ struct user_request {
struct client_state {
struct user_request user_request;
bool stop;
/* Globals */
struct wl_registry *wl_registry;
struct wl_display *wl_display;
struct wl_shm *wl_shm;
struct wl_compositor *wl_compositor;
struct zwlr_layer_shell_v1 *layer_shell;
struct wl_seat *wl_seat;
/* Objects */
struct zwlr_layer_shell_v1 *layer_shell;
struct wl_surface *wl_surface;
struct zwlr_layer_surface_v1 *zwlr_surface;
bool stop;
};
static void
@ -452,12 +453,17 @@ main(int argc, char *argv[])
state.wl_display = wl_display_connect(NULL);
if (!state.wl_display) {
fprintf(stderr, "Could not connect to Wayland server\n");
return 1;
exit(1);
}
state.wl_registry = wl_display_get_registry(state.wl_display);
wl_registry_add_listener(state.wl_registry, &wl_registry_listener, &state);
wl_display_roundtrip(state.wl_display);
if (state.layer_shell == NULL) {
fprintf(stderr, "Wayland compositor does not support wlr-layer-shell protocol\n");
exit(1);
}
state.wl_surface = wl_compositor_create_surface(state.wl_compositor);
state.zwlr_surface = zwlr_layer_shell_v1_get_layer_surface(
state.layer_shell, state.wl_surface, NULL, ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, "wl-overlay");