[PATCH weston 01/21] libweston: move weston_output::mode_list init to core
Pekka Paalanen
ppaalanen at gmail.com
Fri Sep 22 14:31:09 UTC 2017
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Initialize the list in weston_output_init() instead of doing it
separately in each backend.
One would expect weston_output_init() to initialize all weston_output
members, at least those that are not NULL.
We rely on the set_size() functions to be called only once, as is
assert()'d. If set_size() becomes callable multiple times, this patch
will force them to be fixed to properly manage the mode list instead of
losing all members.
compositor-wayland.c is strange in
wayland_output_create_for_parent_output(): it first called
wayland_output_set_size() that initialized the mode list with a single
mode manufactured from width and height and set that mode as current.
Then it continued to reset the mode list and adding the list of modes
from the parent output, leaving the current mode left to point to a mode
struct that is no longer in the mode list and with a broken 'link'
element. This patch changes things such that the manufactured mode is
left in the list, and the parent mode list is added. This is probably
not quite right either.
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
libweston/compositor-drm.c | 2 --
libweston/compositor-fbdev.c | 1 -
libweston/compositor-headless.c | 1 -
libweston/compositor-rdp.c | 1 -
libweston/compositor-wayland.c | 2 --
libweston/compositor-x11.c | 1 -
libweston/compositor.c | 1 +
7 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 1a961389..ea2c6991 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3364,8 +3364,6 @@ create_output_for_connector(struct drm_backend *b,
weston_output_init(&output->base, b->compositor);
- wl_list_init(&output->base.mode_list);
-
for (i = 0; i < output->connector->count_modes; i++) {
drm_mode = drm_output_add_mode(output, &output->connector->modes[i]);
if (!drm_mode) {
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 6a305385..b3ce0588 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -523,7 +523,6 @@ fbdev_output_create(struct fbdev_backend *backend,
output->mode.width = output->fb_info.x_resolution;
output->mode.height = output->fb_info.y_resolution;
output->mode.refresh = output->fb_info.refresh_rate;
- wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
index 9e42e7f6..5425ad5b 100644
--- a/libweston/compositor-headless.c
+++ b/libweston/compositor-headless.c
@@ -201,7 +201,6 @@ headless_output_set_size(struct weston_output *base,
output->mode.width = output_width;
output->mode.height = output_height;
output->mode.refresh = 60000;
- wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 091472b0..6886038b 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -484,7 +484,6 @@ rdp_output_set_size(struct weston_output *base,
assert(!output->base.current_mode);
wl_list_init(&output->peers);
- wl_list_init(&output->base.mode_list);
initMode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
initMode.width = width;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 77a73689..625a352c 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1323,7 +1323,6 @@ wayland_output_set_size(struct weston_output *base, int width, int height)
output->mode.height = output_height;
output->mode.refresh = 60000;
output->scale = output->base.scale;
- wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
@@ -1374,7 +1373,6 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
output->base.make = poutput->physical.make;
output->base.model = poutput->physical.model;
- wl_list_init(&output->base.mode_list);
wl_list_insert_list(&output->base.mode_list, &poutput->mode_list);
wl_list_init(&poutput->mode_list);
diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 02cdf3ea..8cf512fe 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -999,7 +999,6 @@ x11_output_set_size(struct weston_output *base, int width, int height)
output->mode.height = output_height;
output->mode.refresh = 60000;
output->scale = output->base.scale;
- wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 813b6634..ae839b87 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4711,6 +4711,7 @@ weston_output_init(struct weston_output *output,
pixman_region32_init(&output->previous_damage);
pixman_region32_init(&output->region);
+ wl_list_init(&output->mode_list);
}
/** Adds weston_output object to pending output list.
--
2.13.5
More information about the wayland-devel
mailing list