aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-05-07 10:00:23 -0400
committerDrew DeVault <sir@cmpwn.com>2017-05-07 10:12:54 -0400
commit15b1ce9e6ced22a90ab0df7a6b86c6d35c40ca93 (patch)
tree5fde5b7177005e3270509d3a119323d1f5897907 /include
parent7e9feb70a0b50caf7e9072d3b5c77b4e91235efa (diff)
Refactor backend state management
Diffstat (limited to 'include')
-rw-r--r--include/backend.h17
-rw-r--r--include/backend/drm/backend.h10
-rw-r--r--include/backend/drm/drm.h3
-rw-r--r--include/wlr/backend.h27
-rw-r--r--include/wlr/backend/drm.h7
5 files changed, 50 insertions, 14 deletions
diff --git a/include/backend.h b/include/backend.h
new file mode 100644
index 00000000..d42c6f17
--- /dev/null
+++ b/include/backend.h
@@ -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
diff --git a/include/backend/drm/backend.h b/include/backend/drm/backend.h
index bdda7ea7..0c725ccb 100644
--- a/include/backend/drm/backend.h
+++ b/include/backend/drm/backend.h
@@ -12,21 +12,17 @@
#include <wlr/common/list.h>
#include <wlr/backend/drm.h>
+#include "backend.h"
#include "udev.h"
#include "event.h"
#include "drm.h"
-struct wlr_drm_backend {
+struct wlr_backend_state {
int fd;
+ struct wlr_backend *backend;
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;
list_t *outputs;
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 51b0cdc6..3e83058a 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -8,6 +8,7 @@
#include <gbm.h>
#include "backend/egl.h"
+#include "backend.h"
struct wlr_drm_renderer {
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_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);
#endif
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index 527efa05..88a5c8e9 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -1,7 +1,30 @@
#ifndef _WLR_BACKEND_H
#define _WLR_BACKEND_H
-struct wlr_backend *wlr_backend_init();
-void wlr_backend_free(struct wlr_backend *backend);
+#include <wayland-server.h>
+
+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
diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h
index 4131b4cb..5db9b35c 100644
--- a/include/wlr/backend/drm.h
+++ b/include/wlr/backend/drm.h
@@ -3,6 +3,7 @@
#include <wayland-server.h>
#include <wlr/session.h>
+#include <wlr/backend.h>
#include <xf86drmMode.h> // drmModeModeInfo
struct wlr_drm_backend;
@@ -15,10 +16,8 @@ struct wlr_drm_mode {
drmModeModeInfo mode;
};
-struct wlr_drm_backend *wlr_drm_backend_init(struct wl_display *display,
- struct wlr_session *session, struct wl_listener *add, struct wl_listener *rem,
- struct wl_listener *render);
-void wlr_drm_backend_free(struct wlr_drm_backend *backend);
+struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
+ struct wlr_session *session);
const char *wlr_drm_output_get_name(struct wlr_drm_output *out);