1 From affd6eb25a08a3f10f2c7010c3205e930ceb4ec0 Mon Sep 17 00:00:00 2001
2 From: Nobuhiko Tanibata <ntanibata@jp.adit-jv.com>
3 Date: Thu, 10 Dec 2015 16:07:20 +0900
4 Subject: [PATCH] ivi-shell: Temporary fix: Send keyboard events to clients who binds
7 This is a temporary solution to send keyboard events to clients for CES2016 demo.
8 This shall be resolved by using ilm keyboard focus later.
10 Signed-off-by: Nobuhiko Tanibata <ntanibata@jp.adit-jv.com>
13 ivi-shell/ivi-layout-private.h | 2 ++
14 ivi-shell/ivi-layout.c | 65 ++++++++++++++++++++++++++++++++++++++++++
15 ivi-shell/ivi-shell.c | 45 +++++++++++++++++++++++++++++
16 ivi-shell/ivi-shell.h | 4 +++
17 4 files changed, 116 insertions(+)
19 diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h
20 index ee945a6..a75d9b0 100644
21 --- a/ivi-shell/ivi-layout-private.h
22 +++ b/ivi-shell/ivi-layout-private.h
23 @@ -112,6 +112,8 @@ struct ivi_layout {
25 struct ivi_layout_transition_set *transitions;
26 struct wl_list pending_transition_list;
28 + struct weston_keyboard_grab keyboard_grab;
31 struct ivi_layout *get_instance(void);
32 diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
33 index dbe1010..75404c8 100644
34 --- a/ivi-shell/ivi-layout.c
35 +++ b/ivi-shell/ivi-layout.c
36 @@ -124,6 +124,8 @@ struct ivi_rectangle
38 remove_notification(struct wl_list *listener_list, void *callback, void *userdata);
40 +static const struct weston_keyboard_grab_interface ivi_layout_keyboard_grab_interface;
42 static struct ivi_layout ivilayout = {0};
45 @@ -2854,6 +2856,9 @@ ivi_layout_init_with_compositor(struct weston_compositor *ec)
47 layout->transitions = ivi_layout_transition_set_create(ec);
48 wl_list_init(&layout->pending_transition_list);
50 + layout->keyboard_grab.interface = &ivi_layout_keyboard_grab_interface;
51 + layout->keyboard_grab.keyboard = NULL;
55 @@ -2904,6 +2909,66 @@ ivi_layout_surface_is_forced_configure_event(struct ivi_layout_surface *ivisurf)
56 return ivisurf->prop.is_forced_configure_event;
60 +ivi_layout_grab_keyboard_key(struct weston_keyboard_grab *grab,
61 + uint32_t time, uint32_t key, uint32_t state)
63 + struct weston_keyboard *keyboard = grab->keyboard;
64 + struct wl_display *display = keyboard->seat->compositor->wl_display;
66 + struct wl_resource *resource;
68 + wl_resource_for_each(resource, &keyboard->focus_resource_list) {
69 + serial = wl_display_next_serial(display);
70 + wl_keyboard_send_key(resource,
77 + wl_resource_for_each(resource, &keyboard->resource_list) {
78 + serial = wl_display_next_serial(display);
79 + wl_keyboard_send_key(resource,
88 +ivi_layout_grab_keyboard_modifier(struct weston_keyboard_grab *grab,
89 + uint32_t serial, uint32_t mods_depressed,
90 + uint32_t mods_latched, uint32_t mods_locked,
93 + struct wl_resource *resource;
94 + struct weston_keyboard *keyboard = grab->keyboard;
96 + wl_resource_for_each(resource, &keyboard->focus_resource_list) {
97 + wl_keyboard_send_modifiers(resource, serial, mods_depressed,
98 + mods_latched, mods_locked, group);
101 + wl_resource_for_each(resource, &keyboard->resource_list) {
102 + wl_keyboard_send_modifiers(resource, serial, mods_depressed,
103 + mods_latched, mods_locked, group);
108 +ivi_layout_grab_keyboard_cancel(struct weston_keyboard_grab *grab)
110 + (void)grab; /* no op */
113 +static const struct weston_keyboard_grab_interface ivi_layout_keyboard_grab_interface = {
114 + ivi_layout_grab_keyboard_key,
115 + ivi_layout_grab_keyboard_modifier,
116 + ivi_layout_grab_keyboard_cancel
119 static struct ivi_controller_interface ivi_controller_interface = {
122 diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
123 index 3b6c82f..43f48cc 100644
124 --- a/ivi-shell/ivi-shell.c
125 +++ b/ivi-shell/ivi-shell.c
126 @@ -423,6 +423,43 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
131 +handle_seat_destroy(struct wl_listener *listener, void *data)
133 + struct weston_seat *seat = data;
135 + if (seat->keyboard) {
136 + weston_keyboard_end_grab(seat->keyboard);
141 +handle_seat_updated_caps(struct wl_listener *listener, void *data)
143 + struct weston_seat *seat = data;
145 + if ((seat->keyboard_device_count > 0) && seat->keyboard) {
146 + weston_keyboard_start_grab(seat->keyboard,
147 + &(get_instance()->keyboard_grab));
152 +handle_seat_created(struct wl_listener *listener, void *data)
154 + struct weston_seat *seat = data;
155 + struct ivi_shell *shell =
156 + container_of(listener, struct ivi_shell, seat_created_listener);
158 + shell->seat_destroy_listener.notify = handle_seat_destroy;
159 + wl_signal_add(&seat->destroy_signal, &shell->seat_destroy_listener);
161 + shell->seat_updated_caps_listener.notify = handle_seat_updated_caps;
162 + wl_signal_add(&seat->updated_caps_signal, &shell->seat_updated_caps_listener);
164 + handle_seat_updated_caps(&shell->seat_updated_caps_listener, seat);
168 * Initialization of ivi-shell.
170 @@ -432,6 +469,7 @@ module_init(struct weston_compositor *compositor,
172 struct ivi_shell *shell;
173 struct ivi_shell_setting setting = { };
174 + struct weston_seat *seat;
177 shell = zalloc(sizeof *shell);
178 @@ -458,6 +496,13 @@ module_init(struct weston_compositor *compositor,
180 ivi_layout_init_with_compositor(compositor);
182 + shell->seat_created_listener.notify = handle_seat_created;
183 + wl_signal_add(&compositor->seat_created_signal, &shell->seat_created_listener);
185 + wl_list_for_each(seat, &compositor->seat_list, link) {
186 + handle_seat_created(&shell->seat_created_listener, seat);
189 /* Call module_init of ivi-modules which are defined in weston.ini */
190 if (load_controller_modules(compositor, setting.ivi_module,
192 diff --git a/ivi-shell/ivi-shell.h b/ivi-shell/ivi-shell.h
193 index 9a05eb2..dc1d85a 100644
194 --- a/ivi-shell/ivi-shell.h
195 +++ b/ivi-shell/ivi-shell.h
196 @@ -41,6 +41,10 @@ struct ivi_shell
197 struct wl_listener hide_input_panel_listener;
198 struct wl_listener update_input_panel_listener;
200 + struct wl_listener seat_created_listener;
201 + struct wl_listener seat_updated_caps_listener;
202 + struct wl_listener seat_destroy_listener;
204 struct weston_layer input_panel_layer;