diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2023-11-02 10:25:46 +0100 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2024-03-20 09:05:36 +0100 |
commit | 54f8fc409091ea3b3466cbf948a53194aaa26aad (patch) | |
tree | e2bed5a1ce4b11c958930e3e660f19d4522377e8 /hw/xwayland/xwayland-cursor.c | |
parent | b678297c53b081d42cb19fabc65d13202ad5494e (diff) |
xwayland: Account for the scale factor
Apply the scale factor to the root window and adjust the coordinates and
hotspot location for cursors.
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/xwayland-cursor.c')
-rw-r--r-- | hw/xwayland/xwayland-cursor.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c index bd94b0cfb..9ee427063 100644 --- a/hw/xwayland/xwayland-cursor.c +++ b/hw/xwayland/xwayland-cursor.c @@ -156,6 +156,7 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat, struct xwl_cursor *xwl_cursor, PixmapPtr pixmap) { struct wl_buffer *buffer; + struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; buffer = xwl_shm_pixmap_get_wl_buffer(pixmap); if (!buffer) { @@ -164,7 +165,8 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat, } wl_surface_attach(xwl_cursor->surface, buffer, 0, 0); - xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0, + wl_surface_set_buffer_scale(xwl_cursor->surface, xwl_screen->global_surface_scale); + xwl_surface_damage(xwl_screen, xwl_cursor->surface, 0, 0, xwl_seat->x_cursor->bits->width, xwl_seat->x_cursor->bits->height); @@ -196,8 +198,10 @@ void xwl_seat_set_cursor(struct xwl_seat *xwl_seat) { struct xwl_cursor *xwl_cursor = &xwl_seat->cursor; + struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; PixmapPtr pixmap; CursorPtr cursor; + int xhot, yhot; if (!xwl_seat->wl_pointer) return; @@ -222,11 +226,14 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat) xwl_cursor_copy_bits_to_pixmap(cursor, pixmap); + xhot = xwl_seat->x_cursor->bits->xhot / xwl_screen->global_surface_scale; + yhot = xwl_seat->x_cursor->bits->yhot / xwl_screen->global_surface_scale; + wl_pointer_set_cursor(xwl_seat->wl_pointer, xwl_seat->pointer_enter_serial, xwl_cursor->surface, - xwl_seat->x_cursor->bits->xhot, - xwl_seat->x_cursor->bits->yhot); + xhot, + yhot); xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap); } @@ -235,9 +242,11 @@ void xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool) { struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; struct xwl_cursor *xwl_cursor = &xwl_tablet_tool->cursor; PixmapPtr pixmap; CursorPtr cursor; + int xhot, yhot; if (!xwl_seat->x_cursor) { zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool, @@ -260,11 +269,14 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool) xwl_cursor_copy_bits_to_pixmap(cursor, pixmap); + xhot = xwl_seat->x_cursor->bits->xhot / xwl_screen->global_surface_scale; + yhot = xwl_seat->x_cursor->bits->yhot / xwl_screen->global_surface_scale; + zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool, xwl_tablet_tool->proximity_in_serial, xwl_cursor->surface, - xwl_seat->x_cursor->bits->xhot, - xwl_seat->x_cursor->bits->yhot); + xhot, + yhot); xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap); } |