swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit f8ab5edb2d102dfef49485984a833304771e0c02
parent dcc33a0c707ae02a4e35bdedbb62427c0468c538
Author: Michael Forney <mforney@mforney.org>
Date:   Tue, 17 Dec 2013 09:02:00 -0800

drm: Move initialization from compositor.c to swc.c

Diffstat:
Mlibswc/compositor.c | 34++++------------------------------
Mlibswc/compositor.h | 2--
Mlibswc/drm.c | 166++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mlibswc/drm.h | 21+++------------------
Mlibswc/internal.h | 1+
Mlibswc/output.c | 11+++++------
Mlibswc/output.h | 5+----
Mlibswc/plane.c | 18+++++++++---------
Mlibswc/renderer.c | 16+++-------------
Mlibswc/renderer.h | 7-------
Mlibswc/swc.c | 37+++++++++++++++++++++++++------------
11 files changed, 144 insertions(+), 174 deletions(-)

diff --git a/libswc/compositor.c b/libswc/compositor.c @@ -3,6 +3,7 @@ #include "compositor_surface.h" #include "cursor_surface.h" #include "data_device_manager.h" +#include "drm.h" #include "internal.h" #include "output.h" #include "pointer.h" @@ -15,8 +16,6 @@ #include <stdio.h> #include <xkbcommon/xkbcommon-keysyms.h> -static const char default_seat[] = "seat0"; - static void calculate_damage(struct swc_compositor * compositor) { struct swc_surface * surface; @@ -340,23 +339,9 @@ bool swc_compositor_initialize(struct swc_compositor * compositor, .motion = &handle_motion }; - /* TODO: configurable seat */ - if (!swc_drm_initialize(&compositor->drm, default_seat)) - { - printf("could not initialize drm\n"); - goto error0; - } - - wl_signal_add(&compositor->drm.event_signal, &compositor->drm_listener); - swc_drm_add_event_sources(&compositor->drm, event_loop); + wl_signal_add(&swc.drm->event_signal, &compositor->drm_listener); - if (!swc_renderer_initialize(&compositor->renderer, &compositor->drm)) - { - printf("could not initialize renderer\n"); - goto error1; - } - - outputs = swc_drm_create_outputs(&compositor->drm); + outputs = swc_drm_create_outputs(); if (outputs) { @@ -367,7 +352,7 @@ bool swc_compositor_initialize(struct swc_compositor * compositor, else { printf("could not create outputs\n"); - goto error2; + return false; } pixman_region32_init(&compositor->damage); @@ -387,13 +372,6 @@ bool swc_compositor_initialize(struct swc_compositor * compositor, return true; - - error2: - swc_renderer_finalize(&compositor->renderer); - error1: - swc_drm_finish(&compositor->drm); - error0: - return false; } void swc_compositor_finish(struct swc_compositor * compositor) @@ -405,8 +383,6 @@ void swc_compositor_finish(struct swc_compositor * compositor) swc_output_finish(output); free(output); } - - swc_drm_finish(&compositor->drm); } void swc_compositor_add_globals(struct swc_compositor * compositor, @@ -417,8 +393,6 @@ void swc_compositor_add_globals(struct swc_compositor * compositor, wl_global_create(display, &wl_compositor_interface, 3, compositor, &bind_compositor); - swc_drm_add_globals(&compositor->drm, display); - wl_list_for_each(output, &compositor->outputs, link) { swc_output_add_globals(output, display); diff --git a/libswc/compositor.h b/libswc/compositor.h @@ -1,7 +1,6 @@ #ifndef SWC_COMPOSITOR_H #define SWC_COMPOSITOR_H -#include "drm.h" #include "pointer.h" #include "renderer.h" @@ -11,7 +10,6 @@ struct swc_compositor { struct wl_display * display; - struct swc_drm drm; struct swc_renderer renderer; struct wl_list outputs; diff --git a/libswc/drm.c b/libswc/drm.c @@ -40,13 +40,25 @@ #include <wayland-server.h> #include "protocol/wayland-drm-server-protocol.h" +struct swc_drm drm_global; + +static struct +{ + uint32_t id; + char * path; + + uint32_t taken_output_ids; + + struct wl_global * global; + struct wl_event_source * event_source; +} drm; + static void authenticate(struct wl_client * client, struct wl_resource * resource, uint32_t magic) { - struct swc_drm * drm = wl_resource_get_user_data(resource); int ret; - if ((ret = drmAuthMagic(drm->fd, magic)) == 0) + if ((ret = drmAuthMagic(swc.drm->fd, magic)) == 0) wl_drm_send_authenticated(resource); else { @@ -60,11 +72,10 @@ static void create_buffer(struct wl_client * client, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format) { - struct swc_drm * drm = wl_resource_get_user_data(resource); struct wld_drawable * drawable; struct swc_drm_buffer * buffer; - drawable = wld_drm_import_gem(drm->context, width, height, format, + drawable = wld_drm_import_gem(swc.drm->context, width, height, format, name, stride); if (!drawable) @@ -103,11 +114,11 @@ static void create_prime_buffer(struct wl_client * client, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2) { - struct swc_drm * drm = wl_resource_get_user_data(resource); struct wld_drawable * drawable; struct swc_drm_buffer * buffer; - drawable = wld_drm_import(drm->context, width, height, format, fd, stride0); + drawable = wld_drm_import(swc.drm->context, width, height, format, + fd, stride0); close(fd); if (!drawable) @@ -199,7 +210,7 @@ static struct udev_device * find_primary_drm_device(const char * seat) return drm_device; } -static bool find_available_crtc(struct swc_drm * drm, drmModeRes * resources, +static bool find_available_crtc(drmModeRes * resources, drmModeConnector * connector, uint32_t taken_crtcs, uint32_t * crtc) { @@ -211,7 +222,8 @@ static bool find_available_crtc(struct swc_drm * drm, drmModeRes * resources, encoder_index < connector->count_encoders; ++encoder_index) { - encoder = drmModeGetEncoder(drm->fd, connector->encoders[encoder_index]); + encoder = drmModeGetEncoder(swc.drm->fd, + connector->encoders[encoder_index]); possible_crtcs = encoder->possible_crtcs; drmModeFreeEncoder(encoder); @@ -232,11 +244,9 @@ static bool find_available_crtc(struct swc_drm * drm, drmModeRes * resources, return false; } -static bool find_available_id(struct swc_drm * drm, uint32_t * id) +static bool find_available_id(uint32_t * id) { - uint32_t index = __builtin_ffsl(~drm->taken_output_ids); - - printf("drm->taken_output_ids: %u, index: %u\n", drm->taken_output_ids, index); + uint32_t index = __builtin_ffsl(~drm.taken_output_ids); if (index == 0) return false; @@ -262,7 +272,7 @@ static void handle_page_flip(int fd, unsigned int sequence, unsigned int sec, /* XXX: It doesn't make sense for multiple things to be listening for page * flips (or does it?). Maybe this should be a callback instead? */ - swc_send_event(&output->drm->event_signal, SWC_DRM_PAGE_FLIP, &event_data); + swc_send_event(&swc.drm->event_signal, SWC_DRM_PAGE_FLIP, &event_data); } static drmEventContext event_context = { @@ -278,14 +288,33 @@ static int handle_data(int fd, uint32_t mask, void * data) return 1; } -bool swc_drm_initialize(struct swc_drm * drm, const char * seat) +static void bind_drm(struct wl_client * client, void * data, uint32_t version, + uint32_t id) +{ + struct wl_resource * resource; + + if (version >= 2) + version = 2; + + resource = wl_resource_create(client, &wl_drm_interface, version, id); + wl_resource_set_implementation(resource, &drm_implementation, NULL, NULL); + + if (version >= 2) + wl_drm_send_capabilities(resource, WL_DRM_CAPABILITY_PRIME); + + wl_drm_send_device(resource, drm.path); + wl_drm_send_format(resource, WL_DRM_FORMAT_XRGB8888); + wl_drm_send_format(resource, WL_DRM_FORMAT_ARGB8888); +} + +bool swc_drm_initialize(const char * seat_name) { const char * sysnum; char * end; - wl_signal_init(&drm->event_signal); + wl_signal_init(&swc.drm->event_signal); - struct udev_device * drm_device = find_primary_drm_device(seat); + struct udev_device * drm_device = find_primary_drm_device(seat_name); if (!drm_device) { @@ -295,9 +324,7 @@ bool swc_drm_initialize(struct swc_drm * drm, const char * seat) /* XXX: Why do we need the sysnum? */ sysnum = udev_device_get_sysnum(drm_device); - drm->id = strtoul(sysnum, &end, 10); - - drm->taken_output_ids = 0; + drm.id = strtoul(sysnum, &end, 10); if (*end != '\0') { @@ -306,74 +333,65 @@ bool swc_drm_initialize(struct swc_drm * drm, const char * seat) goto error0; } - printf("sysnum: %s\n", sysnum); - - drm->path = strdup(udev_device_get_devnode(drm_device)); + drm.taken_output_ids = 0; + drm.path = strdup(udev_device_get_devnode(drm_device)); udev_device_unref(drm_device); - drm->fd = swc_launch_open_device(drm->path, O_RDWR | O_CLOEXEC); + swc.drm->fd = swc_launch_open_device(drm.path, O_RDWR | O_CLOEXEC); - if (drm->fd == -1) + if (swc.drm->fd == -1) { - fprintf(stderr, "Could not open %s\n", drm->path); + fprintf(stderr, "Could not open %s\n", drm.path); goto error1; } - if (!(drm->context = wld_drm_create_context(drm->fd))) + if (!(swc.drm->context = wld_drm_create_context(swc.drm->fd))) { fprintf(stderr, "Could not create WLD DRM context\n"); goto error2; } + drm.global = wl_global_create(swc.display, &wl_drm_interface, 2, + NULL, &bind_drm); + + if (!drm.global) + { + ERROR("Could not create wl_drm global\n"); + goto error3; + } + + drm.event_source = wl_event_loop_add_fd + (swc.event_loop, swc.drm->fd, WL_EVENT_READABLE, &handle_data, NULL); + + if (!drm.event_source) + { + ERROR("Could not create DRM event source\n"); + goto error4; + } + return true; + error4: + wl_global_destroy(drm.global); + error3: + wld_drm_destroy_context(swc.drm->context); error2: - close(drm->fd); + close(swc.drm->fd); error1: - free(drm->path); + free(drm.path); error0: return false; } -void swc_drm_finish(struct swc_drm * drm) -{ - wld_drm_destroy_context(drm->context); - free(drm->path); - close(drm->fd); -} - -void swc_drm_add_event_sources(struct swc_drm * drm, - struct wl_event_loop * event_loop) -{ - drm->source = wl_event_loop_add_fd(event_loop, drm->fd, WL_EVENT_READABLE, - &handle_data, NULL); -} - -static void bind_drm(struct wl_client * client, void * data, uint32_t version, - uint32_t id) -{ - struct swc_drm * drm = data; - struct wl_resource * resource; - - if (version >= 2) - version = 2; - - resource = wl_resource_create(client, &wl_drm_interface, version, id); - wl_resource_set_implementation(resource, &drm_implementation, drm, NULL); - - if (version >= 2) - wl_drm_send_capabilities(resource, WL_DRM_CAPABILITY_PRIME); - - wl_drm_send_device(resource, drm->path); - wl_drm_send_format(resource, WL_DRM_FORMAT_XRGB8888); - wl_drm_send_format(resource, WL_DRM_FORMAT_ARGB8888); -} - -void swc_drm_add_globals(struct swc_drm * drm, struct wl_display * display) +void swc_drm_finalize() { - wl_global_create(display, &wl_drm_interface, 2, drm, &bind_drm); + wl_event_source_remove(drm.event_source); + wl_global_destroy(drm.global); + wld_drm_destroy_context(swc.drm->context); + free(drm.path); + close(swc.drm->fd); } -struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) +struct wl_list * swc_drm_create_outputs() { drmModeRes * resources; drmModeConnector * connector; @@ -387,7 +405,7 @@ struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) outputs = malloc(sizeof(struct wl_list)); wl_list_init(outputs); - resources = drmModeGetResources(drm->fd); + resources = drmModeGetResources(swc.drm->fd); if (!resources) { printf("couldn't get DRM resources\n"); @@ -400,7 +418,7 @@ struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) for (index = 0; index < resources->count_crtcs; ++index) { printf("crtc[%u]: %u\n", index, resources->crtcs[index]); - crtc = drmModeGetCrtc(drm->fd, resources->crtcs[index]); + crtc = drmModeGetCrtc(swc.drm->fd, resources->crtcs[index]); printf("crtc, id: %u, x: %u, y: %u, width: %u, height: %u\n", crtc->crtc_id, crtc->x, crtc->y, crtc->width, crtc->height); drmModeFreeCrtc(crtc); @@ -409,14 +427,16 @@ struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) for (index = 0; index < resources->count_encoders; ++index) { printf("encoder[%u]: %u\n", index, resources->encoders[index]); - drmModeEncoder * encoder = drmModeGetEncoder(drm->fd, resources->encoders[index]); + drmModeEncoder * encoder = drmModeGetEncoder + (swc.drm->fd, resources->encoders[index]); printf("encoder, id: %u, type: %u\n", encoder->encoder_id, encoder->encoder_type); drmModeFreeEncoder(encoder); } for (index = 0; index < resources->count_connectors; ++index) { - connector = drmModeGetConnector(drm->fd, resources->connectors[index]); + connector = drmModeGetConnector(swc.drm->fd, + resources->connectors[index]); printf("connector, id: %u, type: %u, type_id: %u, connection: %u\n", connector->connector_id, connector->connector_type, @@ -428,14 +448,14 @@ struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) uint32_t crtc_index; uint32_t id; - if (!find_available_crtc(drm, resources, connector, taken_crtcs, + if (!find_available_crtc(resources, connector, taken_crtcs, &crtc_index)) { printf("couldn't find crtc for connector %u\n", index); continue; } - if (!find_available_id(drm, &id)) + if (!find_available_id(&id)) { printf("no more available output IDs\n"); break; @@ -446,7 +466,7 @@ struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) output->geometry.x = x; output->geometry.y = 0; - if (!swc_output_initialize(output, drm, id, + if (!swc_output_initialize(output, id, resources->crtcs[crtc_index], connector)) { drmModeFreeConnector(connector); @@ -455,7 +475,7 @@ struct wl_list * swc_drm_create_outputs(struct swc_drm * drm) } taken_crtcs |= 1 << crtc_index; - drm->taken_output_ids |= 1 << id; + drm.taken_output_ids |= 1 << id; wl_list_insert(outputs, &output->link); x += output->geometry.width; diff --git a/libswc/drm.h b/libswc/drm.h @@ -5,8 +5,6 @@ #include <stdint.h> #include <wayland-server.h> -struct wld_drm_context * context; - enum swc_drm_event_type { SWC_DRM_PAGE_FLIP @@ -21,27 +19,14 @@ struct swc_drm_event_data struct swc_drm { int fd; - uint32_t id; - char * path; - struct wld_drm_context * context; - - uint32_t taken_output_ids; - - struct wl_event_source * source; - struct wl_signal event_signal; }; -bool swc_drm_initialize(struct swc_drm * drm, const char * seat); -void swc_drm_finish(struct swc_drm * drm); - -void swc_drm_add_event_sources(struct swc_drm * drm, - struct wl_event_loop * event_loop); - -void swc_drm_add_globals(struct swc_drm * drm, struct wl_display * display); +bool swc_drm_initialize(const char * seat); +void swc_drm_finalize(); -struct wl_list * swc_drm_create_outputs(struct swc_drm * drm); +struct wl_list * swc_drm_create_outputs(); #endif diff --git a/libswc/internal.h b/libswc/internal.h @@ -35,6 +35,7 @@ struct swc const struct swc_seat_global * const seat; const struct swc_bindings_global * const bindings; struct swc_compositor * compositor; + struct swc_drm * const drm; }; extern struct swc swc; diff --git a/libswc/output.c b/libswc/output.c @@ -1,5 +1,6 @@ #include "output.h" #include "drm.h" +#include "internal.h" #include "mode.h" #include "util.h" @@ -45,7 +46,7 @@ static void bind_output(struct wl_client * client, void * data, wl_output_send_done(resource); } -bool swc_output_initialize(struct swc_output * output, struct swc_drm * drm, +bool swc_output_initialize(struct swc_output * output, uint32_t id, uint32_t crtc_id, drmModeConnector * connector) { @@ -54,8 +55,6 @@ bool swc_output_initialize(struct swc_output * output, struct swc_drm * drm, struct swc_mode * modes; uint32_t index; - output->drm = drm; - printf("initializing output with id: %u\n", id); output->id = id; @@ -71,8 +70,8 @@ bool swc_output_initialize(struct swc_output * output, struct swc_drm * drm, output->connector_id = connector->connector_id; /* Determine the current CRTC of this output. */ - encoder = drmModeGetEncoder(drm->fd, connector->encoder_id); - current_crtc = drmModeGetCrtc(drm->fd, encoder->crtc_id); + encoder = drmModeGetEncoder(swc.drm->fd, connector->encoder_id); + current_crtc = drmModeGetCrtc(swc.drm->fd, encoder->crtc_id); drmModeFreeEncoder(encoder); modes = wl_array_add(&output->modes, connector->count_modes * sizeof *modes); @@ -125,7 +124,7 @@ void swc_output_finish(struct swc_output * output) swc_mode_finish(mode); wl_array_release(&output->modes); - drmModeSetCrtc(output->drm->fd, crtc->crtc_id, crtc->buffer_id, crtc->x, + drmModeSetCrtc(swc.drm->fd, crtc->crtc_id, crtc->buffer_id, crtc->x, crtc->y, &output->connector_id, 1, &crtc->mode); drmModeFreeCrtc(crtc); } diff --git a/libswc/output.h b/libswc/output.h @@ -16,8 +16,6 @@ struct swc_output { uint32_t id; - struct swc_drm * drm; - /* The geometry of this output */ pixman_rectangle32_t geometry; uint32_t physical_width, physical_height; @@ -44,8 +42,7 @@ struct swc_output struct wl_list link; }; -bool swc_output_initialize(struct swc_output * output, struct swc_drm * drm, - uint32_t id, uint32_t crtc_id, +bool swc_output_initialize(struct swc_output * output, uint32_t id, uint32_t crtc_id, drmModeConnector * connector); void swc_output_finish(struct swc_output * output); diff --git a/libswc/plane.c b/libswc/plane.c @@ -23,6 +23,7 @@ #include "plane.h" #include "drm.h" +#include "internal.h" #include "mode.h" #include "output.h" @@ -43,7 +44,7 @@ static bool framebuffer_initialize(struct swc_plane * plane) struct framebuffer * buffer = swc_double_buffer_front(&plane->double_buffer); - return drmModeSetCrtc(plane->output->drm->fd, plane->output->crtc_id, + return drmModeSetCrtc(swc.drm->fd, plane->output->crtc_id, buffer->fb_id, 0, 0, &plane->output->connector_id, 1, &plane->output->current_mode->info) == 0; } @@ -58,7 +59,7 @@ static void * framebuffer_create_buffer(struct swc_plane * plane) if (!(buffer = malloc(sizeof *buffer))) goto error0; - drawable = wld_drm_create_drawable(output->drm->context, + drawable = wld_drm_create_drawable(swc.drm->context, output->geometry.width, output->geometry.height, WLD_FORMAT_XRGB8888); @@ -71,7 +72,7 @@ static void * framebuffer_create_buffer(struct swc_plane * plane) handle = wld_drm_get_handle(drawable); - if (drmModeAddFB(plane->output->drm->fd, drawable->width, drawable->height, + if (drmModeAddFB(swc.drm->fd, drawable->width, drawable->height, 24, 32, drawable->pitch, handle, &buffer->fb_id) != 0) { fprintf(stderr, "drmModeAddFB failed\n"); @@ -94,7 +95,7 @@ static void framebuffer_destroy_buffer(struct swc_plane * plane, void * data) { struct framebuffer * buffer = data; - drmModeRmFB(plane->output->drm->fd, buffer->fb_id); + drmModeRmFB(swc.drm->fd, buffer->fb_id); wld_destroy_drawable(buffer->drawable); } @@ -110,7 +111,7 @@ static bool framebuffer_flip(struct swc_plane * plane) struct swc_output * output = plane->output; struct framebuffer * buffer = swc_double_buffer_back(&plane->double_buffer); - return drmModePageFlip(output->drm->fd, output->crtc_id, buffer->fb_id, + return drmModePageFlip(swc.drm->fd, output->crtc_id, buffer->fb_id, DRM_MODE_PAGE_FLIP_EVENT, output) == 0; } @@ -129,7 +130,7 @@ static bool cursor_initialize(struct swc_plane * plane) static void * cursor_create_buffer(struct swc_plane * plane) { - return wld_drm_create_drawable(plane->output->drm->context, 64, 64, + return wld_drm_create_drawable(swc.drm->context, 64, 64, WLD_FORMAT_ARGB8888); } @@ -151,14 +152,13 @@ static bool cursor_flip(struct swc_plane * plane) = swc_double_buffer_back(&plane->double_buffer); int handle = wld_drm_get_handle(drawable); - return drmModeSetCursor(plane->output->drm->fd, plane->output->crtc_id, + return drmModeSetCursor(swc.drm->fd, plane->output->crtc_id, handle, 64, 64) == 0; } static bool cursor_move(struct swc_plane * plane, int32_t x, int32_t y) { - return drmModeMoveCursor(plane->output->drm->fd, plane->output->crtc_id, - x, y) == 0; + return drmModeMoveCursor(swc.drm->fd, plane->output->crtc_id, x, y) == 0; } const struct swc_plane_interface swc_cursor_plane = { diff --git a/libswc/renderer.c b/libswc/renderer.c @@ -1,6 +1,8 @@ #include "renderer.h" #include "compositor_surface.h" +#include "drm.h" #include "drm_buffer.h" +#include "internal.h" #include <assert.h> #include <stdio.h> @@ -127,18 +129,6 @@ static void repaint_surface(struct swc_renderer * renderer, pixman_region32_fini(&border_damage); } -bool swc_renderer_initialize(struct swc_renderer * renderer, - struct swc_drm * drm) -{ - renderer->drm = drm; - - return true; -} - -void swc_renderer_finalize(struct swc_renderer * renderer) -{ -} - void swc_renderer_set_target(struct swc_renderer * renderer, struct swc_plane * plane) { @@ -206,7 +196,7 @@ void swc_renderer_attach(struct swc_renderer * renderer, pitch = wl_shm_buffer_get_stride(shm_buffer); void * data = wl_shm_buffer_get_data(shm_buffer); - state->drawable = wld_drm_create_drawable(renderer->drm->context, + state->drawable = wld_drm_create_drawable(swc.drm->context, width, height, wld_format(format)); state->src = pixman_image_create_bits_no_clear(pixman_format(format), diff --git a/libswc/renderer.h b/libswc/renderer.h @@ -1,7 +1,6 @@ #ifndef SWC_RENDERER_H #define SWC_RENDERER_H -#include "drm.h" #include "output.h" #include "surface.h" @@ -13,15 +12,9 @@ struct swc_render_target struct swc_renderer { - struct swc_drm * drm; struct swc_render_target target; }; -bool swc_renderer_initialize(struct swc_renderer * renderer, - struct swc_drm * drm); - -void swc_renderer_finalize(struct swc_renderer * renderer); - void swc_renderer_set_target(struct swc_renderer * renderer, struct swc_plane * plane); diff --git a/libswc/swc.c b/libswc/swc.c @@ -25,6 +25,7 @@ #include "bindings.h" #include "compositor.h" #include "data_device_manager.h" +#include "drm.h" #include "internal.h" #include "keyboard.h" #include "pointer.h" @@ -39,12 +40,14 @@ extern const struct swc_seat_global seat_global; extern const struct swc_bindings_global bindings_global; +extern struct swc_drm drm_global; static struct swc_compositor compositor; struct swc swc = { .seat = &seat_global, .bindings = &bindings_global, - .compositor = &compositor + .compositor = &compositor, + .drm = &drm_global, }; static void setup_compositor() @@ -83,6 +86,7 @@ bool swc_initialize(struct wl_display * display, swc.display = display; swc.event_loop = event_loop ?: wl_display_get_event_loop(display); swc.manager = manager; + const char * default_seat = "seat0"; if (!(swc.udev = udev_new())) { @@ -90,10 +94,16 @@ bool swc_initialize(struct wl_display * display, goto error0; } + if (!swc_drm_initialize(default_seat)) + { + ERROR("Could not initialize DRM\n"); + goto error1; + } + if (!swc_compositor_initialize(&compositor, display, swc.event_loop)) { ERROR("Could not initialize compositor\n"); - goto error1; + goto error2; } swc_compositor_add_globals(&compositor, display); @@ -101,32 +111,32 @@ bool swc_initialize(struct wl_display * display, if (!swc_data_device_manager_initialize()) { ERROR("Could not initialize data device manager\n"); - goto error2; + goto error3; } if (!swc_seat_initialize()) { ERROR("Could not initialize seat\n"); - goto error3; + goto error4; } if (!swc_bindings_initialize()) { ERROR("Could not initialize bindings\n"); - goto error4; + goto error5; } if (!swc_shell_initialize()) { ERROR("Could not initialize shell\n"); - goto error5; + goto error6; } #ifdef ENABLE_XWAYLAND if (!swc_xserver_initialize()) { ERROR("Could not initialize xwayland\n"); - goto error6; + goto error7; } #endif @@ -134,16 +144,18 @@ bool swc_initialize(struct wl_display * display, return true; - error6: + error7: swc_shell_finalize(); - error5: + error6: swc_bindings_finalize(); - error4: + error5: swc_seat_finalize(); - error3: + error4: swc_data_device_manager_finalize(); - error2: + error3: swc_compositor_finish(&compositor); + error2: + swc_drm_finalize(); error1: udev_unref(swc.udev); error0: @@ -161,6 +173,7 @@ void swc_finalize() swc_seat_finalize(); swc_data_device_manager_finalize(); swc_compositor_finish(&compositor); + swc_drm_finalize(); udev_unref(swc.udev); }