summaryrefslogtreecommitdiff
path: root/src/wayland/pointer.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-12 10:17:33 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-12 10:17:33 +0300
commit881fb6cb1d64868132287bd9637f4ae1cbc3504c (patch)
tree5688d5f8be69805ccf290178675b522802155e6d /src/wayland/pointer.c
parent3b8af02be94a510e385f44d58c35c86bb89424a6 (diff)
cursor hidden and tablet support
Diffstat (limited to 'src/wayland/pointer.c')
-rw-r--r--src/wayland/pointer.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/wayland/pointer.c b/src/wayland/pointer.c
index 3b3ad73..3341d35 100644
--- a/src/wayland/pointer.c
+++ b/src/wayland/pointer.c
@@ -164,7 +164,7 @@ static void set_cursor_theme_fallback(struct seat *s, struct wayland_surface *w,
{"ew-resize", "ew-resize"},
{"ns-resize", "ns-resize"},
};
- int idx = shape < YASL_CURSOR_NONE ? (int)shape : 0;
+ int idx = (unsigned)shape < YASL_CURSOR_HIDDEN ? (int)shape : 0;
struct wl_cursor *cursor = wl_cursor_theme_get_cursor(c->cursor_theme, names[idx][0]);
if (!cursor) cursor = wl_cursor_theme_get_cursor(c->cursor_theme, names[idx][1]);
if (!cursor || !cursor->image_count) return;
@@ -211,7 +211,7 @@ static void seat_set_cursor(struct seat *s, struct wayland_surface *w, enum yasl
if (!s->pointer || !s->pointer_serial || s->pointer_focus != w ||
s->cursor_shape == (int)shape)
return;
- if (shape == YASL_CURSOR_NONE)
+ if (shape == YASL_CURSOR_HIDDEN)
wl_pointer_set_cursor(s->pointer, s->pointer_serial, NULL, 0, 0);
else if (s->cursor_shape_dev)
wp_cursor_shape_device_v1_set_shape(s->cursor_shape_dev,
@@ -225,7 +225,7 @@ static void tool_set_cursor(struct tablet_tool *t, enum yasl_cursor shape)
{
if (!t->proximity_serial)
return;
- if (shape == YASL_CURSOR_NONE)
+ if (shape == YASL_CURSOR_HIDDEN)
zwp_tablet_tool_v2_set_cursor(t->proxy, t->proximity_serial, NULL, 0, 0);
else if (t->shape_dev)
wp_cursor_shape_device_v1_set_shape(t->shape_dev, t->proximity_serial,
@@ -234,7 +234,8 @@ static void tool_set_cursor(struct tablet_tool *t, enum yasl_cursor shape)
void wayland_surface_set_cursor(struct wayland_surface *w, enum yasl_cursor shape)
{
- if (!w || !w->conn) return;
+ if (!w || !w->conn || w->destroyed || (unsigned)shape > YASL_CURSOR_HIDDEN) return;
+ w->cursor = shape;
for (struct seat *s = w->conn->seats; s; s = s->next) {
seat_set_cursor(s, w, shape);
if (s->tool && s->tablet_focus == w)
@@ -325,7 +326,7 @@ static void pointer_enter(void *data, struct wl_pointer *pointer,
s->pointer_pos = device_from_fixed(w, surface_x, surface_y);
s->pointer_serial = serial;
s->cursor_shape = -1;
- seat_set_cursor(s, w, w->parent ? YASL_CURSOR_ARROW : YASL_CURSOR_TEXT);
+ seat_set_cursor(s, w, w->cursor);
s->motion_pending = true;
pointer_event_done(s);
}
@@ -741,7 +742,7 @@ static void tablet_tool_proximity_in(void *data,
if (s->conn->cursor_shape_mgr && !t->shape_dev)
t->shape_dev = wp_cursor_shape_manager_v1_get_tablet_tool_v2(
s->conn->cursor_shape_mgr, t->proxy);
- tool_set_cursor(t, w->parent ? YASL_CURSOR_ARROW : YASL_CURSOR_TEXT);
+ tool_set_cursor(t, w->cursor);
s->tool_motion = true;
}
@@ -753,6 +754,7 @@ static void tablet_tool_proximity_out(void *data, struct zwp_tablet_tool_v2 *too
struct wayland_surface *w = s->tablet_focus;
if (w) {
press_queue_flush(s, &s->tool_presses, NULL, &s->tool_buttons, tool_event(s));
+ s->pen.pressure = 0;
struct yasl_mouse_event ev = tool_event(s);
ev.pos = s->tool_pos;
ev.button = 3;
@@ -763,6 +765,8 @@ static void tablet_tool_proximity_out(void *data, struct zwp_tablet_tool_v2 *too
s->tablet_focus = NULL;
s->tool = NULL;
s->tool_motion = false;
+ s->tool_wheel = 0;
+ s->tool_buttons = 0;
t->proximity_serial = 0;
}
@@ -867,7 +871,11 @@ static void tool_frame(void *d, struct zwp_tablet_tool_v2 *t, uint32_t time)
}
press_queue_flush(s, &s->tool_presses, NULL, &s->tool_buttons, like);
if (s->tool_wheel) {
- report_wheel(s, w, s->tool_pos, s->tool_wheel > 0 ? 5 : 4, -s->tool_wheel, 0.0f);
+ struct yasl_mouse_event ev = like;
+ ev.pos = s->tool_pos;
+ ev.kind = YASL_PTR_SCROLL;
+ ev.scroll_lines = -s->tool_wheel;
+ push_mouse(s, w, ev);
s->tool_wheel = 0;
}
}
@@ -877,9 +885,7 @@ static void tablet_tool_removed(void *data, struct zwp_tablet_tool_v2 *tool)
struct tablet_tool *t = data;
struct seat *s = t->seat;
if (s->tool == t) {
- s->tool = NULL;
- s->tablet_focus = NULL;
- s->tool_presses.n = 0;
+ tablet_tool_proximity_out(t, tool);
}
struct tablet_tool **link = &s->tablet_tools;
while (*link && *link != t)