libweston: Keep a local copy of native_mode

This avoids dereferencing a possible stale pointer, and allows
retrieving the modeline/refresh later on when one needs to retrieve
those values. This is a temporary band-aid.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-08-12 14:53:09 +03:00 committed by Derek Foreman
parent 3842c1c737
commit c4eb15d453
2 changed files with 15 additions and 0 deletions

View File

@ -624,6 +624,15 @@ struct weston_output {
struct weston_mode *native_mode;
struct weston_mode *current_mode;
struct weston_mode *original_mode;
/* FIXME: keep a local copy for native_mode */
struct {
uint32_t flags;
enum weston_mode_aspect_ratio aspect_ratio;
int32_t width;
int32_t height;
uint32_t refresh;
} native_mode_copy;
struct wl_list mode_list;
struct wl_list head_list; /**< List of driven weston_heads */

View File

@ -555,6 +555,12 @@ weston_output_mode_set_native(struct weston_output *output,
output->native_mode = mode;
output->native_scale = scale;
output->native_mode_copy.width = mode->width;
output->native_mode_copy.height = mode->height;
output->native_mode_copy.flags = mode->flags;
output->native_mode_copy.aspect_ratio = mode->aspect_ratio;
output->native_mode_copy.refresh = mode->refresh;
weston_mode_switch_finish(output, mode_changed, scale_changed);
if (mode_changed || scale_changed) {