commit 29e72e6
Michael Forney
·
2013-08-10 20:42:58 +0000 UTC
parent e244949
Use swc_send_event helper
6 files changed,
+21,
-29
+4,
-7
1@@ -38,14 +38,11 @@ static void set_selection(struct wl_client * client,
2 struct wl_resource * data_source, uint32_t serial)
3 {
4 struct swc_data_device * data_device = wl_resource_get_user_data(resource);
5- struct swc_event event;
6
7 /* Check if this data source is already the current selection. */
8 if (data_source == data_device->selection)
9 return;
10
11- event.type = SWC_DATA_DEVICE_EVENT_SELECTION_CHANGED;
12-
13 if (data_device->selection)
14 {
15 wl_data_source_send_cancelled(data_device->selection);
16@@ -60,7 +57,8 @@ static void set_selection(struct wl_client * client,
17 (data_source, &data_device->selection_destroy_listener);
18 }
19
20- wl_signal_emit(&data_device->event_signal, &event);
21+ swc_send_event(&data_device->event_signal,
22+ SWC_DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
23 }
24
25 struct wl_data_device_interface data_device_implementation = {
26@@ -72,11 +70,10 @@ static void handle_selection_destroy(struct wl_listener * listener, void * data)
27 {
28 struct swc_data_device * data_device = swc_container_of
29 (listener, typeof(*data_device), selection_destroy_listener);
30- struct swc_event event;
31
32- event.type = SWC_DATA_DEVICE_EVENT_SELECTION_CHANGED;
33 data_device->selection = NULL;
34- wl_signal_emit(&data_device->event_signal, &event);
35+ swc_send_event(&data_device->event_signal,
36+ SWC_DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
37 }
38
39 bool swc_data_device_initialize(struct swc_data_device * data_device)
M
drm.c
+3,
-5
1@@ -139,15 +139,13 @@ static void handle_page_flip(int fd, unsigned int sequence, unsigned int sec,
2 unsigned int usec, void * data)
3 {
4 struct swc_output * output = data;
5- struct swc_event event = {
6- .type = SWC_DRM_PAGE_FLIP,
7- .data = output
8- };
9
10 printf("page flip\n");
11 output->front_buffer ^= 1;
12
13- wl_signal_emit(&output->drm->event_signal, &event);
14+ /* XXX: It doesn't make sense for multiple things to be listening for page
15+ * flips (or does it?). Maybe this should be a callback instead? */
16+ swc_send_event(&output->drm->event_signal, SWC_DRM_PAGE_FLIP, output);
17 }
18
19 static drmEventContext event_context = {
M
event.h
+9,
-0
1@@ -2,6 +2,7 @@
2 #define SWC_EVENT_H
3
4 #include <stdint.h>
5+#include <wayland-server.h>
6
7 struct swc_event
8 {
9@@ -9,5 +10,13 @@ struct swc_event
10 void * data;
11 };
12
13+static inline void swc_send_event(struct wl_signal * signal, uint32_t type,
14+ void * event_data)
15+{
16+ struct swc_event event = { .type = type, .data = event_data };
17+
18+ wl_signal_emit(signal, &event);
19+}
20+
21 #endif
22
+2,
-5
1@@ -124,10 +124,6 @@ void swc_input_focus_set(struct swc_input_focus * input_focus,
2 struct wl_resource * resource;
3 uint32_t serial;
4 struct swc_input_focus_event_data data;
5- struct swc_event event;
6-
7- event.type = SWC_INPUT_FOCUS_EVENT_CHANGED;
8- event.data = &data;
9
10 if (surface == input_focus->surface)
11 return;
12@@ -153,7 +149,8 @@ void swc_input_focus_set(struct swc_input_focus * input_focus,
13
14 data.new = input_focus->surface;
15
16- wl_signal_emit(&input_focus->event_signal, &event);
17+ swc_send_event(&input_focus->event_signal, SWC_INPUT_FOCUS_EVENT_CHANGED,
18+ &data);
19
20 return;
21 }
+1,
-5
1@@ -77,7 +77,6 @@ static void set_cursor(struct wl_client * client,
2 {
3 struct swc_pointer * pointer = wl_resource_get_user_data(resource);
4 struct swc_surface * surface;
5- struct swc_event event;
6
7 printf("set_cursor\n");
8
9@@ -94,10 +93,7 @@ static void set_cursor(struct wl_client * client,
10 pointer->cursor.hotspot_x = hotspot_x;
11 pointer->cursor.hotspot_y = hotspot_y;
12
13- event.type = SWC_POINTER_CURSOR_CHANGED;
14- event.data = pointer;
15-
16- wl_signal_emit(&pointer->event_signal, &event);
17+ swc_send_event(&pointer->event_signal, SWC_POINTER_CURSOR_CHANGED, pointer);
18 }
19
20 struct wl_pointer_interface pointer_implementation = {
M
tty.c
+2,
-7
1@@ -197,13 +197,10 @@ void restore_tty(struct swc_tty * tty)
2 static int handle_vt_signal(int signal_number, void * data)
3 {
4 struct swc_tty * tty = data;
5- struct swc_event event;
6
7 if (tty->active)
8 {
9- event.type = SWC_TTY_VT_LEAVE;
10- wl_signal_emit(&tty->event_signal, &event);
11-
12+ swc_send_event(&tty->event_signal, SWC_TTY_VT_LEAVE, NULL);
13 ioctl(tty->fd, VT_RELDISP, 1);
14 tty->active = false;
15 }
16@@ -211,9 +208,7 @@ static int handle_vt_signal(int signal_number, void * data)
17 {
18 ioctl(tty->fd, VT_RELDISP, VT_ACKACQ);
19 tty->active = true;
20-
21- event.type = SWC_TTY_VT_ENTER;
22- wl_signal_emit(&tty->event_signal, &event);
23+ swc_send_event(&tty->event_signal, SWC_TTY_VT_ENTER, NULL);
24 }
25
26 return 1;