From a564eb4655e06ef4a9d97556c3e2a094577cb225 Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:13:15 +0200 Subject: [PATCH] Scale wayland input coordinates --- src/icon.h | 2 -- src/wayland/wl_seat.c | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/icon.h b/src/icon.h index 14c3ed80b..a411ab185 100644 --- a/src/icon.h +++ b/src/icon.h @@ -13,7 +13,6 @@ cairo_surface_t *gdk_pixbuf_to_cairo_surface(GdkPixbuf *pixbuf); * @param filename A string representing a readable file path * @param min_size An iteger representing the desired minimum unscaled icon size. * @param max_size An iteger representing the desired maximum unscaled icon size. - * @param scale An integer representing the output dpi scaling. * * @return an instance of `GdkPixbuf` * @retval NULL: file does not exist, not readable, etc.. @@ -56,7 +55,6 @@ char *get_path_from_icon_name(const char *iconname, int size); * like described in the notification spec. * @param id (necessary) A unique identifier of the returned pixbuf. * Only filled, if the return value is non-NULL. - * @param dpi_scale An integer representing the output dpi scaling. * @param min_size An integer representing the desired minimum unscaled icon size. * @param max_size An integer representing the desired maximum unscaled icon size. * @return an instance of `GdkPixbuf` derived from the GVariant diff --git a/src/wayland/wl_seat.c b/src/wayland/wl_seat.c index ffc1e48be..37134e446 100644 --- a/src/wayland/wl_seat.c +++ b/src/wayland/wl_seat.c @@ -18,6 +18,7 @@ #include "../log.h" #include "../settings.h" #include "wl_ctx.h" +#include "wl.h" static void touch_handle_motion(void *data, struct wl_touch *wl_touch, uint32_t time, int32_t id, @@ -50,8 +51,10 @@ static void touch_handle_up(void *data, struct wl_touch *wl_touch, if (id >= MAX_TOUCHPOINTS) { return; } + + double scale = wl_get_scale(); input_handle_click(BTN_TOUCH, false, - seat->touch.pts[id].x, seat->touch.pts[id].y); + seat->touch.pts[id].x/scale, seat->touch.pts[id].y/scale); } @@ -100,7 +103,8 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uint32_t button_state) { struct dunst_seat *seat = data; - input_handle_click(button, button_state, seat->pointer.x, seat->pointer.y); + double scale = wl_get_scale(); + input_handle_click(button, button_state, seat->pointer.x/scale, seat->pointer.y/scale); } static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,