Refactor backend state management

This commit is contained in:
Drew DeVault 2017-05-07 10:00:23 -04:00
parent 7e9feb70a0
commit 15b1ce9e6c
11 changed files with 196 additions and 126 deletions

View File

@ -12,6 +12,7 @@ add_library(wlr-backend
drm/backend.c drm/backend.c
drm/drm.c drm/drm.c
drm/udev.c drm/udev.c
backend.c
egl.c egl.c
) )

37
backend/backend.c Normal file
View File

@ -0,0 +1,37 @@
#include <wayland-server.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "common/log.h"
#include "backend.h"
struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl,
struct wlr_backend_state *state) {
struct wlr_backend *backend = calloc(1, sizeof(struct wlr_backend));
if (!backend) {
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
return NULL;
}
backend->state = state;
backend->impl = impl;
wl_signal_init(&backend->events.output_add);
wl_signal_init(&backend->events.output_remove);
wl_signal_init(&backend->events.output_frame);
wl_signal_init(&backend->events.keyboard_add);
wl_signal_init(&backend->events.keyboard_remove);
wl_signal_init(&backend->events.pointer_add);
wl_signal_init(&backend->events.pointer_remove);
wl_signal_init(&backend->events.touch_add);
wl_signal_init(&backend->events.touch_remove);
return backend;
}
bool wlr_backend_init(struct wlr_backend *backend) {
return backend->impl->init(backend->state);
}
void wlr_backend_destroy(struct wlr_backend *backend) {
backend->impl->destroy(backend->state);
// TODO: Free anything else?
free(backend);
}

View File

@ -8,106 +8,101 @@
#include <wlr/session.h> #include <wlr/session.h>
#include <wlr/common/list.h> #include <wlr/common/list.h>
#include "backend.h"
#include "backend/drm/backend.h" #include "backend/drm/backend.h"
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "backend/drm/udev.h" #include "backend/drm/udev.h"
#include "common/log.h" #include "common/log.h"
struct wlr_drm_backend *wlr_drm_backend_init(struct wl_display *display, static bool wlr_drm_backend_init(struct wlr_backend_state *state) {
struct wlr_session *session, struct wl_listener *add, struct wl_listener *rem, wlr_drm_scan_connectors(state);
struct wl_listener *render) { return true;
}
struct wlr_drm_backend *backend = calloc(1, sizeof *backend); static void free_output(void *item) {
struct wlr_drm_output *out = item;
wlr_drm_output_cleanup(out, true);
free(out);
}
static void wlr_drm_backend_destroy(struct wlr_backend_state *state) {
if (!state) {
return;
}
list_foreach(state->outputs, free_output);
list_free(state->outputs);
wlr_drm_renderer_free(&state->renderer);
wlr_udev_free(&state->udev);
wlr_session_close_file(state->session, state->fd);
wlr_session_finish(state->session);
wl_event_source_remove(state->drm_event);
free(state);
}
static struct wlr_backend_impl backend_impl = {
.init = wlr_drm_backend_init,
.destroy = wlr_drm_backend_destroy
};
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session) {
struct wlr_backend_state *state = calloc(1, sizeof(struct wlr_backend_state));
if (!state) {
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
return NULL;
}
struct wlr_backend *backend = wlr_backend_create(&backend_impl, state);
if (!backend) { if (!backend) {
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
return NULL; return NULL;
} }
backend->session = session; state->backend = backend;
state->session = session;
backend->outputs = list_create(); state->outputs = list_create();
if (!backend->outputs) { if (!state->outputs) {
wlr_log(L_ERROR, "Failed to allocate list"); wlr_log(L_ERROR, "Failed to allocate list");
goto error_backend; goto error_backend;
} }
if (!wlr_udev_init(display, &backend->udev)) { if (!wlr_udev_init(display, &state->udev)) {
wlr_log(L_ERROR, "Failed to start udev"); wlr_log(L_ERROR, "Failed to start udev");
goto error_list; goto error_list;
} }
backend->fd = wlr_udev_find_gpu(&backend->udev, backend->session); state->fd = wlr_udev_find_gpu(&state->udev, state->session);
if (backend->fd == -1) { if (state->fd == -1) {
wlr_log(L_ERROR, "Failed to open DRM device"); wlr_log(L_ERROR, "Failed to open DRM device");
goto error_udev; goto error_udev;
} }
struct wl_event_loop *event_loop = wl_display_get_event_loop(display); struct wl_event_loop *event_loop = wl_display_get_event_loop(display);
backend->drm_event = wl_event_loop_add_fd(event_loop, backend->fd, state->drm_event = wl_event_loop_add_fd(event_loop, state->fd,
WL_EVENT_READABLE, wlr_drm_event, NULL); WL_EVENT_READABLE, wlr_drm_event, NULL);
if (!backend->drm_event) { if (!state->drm_event) {
wlr_log(L_ERROR, "Failed to create DRM event source"); wlr_log(L_ERROR, "Failed to create DRM event source");
goto error_fd; goto error_fd;
} }
if (!wlr_drm_renderer_init(&backend->renderer, backend->fd)) { if (!wlr_drm_renderer_init(&state->renderer, state->fd)) {
wlr_log(L_ERROR, "Failed to initialize renderer"); wlr_log(L_ERROR, "Failed to initialize renderer");
goto error_event; goto error_event;
} }
wl_signal_init(&backend->signals.output_add);
wl_signal_init(&backend->signals.output_rem);
wl_signal_init(&backend->signals.output_render);
if (add) {
wl_signal_add(&backend->signals.output_add, add);
}
if (rem) {
wl_signal_add(&backend->signals.output_rem, rem);
}
if (render) {
wl_signal_add(&backend->signals.output_render, render);
}
wlr_drm_scan_connectors(backend);
return backend; return backend;
error_event: error_event:
wl_event_source_remove(backend->drm_event); wl_event_source_remove(state->drm_event);
error_fd: error_fd:
wlr_session_close_file(backend->session, backend->fd); wlr_session_close_file(state->session, state->fd);
error_udev: error_udev:
wlr_udev_free(&backend->udev); wlr_udev_free(&state->udev);
error_list: error_list:
list_free(backend->outputs); list_free(state->outputs);
error_backend: error_backend:
free(state);
free(backend); free(backend);
return NULL; return NULL;
} }
static void free_output(void *item)
{
struct wlr_drm_output *out = item;
wlr_drm_output_cleanup(out, true);
free(out);
}
void wlr_drm_backend_free(struct wlr_drm_backend *backend)
{
if (!backend)
return;
list_foreach(backend->outputs, free_output);
wlr_drm_renderer_free(&backend->renderer);
wlr_udev_free(&backend->udev);
wlr_session_close_file(backend->session, backend->fd);
wlr_session_finish(backend->session);
wl_event_source_remove(backend->drm_event);
list_free(backend->outputs);
free(backend);
}

