mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-23 05:15:58 +01:00
wayland output: add error handling for xdg shell
Note that this does not go on to the next backend, because attempt_wl_backend does not check if we have any output created. We cannot test simply because (right now) a run of our examples will go in this function twice, the first of which will (rightly?) return no display but needs to return backend creation success.
This commit is contained in:
parent
577d2f6fcd
commit
4f3d21c3ff
1 changed files with 21 additions and 8 deletions
|
@ -137,7 +137,8 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
|
||||||
}
|
}
|
||||||
eglDestroySurface(output->backend->egl.display, output->surface);
|
eglDestroySurface(output->backend->egl.display, output->surface);
|
||||||
wl_egl_window_destroy(output->egl_window);
|
wl_egl_window_destroy(output->egl_window);
|
||||||
// xdg_surface/toplevel destroy
|
zxdg_toplevel_v6_destroy(output->xdg_toplevel);
|
||||||
|
zxdg_surface_v6_destroy(output->xdg_surface);
|
||||||
wl_surface_destroy(output->surface);
|
wl_surface_destroy(output->surface);
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
@ -230,12 +231,23 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
||||||
|
|
||||||
output->backend = backend;
|
output->backend = backend;
|
||||||
|
|
||||||
// TODO: error handling
|
|
||||||
output->surface = wl_compositor_create_surface(backend->compositor);
|
output->surface = wl_compositor_create_surface(backend->compositor);
|
||||||
|
if (!output->surface) {
|
||||||
|
wlr_log_errno(L_ERROR, "Could not create output surface");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
output->xdg_surface =
|
output->xdg_surface =
|
||||||
zxdg_shell_v6_get_xdg_surface(backend->shell, output->surface);
|
zxdg_shell_v6_get_xdg_surface(backend->shell, output->surface);
|
||||||
|
if (!output->xdg_surface) {
|
||||||
|
wlr_log_errno(L_ERROR, "Could not get xdg surface");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
output->xdg_toplevel =
|
output->xdg_toplevel =
|
||||||
zxdg_surface_v6_get_toplevel(output->xdg_surface);
|
zxdg_surface_v6_get_toplevel(output->xdg_surface);
|
||||||
|
if (!output->xdg_toplevel) {
|
||||||
|
wlr_log_errno(L_ERROR, "Could not get xdg toplevel");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
// class? app_id?
|
// class? app_id?
|
||||||
zxdg_toplevel_v6_set_title(output->xdg_toplevel, "sway-wl");
|
zxdg_toplevel_v6_set_title(output->xdg_toplevel, "sway-wl");
|
||||||
|
@ -253,8 +265,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
||||||
output->egl_surface, output->egl_surface,
|
output->egl_surface, output->egl_surface,
|
||||||
output->backend->egl.context)) {
|
output->backend->egl.context)) {
|
||||||
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
|
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
|
||||||
free(output);
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glViewport(0, 0, wlr_output->width, wlr_output->height);
|
glViewport(0, 0, wlr_output->width, wlr_output->height);
|
||||||
|
@ -266,16 +277,18 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
||||||
|
|
||||||
if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
|
if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
|
||||||
wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error());
|
wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error());
|
||||||
free(output);
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_add(backend->outputs, wlr_output) == -1) {
|
if (list_add(backend->outputs, wlr_output) == -1) {
|
||||||
wlr_log(L_ERROR, "Allocation failed");
|
wlr_log(L_ERROR, "Allocation failed");
|
||||||
free(output);
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
wlr_output_create_global(wlr_output, backend->local_display);
|
wlr_output_create_global(wlr_output, backend->local_display);
|
||||||
wl_signal_emit(&backend->backend.events.output_add, wlr_output);
|
wl_signal_emit(&backend->backend.events.output_add, wlr_output);
|
||||||
return wlr_output;
|
return wlr_output;
|
||||||
|
|
||||||
|
error:
|
||||||
|
wlr_output_destroy(&output->wlr_output);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue