summaryrefslogtreecommitdiff
path: root/src/wayland/pointer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wayland/pointer.c')
-rw-r--r--src/wayland/pointer.c99
1 files changed, 49 insertions, 50 deletions
diff --git a/src/wayland/pointer.c b/src/wayland/pointer.c
index 5f97370..d434047 100644
--- a/src/wayland/pointer.c
+++ b/src/wayland/pointer.c
@@ -30,7 +30,7 @@ static inline int device_px_round(double v)
return (int)lrint(v);
}
-static struct yasl_vector2i device_from_fixed(const struct yasl_surface *w,
+static struct yasl_vector2i device_from_fixed(const struct wayland_surface *w,
wl_fixed_t x, wl_fixed_t y)
{
return (struct yasl_vector2i){
@@ -85,23 +85,23 @@ void seat_note_input(struct seat *s, uint32_t serial)
s->conn->active_seat = s;
}
-struct seat *conn_active_seat(const struct yasl_display *c)
+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 yasl_surface *w, struct yasl_mouse_event ev)
+static void push_mouse(struct seat *s, struct wayland_surface *w, struct yasl_mouse_event ev)
{
ev.mods = (unsigned)seat_modifiers(s);
struct yasl_input_event input_ev = {
.kind = YASL_INPUT_MOUSE,
- .surface = w,
+ .surface = &w->base,
.mouse = ev,
};
input_queue_push(&surface_root(w)->input, &input_ev);
}
-static void report_mouse(struct seat *s, struct yasl_surface *w, struct yasl_vector2i pos,
+static void report_mouse(struct seat *s, struct wayland_surface *w, struct yasl_vector2i pos,
int button, enum yasl_pointer_kind kind)
{
push_mouse(s, w, (struct yasl_mouse_event){
@@ -109,7 +109,7 @@ static void report_mouse(struct seat *s, struct yasl_surface *w, struct yasl_vec
});
}
-static void report_wheel(struct seat *s, struct yasl_surface *w, struct yasl_vector2i pos,
+static void report_wheel(struct seat *s, struct wayland_surface *w, struct yasl_vector2i pos,
int button, int lines, float delta)
{
push_mouse(s, w, (struct yasl_mouse_event){
@@ -118,7 +118,7 @@ static void report_wheel(struct seat *s, struct yasl_surface *w, struct yasl_vec
});
}
-static bool cursor_theme_for(struct yasl_display *c, int scale)
+static bool cursor_theme_for(struct wayland_display *c, int scale)
{
if (c->cursor_theme && c->cursor_theme_scale == scale)
return true;
@@ -135,7 +135,7 @@ static bool cursor_theme_for(struct yasl_display *c, int scale)
static bool seat_cursor_surface(struct seat *s)
{
- struct yasl_display *c = s->conn;
+ struct wayland_display *c = s->conn;
if (s->cursor_surface)
return true;
s->cursor_surface = wl_compositor_create_surface(c->compositor);
@@ -146,10 +146,10 @@ static bool seat_cursor_surface(struct seat *s)
return true;
}
-static void set_cursor_theme_fallback(struct seat *s, struct yasl_surface *w,
+static void set_cursor_theme_fallback(struct seat *s, struct wayland_surface *w,
enum yasl_cursor shape)
{
- struct yasl_display *c = s->conn;
+ struct wayland_display *c = s->conn;
int scale = (int)((w->scale_120 + YASL_SCALE_UNIT - 1) / YASL_SCALE_UNIT);
if (scale < 1) scale = 1;
if (!seat_cursor_surface(s) || !cursor_theme_for(c, scale)) return;
@@ -206,7 +206,7 @@ static uint32_t cursor_shape_of(enum yasl_cursor shape)
}
}
-static void seat_set_cursor(struct seat *s, struct yasl_surface *w, enum yasl_cursor shape)
+static void seat_set_cursor(struct seat *s, struct wayland_surface *w, enum yasl_cursor shape)
{
if (!s->pointer || !s->pointer_serial || s->pointer_focus != w ||
s->cursor_shape == (int)shape)
@@ -232,7 +232,7 @@ static void tool_set_cursor(struct tablet_tool *t, enum yasl_cursor shape)
cursor_shape_of(shape));
}
-void yasl_surface_set_cursor(struct yasl_surface *w, enum yasl_cursor shape)
+void wayland_surface_set_cursor(struct wayland_surface *w, enum yasl_cursor shape)
{
if (!w || !w->conn) return;
for (struct seat *s = w->conn->seats; s; s = s->next) {
@@ -243,7 +243,7 @@ void yasl_surface_set_cursor(struct yasl_surface *w, enum yasl_cursor shape)
}
static void press_queue_flush(struct seat *s, struct press_queue *q,
- struct yasl_surface *only, uint64_t *buttons,
+ struct wayland_surface *only, uint64_t *buttons,
struct yasl_mouse_event like)
{
int kept = 0;
@@ -265,7 +265,7 @@ static void press_queue_flush(struct seat *s, struct press_queue *q,
q->n = kept;
}
-static void press_queue_push(struct press_queue *q, struct yasl_surface *w,
+static void press_queue_push(struct press_queue *q, struct wayland_surface *w,
struct yasl_vector2i pos, int button, bool release)
{
if (q->n == (int)(sizeof(q->ev) / sizeof(q->ev[0]))) {
@@ -277,7 +277,7 @@ static void press_queue_push(struct press_queue *q, struct yasl_surface *w,
};
}
-static void press_queue_forget(struct press_queue *q, struct yasl_surface *w)
+static void press_queue_forget(struct press_queue *q, struct wayland_surface *w)
{
for (int i = 0; i < q->n; i++)
if (q->ev[i].surface == w)
@@ -306,7 +306,7 @@ static void pointer_event_done(struct seat *s)
pointer_frame(s, s->pointer);
}
-static void flush_pending_motion(struct seat *s, struct yasl_surface *w)
+static void flush_pending_motion(struct seat *s, struct wayland_surface *w)
{
if (!s->motion_pending) return;
s->motion_pending = false;
@@ -319,7 +319,7 @@ static void pointer_enter(void *data, struct wl_pointer *pointer,
{
(void)pointer;
struct seat *s = data;
- struct yasl_surface *w = conn_surface_for(s->conn, surface);
+ struct wayland_surface *w = conn_surface_for(s->conn, surface);
s->pointer_focus = w;
if (!w) return;
s->pointer_pos = device_from_fixed(w, surface_x, surface_y);
@@ -335,7 +335,7 @@ static void pointer_leave(void *data, struct wl_pointer *pointer,
{
(void)pointer; (void)serial; (void)surface;
struct seat *s = data;
- struct yasl_surface *w = s->pointer_focus;
+ struct wayland_surface *w = s->pointer_focus;
s->pointer_focus = NULL;
if (!w) return;
if (s->ptr_left)
@@ -352,7 +352,7 @@ static void pointer_motion(void *data, struct wl_pointer *pointer,
{
(void)pointer; (void)time;
struct seat *s = data;
- struct yasl_surface *w = s->pointer_focus;
+ struct wayland_surface *w = s->pointer_focus;
if (!w) return;
s->pointer_pos = device_from_fixed(w, surface_x, surface_y);
s->motion_pending = true;
@@ -364,7 +364,7 @@ static void pointer_button(void *data, struct wl_pointer *pointer,
{
(void)pointer; (void)time;
struct seat *s = data;
- struct yasl_surface *w = s->pointer_focus;
+ struct wayland_surface *w = s->pointer_focus;
if (unlikely(!w)) return;
static const int8_t btn_map[8] = {
@@ -381,7 +381,6 @@ static void pointer_button(void *data, struct wl_pointer *pointer,
if (unlikely(idx >= 7)) return;
int b = btn_map[idx];
if (unlikely(b < 0)) return;
-
seat_note_input(s, serial);
bool release = (state == WL_POINTER_BUTTON_STATE_RELEASED);
if (!release) {
@@ -443,7 +442,7 @@ static void pointer_axis_value120(void *data, struct wl_pointer *pointer, uint32
}
}
-static void pointer_frame_vertical(struct seat *s, struct yasl_surface *w)
+static void pointer_frame_vertical(struct seat *s, struct wayland_surface *w)
{
if (s->axis_has_v120_v) {
int discrete = s->axis_value120_v / 120;
@@ -466,7 +465,7 @@ static void pointer_frame_vertical(struct seat *s, struct yasl_surface *w)
s->frame_v120 = 0;
}
-static void pointer_frame_horizontal(struct seat *s, struct yasl_surface *w)
+static void pointer_frame_horizontal(struct seat *s, struct wayland_surface *w)
{
if (s->axis_has_v120_h) {
int discrete = s->axis_value120_h / 120;
@@ -490,7 +489,7 @@ static void pointer_frame(void *data, struct wl_pointer *pointer)
{
(void)pointer;
struct seat *s = data;
- struct yasl_surface *left = s->ptr_left;
+ struct wayland_surface *left = s->ptr_left;
if (left) {
s->ptr_left = NULL;
if (s->ptr_left_motion)
@@ -507,7 +506,7 @@ static void pointer_frame(void *data, struct wl_pointer *pointer)
s->pointer_serial = serial;
s->cursor_shape = shape;
}
- struct yasl_surface *w = s->pointer_focus;
+ struct wayland_surface *w = s->pointer_focus;
if (!w) {
s->ptr_presses.n = 0;
return;
@@ -575,7 +574,7 @@ static int touch_count(const struct seat *s)
return n;
}
-static double touch_centroid_y(const struct seat *s, const struct yasl_surface *on)
+static double touch_centroid_y(const struct seat *s, const struct wayland_surface *on)
{
double sum = 0;
int n = 0;
@@ -604,7 +603,7 @@ static void touch_down(void *data, struct wl_touch *touch,
{
(void)touch; (void)time;
struct seat *s = data;
- struct yasl_surface *w = conn_surface_for(s->conn, surface);
+ struct wayland_surface *w = conn_surface_for(s->conn, surface);
if (!w || touch_find(s, id)) return;
struct touch_point *p = NULL;
for (int i = 0; i < SEAT_TOUCH_POINTS && !p; i++)
@@ -732,7 +731,7 @@ static void tablet_tool_proximity_in(void *data,
(void)tool; (void)tablet;
struct tablet_tool *t = data;
struct seat *s = t->seat;
- struct yasl_surface *w = conn_surface_for(s->conn, surface);
+ struct wayland_surface *w = conn_surface_for(s->conn, surface);
s->tablet_focus = w;
s->tool = t;
s->tool_buttons = 0;
@@ -751,7 +750,7 @@ static void tablet_tool_proximity_out(void *data, struct zwp_tablet_tool_v2 *too
(void)tool;
struct tablet_tool *t = data;
struct seat *s = t->seat;
- struct yasl_surface *w = s->tablet_focus;
+ struct wayland_surface *w = s->tablet_focus;
if (w) {
press_queue_flush(s, &s->tool_presses, NULL, &s->tool_buttons, tool_event(s));
struct yasl_mouse_event ev = tool_event(s);
@@ -771,7 +770,7 @@ static void tablet_tool_down(void *data, struct zwp_tablet_tool_v2 *tool, uint32
{
(void)tool;
struct seat *s = ((struct tablet_tool *)data)->seat;
- struct yasl_surface *w = s->tablet_focus;
+ struct wayland_surface *w = s->tablet_focus;
if (!w) return;
seat_note_input(s, serial);
s->press_serial = serial;
@@ -783,7 +782,7 @@ static void tablet_tool_up(void *data, struct zwp_tablet_tool_v2 *tool)
{
(void)tool;
struct seat *s = ((struct tablet_tool *)data)->seat;
- struct yasl_surface *w = s->tablet_focus;
+ struct wayland_surface *w = s->tablet_focus;
if (!w) return;
s->pen.pressure = 0;
press_queue_push(&s->tool_presses, w, s->tool_pos, 0, true);
@@ -793,7 +792,7 @@ static void tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool, wl_f
{
(void)tool;
struct seat *s = ((struct tablet_tool *)data)->seat;
- struct yasl_surface *w = s->tablet_focus;
+ struct wayland_surface *w = s->tablet_focus;
if (!w) return;
s->tool_pos = device_from_fixed(w, x, y);
s->tool_motion = true;
@@ -804,7 +803,7 @@ static void tablet_tool_button(void *data, struct zwp_tablet_tool_v2 *tool,
{
(void)tool;
struct seat *s = ((struct tablet_tool *)data)->seat;
- struct yasl_surface *w = s->tablet_focus;
+ struct wayland_surface *w = s->tablet_focus;
if (!w) return;
seat_note_input(s, serial);
int b;
@@ -851,7 +850,7 @@ static void tool_frame(void *d, struct zwp_tablet_tool_v2 *t, uint32_t time)
{
(void)t; (void)time;
struct seat *s = ((struct tablet_tool *)d)->seat;
- struct yasl_surface *w = s->tablet_focus;
+ struct wayland_surface *w = s->tablet_focus;
if (!w) {
s->tool_presses.n = 0;
s->tool_wheel = 0;
@@ -1032,13 +1031,13 @@ static void clipboard_received(const char *text, size_t len, bool uri_list,
struct wl_surface *on, void *ud)
{
struct seat *s = ud;
- struct yasl_display *c = s->conn;
- struct yasl_surface *w = on ? surface_root(conn_surface_for(c, on)) : NULL;
+ struct wayland_display *c = s->conn;
+ struct wayland_surface *w = on ? surface_root(conn_surface_for(c, on)) : NULL;
if (!w)
w = c->paste_target ? c->paste_target : s->keyboard_focus;
if (!len || !w) return;
struct yasl_input_event ev = {
- .surface = w,
+ .surface = &w->base,
.kind = uri_list ? YASL_INPUT_DROP_FILES : YASL_INPUT_PASTE,
};
if (uri_list) {
@@ -1067,7 +1066,7 @@ static void clipboard_drop_hover(enum yasl_drop_event ev, struct wl_surface *on,
void seat_clipboard_ensure(struct seat *s)
{
- struct yasl_display *c = s->conn;
+ struct wayland_display *c = s->conn;
if (!c->data_manager || !s->proxy)
return;
if (!s->clipboard) {
@@ -1111,7 +1110,7 @@ static void seat_drop_keyboard(struct seat *s)
s->keyboard = NULL;
}
s->repeat_rate = 0;
- struct yasl_surface *w = s->keyboard_focus;
+ struct wayland_surface *w = s->keyboard_focus;
s->keyboard_focus = NULL;
if (w && !s->focus_leaving)
s->focus_leaving = w;
@@ -1132,7 +1131,7 @@ static void seat_drop_touch(struct seat *s)
static void seat_capabilities(void *data, struct wl_seat *proxy, uint32_t caps)
{
struct seat *s = data;
- struct yasl_display *c = s->conn;
+ struct wayland_display *c = s->conn;
if (caps & WL_SEAT_CAPABILITY_KEYBOARD) {
if (!s->keyboard) {
s->keyboard = wl_seat_get_keyboard(proxy);
@@ -1194,7 +1193,7 @@ const struct wl_seat_listener seat_listener = {
.name = seat_name,
};
-void seat_bind(struct yasl_display *c, struct wl_registry *registry,
+void seat_bind(struct wayland_display *c, struct wl_registry *registry,
uint32_t name, uint32_t version)
{
struct seat *s = calloc(1, sizeof(*s));
@@ -1215,9 +1214,9 @@ void seat_bind(struct yasl_display *c, struct wl_registry *registry,
keyboard_repeat_init(s);
}
-void seat_forget_surface(struct seat *s, struct yasl_surface *w)
+void seat_forget_surface(struct seat *s, struct wayland_surface *w)
{
- struct yasl_surface **refs[] = {
+ struct wayland_surface **refs[] = {
&s->pointer_focus, &s->keyboard_focus,
&s->tablet_focus, &s->ime_focus, &s->focus_leaving, &s->ptr_left,
&s->press_surface,
@@ -1240,7 +1239,7 @@ void seat_forget_surface(struct seat *s, struct yasl_surface *w)
void seat_destroy(struct seat *s)
{
- struct yasl_display *c = s->conn;
+ struct wayland_display *c = s->conn;
for (struct seat **link = &c->seats; *link; link = &(*link)->next) {
if (*link == s) {
*link = s->next;
@@ -1249,7 +1248,7 @@ void seat_destroy(struct seat *s)
}
if (c->active_seat == s)
c->active_seat = NULL;
- for (struct yasl_surface *w = c->surfaces; w; w = w->conn_next) {
+ for (struct wayland_surface *w = c->surfaces; w; w = w->conn_next) {
if (w->ime_seat == s) {
w->ime_seat = NULL;
ime_reset(w);
@@ -1262,11 +1261,11 @@ void seat_destroy(struct seat *s)
seat_destroy_tablet(s);
seat_drop_pointer(s);
seat_drop_keyboard(s);
- struct yasl_surface *left = s->focus_leaving;
+ struct wayland_surface *left = s->focus_leaving;
if (left && !conn_keyboard_on(c, left, NULL)) {
struct yasl_input_event ev = {
.kind = YASL_INPUT_FOCUS,
- .surface = left,
+ .surface = &left->base,
.focus = { .focused = false },
};
input_queue_push(&left->input, &ev);
@@ -1288,7 +1287,7 @@ void seat_destroy(struct seat *s)
free(s);
}
-bool seat_remove(struct yasl_display *c, uint32_t name)
+bool seat_remove(struct wayland_display *c, uint32_t name)
{
for (struct seat *s = c->seats; s; s = s->next) {
if (s->name == name) {
@@ -1299,7 +1298,7 @@ bool seat_remove(struct yasl_display *c, uint32_t name)
return false;
}
-int display_input_init(struct yasl_display *c)
+int display_input_init(struct wayland_display *c)
{
for (struct seat *s = c->seats; s; s = s->next) {
keyboard_repeat_init(s);
@@ -1308,7 +1307,7 @@ int display_input_init(struct yasl_display *c)
return 0;
}
-void surface_init_cursor(struct yasl_display *c)
+void surface_init_cursor(struct wayland_display *c)
{
if (c->cursor_shape_mgr)
return;