View File

@ -13,6 +13,7 @@
#include <GLES3/gl3.h> #include <GLES3/gl3.h>
#include <wayland-server.h> #include <wayland-server.h>
#include "backend.h"
#include "backend/drm/backend.h" #include "backend/drm/backend.h"
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "common/log.h" #include "common/log.h"
@ -167,10 +168,10 @@ static int find_id(const void *item, const void *cmp_to) {
} }
} }
void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) { void wlr_drm_scan_connectors(struct wlr_backend_state *state) {
wlr_log(L_INFO, "Scanning DRM connectors"); wlr_log(L_INFO, "Scanning DRM connectors");
drmModeRes *res = drmModeGetResources(backend->fd); drmModeRes *res = drmModeGetResources(state->fd);
if (!res) { if (!res) {
wlr_log(L_ERROR, "Failed to get DRM resources"); wlr_log(L_ERROR, "Failed to get DRM resources");
return; return;
@ -179,40 +180,40 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
for (int i = 0; i < res->count_connectors; ++i) { for (int i = 0; i < res->count_connectors; ++i) {
uint32_t id = res->connectors[i]; uint32_t id = res->connectors[i];
drmModeConnector *conn = drmModeGetConnector(backend->fd, id); drmModeConnector *conn = drmModeGetConnector(state->fd, id);
if (!conn) { if (!conn) {
wlr_log(L_ERROR, "Failed to get DRM connector"); wlr_log(L_ERROR, "Failed to get DRM connector");
continue; continue;
} }
struct wlr_drm_output *out; struct wlr_drm_output *out;
int index = list_seq_find(backend->outputs, find_id, &id); int index = list_seq_find(state->outputs, find_id, &id);
if (index == -1) { if (index == -1) {
out = calloc(1, sizeof *out); out = calloc(1, sizeof(struct wlr_drm_output));
if (!out) { if (!out) {
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
drmModeFreeConnector(conn); drmModeFreeConnector(conn);
continue; continue;
} }
out->renderer = &backend->renderer; out->renderer = &state->renderer;
out->state = DRM_OUTPUT_DISCONNECTED; out->state = DRM_OUTPUT_DISCONNECTED;
out->connector = id; out->connector = id;
snprintf(out->name, sizeof out->name, "%s-%"PRIu32, snprintf(out->name, sizeof out->name, "%s-%"PRIu32,
conn_name[conn->connector_type], conn_name[conn->connector_type],
conn->connector_type_id); conn->connector_type_id);
drmModeEncoder *curr_enc = drmModeGetEncoder(backend->fd, conn->encoder_id); drmModeEncoder *curr_enc = drmModeGetEncoder(state->fd, conn->encoder_id);
if (curr_enc) { if (curr_enc) {
out->old_crtc = drmModeGetCrtc(backend->fd, curr_enc->crtc_id); out->old_crtc = drmModeGetCrtc(state->fd, curr_enc->crtc_id);
free(curr_enc); free(curr_enc);
} }
list_add(backend->outputs, out); list_add(state->outputs, out);
wlr_log(L_INFO, "Found display '%s'", out->name); wlr_log(L_INFO, "Found display '%s'", out->name);
} else { } else {
out = backend->outputs->items[index]; out = state->outputs->items[index];
} }
if (out->state == DRM_OUTPUT_DISCONNECTED && if (out->state == DRM_OUTPUT_DISCONNECTED &&
@ -244,8 +245,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
out->state = DRM_OUTPUT_NEEDS_MODESET; out->state = DRM_OUTPUT_NEEDS_MODESET;
wlr_log(L_INFO, "Sending modesetting signal for '%s'", out->name); wlr_log(L_INFO, "Sending modesetting signal for '%s'", out->name);
wl_signal_emit(&backend->signals.output_add, out); wl_signal_emit(&state->backend->events.output_add, out);
} else if (out->state == DRM_OUTPUT_CONNECTED && } else if (out->state == DRM_OUTPUT_CONNECTED &&
conn->connection != DRM_MODE_CONNECTED) { conn->connection != DRM_MODE_CONNECTED) {
@ -270,12 +270,12 @@ struct wlr_drm_mode *wlr_drm_output_get_modes(struct wlr_drm_output *out, size_t
} }
bool wlr_drm_output_modeset(struct wlr_drm_output *out, struct wlr_drm_mode *mode) { bool wlr_drm_output_modeset(struct wlr_drm_output *out, struct wlr_drm_mode *mode) {
struct wlr_drm_backend *backend = wl_container_of(out->renderer, backend, renderer); struct wlr_backend_state *state = wl_container_of(out->renderer, state, renderer);
wlr_log(L_INFO, "Modesetting '%s' with '%ux%u@%u'", out->name, mode->width, wlr_log(L_INFO, "Modesetting '%s' with '%ux%u@%u'", out->name, mode->width,
mode->height, mode->rate); mode->height, mode->rate);
drmModeConnector *conn = drmModeGetConnector(backend->fd, out->connector); drmModeConnector *conn = drmModeGetConnector(state->fd, out->connector);
if (!conn) { if (!conn) {
wlr_log(L_ERROR, "Failed to get DRM connector"); wlr_log(L_ERROR, "Failed to get DRM connector");
goto error; goto error;
@ -286,7 +286,7 @@ bool wlr_drm_output_modeset(struct wlr_drm_output *out, struct wlr_drm_mode *mod
goto error; goto error;
} }
drmModeRes *res = drmModeGetResources(backend->fd); drmModeRes *res = drmModeGetResources(state->fd);
if (!res) { if (!res) {
wlr_log(L_ERROR, "Failed to get DRM resources"); wlr_log(L_ERROR, "Failed to get DRM resources");
goto error; goto error;
@ -294,7 +294,7 @@ bool wlr_drm_output_modeset(struct wlr_drm_output *out, struct wlr_drm_mode *mod
bool success = false; bool success = false;
for (int i = 0; !success && i < conn->count_encoders; ++i) { for (int i = 0; !success && i < conn->count_encoders; ++i) {
drmModeEncoder *enc = drmModeGetEncoder(backend->fd, conn->encoders[i]); drmModeEncoder *enc = drmModeGetEncoder(state->fd, conn->encoders[i]);
if (!enc) if (!enc)
continue; continue;
@ -303,8 +303,8 @@ bool wlr_drm_output_modeset(struct wlr_drm_output *out, struct wlr_drm_mode *mod
continue; continue;
} }
if ((backend->taken_crtcs & (1 << j)) == 0) { if ((state->taken_crtcs & (1 << j)) == 0) {
backend->taken_crtcs |= 1 << j; state->taken_crtcs |= 1 << j;
out->crtc = res->crtcs[j]; out->crtc = res->crtcs[j];
success = true; success = true;
@ -327,7 +327,7 @@ bool wlr_drm_output_modeset(struct wlr_drm_output *out, struct wlr_drm_mode *mod
out->width = mode->width; out->width = mode->width;
out->height = mode->height; out->height = mode->height;
if (!display_init_renderer(&backend->renderer, out)) { if (!display_init_renderer(&state->renderer, out)) {
wlr_log(L_ERROR, "Failed to initalise renderer for %s", out->name); wlr_log(L_ERROR, "Failed to initalise renderer for %s", out->name);
goto error; goto error;
} }
@ -343,15 +343,14 @@ error:
return false; return false;
} }
static void page_flip_handler(int fd, unsigned seq, unsigned tv_sec, unsigned tv_usec, static void page_flip_handler(int fd, unsigned seq,
void *user) { unsigned tv_sec, unsigned tv_usec, void *user) {
struct wlr_drm_output *out = user; struct wlr_drm_output *out = user;
struct wlr_drm_backend *backend = wl_container_of(out->renderer, backend, renderer); struct wlr_backend_state *state = wl_container_of(out->renderer, state, renderer);
out->pageflip_pending = false; out->pageflip_pending = false;
if (out->state == DRM_OUTPUT_CONNECTED) { if (out->state == DRM_OUTPUT_CONNECTED) {
wl_signal_emit(&backend->signals.output_render, out); wl_signal_emit(&state->backend->events.output_frame, out);
} }
} }
@ -388,7 +387,7 @@ void wlr_drm_output_cleanup(struct wlr_drm_output *out, bool restore) {
} }
struct wlr_drm_renderer *renderer = out->renderer; struct wlr_drm_renderer *renderer = out->renderer;
struct wlr_drm_backend *backend = wl_container_of(renderer, backend, renderer); struct wlr_backend_state *state = wl_container_of(renderer, state, renderer);
switch (out->state) { switch (out->state) {
case DRM_OUTPUT_CONNECTED: case DRM_OUTPUT_CONNECTED:
@ -414,7 +413,7 @@ void wlr_drm_output_cleanup(struct wlr_drm_output *out, bool restore) {
} }
wlr_log(L_INFO, "Emmiting destruction signal for '%s'", out->name); wlr_log(L_INFO, "Emmiting destruction signal for '%s'", out->name);
wl_signal_emit(&backend->signals.output_rem, out); wl_signal_emit(&state->backend->events.output_remove, out);
break; break;
case DRM_OUTPUT_DISCONNECTED: case DRM_OUTPUT_DISCONNECTED:

View File

@ -11,6 +11,7 @@
#include <wlr/session.h> #include <wlr/session.h>
#include "backend.h"
#include "backend/drm/backend.h" #include "backend/drm/backend.h"
#include "backend/drm/udev.h" #include "backend/drm/udev.h"
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
@ -139,7 +140,7 @@ int wlr_udev_find_gpu(struct wlr_udev *udev, struct wlr_session *session) {
static int udev_event(int fd, uint32_t mask, void *data) { static int udev_event(int fd, uint32_t mask, void *data) {
struct wlr_udev *udev = data; struct wlr_udev *udev = data;
struct wlr_drm_backend *backend = wl_container_of(udev, backend, udev); struct wlr_backend_state *state = wl_container_of(udev, state, udev);
struct udev_device *dev = udev_monitor_receive_device(udev->mon); struct udev_device *dev = udev_monitor_receive_device(udev->mon);
if (!dev) { if (!dev) {
@ -156,7 +157,7 @@ static int udev_event(int fd, uint32_t mask, void *data) {
goto out; goto out;
} }
wlr_drm_scan_connectors(backend); wlr_drm_scan_connectors(state);
out: out:
udev_device_unref(dev); udev_device_unref(dev);

View File

@ -14,13 +14,12 @@ struct state {
struct timespec last_frame; struct timespec last_frame;
struct wl_listener add; struct wl_listener output_add;
struct wl_listener rem; struct wl_listener output_remove;
struct wl_listener render; struct wl_listener output_frame;
}; };
void output_add(struct wl_listener *listener, void *data) void output_add(struct wl_listener *listener, void *data) {
{
struct wlr_drm_output *out = data; struct wlr_drm_output *out = data;
fprintf(stderr, "Output '%s' added\n", wlr_drm_output_get_name(out)); fprintf(stderr, "Output '%s' added\n", wlr_drm_output_get_name(out));
@ -30,16 +29,14 @@ void output_add(struct wl_listener *listener, void *data)
wlr_drm_output_modeset(out, &modes[0]); wlr_drm_output_modeset(out, &modes[0]);
} }
void output_rem(struct wl_listener *listener, void *data) void output_remove(struct wl_listener *listener, void *data) {
{
struct wlr_drm_output *out = data; struct wlr_drm_output *out = data;
fprintf(stderr, "Output '%s' removed\n", wlr_drm_output_get_name(out)); fprintf(stderr, "Output '%s' removed\n", wlr_drm_output_get_name(out));
} }
void output_render(struct wl_listener *listener, void *data) void output_frame(struct wl_listener *listener, void *data) {
{
struct wlr_drm_output *out = data; struct wlr_drm_output *out = data;
struct state *s = wl_container_of(listener, s, render); struct state *s = wl_container_of(listener, s, output_frame);
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
@ -68,14 +65,12 @@ void output_render(struct wl_listener *listener, void *data)
wlr_drm_output_end(out); wlr_drm_output_end(out);
} }
int timer_done(void *data) int timer_done(void *data) {
{
*(bool *)data = true; *(bool *)data = true;
return 1; return 1;
} }
int main() int main() {
{
if (getenv("DISPLAY")) { if (getenv("DISPLAY")) {
fprintf(stderr, "Detected that X is running. Run this in its own virtual terminal.\n"); fprintf(stderr, "Detected that X is running. Run this in its own virtual terminal.\n");
return 1; return 1;
@ -87,14 +82,14 @@ int main()
struct state state = { struct state state = {
.color = { 1.0, 0.0, 0.0 }, .color = { 1.0, 0.0, 0.0 },
.dec = 0, .dec = 0,
.add = { .notify = output_add }, .output_add = { .notify = output_add },
.rem = { .notify = output_rem }, .output_remove = { .notify = output_remove },
.render = { .notify = output_render }, .output_frame = { .notify = output_frame },
}; };
wl_list_init(&state.add.link); wl_list_init(&state.output_add.link);
wl_list_init(&state.rem.link); wl_list_init(&state.output_remove.link);
wl_list_init(&state.render.link); wl_list_init(&state.output_frame.link);
clock_gettime(CLOCK_MONOTONIC, &state.last_frame); clock_gettime(CLOCK_MONOTONIC, &state.last_frame);
struct wl_display *display = wl_display_create(); struct wl_display *display = wl_display_create();
@ -105,19 +100,25 @@ int main()
return 1; return 1;
} }
struct wlr_drm_backend *wlr = wlr_drm_backend_init(display, session, struct wlr_backend *wlr = wlr_drm_backend_create(display, session);
&state.add, &state.rem, &state.render); wl_signal_add(&wlr->events.output_add, &state.output_add);
wl_signal_add(&wlr->events.output_remove, &state.output_remove);
wl_signal_add(&wlr->events.output_frame, &state.output_frame);
if (!wlr || !wlr_backend_init(wlr)) {
return 1;
}
bool done = false; bool done = false;
struct wl_event_source *timer = wl_event_loop_add_timer(event_loop, struct wl_event_source *timer = wl_event_loop_add_timer(event_loop,
timer_done, &done); timer_done, &done);
wl_event_source_timer_update(timer, 10000); wl_event_source_timer_update(timer, 5000);
while (!done) while (!done) {
wl_event_loop_dispatch(event_loop, 0); wl_event_loop_dispatch(event_loop, 0);
}
wl_event_source_remove(timer); wl_event_source_remove(timer);
wlr_drm_backend_free(wlr); wlr_backend_destroy(wlr);
wl_display_destroy(display); wl_display_destroy(display);
} }

17
include/backend.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _WLR_BACKEND_INTERNAL_H
#define _WLR_BACKEND_INTERNAL_H
#include <stdbool.h>
#include <wlr/backend.h>
struct wlr_backend_state;
struct wlr_backend_impl {
bool (*init)(struct wlr_backend_state *state);
void (*destroy)(struct wlr_backend_state *state);
};
struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl,
struct wlr_backend_state *state);
#endif

View File

@ -12,21 +12,17 @@
#include <wlr/common/list.h> #include <wlr/common/list.h>
#include <wlr/backend/drm.h> #include <wlr/backend/drm.h>
#include "backend.h"
#include "udev.h" #include "udev.h"
#include "event.h" #include "event.h"
#include "drm.h" #include "drm.h"
struct wlr_drm_backend { struct wlr_backend_state {
int fd; int fd;
struct wlr_backend *backend;
struct wl_event_source *drm_event; struct wl_event_source *drm_event;
struct {
struct wl_signal output_add;
struct wl_signal output_rem;
struct wl_signal output_render;
} signals;
uint32_t taken_crtcs; uint32_t taken_crtcs;
list_t *outputs; list_t *outputs;

View File

@ -8,6 +8,7 @@
#include <gbm.h> #include <gbm.h>
#include "backend/egl.h" #include "backend/egl.h"
#include "backend.h"
struct wlr_drm_renderer { struct wlr_drm_renderer {
int fd; int fd;
@ -50,7 +51,7 @@ struct wlr_drm_output {
void wlr_drm_output_cleanup(struct wlr_drm_output *out, bool restore); void wlr_drm_output_cleanup(struct wlr_drm_output *out, bool restore);
void wlr_drm_scan_connectors(struct wlr_drm_backend *backend); void wlr_drm_scan_connectors(struct wlr_backend_state *state);
int wlr_drm_event(int fd, uint32_t mask, void *data); int wlr_drm_event(int fd, uint32_t mask, void *data);
#endif #endif

View File

@ -1,7 +1,30 @@
#ifndef _WLR_BACKEND_H #ifndef _WLR_BACKEND_H
#define _WLR_BACKEND_H #define _WLR_BACKEND_H
struct wlr_backend *wlr_backend_init(); #include <wayland-server.h>
void wlr_backend_free(struct wlr_backend *backend);
struct wlr_backend_impl;
struct wlr_backend_state;
struct wlr_backend {
const struct wlr_backend_impl *impl;
struct wlr_backend_state *state;
struct {
struct wl_signal output_add;
struct wl_signal output_remove;
struct wl_signal output_frame;
struct wl_signal keyboard_add;
struct wl_signal keyboard_remove;
struct wl_signal pointer_add;
struct wl_signal pointer_remove;
struct wl_signal touch_add;
struct wl_signal touch_remove;
} events;
};
struct wlr_backend *wlr_backend_autocreate();
bool wlr_backend_init(struct wlr_backend *backend);
void wlr_backend_destroy(struct wlr_backend *backend);
#endif #endif

View File

@ -3,6 +3,7 @@
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/session.h> #include <wlr/session.h>
#include <wlr/backend.h>
#include <xf86drmMode.h> // drmModeModeInfo #include <xf86drmMode.h> // drmModeModeInfo
struct wlr_drm_backend; struct wlr_drm_backend;
@ -15,10 +16,8 @@ struct wlr_drm_mode {
drmModeModeInfo mode; drmModeModeInfo mode;
}; };
struct wlr_drm_backend *wlr_drm_backend_init(struct wl_display *display, struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, struct wl_listener *add, struct wl_listener *rem, struct wlr_session *session);
struct wl_listener *render);
void wlr_drm_backend_free(struct wlr_drm_backend *backend);
const char *wlr_drm_output_get_name(struct wlr_drm_output *out); const char *wlr_drm_output_get_name(struct wlr_drm_output *out);