xwayland: Always set the viewport scale factor

When the viewport is disabled, set the scale x/y back to 1.0 so that we
can apply the scale factor regardless of the viewport being enabled.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
This commit is contained in:
Olivier Fourdan 2023-11-27 15:02:08 +01:00
parent 96fd7cc8c9
commit 3ea36e5214
2 changed files with 6 additions and 4 deletions

View File

@ -663,10 +663,8 @@ dispatch_absolute_motion(struct xwl_seat *xwl_seat)
event_x *= xwl_screen->global_surface_scale; event_x *= xwl_screen->global_surface_scale;
event_y *= xwl_screen->global_surface_scale; event_y *= xwl_screen->global_surface_scale;
if (xwl_window_has_viewport_enabled(xwl_seat->focus_window)) {
event_x *= xwl_seat->focus_window->viewport_scale_x; event_x *= xwl_seat->focus_window->viewport_scale_x;
event_y *= xwl_seat->focus_window->viewport_scale_y; event_y *= xwl_seat->focus_window->viewport_scale_y;
}
x = drawable_x + event_x; x = drawable_x + event_x;
y = drawable_y + event_y; y = drawable_y + event_y;

View File

@ -260,6 +260,8 @@ xwl_window_disable_viewport(struct xwl_window *xwl_window)
DebugF("XWAYLAND: disabling viewport\n"); DebugF("XWAYLAND: disabling viewport\n");
wp_viewport_destroy(xwl_window->viewport); wp_viewport_destroy(xwl_window->viewport);
xwl_window->viewport = NULL; xwl_window->viewport = NULL;
xwl_window->viewport_scale_x = 1.0;
xwl_window->viewport_scale_y = 1.0;
} }
static void static void
@ -977,6 +979,8 @@ ensure_surface_for_window(WindowPtr window)
xwl_window->xwl_screen = xwl_screen; xwl_window->xwl_screen = xwl_screen;
xwl_window->window = window; xwl_window->window = window;
xwl_window->viewport_scale_x = 1.0;
xwl_window->viewport_scale_y = 1.0;
xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor); xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor);
if (xwl_window->surface == NULL) { if (xwl_window->surface == NULL) {
ErrorF("wl_display_create_surface failed\n"); ErrorF("wl_display_create_surface failed\n");