From: Alexandros Frantzis alexandros.frantzis@collabora.com
The reporting of non-current wl_output modes is deprecated, and most compositors now report only the current display mode. --- dlls/winewayland.drv/display.c | 42 ++++------ dlls/winewayland.drv/wayland_output.c | 116 ++++---------------------- dlls/winewayland.drv/waylanddrv.h | 5 +- 3 files changed, 32 insertions(+), 131 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index a1dc925a183..9e43392bb20 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -73,10 +73,10 @@ static int output_info_cmp_primary_x_y(const void *va, const void *vb)
static inline BOOL output_info_overlap(struct output_info *a, struct output_info *b) { - return b->x < a->x + a->output->current_mode->width && - b->x + b->output->current_mode->width > a->x && - b->y < a->y + a->output->current_mode->height && - b->y + b->output->current_mode->height > a->y; + return b->x < a->x + a->output->mode.width && + b->x + b->output->mode.width > a->x && + b->y < a->y + a->output->mode.height && + b->y + b->output->mode.height > a->y; }
/* Map a point to one of the four quadrants of our 2d coordinate space: @@ -158,16 +158,16 @@ static BOOL output_info_array_resolve_overlaps(struct wl_array *output_info_arra rel_x = (move->output->logical_x - anchor->output->logical_x + (x_use_end ? move->output->logical_w : 0)) / (double)anchor->output->logical_w; - move->x = anchor->x + anchor->output->current_mode->width * rel_x - - (x_use_end ? move->output->current_mode->width : 0); + move->x = anchor->x + anchor->output->mode.width * rel_x - + (x_use_end ? move->output->mode.width : 0);
/* Similarly for the Y axis. */ y_use_end = move->output->logical_y < anchor->output->logical_y; rel_y = (move->output->logical_y - anchor->output->logical_y + (y_use_end ? move->output->logical_h : 0)) / (double)anchor->output->logical_h; - move->y = anchor->y + anchor->output->current_mode->height * rel_y - - (y_use_end ? move->output->current_mode->height : 0); + move->y = anchor->y + anchor->output->mode.height * rel_y - + (y_use_end ? move->output->mode.height : 0); } }
@@ -223,8 +223,8 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m struct gdi_monitor monitor = {0};
SetRect(&monitor.rc_monitor, output_info->x, output_info->y, - output_info->x + output_info->output->current_mode->width, - output_info->y + output_info->output->current_mode->height); + output_info->x + output_info->output->mode.width, + output_info->y + output_info->output->mode.height);
/* We don't have a direct way to get the work area in Wayland. */ monitor.rc_work = monitor.rc_monitor; @@ -250,28 +250,14 @@ static void populate_devmode(struct wayland_output_mode *output_mode, DEVMODEW * static void wayland_add_device_modes(const struct gdi_device_manager *device_manager, void *param, struct output_info *output_info) { - DEVMODEW *modes, current = {.dmSize = sizeof(current)}; - struct wayland_output_mode *output_mode; - int modes_count = 0; + DEVMODEW current = {.dmSize = sizeof(current)};
- if (!(modes = malloc(output_info->output->modes_count * sizeof(*modes)))) - return; - - populate_devmode(output_info->output->current_mode, ¤t); + populate_devmode(&output_info->output->mode, ¤t); current.dmFields |= DM_POSITION; current.dmPosition.x = output_info->x; current.dmPosition.y = output_info->y;
- RB_FOR_EACH_ENTRY(output_mode, &output_info->output->modes, - struct wayland_output_mode, entry) - { - DEVMODEW mode = {.dmSize = sizeof(mode)}; - populate_devmode(output_mode, &mode); - modes[modes_count++] = mode; - } - - device_manager->add_modes(¤t, modes_count, modes, param); - free(modes); + device_manager->add_modes(¤t, 0, NULL, param); }
/*********************************************************************** @@ -297,7 +283,7 @@ UINT WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
wl_list_for_each(output, &process_wayland.output_list, link) { - if (!output->current.current_mode) continue; + if (!output->current.mode.width || !output->current.mode.height) continue; output_info = wl_array_add(&output_info_array, sizeof(*output_info)); if (output_info) output_info->output = &output->current; else ERR("Failed to allocate space for output_info\n"); diff --git a/dlls/winewayland.drv/wayland_output.c b/dlls/winewayland.drv/wayland_output.c index f76881a1770..656e59edbec 100644 --- a/dlls/winewayland.drv/wayland_output.c +++ b/dlls/winewayland.drv/wayland_output.c @@ -35,7 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv); static const int32_t default_refresh = 60000; static uint32_t next_output_id = 0;
-#define WAYLAND_OUTPUT_CHANGED_MODES 0x01 +#define WAYLAND_OUTPUT_CHANGED_MODE 0x01 #define WAYLAND_OUTPUT_CHANGED_NAME 0x02 #define WAYLAND_OUTPUT_CHANGED_LOGICAL_XY 0x04 #define WAYLAND_OUTPUT_CHANGED_LOGICAL_WH 0x08 @@ -44,65 +44,6 @@ static uint32_t next_output_id = 0; * Output handling */
-/* Compare a mode rb_tree key with the provided mode rb_entry and return -1 if - * the key compares less than the entry, 0 if the key compares equal to the - * entry, and 1 if the key compares greater than the entry. - * - * The comparison is based on comparing the width, height and refresh in that - * order. */ -static int wayland_output_mode_cmp_rb(const void *key, - const struct rb_entry *entry) -{ - const struct wayland_output_mode *key_mode = key; - const struct wayland_output_mode *entry_mode = - RB_ENTRY_VALUE(entry, const struct wayland_output_mode, entry); - - if (key_mode->width < entry_mode->width) return -1; - if (key_mode->width > entry_mode->width) return 1; - if (key_mode->height < entry_mode->height) return -1; - if (key_mode->height > entry_mode->height) return 1; - if (key_mode->refresh < entry_mode->refresh) return -1; - if (key_mode->refresh > entry_mode->refresh) return 1; - - return 0; -} - -static void wayland_output_state_add_mode(struct wayland_output_state *state, - int32_t width, int32_t height, - int32_t refresh, BOOL current) -{ - struct rb_entry *mode_entry; - struct wayland_output_mode *mode; - struct wayland_output_mode key = - { - .width = width, - .height = height, - .refresh = refresh, - }; - - mode_entry = rb_get(&state->modes, &key); - if (mode_entry) - { - mode = RB_ENTRY_VALUE(mode_entry, struct wayland_output_mode, entry); - } - else - { - mode = calloc(1, sizeof(*mode)); - if (!mode) - { - ERR("Failed to allocate space for wayland_output_mode\n"); - return; - } - mode->width = width; - mode->height = height; - mode->refresh = refresh; - rb_put(&state->modes, mode, &mode->entry); - state->modes_count++; - } - - if (current) state->current_mode = mode; -} - static void maybe_init_display_devices(void) { DWORD desktop_pid = 0; @@ -123,30 +64,13 @@ static void maybe_init_display_devices(void) NtUserPostMessage(desktop_hwnd, WM_WAYLAND_INIT_DISPLAY_DEVICES, 0, 0); }
-static void wayland_output_mode_free_rb(struct rb_entry *entry, void *ctx) -{ - free(RB_ENTRY_VALUE(entry, struct wayland_output_mode, entry)); -} - static void wayland_output_done(struct wayland_output *output) { - struct wayland_output_mode *mode; - /* Update current state from pending state. */ pthread_mutex_lock(&process_wayland.output_mutex);
- if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_MODES) - { - RB_FOR_EACH_ENTRY(mode, &output->pending.modes, struct wayland_output_mode, entry) - { - wayland_output_state_add_mode(&output->current, - mode->width, mode->height, mode->refresh, - mode == output->pending.current_mode); - } - rb_destroy(&output->pending.modes, wayland_output_mode_free_rb, NULL); - rb_init(&output->pending.modes, wayland_output_mode_cmp_rb); - output->pending.modes_count = 0; - } + if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_MODE) + output->current.mode = output->pending.mode;
if (output->pending_flags & WAYLAND_OUTPUT_CHANGED_NAME) { @@ -171,24 +95,19 @@ static void wayland_output_done(struct wayland_output *output)
/* Ensure the logical dimensions have sane values. */ if ((!output->current.logical_w || !output->current.logical_h) && - output->current.current_mode) + output->current.mode.width && output->current.mode.height) { - output->current.logical_w = output->current.current_mode->width; - output->current.logical_h = output->current.current_mode->height; + output->current.logical_w = output->current.mode.width; + output->current.logical_h = output->current.mode.height; }
pthread_mutex_unlock(&process_wayland.output_mutex);
- TRACE("name=%s logical=%d,%d+%dx%d\n", + TRACE("name=%s logical=%d,%d+%dx%d mode=%dx%d@%d\n", output->current.name, output->current.logical_x, output->current.logical_y, - output->current.logical_w, output->current.logical_h); - - RB_FOR_EACH_ENTRY(mode, &output->current.modes, struct wayland_output_mode, entry) - { - TRACE("mode %dx%d @ %d %s\n", - mode->width, mode->height, mode->refresh, - output->current.current_mode == mode ? "*" : ""); - } + output->current.logical_w, output->current.logical_h, + output->current.mode.width, output->current.mode.height, + output->current.mode.refresh);
maybe_init_display_devices(); } @@ -208,13 +127,17 @@ static void output_handle_mode(void *data, struct wl_output *wl_output, { struct wayland_output *output = data;
+ /* Non-current output modes are deprecated. */ + if (!(flags & WL_OUTPUT_MODE_CURRENT)) return; + /* Windows apps don't expect a zero refresh rate, so use a default value. */ if (refresh == 0) refresh = default_refresh;
- wayland_output_state_add_mode(&output->pending, width, height, refresh, - (flags & WL_OUTPUT_MODE_CURRENT)); + output->pending.mode.width = width; + output->pending.mode.height = height; + output->pending.mode.refresh = refresh;
- output->pending_flags |= WAYLAND_OUTPUT_CHANGED_MODES; + output->pending_flags |= WAYLAND_OUTPUT_CHANGED_MODE; }
static void output_handle_done(void *data, struct wl_output *wl_output) @@ -322,10 +245,6 @@ BOOL wayland_output_create(uint32_t id, uint32_t version) wl_output_add_listener(output->wl_output, &output_listener, output);
wl_list_init(&output->link); - rb_init(&output->pending.modes, wayland_output_mode_cmp_rb); - output->pending.modes_count = 0; - rb_init(&output->current.modes, wayland_output_mode_cmp_rb); - output->current.modes_count = 0;
/* Have a fallback while we don't have compositor given name. */ name_len = snprintf(NULL, 0, "WaylandOutput%d", next_output_id); @@ -356,7 +275,6 @@ err:
static void wayland_output_state_deinit(struct wayland_output_state *state) { - rb_destroy(&state->modes, wayland_output_mode_free_rb, NULL); free(state->name); }
diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 7852c23b690..cabb508827c 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -135,7 +135,6 @@ struct wayland
struct wayland_output_mode { - struct rb_entry entry; int32_t width; int32_t height; int32_t refresh; @@ -143,9 +142,7 @@ struct wayland_output_mode
struct wayland_output_state { - int modes_count; - struct rb_tree modes; - struct wayland_output_mode *current_mode; + struct wayland_output_mode mode; char *name; int logical_x, logical_y; int logical_w, logical_h;