compositor-x11: migrate to head-based output API
Follow the standard pattern set by the headless backend which also uses the the window output API. Stops relying on the implicit weston_output::head. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ian Ray <ian.ray@ge.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
parent
2305812296
commit
c900881e09
@ -116,6 +116,10 @@ struct x11_backend {
|
||||
} atom;
|
||||
};
|
||||
|
||||
struct x11_head {
|
||||
struct weston_head base;
|
||||
};
|
||||
|
||||
struct x11_output {
|
||||
struct weston_output base;
|
||||
|
||||
@ -142,6 +146,12 @@ struct window_delete_data {
|
||||
|
||||
struct gl_renderer_interface *gl_renderer;
|
||||
|
||||
static inline struct x11_head *
|
||||
to_x11_head(struct weston_head *base)
|
||||
{
|
||||
return container_of(base, struct x11_head, base);
|
||||
}
|
||||
|
||||
static inline struct x11_output *
|
||||
to_x11_output(struct weston_output *base)
|
||||
{
|
||||
@ -1065,7 +1075,7 @@ x11_output_set_size(struct weston_output *base, int width, int height)
|
||||
{
|
||||
struct x11_output *output = to_x11_output(base);
|
||||
struct x11_backend *b = to_x11_backend(base->compositor);
|
||||
struct weston_head *head = &output->base.head;
|
||||
struct weston_head *head;
|
||||
xcb_screen_t *scrn = b->screen;
|
||||
int output_width, output_height;
|
||||
|
||||
@ -1087,6 +1097,13 @@ x11_output_set_size(struct weston_output *base, int width, int height)
|
||||
return -1;
|
||||
}
|
||||
|
||||
wl_list_for_each(head, &output->base.head_list, output_link) {
|
||||
weston_head_set_monitor_strings(head, "weston-X11", "none", NULL);
|
||||
weston_head_set_physical_size(head,
|
||||
width * scrn->width_in_millimeters / scrn->width_in_pixels,
|
||||
height * scrn->height_in_millimeters / scrn->height_in_pixels);
|
||||
}
|
||||
|
||||
output_width = width * output->base.scale;
|
||||
output_height = height * output->base.scale;
|
||||
|
||||
@ -1104,17 +1121,11 @@ x11_output_set_size(struct weston_output *base, int width, int height)
|
||||
output->base.native_mode = &output->native;
|
||||
output->base.native_scale = output->base.scale;
|
||||
|
||||
weston_head_set_monitor_strings(head, "weston-X11", "none", NULL);
|
||||
weston_head_set_physical_size(head,
|
||||
width * scrn->width_in_millimeters / scrn->width_in_pixels,
|
||||
height * scrn->height_in_millimeters / scrn->height_in_pixels);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
x11_output_create(struct weston_compositor *compositor,
|
||||
const char *name)
|
||||
static struct weston_output *
|
||||
x11_output_create(struct weston_compositor *compositor, const char *name)
|
||||
{
|
||||
struct x11_output *output;
|
||||
|
||||
@ -1122,22 +1133,46 @@ x11_output_create(struct weston_compositor *compositor,
|
||||
assert(name);
|
||||
|
||||
output = zalloc(sizeof *output);
|
||||
if (output == NULL) {
|
||||
perror("zalloc");
|
||||
return -1;
|
||||
}
|
||||
if (!output)
|
||||
return NULL;
|
||||
|
||||
weston_output_init(&output->base, compositor, name);
|
||||
|
||||
output->base.destroy = x11_output_destroy;
|
||||
output->base.disable = x11_output_disable;
|
||||
output->base.enable = x11_output_enable;
|
||||
output->base.attach_head = NULL;
|
||||
|
||||
weston_compositor_add_pending_output(&output->base, compositor);
|
||||
|
||||
return &output->base;
|
||||
}
|
||||
|
||||
static int
|
||||
x11_head_create(struct weston_compositor *compositor, const char *name)
|
||||
{
|
||||
struct x11_head *head;
|
||||
|
||||
assert(name);
|
||||
|
||||
head = zalloc(sizeof *head);
|
||||
if (!head)
|
||||
return -1;
|
||||
|
||||
weston_head_init(&head->base, name);
|
||||
weston_head_set_connection_status(&head->base, true);
|
||||
weston_compositor_add_head(compositor, &head->base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_head_destroy(struct x11_head *head)
|
||||
{
|
||||
weston_head_release(&head->base);
|
||||
free(head);
|
||||
}
|
||||
|
||||
static struct x11_output *
|
||||
x11_backend_find_output(struct x11_backend *b, xcb_window_t window)
|
||||
{
|
||||
@ -1745,12 +1780,16 @@ static void
|
||||
x11_destroy(struct weston_compositor *ec)
|
||||
{
|
||||
struct x11_backend *backend = to_x11_backend(ec);
|
||||
struct weston_head *base, *next;
|
||||
|
||||
wl_event_source_remove(backend->xcb_source);
|
||||
x11_input_destroy(backend);
|
||||
|
||||
weston_compositor_shutdown(ec); /* destroys outputs, too */
|
||||
|
||||
wl_list_for_each_safe(base, next, &ec->head_list, compositor_link)
|
||||
x11_head_destroy(to_x11_head(base));
|
||||
|
||||
XCloseDisplay(backend->dpy);
|
||||
free(backend);
|
||||
}
|
||||
@ -1774,7 +1813,7 @@ init_gl_renderer(struct x11_backend *b)
|
||||
|
||||
static const struct weston_windowed_output_api api = {
|
||||
x11_output_set_size,
|
||||
x11_output_create,
|
||||
x11_head_create,
|
||||
};
|
||||
|
||||
static struct x11_backend *
|
||||
@ -1833,6 +1872,7 @@ x11_backend_create(struct weston_compositor *compositor,
|
||||
weston_log("Using %s renderer\n", config->use_pixman ? "pixman" : "gl");
|
||||
|
||||
b->base.destroy = x11_destroy;
|
||||
b->base.create_output = x11_output_create;
|
||||
|
||||
if (x11_input_create(b, config->no_input) < 0) {
|
||||
weston_log("Failed to create X11 input\n");
|
||||
|
Loading…
Reference in New Issue
Block a user