commit c22ad42
Michael Forney
·
2014-02-27 03:37:30 +0000 UTC
parent 6545140
input: Use common press structure
6 files changed,
+29,
-22
+10,
-0
1@@ -77,5 +77,15 @@ void input_focus_set(struct input_focus * input_focus,
2
3 /* }}} */
4
5+/* Key/button handling {{{ */
6+
7+struct press
8+{
9+ uint32_t value;
10+ uint32_t serial;
11+};
12+
13+/* }}} */
14+
15 #endif
16
+7,
-8
1@@ -336,14 +336,13 @@ struct wl_resource * pointer_bind(struct pointer * pointer,
2 return client_resource;
3 }
4
5-struct button_press * pointer_get_button_press(struct pointer * pointer,
6- uint32_t serial)
7+struct button * pointer_get_button(struct pointer * pointer, uint32_t serial)
8 {
9- struct button_press * button;
10+ struct button * button;
11
12 wl_array_for_each(button, &pointer->buttons)
13 {
14- if (button->serial == serial)
15+ if (button->press.serial == serial)
16 return button;
17 }
18
19@@ -354,7 +353,7 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time,
20 uint32_t value, uint32_t state)
21 {
22 struct pointer_handler * handler;
23- struct button_press * button;
24+ struct button * button;
25 uint32_t serial;
26
27 serial = wl_display_next_serial(swc.display);
28@@ -363,7 +362,7 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time,
29 {
30 wl_array_for_each(button, &pointer->buttons)
31 {
32- if (button->value == value)
33+ if (button->press.value == value)
34 {
35 swc_array_remove(&pointer->buttons, button, sizeof *button);
36
37@@ -384,8 +383,8 @@ void pointer_handle_button(struct pointer * pointer, uint32_t time,
38 if (handler->button && handler->button(handler, time, value, state))
39 {
40 button = wl_array_add(&pointer->buttons, sizeof *button);
41- button->value = value;
42- button->serial = serial;
43+ button->press.value = value;
44+ button->press.serial = serial;
45 button->handler = handler;
46 break;
47 }
+3,
-5
1@@ -31,10 +31,9 @@
2 #include <wayland-server.h>
3 #include <pixman.h>
4
5-struct button_press
6+struct button
7 {
8- uint32_t value;
9- uint32_t serial;
10+ struct press press;
11 struct pointer_handler * handler;
12 };
13
14@@ -85,8 +84,7 @@ void pointer_set_focus(struct pointer * pointer, struct compositor_view * view);
15 void pointer_set_region(struct pointer * pointer, pixman_region32_t * region);
16 void pointer_set_cursor(struct pointer * pointer, uint32_t id);
17
18-struct button_press * pointer_get_button_press(struct pointer * pointer,
19- uint32_t serial);
20+struct button * pointer_get_button(struct pointer * pointer, uint32_t serial);
21
22 struct wl_resource * pointer_bind(struct pointer * pointer,
23 struct wl_client * client, uint32_t id);
+4,
-4
1@@ -52,9 +52,9 @@ static void move(struct wl_client * client, struct wl_resource * resource,
2 struct wl_resource * seat_resource, uint32_t serial)
3 {
4 struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
5- struct button_press * button;
6+ struct button * button;
7
8- if (!(button = pointer_get_button_press(swc.seat->pointer, serial)))
9+ if (!(button = pointer_get_button(swc.seat->pointer, serial)))
10 return;
11
12 window_begin_interactive_move(&shell_surface->window, button);
13@@ -65,9 +65,9 @@ static void resize(struct wl_client * client, struct wl_resource * resource,
14 uint32_t edges)
15 {
16 struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
17- struct button_press * button;
18+ struct button * button;
19
20- if (!(button = pointer_get_button_press(swc.seat->pointer, serial)))
21+ if (!(button = pointer_get_button(swc.seat->pointer, serial)))
22 return;
23
24 window_begin_interactive_resize(&shell_surface->window, edges, button);
+3,
-3
1@@ -114,7 +114,7 @@ void swc_window_set_border(struct swc_window * window,
2
3 static inline void window_begin_interaction
4 (struct window * window, struct window_pointer_interaction * interaction,
5- struct button_press * button)
6+ struct button * button)
7 {
8 if (button)
9 {
10@@ -128,7 +128,7 @@ static inline void window_begin_interaction
11 }
12
13 void window_begin_interactive_move(struct window * window,
14- struct button_press * button)
15+ struct button * button)
16 {
17 struct swc_rectangle * geometry = &window->view->base.geometry;
18 int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
19@@ -140,7 +140,7 @@ void window_begin_interactive_move(struct window * window,
20 }
21
22 void window_begin_interactive_resize(struct window * window, uint32_t edges,
23- struct button_press * button)
24+ struct button * button)
25 {
26 window_begin_interaction(window, &window->resize.interaction, button);
27
+2,
-2
1@@ -79,10 +79,10 @@ void window_set_state(struct window * window, uint32_t state);
2 void window_set_parent(struct window * window, struct window * parent);
3
4 void window_begin_interactive_move(struct window * window,
5- struct button_press * button);
6+ struct button * button);
7
8 void window_begin_interactive_resize(struct window * window, uint32_t edges,
9- struct button_press * button);
10+ struct button * button);
11
12 #endif
13