commit 533d15f
Michael Forney
·
2013-07-01 05:12:21 +0000 UTC
parent b9f6dd5
Add focus change signal
2 files changed,
+25,
-0
+13,
-0
1@@ -24,6 +24,7 @@
2 #include "input_focus.h"
3 #include "surface.h"
4 #include "util.h"
5+#include "event.h"
6
7 static inline void focus(struct swc_input_focus * input_focus,
8 struct swc_surface * surface,
9@@ -55,6 +56,7 @@ bool swc_input_focus_initialize(struct swc_input_focus * input_focus,
10 input_focus->handler = handler;
11
12 wl_list_init(&input_focus->resources);
13+ wl_signal_init(&input_focus->event_signal);
14
15 return true;
16 }
17@@ -102,10 +104,17 @@ void swc_input_focus_set(struct swc_input_focus * input_focus,
18 struct wl_display * display;
19 struct wl_resource * resource;
20 uint32_t serial;
21+ struct swc_input_focus_event_data data;
22+ struct swc_event event;
23+
24+ event.type = SWC_INPUT_FOCUS_EVENT_CHANGED;
25+ event.data = &data;
26
27 if (surface == input_focus->surface)
28 return;
29
30+ data.old = input_focus->surface;
31+
32 /* Unfocus previously focused surface. */
33 unfocus(input_focus);
34
35@@ -123,6 +132,10 @@ void swc_input_focus_set(struct swc_input_focus * input_focus,
36 input_focus->resource = NULL;
37 }
38
39+ data.new = input_focus->surface;
40+
41+ wl_signal_emit(&input_focus->event_signal, &event);
42+
43 return;
44 }
45
+12,
-0
1@@ -29,6 +29,16 @@
2
3 struct swc_surface;
4
5+enum swc_input_focus_event_type
6+{
7+ SWC_INPUT_FOCUS_EVENT_CHANGED
8+};
9+
10+struct swc_input_focus_event_data
11+{
12+ struct swc_surface * old, * new;
13+};
14+
15 struct swc_input_focus_handler
16 {
17 void (* enter)(struct swc_input_focus_handler * handler,
18@@ -46,6 +56,8 @@ struct swc_input_focus
19
20 struct swc_input_focus_handler * handler;
21 struct wl_list resources;
22+
23+ struct wl_signal event_signal;
24 };
25
26 bool swc_input_focus_initialize(struct swc_input_focus * input_focus,