aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-08-13 10:51:50 -0400
committerDrew DeVault <sir@cmpwn.com>2017-08-13 11:38:03 -0400
commit41e735242dc8788618bb668ad70ea164e47099db (patch)
tree79b474aec3b822da9a8f64e3347603d4bb1920a5 /backend
parent43868168897f628fe75157be9ab38ea63310c920 (diff)
Remove wlr_output_state, update backends
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/backend.c7
-rw-r--r--backend/drm/drm-atomic.c8
-rw-r--r--backend/drm/drm-legacy.c4
-rw-r--r--backend/drm/drm.c106
-rw-r--r--backend/wayland/backend.c8
-rw-r--r--backend/wayland/output.c85
-rw-r--r--backend/wayland/wl_seat.c18
7 files changed, 112 insertions, 124 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index d0cdc234..a2c9dff3 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -28,8 +28,8 @@ static void wlr_drm_backend_destroy(struct wlr_backend *_backend) {
}
struct wlr_drm_backend *backend = (struct wlr_drm_backend *)_backend;
for (size_t i = 0; backend->outputs && i < backend->outputs->length; ++i) {
- struct wlr_output_state *output = backend->outputs->items[i];
- wlr_output_destroy(output->base);
+ struct wlr_drm_output *output = backend->outputs->items[i];
+ wlr_output_destroy(&output->output);
}
wlr_udev_signal_remove(backend->udev, &backend->drm_invalidated);
@@ -61,7 +61,7 @@ static void session_signal(struct wl_listener *listener, void *data) {
wlr_log(L_INFO, "DRM fd resumed");
for (size_t i = 0; i < backend->outputs->length; ++i) {
- struct wlr_output_state *output = backend->outputs->items[i];
+ struct wlr_drm_output *output = backend->outputs->items[i];
wlr_drm_output_start_renderer(output);
if (!output->crtc) {
@@ -69,7 +69,6 @@ static void session_signal(struct wl_listener *listener, void *data) {
}
struct wlr_drm_plane *plane = output->crtc->cursor;
-
backend->iface->crtc_set_cursor(backend, output->crtc,
plane ? plane->cursor_bo : NULL);
}
diff --git a/backend/drm/drm-atomic.c b/backend/drm/drm-atomic.c
index 7111799d..64028812 100644
--- a/backend/drm/drm-atomic.c
+++ b/backend/drm/drm-atomic.c
@@ -42,8 +42,8 @@ static bool atomic_end(int drm_fd, struct atomic *atom) {
return true;
}
-static bool atomic_commit(int drm_fd, struct atomic *atom, struct wlr_output_state *output,
- uint32_t flag) {
+static bool atomic_commit(int drm_fd, struct atomic *atom,
+ struct wlr_drm_output *output, uint32_t flag) {
if (atom->failed) {
return false;
}
@@ -88,7 +88,7 @@ static void set_plane_props(struct atomic *atom, struct wlr_drm_plane *plane,
}
static bool atomic_crtc_pageflip(struct wlr_drm_backend *backend,
- struct wlr_output_state *output,
+ struct wlr_drm_output *output,
struct wlr_drm_crtc *crtc,
uint32_t fb_id, drmModeModeInfo *mode) {
if (mode) {
@@ -114,7 +114,7 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *backend,
}
static void atomic_conn_enable(struct wlr_drm_backend *backend,
- struct wlr_output_state *output, bool enable) {
+ struct wlr_drm_output *output, bool enable) {
struct wlr_drm_crtc *crtc = output->crtc;
struct atomic atom;
diff --git a/backend/drm/drm-legacy.c b/backend/drm/drm-legacy.c
index 8caca193..5077fcab 100644
--- a/backend/drm/drm-legacy.c
+++ b/backend/drm/drm-legacy.c
@@ -6,7 +6,7 @@
#include "backend/drm-util.h"
static bool legacy_crtc_pageflip(struct wlr_drm_backend *backend,
- struct wlr_output_state *output, struct wlr_drm_crtc *crtc,
+ struct wlr_drm_output *output, struct wlr_drm_crtc *crtc,
uint32_t fb_id, drmModeModeInfo *mode) {
if (mode) {
drmModeSetCrtc(backend->fd, crtc->id, fb_id, 0, 0,
@@ -19,7 +19,7 @@ static bool legacy_crtc_pageflip(struct wlr_drm_backend *backend,
}
static void legacy_conn_enable(struct wlr_drm_backend *backend,
- struct wlr_output_state *output, bool enable) {
+ struct wlr_drm_output *output, bool enable) {
drmModeConnectorSetProperty(backend->fd, output->connector, output->props.dpms,
enable ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF);
}
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 8b6d97d3..13d5aa0b 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -282,11 +282,13 @@ static void wlr_drm_plane_swap_buffers(struct wlr_drm_renderer *renderer,
plane->back = gbm_surface_lock_front_buffer(plane->gbm);
}
-static void wlr_drm_output_make_current(struct wlr_output_state *output) {
+static void wlr_drm_output_make_current(struct wlr_output *_output) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
wlr_drm_plane_make_current(output->renderer, output->crtc->primary);
}
-static void wlr_drm_output_swap_buffers(struct wlr_output_state *output) {
+static void wlr_drm_output_swap_buffers(struct wlr_output *_output) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
struct wlr_drm_backend *backend =
wl_container_of(output->renderer, backend, renderer);
struct wlr_drm_renderer *renderer = output->renderer;
@@ -299,7 +301,7 @@ static void wlr_drm_output_swap_buffers(struct wlr_output_state *output) {
output->pageflip_pending = true;
}
-void wlr_drm_output_start_renderer(struct wlr_output_state *output) {
+void wlr_drm_output_start_renderer(struct wlr_drm_output *output) {
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
return;
}
@@ -322,12 +324,13 @@ void wlr_drm_output_start_renderer(struct wlr_output_state *output) {
bo = plane->back;
}
- drmModeModeInfo *mode = &output->base->current_mode->state->mode;
+ drmModeModeInfo *mode = &output->output.current_mode->state->mode;
backend->iface->crtc_pageflip(backend, output, crtc, get_fb_for_bo(bo), mode);
output->pageflip_pending = true;
}
-static void wlr_drm_output_enable(struct wlr_output_state *output, bool enable) {
+static void wlr_drm_output_enable(struct wlr_output *_output, bool enable) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
struct wlr_drm_backend *backend =
wl_container_of(output->renderer, backend, renderer);
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
@@ -389,7 +392,7 @@ static void realloc_planes(struct wlr_drm_backend *backend, const uint32_t *crtc
}
static void realloc_crtcs(struct wlr_drm_backend *backend,
- struct wlr_output_state *output) {
+ struct wlr_drm_output *output) {
uint32_t crtc[backend->num_crtcs];
uint32_t crtc_res[backend->num_crtcs];
uint32_t possible_crtc[backend->outputs->length];
@@ -402,7 +405,7 @@ static void realloc_crtcs(struct wlr_drm_backend *backend,
size_t index;
for (size_t i = 0; i < backend->outputs->length; ++i) {
- struct wlr_output_state *o = backend->outputs->items[i];
+ struct wlr_drm_output *o = backend->outputs->items[i];
if (o == output) {
index = i;
}
@@ -441,7 +444,7 @@ static void realloc_crtcs(struct wlr_drm_backend *backend,
}
if (crtc_res[i] != crtc[i]) {
- struct wlr_output_state *o = backend->outputs->items[crtc_res[i]];
+ struct wlr_drm_output *o = backend->outputs->items[crtc_res[i]];
o->crtc = &backend->crtcs[i];
}
}
@@ -449,12 +452,13 @@ static void realloc_crtcs(struct wlr_drm_backend *backend,
realloc_planes(backend, crtc_res);
}
-static bool wlr_drm_output_set_mode(struct wlr_output_state *output,
+static bool wlr_drm_output_set_mode(struct wlr_output *_output,
struct wlr_output_mode *mode) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
struct wlr_drm_backend *backend
= wl_container_of(output->renderer, backend, renderer);
- wlr_log(L_INFO, "Modesetting '%s' with '%ux%u@%u mHz'", output->base->name,
+ wlr_log(L_INFO, "Modesetting '%s' with '%ux%u@%u mHz'", output->output.name,
mode->width, mode->height, mode->refresh);
drmModeConnector *conn = drmModeGetConnector(backend->fd, output->connector);
@@ -464,7 +468,7 @@ static bool wlr_drm_output_set_mode(struct wlr_output_state *output,
}
if (conn->connection != DRM_MODE_CONNECTED || conn->count_modes == 0) {
- wlr_log(L_ERROR, "%s is not connected", output->base->name);
+ wlr_log(L_ERROR, "%s is not connected", output->output.name);
goto error_output;
}
@@ -482,28 +486,28 @@ static bool wlr_drm_output_set_mode(struct wlr_output_state *output,
realloc_crtcs(backend, output);
if (!output->crtc) {
- wlr_log(L_ERROR, "Unable to match %s with a CRTC", output->base->name);
+ wlr_log(L_ERROR, "Unable to match %s with a CRTC", output->output.name);
goto error_enc;
}
struct wlr_drm_crtc *crtc = output->crtc;
- wlr_log(L_DEBUG, "%s: crtc=%ju ovr=%jd pri=%jd cur=%jd", output->base->name,
+ wlr_log(L_DEBUG, "%s: crtc=%ju ovr=%jd pri=%jd cur=%jd", output->output.name,
crtc - backend->crtcs,
crtc->overlay ? crtc->overlay - backend->overlay_planes : -1,
crtc->primary ? crtc->primary - backend->primary_planes : -1,
crtc->cursor ? crtc->cursor - backend->cursor_planes : -1);
output->state = WLR_DRM_OUTPUT_CONNECTED;
- output->width = output->base->width = mode->width;
- output->height = output->base->height = mode->height;
- output->base->current_mode = mode;
- wl_signal_emit(&output->base->events.resolution, output->base);
+ output->width = output->output.width = mode->width;
+ output->height = output->output.height = mode->height;
+ output->output.current_mode = mode;
+ wl_signal_emit(&output->output.events.resolution, &output->output);
// Since realloc_crtcs can deallocate planes on OTHER outputs,
// we actually need to reinitalise all of them
for (size_t i = 0; i < backend->outputs->length; ++i) {
- struct wlr_output_state *output = backend->outputs->items[i];
- struct wlr_output_mode *mode = output->base->current_mode;
+ struct wlr_drm_output *output = backend->outputs->items[i];
+ struct wlr_output_mode *mode = output->output.current_mode;
struct wlr_drm_crtc *crtc = output->crtc;
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
@@ -533,13 +537,14 @@ error_output:
return false;
}
-static void wlr_drm_output_transform(struct wlr_output_state *output,
+static void wlr_drm_output_transform(struct wlr_output *output,
enum wl_output_transform transform) {
- output->base->transform = transform;
+ output->transform = transform;
}
-static bool wlr_drm_output_set_cursor(struct wlr_output_state *output,
+static bool wlr_drm_output_set_cursor(struct wlr_output *_output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
struct wlr_drm_backend *backend
= wl_container_of(output->renderer, backend, renderer);
struct wlr_drm_renderer *renderer = output->renderer;
@@ -588,7 +593,7 @@ static bool wlr_drm_output_set_cursor(struct wlr_output_state *output,
// OpenGL will read the pixels out upside down,
// so we need to flip the image vertically
wlr_matrix_texture(plane->matrix, plane->width, plane->height,
- output->base->transform ^ WL_OUTPUT_TRANSFORM_FLIPPED_180);
+ output->output.transform ^ WL_OUTPUT_TRANSFORM_FLIPPED_180);
plane->wlr_rend = wlr_gles2_renderer_init(&backend->backend);
if (!plane->wlr_rend) {
@@ -638,14 +643,16 @@ static bool wlr_drm_output_set_cursor(struct wlr_output_state *output,
return backend->iface->crtc_set_cursor(backend, crtc, bo);
}
-static bool wlr_drm_output_move_cursor(struct wlr_output_state *output,
+static bool wlr_drm_output_move_cursor(struct wlr_output *_output,
int x, int y) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
struct wlr_drm_backend *backend =
wl_container_of(output->renderer, backend, renderer);
return backend->iface->crtc_move_cursor(backend, output->crtc, x, y);
}
-static void wlr_drm_output_destroy(struct wlr_output_state *output) {
+static void wlr_drm_output_destroy(struct wlr_output *_output) {
+ struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
wlr_drm_output_cleanup(output, true);
free(output);
}
@@ -662,7 +669,7 @@ static struct wlr_output_impl output_impl = {
};
static int find_id(const void *item, const void *cmp_to) {
- const struct wlr_output_state *output = item;
+ const struct wlr_drm_output *output = item;
const uint32_t *id = cmp_to;
if (output->connector < *id) {
@@ -700,7 +707,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
continue;
}
- struct wlr_output_state *output;
+ struct wlr_drm_output *output;
int index = list_seq_find(backend->outputs, find_id, &conn->connector_id);
if (index == -1) {
@@ -710,14 +717,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
drmModeFreeConnector(conn);
continue;
}
-
- output->base = wlr_output_create(&output_impl, output);
- if (!output->base) {
- wlr_log_errno(L_ERROR, "Allocation failed");
- drmModeFreeConnector(conn);
- free(output);
- continue;
- }
+ wlr_output_init(&output->output, &output_impl);
output->renderer = &backend->renderer;
output->state = WLR_DRM_OUTPUT_DISCONNECTED;
@@ -730,10 +730,10 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
drmModeFreeEncoder(curr_enc);
}
- output->base->phys_width = conn->mmWidth;
- output->base->phys_height = conn->mmHeight;
- output->base->subpixel = subpixel_map[conn->subpixel];
- snprintf(output->base->name, sizeof(output->base->name), "%s-%"PRIu32,
+ output->output.phys_width = conn->mmWidth;
+ output->output.phys_height = conn->mmHeight;
+ output->output.subpixel = subpixel_map[conn->subpixel];
+ snprintf(output->output.name, sizeof(output->output.name), "%s-%"PRIu32,
conn_get_name(conn->connector_type),
conn->connector_type_id);
@@ -743,12 +743,12 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
size_t edid_len = 0;
uint8_t *edid = wlr_drm_get_prop_blob(backend->fd,
output->connector, output->props.edid, &edid_len);
- parse_edid(output->base, edid_len, edid);
+ parse_edid(&output->output, edid_len, edid);
free(edid);
- wlr_output_create_global(output->base, backend->display);
+ wlr_output_create_global(&output->output, backend->display);
list_add(backend->outputs, output);
- wlr_log(L_INFO, "Found display '%s'", output->base->name);
+ wlr_log(L_INFO, "Found display '%s'", output->output.name);
} else {
output = backend->outputs->items[index];
}
@@ -756,7 +756,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
if (output->state == WLR_DRM_OUTPUT_DISCONNECTED &&
conn->connection == DRM_MODE_CONNECTED) {
- wlr_log(L_INFO, "'%s' connected", output->base->name);
+ wlr_log(L_INFO, "'%s' connected", output->output.name);
wlr_log(L_INFO, "Detected modes:");
for (int i = 0; i < conn->count_modes; ++i) {
@@ -773,16 +773,16 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
wlr_log(L_INFO, " %"PRId32"@%"PRId32"@%"PRId32,
mode->width, mode->height, mode->refresh);
- list_add(output->base->modes, mode);
+ list_add(output->output.modes, mode);
}
output->state = WLR_DRM_OUTPUT_NEEDS_MODESET;
- wlr_log(L_INFO, "Sending modesetting signal for '%s'", output->base->name);
- wl_signal_emit(&backend->backend.events.output_add, output->base);
+ wlr_log(L_INFO, "Sending modesetting signal for '%s'", output->output.name);
+ wl_signal_emit(&backend->backend.events.output_add, &output->output);
} else if (output->state == WLR_DRM_OUTPUT_CONNECTED &&
conn->connection != DRM_MODE_CONNECTED) {
- wlr_log(L_INFO, "'%s' disconnected", output->base->name);
+ wlr_log(L_INFO, "'%s' disconnected", output->output.name);
wlr_drm_output_cleanup(output, false);
}
@@ -794,7 +794,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
static void page_flip_handler(int fd, unsigned seq,
unsigned tv_sec, unsigned tv_usec, void *user) {
- struct wlr_output_state *output = user;
+ struct wlr_drm_output *output = user;
struct wlr_drm_backend *backend =
wl_container_of(output->renderer, backend, renderer);
@@ -810,7 +810,7 @@ static void page_flip_handler(int fd, unsigned seq,
}
if (backend->session->active) {
- wl_signal_emit(&output->base->events.frame, output->base);
+ wl_signal_emit(&output->output.events.frame, &output->output);
}
}
@@ -824,7 +824,7 @@ int wlr_drm_event(int fd, uint32_t mask, void *data) {
return 1;
}
-static void restore_output(struct wlr_output_state *output, int fd) {
+static void restore_output(struct wlr_drm_output *output, int fd) {
// Wait for any pending pageflips to finish
while (output->pageflip_pending) {
wlr_drm_event(fd, 0, NULL);
@@ -840,7 +840,7 @@ static void restore_output(struct wlr_output_state *output, int fd) {
drmModeFreeCrtc(crtc);
}
-void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore) {
+void wlr_drm_output_cleanup(struct wlr_drm_output *output, bool restore) {
if (!output) {
return;
}
@@ -875,8 +875,8 @@ void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore) {
restore_output(output, renderer->fd);
}
wlr_log(L_INFO, "Emmiting destruction signal for '%s'",
- output->base->name);
- wl_signal_emit(&backend->backend.events.output_remove, output->base);
+ output->output.name);
+ wl_signal_emit(&backend->backend.events.output_remove, &output->output);
break;
case WLR_DRM_OUTPUT_DISCONNECTED:
break;
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 8ca63036..467d137b 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -111,11 +111,11 @@ bool wlr_backend_is_wl(struct wlr_backend *b) {
return b->impl == &backend_impl;
}
-struct wlr_output *wlr_wl_output_for_surface(struct wlr_wl_backend *backend,
- struct wl_surface *surface) {
+struct wlr_wl_backend_output *wlr_wl_output_for_surface(
+ struct wlr_wl_backend *backend, struct wl_surface *surface) {
for (size_t i = 0; i < backend->outputs->length; ++i) {
- struct wlr_output *output = backend->outputs->items[i];
- if (output->state->surface == surface) {
+ struct wlr_wl_backend_output *output = backend->outputs->items[i];
+ if (output->surface == surface) {
return output;
}
}
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 5416f112..6a7b9e54 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -12,10 +12,8 @@
static struct wl_callback_listener frame_listener;
static void surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
- struct wlr_output_state *output = data;
- assert(output);
-
- struct wlr_output *wlr_output = output->wlr_output;
+ struct wlr_output *wlr_output = data;
+ assert(wlr_output);
wl_signal_emit(&wlr_output->events.frame, wlr_output);
wl_callback_destroy(cb);
}
@@ -24,7 +22,8 @@ static struct wl_callback_listener frame_listener = {
.done = surface_frame_callback
};
-static void wlr_wl_output_make_current(struct wlr_output_state *output) {
+static void wlr_wl_output_make_current(struct wlr_output *_output) {
+ struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
if (!eglMakeCurrent(output->backend->egl.display,
output->egl_surface, output->egl_surface,
output->backend->egl.context)) {
@@ -32,7 +31,8 @@ static void wlr_wl_output_make_current(struct wlr_output_state *output) {
}
}
-static void wlr_wl_output_swap_buffers(struct wlr_output_state *output) {
+static void wlr_wl_output_swap_buffers(struct wlr_output *_output) {
+ struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
output->frame_callback = wl_surface_frame(output->surface);
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
@@ -40,13 +40,15 @@ static void wlr_wl_output_swap_buffers(struct wlr_output_state *output) {
}
}
-static void wlr_wl_output_transform(struct wlr_output_state *output,
+static void wlr_wl_output_transform(struct wlr_output *_output,
enum wl_output_transform transform) {
- output->wlr_output->transform = transform;
+ struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
+ output->wlr_output.transform = transform;
}
-static void wlr_wl_output_destroy(struct wlr_output_state *output) {
- wl_signal_emit(&output->backend->backend.events.output_remove, output->wlr_output);
+static void wlr_wl_output_destroy(struct wlr_output *_output) {
+ struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
+ wl_signal_emit(&output->backend->backend.events.output_remove, &output->wlr_output);
if (output->frame_callback) {
wl_callback_destroy(output->frame_callback);
}
@@ -65,21 +67,20 @@ static struct wlr_output_impl output_impl = {
};
void handle_ping(void* data, struct wl_shell_surface* ssurface, uint32_t serial) {
- struct wlr_output_state *output = data;
+ struct wlr_wl_backend_output *output = data;
assert(output && output->shell_surface == ssurface);
wl_shell_surface_pong(ssurface, serial);
}
void handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
uint32_t edges, int32_t width, int32_t height){
- struct wlr_output_state *ostate = data;
- assert(ostate && ostate->shell_surface == wl_shell_surface);
- struct wlr_output *output = ostate->wlr_output;
- wl_egl_window_resize(ostate->egl_window, width, height, 0, 0);
- output->width = width;
- output->height = height;
- wlr_output_update_matrix(output);
- wl_signal_emit(&output->events.resolution, output);
+ struct wlr_wl_backend_output *output = data;
+ assert(output && output->shell_surface == wl_shell_surface);
+ wl_egl_window_resize(output->egl_window, width, height, 0, 0);
+ output->wlr_output.width = width;
+ output->wlr_output.height = height;
+ wlr_output_update_matrix(&output->wlr_output);
+ wl_signal_emit(&output->wlr_output.events.resolution, output);
}
void handle_popup_done(void *data, struct wl_shell_surface *wl_shell_surface) {
@@ -100,18 +101,13 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
return NULL;
}
- struct wlr_output_state *ostate;
- if (!(ostate = calloc(sizeof(struct wlr_output_state), 1))) {
+ struct wlr_wl_backend_output *output;
+ if (!(output = calloc(sizeof(struct wlr_wl_backend_output), 1))) {
wlr_log(L_ERROR, "Failed to allocate wlr_output_state");
return NULL;
}
-
- struct wlr_output *wlr_output = wlr_output_create(&output_impl, ostate);
- if (!wlr_output) {
- free(ostate);
- wlr_log_errno(L_ERROR, "Allocation failed");
- return NULL;
- }
+ wlr_output_init(&output->wlr_output, &output_impl);
+ struct wlr_output *wlr_output = &output->wlr_output;
wlr_output->width = 640;
wlr_output->height = 480;
@@ -122,26 +118,27 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
backend->outputs->length + 1);
wlr_output_update_matrix(wlr_output);
- ostate->backend = backend;
- ostate->wlr_output = wlr_output;
+ output->backend = backend;
// TODO: error handling
- ostate->surface = wl_compositor_create_surface(backend->compositor);
- ostate->shell_surface = wl_shell_get_shell_surface(backend->shell, ostate->surface);
+ output->surface = wl_compositor_create_surface(backend->compositor);
+ output->shell_surface =
+ wl_shell_get_shell_surface(backend->shell, output->surface);
- wl_shell_surface_set_class(ostate->shell_surface, "sway");
- wl_shell_surface_set_title(ostate->shell_surface, "sway-wl");
- wl_shell_surface_add_listener(ostate->shell_surface, &shell_surface_listener, ostate);
- wl_shell_surface_set_toplevel(ostate->shell_surface);
+ wl_shell_surface_set_class(output->shell_surface, "sway");
+ wl_shell_surface_set_title(output->shell_surface, "sway-wl");
+ wl_shell_surface_add_listener(output->shell_surface,
+ &shell_surface_listener, output);
+ wl_shell_surface_set_toplevel(output->shell_surface);
- ostate->egl_window = wl_egl_window_create(ostate->surface,
+ output->egl_window = wl_egl_window_create(output->surface,
wlr_output->width, wlr_output->height);
- ostate->egl_surface = wlr_egl_create_surface(&backend->egl, ostate->egl_window);
+ output->egl_surface = wlr_egl_create_surface(&backend->egl, output->egl_window);
// start rendering loop per callbacks by rendering first frame
- if (!eglMakeCurrent(ostate->backend->egl.display,
- ostate->egl_surface, ostate->egl_surface,
- ostate->backend->egl.context)) {
+ if (!eglMakeCurrent(output->backend->egl.display,
+ output->egl_surface, output->egl_surface,
+ output->backend->egl.context)) {
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
return false;
}
@@ -150,10 +147,10 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
- ostate->frame_callback = wl_surface_frame(ostate->surface);
- wl_callback_add_listener(ostate->frame_callback, &frame_listener, ostate);
+ output->frame_callback = wl_surface_frame(output->surface);
+ wl_callback_add_listener(output->frame_callback, &frame_listener, output);
- if (!eglSwapBuffers(ostate->backend->egl.display, ostate->egl_surface)) {
+ if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error());
return false;
}
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index 80cc194d..99a67df5 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -17,14 +17,9 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
wl_fixed_t surface_y) {
struct wlr_input_device *dev = data;
assert(dev && dev->pointer && dev->pointer->state);
- struct wlr_output* output = wlr_wl_output_for_surface(dev->state->backend,
- surface);
-
- if (!output) {
- wlr_log(L_ERROR, "pointer entered invalid surface");
- return;
- }
-
+ struct wlr_wl_backend_output* output =
+ wlr_wl_output_for_surface(dev->state->backend, surface);
+ assert(output);
dev->pointer->state->current_output = output;
}
@@ -40,16 +35,13 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
struct wlr_input_device *dev = data;
assert(dev && dev->pointer && dev->pointer->state);
struct wlr_pointer_state *state = dev->pointer->state;
-
- if(!state->current_output) {
+ if (!state->current_output) {
wlr_log(L_ERROR, "pointer motion event without current output");
return;
}
-
int width, height;
- wl_egl_window_get_attached_size(state->current_output->state->egl_window,
+ wl_egl_window_get_attached_size(state->current_output->egl_window,
&width, &height);
-
struct wlr_event_pointer_motion_absolute wlr_event;
wlr_event.time_sec = time / 1000;
wlr_event.time_usec = time * 1000;