aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/event.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/drm/event.c')
-rw-r--r--backend/drm/event.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/backend/drm/event.c b/backend/drm/event.c
index 34679514..db17b5b7 100644
--- a/backend/drm/event.c
+++ b/backend/drm/event.c
@@ -1,47 +1,48 @@
-#include "backend/drm/otd.h"
-#include "backend/drm/event.h"
-#include "backend/drm/drm.h"
-#include "backend/drm/udev.h"
-
#include <stdbool.h>
#include <stdlib.h>
#include <poll.h>
-static inline void event_swap(struct otd_event *a, struct otd_event *b)
+#include "backend/drm/backend.h"
+#include "backend/drm/event.h"
+#include "backend/drm/drm.h"
+#include "backend/drm/udev.h"
+
+static inline void event_swap(struct wlr_drm_event *a, struct wlr_drm_event *b)
{
- struct otd_event tmp = *a;
+ struct wlr_drm_event tmp = *a;
*a = *b;
*b = tmp;
}
-bool otd_get_event(struct otd *otd, struct otd_event *restrict ret)
+bool wlr_drm_get_event(struct wlr_drm_backend *backend,
+ struct wlr_drm_event *restrict ret)
{
struct pollfd fds[] = {
- { .fd = otd->fd, .events = POLLIN },
- { .fd = otd->udev_fd, .events = POLLIN },
+ { .fd = backend->fd, .events = POLLIN },
+ { .fd = backend->udev.mon_fd, .events = POLLIN },
};
while (poll(fds, 2, 0) > 0) {
if (fds[0].revents)
- get_drm_event(otd);
+ wlr_drm_event(backend->fd);
if (fds[1].revents)
- otd_udev_event(otd);
+ wlr_udev_event(backend);
}
- if (otd->event_len == 0) {
- ret->type = OTD_EV_NONE;
+ if (backend->event_len == 0) {
+ ret->type = DRM_EV_NONE;
ret->display = NULL;
return false;
}
- struct otd_event *ev = otd->events;
+ struct wlr_drm_event *ev = backend->events;
// Downheap
*ret = ev[0];
- ev[0] = ev[--otd->event_len];
+ ev[0] = ev[--backend->event_len];
size_t i = 0;
- while (i < otd->event_len / 2) {
+ while (i < backend->event_len / 2) {
size_t left = i * 2 + 1;
size_t right = i * 2 + 2;
size_t max = (ev[left].type > ev[right].type) ? left : right;
@@ -57,27 +58,28 @@ bool otd_get_event(struct otd *otd, struct otd_event *restrict ret)
return true;
}
-bool event_add(struct otd *otd, struct otd_display *disp, enum otd_event_type type)
+bool wlr_drm_add_event(struct wlr_drm_backend *backend,
+ struct wlr_drm_display *disp, enum wlr_drm_event_type type)
{
- if (type == OTD_EV_NONE)
+ if (type == DRM_EV_NONE)
return true;
- if (otd->event_len == otd->event_cap) {
- size_t new_size = (otd->event_cap == 0) ? 8 : otd->event_cap * 2;
+ if (backend->event_len == backend->event_cap) {
+ size_t new_size = (backend->event_cap == 0) ? 8 : backend->event_cap * 2;
- struct otd_event *new = realloc(otd->events, sizeof *new * new_size);
+ struct wlr_drm_event *new = realloc(backend->events, sizeof *new * new_size);
if (!new) {
return false;
}
- otd->event_cap = new_size;
- otd->events = new;
+ backend->event_cap = new_size;
+ backend->events = new;
}
- struct otd_event *ev = otd->events;
+ struct wlr_drm_event *ev = backend->events;
// Upheap
- size_t i = otd->event_len++;
+ size_t i = backend->event_len++;
ev[i].type = type;
ev[i].display = disp;