diff options
-rw-r--r-- | include/client/window.h | 10 | ||||
-rw-r--r-- | wayland/window.c | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/client/window.h b/include/client/window.h index e48ec4f3..b5cc1880 100644 --- a/include/client/window.h +++ b/include/client/window.h | |||
@@ -9,6 +9,8 @@ | |||
9 | #include "list.h" | 9 | #include "list.h" |
10 | #include "client/registry.h" | 10 | #include "client/registry.h" |
11 | 11 | ||
12 | struct window; | ||
13 | |||
12 | struct buffer { | 14 | struct buffer { |
13 | struct wl_buffer *buffer; | 15 | struct wl_buffer *buffer; |
14 | cairo_surface_t *surface; | 16 | cairo_surface_t *surface; |
@@ -25,6 +27,13 @@ struct cursor { | |||
25 | struct wl_poitner *pointer; | 27 | struct wl_poitner *pointer; |
26 | }; | 28 | }; |
27 | 29 | ||
30 | struct pointer_input { | ||
31 | wl_fixed_t last_x; | ||
32 | wl_fixed_t last_y; | ||
33 | |||
34 | void (*notify)(struct window *window, wl_fixed_t x, wl_fixed_t y, uint32_t button); | ||
35 | }; | ||
36 | |||
28 | struct window { | 37 | struct window { |
29 | struct registry *registry; | 38 | struct registry *registry; |
30 | struct buffer buffers[2]; | 39 | struct buffer buffers[2]; |
@@ -36,6 +45,7 @@ struct window { | |||
36 | uint32_t width, height; | 45 | uint32_t width, height; |
37 | char *font; | 46 | char *font; |
38 | cairo_t *cairo; | 47 | cairo_t *cairo; |
48 | struct pointer_input pointer_input; | ||
39 | }; | 49 | }; |
40 | 50 | ||
41 | struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface); | 51 | struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface); |
diff --git a/wayland/window.c b/wayland/window.c index 7ca9e4ec..e055e244 100644 --- a/wayland/window.c +++ b/wayland/window.c | |||
@@ -30,10 +30,20 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer, | |||
30 | 30 | ||
31 | static void pointer_handle_motion(void *data, struct wl_pointer *pointer, | 31 | static void pointer_handle_motion(void *data, struct wl_pointer *pointer, |
32 | uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w) { | 32 | uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w) { |
33 | struct window *window = data; | ||
34 | |||
35 | window->pointer_input.last_x = sx_w; | ||
36 | window->pointer_input.last_y = sy_w; | ||
33 | } | 37 | } |
34 | 38 | ||
35 | static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, | 39 | static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, |
36 | uint32_t time, uint32_t button, uint32_t state_w) { | 40 | uint32_t time, uint32_t button, uint32_t state_w) { |
41 | struct window *window = data; | ||
42 | struct pointer_input *input = &window->pointer_input; | ||
43 | |||
44 | if (window->pointer_input.notify) { | ||
45 | window->pointer_input.notify(window, input->last_x, input->last_y, button); | ||
46 | } | ||
37 | } | 47 | } |
38 | 48 | ||
39 | static void pointer_handle_axis(void *data, struct wl_pointer *pointer, | 49 | static void pointer_handle_axis(void *data, struct wl_pointer *pointer, |