From ce67045211a2ee560fe33fb3769d025dfc2ddc92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 16 Oct 2025 12:01:17 +0200 Subject: [PATCH] xwayland: Use logical_ prefix for logical coordinate system values Inspired by https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/878 . Part-of: --- hw/xwayland/xwayland-output.c | 60 +++++++++++++++++----------------- hw/xwayland/xwayland-output.h | 4 +-- hw/xwayland/xwayland-screen.c | 2 +- hw/xwayland/xwayland-vidmode.c | 6 ++-- hw/xwayland/xwayland-window.c | 14 ++++---- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index d41b19e58..0b7bfa97f 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -102,8 +102,8 @@ output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, /* Apply the change from wl_output only if xdg-output is not supported */ if (!xwl_output->xdg_output) { - xwl_output->x = x; - xwl_output->y = y; + xwl_output->logical_x = x; + xwl_output->logical_y = y; } xwl_output->rotation = wl_transform_to_xrandr(transform); } @@ -119,8 +119,8 @@ output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, /* Apply the change from wl_output only if xdg-output is not supported */ if (!xwl_output->xdg_output) { - xwl_output->width = width; - xwl_output->height = height; + xwl_output->logical_w = width; + xwl_output->logical_h = height; } xwl_output->refresh = refresh; } @@ -133,23 +133,23 @@ output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, static inline void output_get_new_size(struct xwl_output *xwl_output, int *width, int *height) { - int output_width, output_height; + int logical_width, logical_height; /* When we have xdg-output support the stored size is already rotated. */ if (xwl_output->xdg_output || (xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180))) { - output_width = xwl_output->width; - output_height = xwl_output->height; + logical_width = xwl_output->logical_w; + logical_height = xwl_output->logical_h; } else { - output_width = xwl_output->height; - output_height = xwl_output->width; + logical_width = xwl_output->logical_h; + logical_height = xwl_output->logical_w; } - if (*width < xwl_output->x + output_width) - *width = xwl_output->x + output_width; + if (*width < xwl_output->logical_x + logical_width) + *width = xwl_output->logical_x + logical_width; - if (*height < xwl_output->y + output_height) - *height = xwl_output->y + output_height; + if (*height < xwl_output->logical_y + logical_height) + *height = xwl_output->logical_y + logical_height; } static int @@ -446,8 +446,8 @@ xwl_output_randr_emu_prop(struct xwl_screen *xwl_screen, ClientPtr client, if (!emulated_mode) continue; - prop->rects[index][0] = xwl_output->x; - prop->rects[index][1] = xwl_output->y; + prop->rects[index][0] = xwl_output->logical_x; + prop->rects[index][1] = xwl_output->logical_y; prop->rects[index][2] = emulated_mode->width; prop->rects[index][3] = emulated_mode->height; index++; @@ -629,8 +629,7 @@ apply_output_change(struct xwl_output *xwl_output) { struct xwl_screen *xwl_screen = xwl_output->xwl_screen; struct xwl_output *it; - int mode_width, mode_height, count; - int width = 0, height = 0, has_this_output = 0; + int logical_width, logical_height, count, has_this_output = 0; RRModePtr *randr_modes; /* Clear out the "done" received flags */ @@ -642,18 +641,18 @@ apply_output_change(struct xwl_output *xwl_output) */ if (xwl_output->xdg_output == NULL || xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180)) { - mode_width = xwl_output->width; - mode_height = xwl_output->height; + logical_width = xwl_output->logical_w; + logical_height = xwl_output->logical_h; } else { - mode_width = xwl_output->height; - mode_height = xwl_output->width; + logical_width = xwl_output->logical_h; + logical_height = xwl_output->logical_w; } if (xwl_output->randr_output) { /* Build a fresh modes array using the current refresh rate */ - randr_modes = output_get_rr_modes(xwl_output, mode_width, mode_height, &count); + randr_modes = output_get_rr_modes(xwl_output, logical_width, logical_height, &count); RROutputSetModes(xwl_output->randr_output, randr_modes, count, 1); RRCrtcNotify(xwl_output->randr_crtc, randr_modes[0], - xwl_output->x, xwl_output->y, + xwl_output->logical_x, xwl_output->logical_y, xwl_output->rotation, NULL, 1, &xwl_output->randr_output); /* RROutputSetModes takes ownership of the passed in modes, so we only * have to free the pointer array. @@ -661,6 +660,7 @@ apply_output_change(struct xwl_output *xwl_output) free(randr_modes); } + logical_width = logical_height = 0; xorg_list_for_each_entry(it, &xwl_screen->output_list, link) { /* output done event is sent even when some property * of output is changed. That means that we may already @@ -669,20 +669,20 @@ apply_output_change(struct xwl_output *xwl_output) if (it == xwl_output) has_this_output = 1; - output_get_new_size(it, &width, &height); + output_get_new_size(it, &logical_width, &logical_height); } if (!has_this_output) { xorg_list_append(&xwl_output->link, &xwl_screen->output_list); /* we did not check this output for new screen size, do it now */ - output_get_new_size(xwl_output, &width, &height); + output_get_new_size(xwl_output, &logical_width, &logical_height); --xwl_screen->expecting_event; } if (xwl_screen->fixed_output == NULL) - update_screen_size(xwl_screen, width, height); + update_screen_size(xwl_screen, logical_width, logical_height); else RRTellChanged(xwl_screen->screen); @@ -788,8 +788,8 @@ xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output { struct xwl_output *xwl_output = data; - xwl_output->x = x; - xwl_output->y = y; + xwl_output->logical_x = x; + xwl_output->logical_y = y; } static void @@ -798,8 +798,8 @@ xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, { struct xwl_output *xwl_output = data; - xwl_output->width = width; - xwl_output->height = height; + xwl_output->logical_w = width; + xwl_output->logical_h = height; } static void diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h index 0d36f459a..17bdf94d9 100644 --- a/hw/xwayland/xwayland-output.h +++ b/hw/xwayland/xwayland-output.h @@ -56,8 +56,8 @@ struct xwl_output { struct wl_output *output; struct zxdg_output_v1 *xdg_output; uint32_t server_output_id; - int32_t x, y, width, height, refresh, scale; - int32_t mode_width, mode_height; + int32_t logical_x, logical_y, logical_w, logical_h; + int32_t mode_width, mode_height, refresh, scale; double xscale; /* Effective scale, can be fractional */ Rotation rotation; Bool wl_output_done; diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c index 22c500801..44d798609 100644 --- a/hw/xwayland/xwayland-screen.c +++ b/hw/xwayland/xwayland-screen.c @@ -134,7 +134,7 @@ xwl_screen_get_first_output(struct xwl_screen *xwl_screen) struct xwl_output *xwl_output; xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) { - if (xwl_output->x == 0 && xwl_output->y == 0) + if (xwl_output->logical_x == 0 && xwl_output->logical_y == 0) return xwl_output; } diff --git a/hw/xwayland/xwayland-vidmode.c b/hw/xwayland/xwayland-vidmode.c index a4ca0eaf1..cabe1963c 100644 --- a/hw/xwayland/xwayland-vidmode.c +++ b/hw/xwayland/xwayland-vidmode.c @@ -308,7 +308,7 @@ xwlVidModeSetViewPort(ScreenPtr pScreen, int x, int y) return FALSE; /* Support only default viewport */ - return (x == xwl_output->x && y == xwl_output->y); + return (x == xwl_output->logical_x && y == xwl_output->logical_y); } static Bool @@ -321,8 +321,8 @@ xwlVidModeGetViewPort(ScreenPtr pScreen, int *x, int *y) if (xwl_output == NULL) return FALSE; - *x = xwl_output->x; - *y = xwl_output->y; + *x = xwl_output->logical_x; + *y = xwl_output->logical_y; return TRUE; } diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index dac4b4ed6..9dadb5acb 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -462,11 +462,11 @@ xwl_window_enable_viewport_for_output(struct xwl_window *xwl_window, wl_fixed_from_int(width), wl_fixed_from_int(height)); wp_viewport_set_destination(xwl_window->viewport, - xwl_output->width, - xwl_output->height); + xwl_output->logical_w, + xwl_output->logical_h); - xwl_window->viewport_scale_x = (float) width / xwl_output->width; - xwl_window->viewport_scale_y = (float) height / xwl_output->height; + xwl_window->viewport_scale_x = (float) width / xwl_output->logical_w; + xwl_window->viewport_scale_y = (float) height / xwl_output->logical_h; xwl_window_set_input_region(xwl_window, wInputShape(xwl_window->toplevel)); } @@ -524,7 +524,7 @@ is_output_suitable_for_fullscreen(struct xwl_output *xwl_output) if (xwl_output == NULL) return FALSE; - if (xwl_output->width == 0 || xwl_output->height == 0) + if (xwl_output->logical_w == 0 || xwl_output->logical_h == 0) return FALSE; return TRUE; @@ -606,8 +606,8 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window, if (!emulated_mode) continue; - if (drawable->x == xwl_output->x && - drawable->y == xwl_output->y && + if (drawable->x == xwl_output->logical_x && + drawable->y == xwl_output->logical_y && drawable->width == emulated_mode->width && drawable->height == emulated_mode->height) {