fix
This commit is contained in:
parent
b5fba46c63
commit
278316bbd5
@ -28,7 +28,13 @@ struct server {
|
|||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
struct wlr_allocator *alloc;
|
struct wlr_allocator *alloc;
|
||||||
|
|
||||||
|
struct wlr_xdg_shell *xdg_shell;
|
||||||
|
struct wl_listener new_xdg_surface;
|
||||||
|
struct wl_list views;
|
||||||
|
|
||||||
struct wlr_cursor *cursor;
|
struct wlr_cursor *cursor;
|
||||||
|
struct wl_listener cursor_motion;
|
||||||
|
struct wl_listener cursor_button;
|
||||||
|
|
||||||
struct wlr_output_layout *output_layout;
|
struct wlr_output_layout *output_layout;
|
||||||
struct wl_list outputs;
|
struct wl_list outputs;
|
||||||
|
19
src/main.c
19
src/main.c
@ -1,5 +1,11 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
void cleanup(struct server *server) {
|
||||||
|
wlr_backend_destroy(server->backend);
|
||||||
|
wlr_allocator_destroy(server->alloc);
|
||||||
|
wl_display_destroy(server->wl_display);
|
||||||
|
}
|
||||||
|
|
||||||
void rendermon(struct wl_listener *listener, void *data) {
|
void rendermon(struct wl_listener *listener, void *data) {
|
||||||
struct output *output = wl_container_of(listener, output, frame);
|
struct output *output = wl_container_of(listener, output, frame);
|
||||||
struct server *server = output->server;
|
struct server *server = output->server;
|
||||||
@ -39,8 +45,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||||||
|
|
||||||
struct output *output = malloc(sizeof(struct output));
|
struct output *output = malloc(sizeof(struct output));
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
wlr_backend_destroy(server->backend);
|
cleanup(server);
|
||||||
wl_display_destroy(server->wl_display);
|
|
||||||
die("createmon", 1);
|
die("createmon", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +58,6 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
output->server = server;
|
output->server = server;
|
||||||
output->wlr_output = wlr_output;
|
output->wlr_output = wlr_output;
|
||||||
wl_list_insert(&server->outputs, &output->link);
|
wl_list_insert(&server->outputs, &output->link);
|
||||||
@ -95,8 +99,7 @@ void server_init(struct server *server) {
|
|||||||
|
|
||||||
const char *socket = wl_display_add_socket_auto(server->wl_display);
|
const char *socket = wl_display_add_socket_auto(server->wl_display);
|
||||||
if (!socket) {
|
if (!socket) {
|
||||||
wlr_backend_destroy(server->backend);
|
cleanup(server);
|
||||||
wl_display_destroy(server->wl_display);
|
|
||||||
die("wl_display_add_socket_auto", 1);
|
die("wl_display_add_socket_auto", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +107,7 @@ void server_init(struct server *server) {
|
|||||||
setenv("WAYLAND_DISPLAY", socket, 1);
|
setenv("WAYLAND_DISPLAY", socket, 1);
|
||||||
|
|
||||||
if (!wlr_backend_start(server->backend)) {
|
if (!wlr_backend_start(server->backend)) {
|
||||||
wlr_backend_destroy(server->backend);
|
cleanup(server);
|
||||||
wl_display_destroy(server->wl_display);
|
|
||||||
die("wlr_backend_start", 1);
|
die("wlr_backend_start", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +126,6 @@ int main(void) {
|
|||||||
server_init(&server);
|
server_init(&server);
|
||||||
|
|
||||||
wl_display_run(server.wl_display);
|
wl_display_run(server.wl_display);
|
||||||
wlr_backend_destroy(server.backend);
|
cleanup(&server);
|
||||||
wl_display_destroy(server.wl_display);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user