mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 07:02:28 +00:00
Remove wlr_output_state, update backends
This commit is contained in:
parent
4386816889
commit
41e735242d
@ -28,8 +28,8 @@ static void wlr_drm_backend_destroy(struct wlr_backend *_backend) {
|
|||||||
}
|
}
|
||||||
struct wlr_drm_backend *backend = (struct wlr_drm_backend *)_backend;
|
struct wlr_drm_backend *backend = (struct wlr_drm_backend *)_backend;
|
||||||
for (size_t i = 0; backend->outputs && i < backend->outputs->length; ++i) {
|
for (size_t i = 0; backend->outputs && i < backend->outputs->length; ++i) {
|
||||||
struct wlr_output_state *output = backend->outputs->items[i];
|
struct wlr_drm_output *output = backend->outputs->items[i];
|
||||||
wlr_output_destroy(output->base);
|
wlr_output_destroy(&output->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_udev_signal_remove(backend->udev, &backend->drm_invalidated);
|
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");
|
wlr_log(L_INFO, "DRM fd resumed");
|
||||||
|
|
||||||
for (size_t i = 0; i < backend->outputs->length; ++i) {
|
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);
|
wlr_drm_output_start_renderer(output);
|
||||||
|
|
||||||
if (!output->crtc) {
|
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;
|
struct wlr_drm_plane *plane = output->crtc->cursor;
|
||||||
|
|
||||||
backend->iface->crtc_set_cursor(backend, output->crtc,
|
backend->iface->crtc_set_cursor(backend, output->crtc,
|
||||||
plane ? plane->cursor_bo : NULL);
|
plane ? plane->cursor_bo : NULL);
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ static bool atomic_end(int drm_fd, struct atomic *atom) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool atomic_commit(int drm_fd, struct atomic *atom, struct wlr_output_state *output,
|
static bool atomic_commit(int drm_fd, struct atomic *atom,
|
||||||
uint32_t flag) {
|
struct wlr_drm_output *output, uint32_t flag) {
|
||||||
if (atom->failed) {
|
if (atom->failed) {
|
||||||
return false;
|
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,
|
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,
|
struct wlr_drm_crtc *crtc,
|
||||||
uint32_t fb_id, drmModeModeInfo *mode) {
|
uint32_t fb_id, drmModeModeInfo *mode) {
|
||||||
if (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,
|
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 wlr_drm_crtc *crtc = output->crtc;
|
||||||
struct atomic atom;
|
struct atomic atom;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "backend/drm-util.h"
|
#include "backend/drm-util.h"
|
||||||
|
|
||||||
static bool legacy_crtc_pageflip(struct wlr_drm_backend *backend,
|
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) {
|
uint32_t fb_id, drmModeModeInfo *mode) {
|
||||||
if (mode) {
|
if (mode) {
|
||||||
drmModeSetCrtc(backend->fd, crtc->id, fb_id, 0, 0,
|
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,
|
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,
|
drmModeConnectorSetProperty(backend->fd, output->connector, output->props.dpms,
|
||||||
enable ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF);
|
enable ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
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);
|
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 =
|
struct wlr_drm_backend *backend =
|
||||||
wl_container_of(output->renderer, backend, renderer);
|
wl_container_of(output->renderer, backend, renderer);
|
||||||
struct wlr_drm_renderer *renderer = output->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;
|
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) {
|
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -322,12 +324,13 @@ void wlr_drm_output_start_renderer(struct wlr_output_state *output) {
|
|||||||
bo = plane->back;
|
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);
|
backend->iface->crtc_pageflip(backend, output, crtc, get_fb_for_bo(bo), mode);
|
||||||
output->pageflip_pending = true;
|
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 =
|
struct wlr_drm_backend *backend =
|
||||||
wl_container_of(output->renderer, backend, renderer);
|
wl_container_of(output->renderer, backend, renderer);
|
||||||
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
|
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,
|
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[backend->num_crtcs];
|
||||||
uint32_t crtc_res[backend->num_crtcs];
|
uint32_t crtc_res[backend->num_crtcs];
|
||||||
uint32_t possible_crtc[backend->outputs->length];
|
uint32_t possible_crtc[backend->outputs->length];
|
||||||
@ -402,7 +405,7 @@ static void realloc_crtcs(struct wlr_drm_backend *backend,
|
|||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
for (size_t i = 0; i < backend->outputs->length; ++i) {
|
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) {
|
if (o == output) {
|
||||||
index = i;
|
index = i;
|
||||||
}
|
}
|
||||||
@ -441,7 +444,7 @@ static void realloc_crtcs(struct wlr_drm_backend *backend,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (crtc_res[i] != crtc[i]) {
|
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];
|
o->crtc = &backend->crtcs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,12 +452,13 @@ static void realloc_crtcs(struct wlr_drm_backend *backend,
|
|||||||
realloc_planes(backend, crtc_res);
|
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_output_mode *mode) {
|
||||||
|
struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
|
||||||
struct wlr_drm_backend *backend
|
struct wlr_drm_backend *backend
|
||||||
= wl_container_of(output->renderer, backend, renderer);
|
= 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);
|
mode->width, mode->height, mode->refresh);
|
||||||
|
|
||||||
drmModeConnector *conn = drmModeGetConnector(backend->fd, output->connector);
|
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) {
|
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;
|
goto error_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,28 +486,28 @@ static bool wlr_drm_output_set_mode(struct wlr_output_state *output,
|
|||||||
realloc_crtcs(backend, output);
|
realloc_crtcs(backend, output);
|
||||||
|
|
||||||
if (!output->crtc) {
|
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;
|
goto error_enc;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_drm_crtc *crtc = output->crtc;
|
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 - backend->crtcs,
|
||||||
crtc->overlay ? crtc->overlay - backend->overlay_planes : -1,
|
crtc->overlay ? crtc->overlay - backend->overlay_planes : -1,
|
||||||
crtc->primary ? crtc->primary - backend->primary_planes : -1,
|
crtc->primary ? crtc->primary - backend->primary_planes : -1,
|
||||||
crtc->cursor ? crtc->cursor - backend->cursor_planes : -1);
|
crtc->cursor ? crtc->cursor - backend->cursor_planes : -1);
|
||||||
|
|
||||||
output->state = WLR_DRM_OUTPUT_CONNECTED;
|
output->state = WLR_DRM_OUTPUT_CONNECTED;
|
||||||
output->width = output->base->width = mode->width;
|
output->width = output->output.width = mode->width;
|
||||||
output->height = output->base->height = mode->height;
|
output->height = output->output.height = mode->height;
|
||||||
output->base->current_mode = mode;
|
output->output.current_mode = mode;
|
||||||
wl_signal_emit(&output->base->events.resolution, output->base);
|
wl_signal_emit(&output->output.events.resolution, &output->output);
|
||||||
|
|
||||||
// Since realloc_crtcs can deallocate planes on OTHER outputs,
|
// Since realloc_crtcs can deallocate planes on OTHER outputs,
|
||||||
// we actually need to reinitalise all of them
|
// we actually need to reinitalise all of them
|
||||||
for (size_t i = 0; i < backend->outputs->length; ++i) {
|
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];
|
||||||
struct wlr_output_mode *mode = output->base->current_mode;
|
struct wlr_output_mode *mode = output->output.current_mode;
|
||||||
struct wlr_drm_crtc *crtc = output->crtc;
|
struct wlr_drm_crtc *crtc = output->crtc;
|
||||||
|
|
||||||
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
|
if (output->state != WLR_DRM_OUTPUT_CONNECTED) {
|
||||||
@ -533,13 +537,14 @@ error_output:
|
|||||||
return false;
|
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) {
|
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) {
|
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
|
struct wlr_drm_backend *backend
|
||||||
= wl_container_of(output->renderer, backend, renderer);
|
= wl_container_of(output->renderer, backend, renderer);
|
||||||
struct wlr_drm_renderer *renderer = output->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,
|
// OpenGL will read the pixels out upside down,
|
||||||
// so we need to flip the image vertically
|
// so we need to flip the image vertically
|
||||||
wlr_matrix_texture(plane->matrix, plane->width, plane->height,
|
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);
|
plane->wlr_rend = wlr_gles2_renderer_init(&backend->backend);
|
||||||
if (!plane->wlr_rend) {
|
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);
|
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) {
|
int x, int y) {
|
||||||
|
struct wlr_drm_output *output = (struct wlr_drm_output *)_output;
|
||||||
struct wlr_drm_backend *backend =
|
struct wlr_drm_backend *backend =
|
||||||
wl_container_of(output->renderer, backend, renderer);
|
wl_container_of(output->renderer, backend, renderer);
|
||||||
return backend->iface->crtc_move_cursor(backend, output->crtc, x, y);
|
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);
|
wlr_drm_output_cleanup(output, true);
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
@ -662,7 +669,7 @@ static struct wlr_output_impl output_impl = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int find_id(const void *item, const void *cmp_to) {
|
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;
|
const uint32_t *id = cmp_to;
|
||||||
|
|
||||||
if (output->connector < *id) {
|
if (output->connector < *id) {
|
||||||
@ -700,7 +707,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output_state *output;
|
struct wlr_drm_output *output;
|
||||||
int index = list_seq_find(backend->outputs, find_id, &conn->connector_id);
|
int index = list_seq_find(backend->outputs, find_id, &conn->connector_id);
|
||||||
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
@ -710,14 +717,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
|
|||||||
drmModeFreeConnector(conn);
|
drmModeFreeConnector(conn);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
wlr_output_init(&output->output, &output_impl);
|
||||||
output->base = wlr_output_create(&output_impl, output);
|
|
||||||
if (!output->base) {
|
|
||||||
wlr_log_errno(L_ERROR, "Allocation failed");
|
|
||||||
drmModeFreeConnector(conn);
|
|
||||||
free(output);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
output->renderer = &backend->renderer;
|
output->renderer = &backend->renderer;
|
||||||
output->state = WLR_DRM_OUTPUT_DISCONNECTED;
|
output->state = WLR_DRM_OUTPUT_DISCONNECTED;
|
||||||
@ -730,10 +730,10 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
|
|||||||
drmModeFreeEncoder(curr_enc);
|
drmModeFreeEncoder(curr_enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
output->base->phys_width = conn->mmWidth;
|
output->output.phys_width = conn->mmWidth;
|
||||||
output->base->phys_height = conn->mmHeight;
|
output->output.phys_height = conn->mmHeight;
|
||||||
output->base->subpixel = subpixel_map[conn->subpixel];
|
output->output.subpixel = subpixel_map[conn->subpixel];
|
||||||
snprintf(output->base->name, sizeof(output->base->name), "%s-%"PRIu32,
|
snprintf(output->output.name, sizeof(output->output.name), "%s-%"PRIu32,
|
||||||
conn_get_name(conn->connector_type),
|
conn_get_name(conn->connector_type),
|
||||||
conn->connector_type_id);
|
conn->connector_type_id);
|
||||||
|
|
||||||
@ -743,12 +743,12 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
|
|||||||
size_t edid_len = 0;
|
size_t edid_len = 0;
|
||||||
uint8_t *edid = wlr_drm_get_prop_blob(backend->fd,
|
uint8_t *edid = wlr_drm_get_prop_blob(backend->fd,
|
||||||
output->connector, output->props.edid, &edid_len);
|
output->connector, output->props.edid, &edid_len);
|
||||||
parse_edid(output->base, edid_len, edid);
|
parse_edid(&output->output, edid_len, edid);
|
||||||
free(edid);
|
free(edid);
|
||||||
|
|
||||||
wlr_output_create_global(output->base, backend->display);
|
wlr_output_create_global(&output->output, backend->display);
|
||||||
list_add(backend->outputs, output);
|
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 {
|
} else {
|
||||||
output = backend->outputs->items[index];
|
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 &&
|
if (output->state == WLR_DRM_OUTPUT_DISCONNECTED &&
|
||||||
conn->connection == DRM_MODE_CONNECTED) {
|
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:");
|
wlr_log(L_INFO, "Detected modes:");
|
||||||
|
|
||||||
for (int i = 0; i < conn->count_modes; ++i) {
|
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,
|
wlr_log(L_INFO, " %"PRId32"@%"PRId32"@%"PRId32,
|
||||||
mode->width, mode->height, mode->refresh);
|
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;
|
output->state = WLR_DRM_OUTPUT_NEEDS_MODESET;
|
||||||
wlr_log(L_INFO, "Sending modesetting signal for '%s'", output->base->name);
|
wlr_log(L_INFO, "Sending modesetting signal for '%s'", output->output.name);
|
||||||
wl_signal_emit(&backend->backend.events.output_add, output->base);
|
wl_signal_emit(&backend->backend.events.output_add, &output->output);
|
||||||
} else if (output->state == WLR_DRM_OUTPUT_CONNECTED &&
|
} else if (output->state == WLR_DRM_OUTPUT_CONNECTED &&
|
||||||
conn->connection != DRM_MODE_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);
|
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,
|
static void page_flip_handler(int fd, unsigned seq,
|
||||||
unsigned tv_sec, unsigned tv_usec, void *user) {
|
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 =
|
struct wlr_drm_backend *backend =
|
||||||
wl_container_of(output->renderer, backend, renderer);
|
wl_container_of(output->renderer, backend, renderer);
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ static void page_flip_handler(int fd, unsigned seq,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (backend->session->active) {
|
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;
|
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
|
// Wait for any pending pageflips to finish
|
||||||
while (output->pageflip_pending) {
|
while (output->pageflip_pending) {
|
||||||
wlr_drm_event(fd, 0, NULL);
|
wlr_drm_event(fd, 0, NULL);
|
||||||
@ -840,7 +840,7 @@ static void restore_output(struct wlr_output_state *output, int fd) {
|
|||||||
drmModeFreeCrtc(crtc);
|
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) {
|
if (!output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -875,8 +875,8 @@ void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore) {
|
|||||||
restore_output(output, renderer->fd);
|
restore_output(output, renderer->fd);
|
||||||
}
|
}
|
||||||
wlr_log(L_INFO, "Emmiting destruction signal for '%s'",
|
wlr_log(L_INFO, "Emmiting destruction signal for '%s'",
|
||||||
output->base->name);
|
output->output.name);
|
||||||
wl_signal_emit(&backend->backend.events.output_remove, output->base);
|
wl_signal_emit(&backend->backend.events.output_remove, &output->output);
|
||||||
break;
|
break;
|
||||||
case WLR_DRM_OUTPUT_DISCONNECTED:
|
case WLR_DRM_OUTPUT_DISCONNECTED:
|
||||||
break;
|
break;
|
||||||
|
@ -111,11 +111,11 @@ bool wlr_backend_is_wl(struct wlr_backend *b) {
|
|||||||
return b->impl == &backend_impl;
|
return b->impl == &backend_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output *wlr_wl_output_for_surface(struct wlr_wl_backend *backend,
|
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
|
||||||
struct wl_surface *surface) {
|
struct wlr_wl_backend *backend, struct wl_surface *surface) {
|
||||||
for (size_t i = 0; i < backend->outputs->length; ++i) {
|
for (size_t i = 0; i < backend->outputs->length; ++i) {
|
||||||
struct wlr_output *output = backend->outputs->items[i];
|
struct wlr_wl_backend_output *output = backend->outputs->items[i];
|
||||||
if (output->state->surface == surface) {
|
if (output->surface == surface) {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,8 @@
|
|||||||
static struct wl_callback_listener frame_listener;
|
static struct wl_callback_listener frame_listener;
|
||||||
|
|
||||||
static void surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
|
static void surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
|
||||||
struct wlr_output_state *output = data;
|
struct wlr_output *wlr_output = data;
|
||||||
assert(output);
|
assert(wlr_output);
|
||||||
|
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
|
||||||
wl_signal_emit(&wlr_output->events.frame, wlr_output);
|
wl_signal_emit(&wlr_output->events.frame, wlr_output);
|
||||||
wl_callback_destroy(cb);
|
wl_callback_destroy(cb);
|
||||||
}
|
}
|
||||||
@ -24,7 +22,8 @@ static struct wl_callback_listener frame_listener = {
|
|||||||
.done = surface_frame_callback
|
.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,
|
if (!eglMakeCurrent(output->backend->egl.display,
|
||||||
output->egl_surface, output->egl_surface,
|
output->egl_surface, output->egl_surface,
|
||||||
output->backend->egl.context)) {
|
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);
|
output->frame_callback = wl_surface_frame(output->surface);
|
||||||
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
||||||
if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
|
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) {
|
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) {
|
static void wlr_wl_output_destroy(struct wlr_output *_output) {
|
||||||
wl_signal_emit(&output->backend->backend.events.output_remove, output->wlr_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) {
|
if (output->frame_callback) {
|
||||||
wl_callback_destroy(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) {
|
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);
|
assert(output && output->shell_surface == ssurface);
|
||||||
wl_shell_surface_pong(ssurface, serial);
|
wl_shell_surface_pong(ssurface, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
|
void handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
|
||||||
uint32_t edges, int32_t width, int32_t height){
|
uint32_t edges, int32_t width, int32_t height){
|
||||||
struct wlr_output_state *ostate = data;
|
struct wlr_wl_backend_output *output = data;
|
||||||
assert(ostate && ostate->shell_surface == wl_shell_surface);
|
assert(output && output->shell_surface == wl_shell_surface);
|
||||||
struct wlr_output *output = ostate->wlr_output;
|
wl_egl_window_resize(output->egl_window, width, height, 0, 0);
|
||||||
wl_egl_window_resize(ostate->egl_window, width, height, 0, 0);
|
output->wlr_output.width = width;
|
||||||
output->width = width;
|
output->wlr_output.height = height;
|
||||||
output->height = height;
|
wlr_output_update_matrix(&output->wlr_output);
|
||||||
wlr_output_update_matrix(output);
|
wl_signal_emit(&output->wlr_output.events.resolution, output);
|
||||||
wl_signal_emit(&output->events.resolution, output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_popup_done(void *data, struct wl_shell_surface *wl_shell_surface) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output_state *ostate;
|
struct wlr_wl_backend_output *output;
|
||||||
if (!(ostate = calloc(sizeof(struct wlr_output_state), 1))) {
|
if (!(output = calloc(sizeof(struct wlr_wl_backend_output), 1))) {
|
||||||
wlr_log(L_ERROR, "Failed to allocate wlr_output_state");
|
wlr_log(L_ERROR, "Failed to allocate wlr_output_state");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
wlr_output_init(&output->wlr_output, &output_impl);
|
||||||
struct wlr_output *wlr_output = wlr_output_create(&output_impl, ostate);
|
struct wlr_output *wlr_output = &output->wlr_output;
|
||||||
if (!wlr_output) {
|
|
||||||
free(ostate);
|
|
||||||
wlr_log_errno(L_ERROR, "Allocation failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_output->width = 640;
|
wlr_output->width = 640;
|
||||||
wlr_output->height = 480;
|
wlr_output->height = 480;
|
||||||
@ -122,26 +118,27 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|||||||
backend->outputs->length + 1);
|
backend->outputs->length + 1);
|
||||||
wlr_output_update_matrix(wlr_output);
|
wlr_output_update_matrix(wlr_output);
|
||||||
|
|
||||||
ostate->backend = backend;
|
output->backend = backend;
|
||||||
ostate->wlr_output = wlr_output;
|
|
||||||
|
|
||||||
// TODO: error handling
|
// TODO: error handling
|
||||||
ostate->surface = wl_compositor_create_surface(backend->compositor);
|
output->surface = wl_compositor_create_surface(backend->compositor);
|
||||||
ostate->shell_surface = wl_shell_get_shell_surface(backend->shell, ostate->surface);
|
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_class(output->shell_surface, "sway");
|
||||||
wl_shell_surface_set_title(ostate->shell_surface, "sway-wl");
|
wl_shell_surface_set_title(output->shell_surface, "sway-wl");
|
||||||
wl_shell_surface_add_listener(ostate->shell_surface, &shell_surface_listener, ostate);
|
wl_shell_surface_add_listener(output->shell_surface,
|
||||||
wl_shell_surface_set_toplevel(ostate->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);
|
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
|
// start rendering loop per callbacks by rendering first frame
|
||||||
if (!eglMakeCurrent(ostate->backend->egl.display,
|
if (!eglMakeCurrent(output->backend->egl.display,
|
||||||
ostate->egl_surface, ostate->egl_surface,
|
output->egl_surface, output->egl_surface,
|
||||||
ostate->backend->egl.context)) {
|
output->backend->egl.context)) {
|
||||||
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
|
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
|
||||||
return false;
|
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);
|
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
ostate->frame_callback = wl_surface_frame(ostate->surface);
|
output->frame_callback = wl_surface_frame(output->surface);
|
||||||
wl_callback_add_listener(ostate->frame_callback, &frame_listener, ostate);
|
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());
|
wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,9 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
|
|||||||
wl_fixed_t surface_y) {
|
wl_fixed_t surface_y) {
|
||||||
struct wlr_input_device *dev = data;
|
struct wlr_input_device *dev = data;
|
||||||
assert(dev && dev->pointer && dev->pointer->state);
|
assert(dev && dev->pointer && dev->pointer->state);
|
||||||
struct wlr_output* output = wlr_wl_output_for_surface(dev->state->backend,
|
struct wlr_wl_backend_output* output =
|
||||||
surface);
|
wlr_wl_output_for_surface(dev->state->backend, surface);
|
||||||
|
assert(output);
|
||||||
if (!output) {
|
|
||||||
wlr_log(L_ERROR, "pointer entered invalid surface");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->pointer->state->current_output = 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;
|
struct wlr_input_device *dev = data;
|
||||||
assert(dev && dev->pointer && dev->pointer->state);
|
assert(dev && dev->pointer && dev->pointer->state);
|
||||||
struct wlr_pointer_state *state = 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");
|
wlr_log(L_ERROR, "pointer motion event without current output");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width, height;
|
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);
|
&width, &height);
|
||||||
|
|
||||||
struct wlr_event_pointer_motion_absolute wlr_event;
|
struct wlr_event_pointer_motion_absolute wlr_event;
|
||||||
wlr_event.time_sec = time / 1000;
|
wlr_event.time_sec = time / 1000;
|
||||||
wlr_event.time_usec = time * 1000;
|
wlr_event.time_usec = time * 1000;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
#include <wlr/backend/drm.h>
|
#include <wlr/backend/drm.h>
|
||||||
|
#include <wlr/types/wlr_output.h>
|
||||||
#include <wlr/egl.h>
|
#include <wlr/egl.h>
|
||||||
#include <wlr/util/list.h>
|
#include <wlr/util/list.h>
|
||||||
|
|
||||||
@ -137,8 +138,9 @@ struct wlr_output_mode_state {
|
|||||||
drmModeModeInfo mode;
|
drmModeModeInfo mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output_state {
|
struct wlr_drm_output {
|
||||||
struct wlr_output *base;
|
struct wlr_output output;
|
||||||
|
|
||||||
enum wlr_drm_output_state state;
|
enum wlr_drm_output_state state;
|
||||||
uint32_t connector;
|
uint32_t connector;
|
||||||
|
|
||||||
@ -161,10 +163,10 @@ struct wlr_output_state {
|
|||||||
struct wlr_drm_interface {
|
struct wlr_drm_interface {
|
||||||
// Enable or disable DPMS for output
|
// Enable or disable DPMS for output
|
||||||
void (*conn_enable)(struct wlr_drm_backend *backend,
|
void (*conn_enable)(struct wlr_drm_backend *backend,
|
||||||
struct wlr_output_state *output, bool enable);
|
struct wlr_drm_output *output, bool enable);
|
||||||
// Pageflip on crtc. If mode is non-NULL perform a full modeset using it.
|
// Pageflip on crtc. If mode is non-NULL perform a full modeset using it.
|
||||||
bool (*crtc_pageflip)(struct wlr_drm_backend *backend,
|
bool (*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);
|
uint32_t fb_id, drmModeModeInfo *mode);
|
||||||
// Enable the cursor buffer on crtc. Set bo to NULL to disable
|
// Enable the cursor buffer on crtc. Set bo to NULL to disable
|
||||||
bool (*crtc_set_cursor)(struct wlr_drm_backend *backend,
|
bool (*crtc_set_cursor)(struct wlr_drm_backend *backend,
|
||||||
@ -177,11 +179,11 @@ struct wlr_drm_interface {
|
|||||||
bool wlr_drm_check_features(struct wlr_drm_backend *drm);
|
bool wlr_drm_check_features(struct wlr_drm_backend *drm);
|
||||||
bool wlr_drm_resources_init(struct wlr_drm_backend *drm);
|
bool wlr_drm_resources_init(struct wlr_drm_backend *drm);
|
||||||
void wlr_drm_resources_free(struct wlr_drm_backend *drm);
|
void wlr_drm_resources_free(struct wlr_drm_backend *drm);
|
||||||
void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore);
|
void wlr_drm_output_cleanup(struct wlr_drm_output *output, bool restore);
|
||||||
|
|
||||||
void wlr_drm_scan_connectors(struct wlr_drm_backend *state);
|
void wlr_drm_scan_connectors(struct wlr_drm_backend *state);
|
||||||
int wlr_drm_event(int fd, uint32_t mask, void *data);
|
int wlr_drm_event(int fd, uint32_t mask, void *data);
|
||||||
|
|
||||||
void wlr_drm_output_start_renderer(struct wlr_output_state *output);
|
void wlr_drm_output_start_renderer(struct wlr_drm_output *output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <wayland-egl.h>
|
#include <wayland-egl.h>
|
||||||
#include <wlr/egl.h>
|
#include <wlr/egl.h>
|
||||||
#include <wlr/backend/wayland.h>
|
#include <wlr/backend/wayland.h>
|
||||||
|
#include <wlr/types/wlr_output.h>
|
||||||
#include <wlr/types/wlr_input_device.h>
|
#include <wlr/types/wlr_input_device.h>
|
||||||
#include <wlr/util/list.h>
|
#include <wlr/util/list.h>
|
||||||
|
|
||||||
@ -29,9 +30,10 @@ struct wlr_wl_backend {
|
|||||||
char *seat_name;
|
char *seat_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output_state {
|
struct wlr_wl_backend_output {
|
||||||
|
struct wlr_output wlr_output;
|
||||||
|
|
||||||
struct wlr_wl_backend *backend;
|
struct wlr_wl_backend *backend;
|
||||||
struct wlr_output *wlr_output;
|
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct wl_shell_surface *shell_surface;
|
struct wl_shell_surface *shell_surface;
|
||||||
struct wl_egl_window *egl_window;
|
struct wl_egl_window *egl_window;
|
||||||
@ -47,12 +49,12 @@ struct wlr_input_device_state {
|
|||||||
|
|
||||||
struct wlr_pointer_state {
|
struct wlr_pointer_state {
|
||||||
enum wlr_axis_source axis_source;
|
enum wlr_axis_source axis_source;
|
||||||
struct wlr_output *current_output;
|
struct wlr_wl_backend_output *current_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_wl_registry_poll(struct wlr_wl_backend *backend);
|
void wlr_wl_registry_poll(struct wlr_wl_backend *backend);
|
||||||
struct wlr_output *wlr_wl_output_for_surface(struct wlr_wl_backend *backend,
|
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
|
||||||
struct wl_surface *surface);
|
struct wlr_wl_backend *backend, struct wl_surface *surface);
|
||||||
|
|
||||||
extern const struct wl_seat_listener seat_listener;
|
extern const struct wl_seat_listener seat_listener;
|
||||||
|
|
||||||
|
@ -4,21 +4,19 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct wlr_output_impl {
|
struct wlr_output_impl {
|
||||||
void (*enable)(struct wlr_output_state *state, bool enable);
|
void (*enable)(struct wlr_output *output, bool enable);
|
||||||
bool (*set_mode)(struct wlr_output_state *state,
|
bool (*set_mode)(struct wlr_output *output, struct wlr_output_mode *mode);
|
||||||
struct wlr_output_mode *mode);
|
void (*transform)(struct wlr_output *output,
|
||||||
void (*transform)(struct wlr_output_state *state,
|
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
bool (*set_cursor)(struct wlr_output_state *state,
|
bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height);
|
int32_t stride, uint32_t width, uint32_t height);
|
||||||
bool (*move_cursor)(struct wlr_output_state *state, int x, int y);
|
bool (*move_cursor)(struct wlr_output *output, int x, int y);
|
||||||
void (*destroy)(struct wlr_output_state *state);
|
void (*destroy)(struct wlr_output *output);
|
||||||
void (*make_current)(struct wlr_output_state *state);
|
void (*make_current)(struct wlr_output *output);
|
||||||
void (*swap_buffers)(struct wlr_output_state *state);
|
void (*swap_buffers)(struct wlr_output *output);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
|
void wlr_output_init(struct wlr_output *output, const struct wlr_output_impl *impl);
|
||||||
struct wlr_output_state *state);
|
|
||||||
void wlr_output_free(struct wlr_output *output);
|
void wlr_output_free(struct wlr_output *output);
|
||||||
void wlr_output_update_matrix(struct wlr_output *output);
|
void wlr_output_update_matrix(struct wlr_output *output);
|
||||||
struct wl_global *wlr_output_create_global(
|
struct wl_global *wlr_output_create_global(
|
||||||
|
@ -14,12 +14,10 @@ struct wlr_output_mode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output_impl;
|
struct wlr_output_impl;
|
||||||
struct wlr_output_state;
|
|
||||||
|
|
||||||
struct wlr_output {
|
struct wlr_output {
|
||||||
const struct wlr_output_impl *impl;
|
const struct wlr_output_impl *impl;
|
||||||
struct wlr_output_state *state;
|
|
||||||
void *user_data;
|
|
||||||
struct wl_global *wl_global;
|
struct wl_global *wl_global;
|
||||||
struct wl_list wl_resources;
|
struct wl_list wl_resources;
|
||||||
|
|
||||||
|
@ -92,27 +92,24 @@ void wlr_output_update_matrix(struct wlr_output *output) {
|
|||||||
wlr_matrix_texture(output->transform_matrix, output->width, output->height, output->transform);
|
wlr_matrix_texture(output->transform_matrix, output->width, output->height, output->transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
|
void wlr_output_init(struct wlr_output *output,
|
||||||
struct wlr_output_state *state) {
|
const struct wlr_output_impl *impl) {
|
||||||
struct wlr_output *output = calloc(1, sizeof(struct wlr_output));
|
|
||||||
output->impl = impl;
|
output->impl = impl;
|
||||||
output->state = state;
|
|
||||||
output->modes = list_create();
|
output->modes = list_create();
|
||||||
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
wl_signal_init(&output->events.frame);
|
wl_signal_init(&output->events.frame);
|
||||||
wl_signal_init(&output->events.resolution);
|
wl_signal_init(&output->events.resolution);
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_enable(struct wlr_output *output, bool enable) {
|
void wlr_output_enable(struct wlr_output *output, bool enable) {
|
||||||
output->impl->enable(output->state, enable);
|
output->impl->enable(output, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode) {
|
bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode) {
|
||||||
if (!output->impl || !output->impl->set_mode) {
|
if (!output->impl || !output->impl->set_mode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool result = output->impl->set_mode(output->state, mode);
|
bool result = output->impl->set_mode(output, mode);
|
||||||
if (result) {
|
if (result) {
|
||||||
wlr_output_update_matrix(output);
|
wlr_output_update_matrix(output);
|
||||||
}
|
}
|
||||||
@ -121,13 +118,13 @@ bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode
|
|||||||
|
|
||||||
void wlr_output_transform(struct wlr_output *output,
|
void wlr_output_transform(struct wlr_output *output,
|
||||||
enum wl_output_transform transform) {
|
enum wl_output_transform transform) {
|
||||||
output->impl->transform(output->state, transform);
|
output->impl->transform(output, transform);
|
||||||
wlr_output_update_matrix(output);
|
wlr_output_update_matrix(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_set_cursor(struct wlr_output *output,
|
bool wlr_output_set_cursor(struct wlr_output *output,
|
||||||
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height) {
|
||||||
if (output->impl->set_cursor && output->impl->set_cursor(output->state, buf,
|
if (output->impl->set_cursor && output->impl->set_cursor(output, buf,
|
||||||
stride, width, height)) {
|
stride, width, height)) {
|
||||||
output->cursor.is_sw = false;
|
output->cursor.is_sw = false;
|
||||||
return true;
|
return true;
|
||||||
@ -167,7 +164,7 @@ bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return output->impl->move_cursor(output->state, x, y);
|
return output->impl->move_cursor(output, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_destroy(struct wlr_output *output) {
|
void wlr_output_destroy(struct wlr_output *output) {
|
||||||
@ -175,10 +172,10 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->impl->destroy(output->state);
|
output->impl->destroy(output);
|
||||||
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
|
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
|
||||||
struct wlr_output_mode *mode = output->modes->items[i];
|
struct wlr_output_mode *mode = output->modes->items[i];
|
||||||
free(mode->state);
|
free(mode);
|
||||||
free(mode);
|
free(mode);
|
||||||
}
|
}
|
||||||
list_free(output->modes);
|
list_free(output->modes);
|
||||||
@ -198,7 +195,7 @@ void wlr_output_effective_resolution(struct wlr_output *output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_make_current(struct wlr_output *output) {
|
void wlr_output_make_current(struct wlr_output *output) {
|
||||||
output->impl->make_current(output->state);
|
output->impl->make_current(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_output_swap_buffers(struct wlr_output *output) {
|
void wlr_output_swap_buffers(struct wlr_output *output) {
|
||||||
@ -212,5 +209,5 @@ void wlr_output_swap_buffers(struct wlr_output *output) {
|
|||||||
wlr_render_with_matrix(output->cursor.renderer, output->cursor.texture, &matrix);
|
wlr_render_with_matrix(output->cursor.renderer, output->cursor.texture, &matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
output->impl->swap_buffers(output->state);
|
output->impl->swap_buffers(output);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user