2017-09-23 04:29:53 +00:00
|
|
|
#define _POSIX_C_SOURCE 200112L
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2017-09-23 00:24:32 +00:00
|
|
|
#include <wayland-server.h>
|
2017-09-23 04:29:53 +00:00
|
|
|
#include <wlr/backend.h>
|
|
|
|
#include <wlr/render.h>
|
|
|
|
#include <wlr/render/gles2.h>
|
2017-09-23 00:24:32 +00:00
|
|
|
#include <wlr/util/log.h>
|
|
|
|
#include "rootston/config.h"
|
|
|
|
#include "rootston/server.h"
|
|
|
|
|
2017-09-23 04:29:53 +00:00
|
|
|
struct roots_server server = { 0 };
|
2017-09-23 00:24:32 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2017-09-23 04:29:53 +00:00
|
|
|
assert(server.config = parse_args(argc, argv));
|
|
|
|
assert(server.wl_display = wl_display_create());
|
|
|
|
assert(server.wl_event_loop = wl_display_get_event_loop(server.wl_display));
|
|
|
|
|
|
|
|
assert(server.backend = wlr_backend_autocreate(server.wl_display));
|
|
|
|
|
|
|
|
assert(server.renderer = wlr_gles2_renderer_create(server.backend));
|
|
|
|
wl_display_init_shm(server.wl_display);
|
|
|
|
server.desktop = desktop_create(&server, server.config);
|
2017-09-30 12:46:18 +00:00
|
|
|
server.input = input_create(&server, server.config);
|
2017-10-11 19:48:40 +00:00
|
|
|
server.data_device_manager =
|
|
|
|
wlr_data_device_manager_create(server.wl_display);
|
2017-09-23 04:29:53 +00:00
|
|
|
|
|
|
|
const char *socket = wl_display_add_socket_auto(server.wl_display);
|
|
|
|
if (!socket) {
|
|
|
|
wlr_log_errno(L_ERROR, "Unable to open wayland socket");
|
|
|
|
wlr_backend_destroy(server.backend);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wlr_log(L_INFO, "Running compositor on wayland display '%s'", socket);
|
|
|
|
setenv("_WAYLAND_DISPLAY", socket, true);
|
|
|
|
|
|
|
|
if (!wlr_backend_start(server.backend)) {
|
|
|
|
wlr_log(L_ERROR, "Failed to start backend");
|
|
|
|
wlr_backend_destroy(server.backend);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-10-03 14:35:54 +00:00
|
|
|
setenv("WAYLAND_DISPLAY", socket, true);
|
2017-09-23 04:29:53 +00:00
|
|
|
wl_display_run(server.wl_display);
|
2017-10-05 20:01:56 +00:00
|
|
|
wlr_backend_destroy(server.backend);
|
2017-09-23 00:24:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|