summaryrefslogtreecommitdiff
path: root/src/platform/wayland/pointer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/wayland/pointer.c')
-rw-r--r--src/platform/wayland/pointer.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/platform/wayland/pointer.c b/src/platform/wayland/pointer.c
index 90b7ecc..4652849 100644
--- a/src/platform/wayland/pointer.c
+++ b/src/platform/wayland/pointer.c
@@ -25,17 +25,12 @@ struct tablet_pad {
struct zwp_tablet_pad_v2 *proxy;
};
-static inline int device_px_round(double v)
-{
- return (int)lrint(v);
-}
-
static struct yasl_vector2i device_from_fixed(const struct wayland_surface *w,
wl_fixed_t x, wl_fixed_t y)
{
return (struct yasl_vector2i){
- .x = device_px_round(wl_fixed_to_double(x) * w->scale_factor),
- .y = device_px_round(wl_fixed_to_double(y) * w->scale_factor),
+ .x = (int)lrint(wl_fixed_to_double(x) * w->scale_factor),
+ .y = (int)lrint(wl_fixed_to_double(y) * w->scale_factor),
};
}
@@ -85,11 +80,6 @@ void seat_note_input(struct seat *s, uint32_t serial)
s->conn->active_seat = s;
}
-struct seat *conn_active_seat(const struct wayland_display *c)
-{
- return c->active_seat ? c->active_seat : c->seats;
-}
-
static void push_mouse(struct seat *s, struct wayland_surface *w, struct yasl_mouse_event ev)
{
ev.mods = (unsigned)seat_modifiers(s);
@@ -174,9 +164,12 @@ static void set_cursor_theme_fallback(struct seat *s, struct wayland_surface *w,
int theme_scale = c->cursor_theme_scale;
if (s->cursor_viewport) {
+ uint32_t scale_120 = (uint32_t)theme_scale * YASL_SCALE_UNIT;
wp_viewport_set_destination(s->cursor_viewport,
- logical_px_ceil((int)img->width, (uint32_t)theme_scale * YASL_SCALE_UNIT),
- logical_px_ceil((int)img->height, (uint32_t)theme_scale * YASL_SCALE_UNIT));
+ (int)(((int64_t)(int)img->width * YASL_SCALE_UNIT + scale_120 - 1) /
+ scale_120),
+ (int)(((int64_t)(int)img->height * YASL_SCALE_UNIT + scale_120 - 1) /
+ scale_120));
} else {
if (img->width % (uint32_t)theme_scale || img->height % (uint32_t)theme_scale)
theme_scale = 1;
@@ -324,7 +317,8 @@ static void pointer_enter(void *data, struct wl_pointer *pointer,
{
(void)pointer;
struct seat *s = data;
- struct wayland_surface *w = conn_surface_for(s->conn, surface);
+ struct wayland_surface *w = surface ?
+ (struct wayland_surface *)wl_surface_get_user_data(surface) : NULL;
s->pointer_focus = w;
if (!w) return;
s->pointer_pos = device_from_fixed(w, surface_x, surface_y);
@@ -522,7 +516,7 @@ static struct yasl_vector2i touch_pos(const struct touch_point *p)
{
double scale = p->surface->scale_factor;
return (struct yasl_vector2i){
- .x = device_px_round(p->x * scale), .y = device_px_round(p->y * scale),
+ .x = (int)lrint(p->x * scale), .y = (int)lrint(p->y * scale),
};
}
@@ -543,7 +537,8 @@ static void touch_down(void *data, struct wl_touch *touch,
{
(void)touch; (void)time;
struct seat *s = data;
- struct wayland_surface *w = conn_surface_for(s->conn, surface);
+ struct wayland_surface *w = surface ?
+ (struct wayland_surface *)wl_surface_get_user_data(surface) : NULL;
if (!w || touch_find(s, id)) return;
struct touch_point *p = NULL;
for (int i = 0; i < SEAT_TOUCH_POINTS && !p; i++)
@@ -678,7 +673,8 @@ static void tablet_tool_proximity_in(void *data,
(void)tool; (void)tablet;
struct tablet_tool *t = data;
struct seat *s = t->seat;
- struct wayland_surface *w = conn_surface_for(s->conn, surface);
+ struct wayland_surface *w = surface ?
+ (struct wayland_surface *)wl_surface_get_user_data(surface) : NULL;
s->tablet_focus = w;
s->tool = t;
s->tool_buttons = 0;
@@ -984,9 +980,9 @@ static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
static void clipboard_received(const char *text, size_t len, bool uri_list,
struct wl_surface *on, void *ud)
{
- struct seat *s = ud;
- struct wayland_display *c = s->conn;
- struct wayland_surface *w = conn_surface_for(c, on);
+ (void)ud;
+ struct wayland_surface *w = on ?
+ (struct wayland_surface *)wl_surface_get_user_data(on) : NULL;
if (uri_list) w = surface_root(w);
if (!w || w->closed) return;
struct yasl_input_event ev = {