Skip to content

Commit

Permalink
Scale wayland input coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
bynect committed Apr 16, 2024
1 parent 6fa62cc commit a564eb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/wayland/wl_seat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a564eb4

Please sign in to comment.