summaryrefslogtreecommitdiff
path: root/hw/xwayland
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2023-11-02 11:05:55 +0100
committerOlivier Fourdan <ofourdan@redhat.com>2024-03-20 09:05:36 +0100
commit290ae87c02abf5070422bb50af948402345ab4e1 (patch)
tree0bc881d0ffba6aa3734c759fe6e7dd4b429d8096 /hw/xwayland
parent4248bfb0da6e14c176acd0750393c66261d6f4c3 (diff)
xwayland: Update the scale based on enter/leave events
Recompute the window scale each time the window enters or leaves an output. 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>
Diffstat (limited to 'hw/xwayland')
-rw-r--r--hw/xwayland/xwayland-window.c30
-rw-r--r--hw/xwayland/xwayland-window.h2
2 files changed, 30 insertions, 2 deletions
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index b439c3a47..626a5d22d 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -795,6 +795,12 @@ static const struct xdg_surface_listener xdg_surface_listener = {
};
static void
+xwl_window_update_surface_scale(struct xwl_window *xwl_window)
+{
+ xwl_window->surface_scale = xwl_window_get_max_output_scale(xwl_window);
+}
+
+static void
xwl_window_enter_output(struct xwl_window *xwl_window, struct xwl_output *xwl_output)
{
struct xwl_window_output *window_output;
@@ -828,6 +834,22 @@ xwl_window_free_outputs(struct xwl_window *xwl_window)
}
}
+int
+xwl_window_get_max_output_scale(struct xwl_window *xwl_window)
+{
+ struct xwl_window_output *window_output;
+ struct xwl_output *xwl_output;
+ int scale = 1;
+
+ xorg_list_for_each_entry(window_output, &xwl_window->xwl_output_list, link) {
+ xwl_output = window_output->xwl_output;
+ if (xwl_output->scale > scale)
+ scale = xwl_output->scale;
+ }
+
+ return scale;
+}
+
static void
xwl_window_surface_enter(void *data,
struct wl_surface *wl_surface,
@@ -837,8 +859,10 @@ xwl_window_surface_enter(void *data,
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
struct xwl_output *xwl_output = xwl_output_from_wl_output(xwl_screen, wl_output);
- if (xwl_output)
+ if (xwl_output) {
xwl_window_enter_output(xwl_window, xwl_output);
+ xwl_window_update_surface_scale(xwl_window);
+ }
if (xwl_window->wl_output != wl_output) {
xwl_window->wl_output = wl_output;
@@ -857,8 +881,10 @@ xwl_window_surface_leave(void *data,
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
struct xwl_output *xwl_output = xwl_output_from_wl_output(xwl_screen, wl_output);
- if (xwl_output)
+ if (xwl_output) {
xwl_window_leave_output(xwl_window, xwl_output);
+ xwl_window_update_surface_scale(xwl_window);
+ }
if (xwl_window->wl_output == wl_output)
xwl_window->wl_output = NULL;
diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h
index 0e45f08d2..03b4ad249 100644
--- a/hw/xwayland/xwayland-window.h
+++ b/hw/xwayland/xwayland-window.h
@@ -59,6 +59,7 @@ struct xwl_window {
struct wl_surface *surface;
struct wp_viewport *viewport;
float viewport_scale_x, viewport_scale_y;
+ int surface_scale;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
WindowPtr window;
@@ -100,6 +101,7 @@ void xwl_window_set_window_pixmap(WindowPtr window, PixmapPtr pixmap);
void xwl_window_leave_output(struct xwl_window *xwl_window,
struct xwl_output *xwl_output);
+int xwl_window_get_max_output_scale(struct xwl_window *xwl_window);
Bool xwl_realize_window(WindowPtr window);
Bool xwl_unrealize_window(WindowPtr window);
Bool xwl_change_window_attributes(WindowPtr window, unsigned long mask);