aboutsummaryrefslogtreecommitdiff
path: root/rootston/cursor.c
blob: 100e4b3213613f2cf6047f176f413e62af7526a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

void cursor_update_position(struct roots_input *input, uint32_t time) {
	/*
	if (input->motion_context.surface) {
		struct example_xdg_surface_v6 *surface;
		surface = sample->motion_context.surface;
		surface->position.lx = sample->cursor->x - sample->motion_context.off_x;
		surface->position.ly = sample->cursor->y - sample->motion_context.off_y;
		return;
	}
	*/

	struct wlr_xdg_surface_v6 *surface = example_xdg_surface_at(sample,
			sample->cursor->x, sample->cursor->y);

	if (surface) {
		struct example_xdg_surface_v6 *esurface = surface->data;

		double sx = sample->cursor->x - esurface->position.lx;
		double sy = sample->cursor->y - esurface->position.ly;

		// TODO z-order
		wlr_seat_pointer_enter(sample->wl_seat, surface->surface, sx, sy);
		wlr_seat_pointer_send_motion(sample->wl_seat, time, sx, sy);
	} else {
		wlr_seat_pointer_clear_focus(sample->wl_seat);
	}
}