1 From 70f5b755b00d5eab576ed897a8301367b0e367a6 Mon Sep 17 00:00:00 2001
2 From: Volodymyr Riazantsev <volodymyr.riazantsev@globallogic.com>
3 Date: Sat, 16 Jul 2016 02:53:25 -0400
4 Subject: [PATCH] ivi-shell: layer-controller-ti: Improve functionality
6 Functionality improved:
8 * can launch multiple application on start
9 * handle keyboard focus:
10 - TAB-LEFTALT can be used for switch focus
12 - focus on new application.
14 Signed-off-by: Volodymyr Riazantsev <volodymyr.riazantsev@globallogic.com>
15 Signed-off-by: Karthik Ramanan <a0393906@ti.com>
17 ivi-shell/ivi-layout-controller-ti.c | 167 +++++++++++++++++++++++++++++++----
18 1 file changed, 148 insertions(+), 19 deletions(-)
20 diff --git a/ivi-shell/ivi-layout-controller-ti.c b/ivi-shell/ivi-layout-controller-ti.c
21 index 4a2d648..9be51d1 100644
22 --- a/ivi-shell/ivi-layout-controller-ti.c
23 +++ b/ivi-shell/ivi-layout-controller-ti.c
28 +#include <linux/input.h>
30 #include "ivi-layout-export.h"
33 @@ -85,6 +87,7 @@ struct hmi_controller_layer {
40 struct wl_list screen_link;
41 @@ -96,8 +99,10 @@ struct hmi_controller_surface {
45 + struct wl_list focus_link;
46 struct wl_listener destroy_listener;
51 struct hmi_controller_screen {
52 @@ -106,11 +111,12 @@ struct hmi_controller_screen {
55 struct hmi_server_setting {
56 - uint32_t base_layer_id;
57 - int32_t panel_height;
58 - char *ivi_homescreen;
59 - char *homescreen_app;
60 - struct wl_array rules;
61 + uint32_t base_layer_id;
62 + int32_t panel_height;
63 + char *ivi_homescreen;
64 + char *homescreen_app;
65 + struct wl_array autolaunch_apps;
66 + struct wl_array rules;
69 struct hmi_controller {
70 @@ -126,6 +132,7 @@ struct hmi_controller {
71 struct wl_listener destroy_listener;
72 struct wl_client *user_interface;
73 struct wl_list layers_list;
74 + struct wl_list focus_history_list;
78 @@ -350,12 +357,59 @@ exit:
82 +move_kbd_focus(struct hmi_controller_surface *ivisurf, struct hmi_controller *hmi_ctrl, bool history)
84 + struct hmi_controller_layer *layer;
85 + struct hmi_controller_surface *surf;
86 + struct weston_seat *seat;
87 + struct weston_keyboard *keyboard;
88 + struct weston_surface *surface;
90 + wl_list_for_each(layer, &hmi_ctrl->layers_list, link) {
91 + wl_list_for_each(surf, &layer->surfaces_list, link) {
94 + wl_list_insert(&hmi_ctrl->focus_history_list, &surf->focus_link);
100 + wl_list_for_each(seat, &hmi_ctrl->compositor->seat_list, link) {
101 + if(!strcmp("default", seat->seat_name))
105 + keyboard = weston_seat_get_keyboard(seat);
111 + surface = ivi_controller_interface->surface_get_weston_surface(ivisurf->ivisurf);
112 + weston_keyboard_set_focus(keyboard, surface);
113 + ivisurf->focus = 1;
115 + if (NULL != ivisurf->focus_link.next)
116 + wl_list_remove(&ivisurf->focus_link);
118 + } else if (history && !wl_list_empty(&hmi_ctrl->focus_history_list)) {
119 + struct hmi_controller_surface *s =
120 + wl_container_of(hmi_ctrl->focus_history_list.next, s, focus_link);
121 + wl_list_remove(&s->focus_link);
122 + surface = ivi_controller_interface->surface_get_weston_surface(s->ivisurf);
123 + weston_keyboard_set_focus(keyboard, surface);
129 set_notification_create_surface(struct ivi_layout_surface *ivisurf,
132 struct hmi_controller *hmi_ctrl = userdata;
133 - struct hmi_controller_layer *hmi_ctrl_layer = NULL;
134 - struct hmi_controller_surface *hmi_ctrl_surf = NULL;
135 + struct hmi_controller_layer *hmi_ctrl_layer;
136 + struct hmi_controller_surface *hmi_ctrl_surf;
137 struct ivi_layout_layer *dest_layer;
138 struct weston_surface *surface;
140 @@ -378,6 +432,7 @@ set_notification_create_surface(struct ivi_layout_surface *ivisurf,
141 hmi_ctrl_surf = calloc(1, sizeof(*hmi_ctrl_surf));
142 hmi_ctrl_surf->ivisurf = ivisurf;
143 wl_list_init(&hmi_ctrl_surf->link);
144 + wl_list_init(&hmi_ctrl_surf->focus_link);
145 wl_list_insert(&hmi_ctrl_layer->surfaces_list, &hmi_ctrl_surf->link);
148 @@ -419,6 +474,9 @@ remove:
150 wl_list_remove(&surf->link);
153 + move_kbd_focus(NULL, hmi_ctrl, true);
155 ivi_controller_interface->layer_remove_surface(dest_layer, ivisurf);
157 if (wl_list_empty(&hmi_ctrl_layer->surfaces_list)) {
158 @@ -451,9 +509,10 @@ set_notification_configure_surface(struct ivi_layout_surface *ivisurf,
161 struct hmi_controller *hmi_ctrl = userdata;
162 - struct hmi_controller_layer *hmi_ctrl_layer = NULL;
163 + struct hmi_controller_layer *hmi_ctrl_layer;
164 struct weston_surface *surface;
165 - struct hmi_controller_surface *hmi_ctrl_surf = NULL;
166 + struct weston_seat *seat = NULL;
167 + struct hmi_controller_surface *hmi_ctrl_surf;
168 int src_rect[4] = {0};
169 int dest_rect[4] = {0};
171 @@ -511,6 +570,16 @@ found:
172 dest_rect[3] = hmi_ctrl_layer->rule->dest_rect[3] > 0 ?
173 hmi_ctrl_layer->rule->dest_rect[3] : dest_rect[3] ;
176 + if (hmi_ctrl_layer->rule->autofocus) {
178 + wl_list_for_each(seat, &hmi_ctrl->compositor->seat_list, link) {
179 + if(!strcmp("default", seat->seat_name))
183 + move_kbd_focus(hmi_ctrl_surf, hmi_ctrl, false);
187 ivi_controller_interface->surface_set_source_rectangle(ivisurf
188 @@ -522,6 +591,7 @@ found:
189 , dest_rect[2], dest_rect[3]);
191 ivi_controller_interface->surface_set_visibility(ivisurf, true);
193 ivi_controller_interface->commit_changes();
195 hmi_ctrl_surf->conf_num++;
196 @@ -543,14 +613,9 @@ hmi_server_setting_create(struct weston_compositor *ec)
197 weston_config_section_get_uint(shell_section, "base-layer-id",
198 &setting->base_layer_id, 1000);
200 - if ((shell_section = weston_config_get_section(config, "ivi-autolaunch",
202 - weston_config_section_get_string(shell_section, "path",
203 - &setting->homescreen_app, NULL);
207 wl_array_init(&setting->rules);
208 + wl_array_init(&setting->autolaunch_apps);
209 + wl_array_init(&setting->autolaunch_apps);
211 while (weston_config_next_section(config, &shell_section, &name)) {
213 @@ -564,6 +629,12 @@ hmi_server_setting_create(struct weston_compositor *ec)
215 struct hmi_launch_rule *rule = NULL;
217 + if (!strcmp(name, "ivi-autolaunch")) {
218 + char **s = wl_array_add(&setting->autolaunch_apps, sizeof(*s));
219 + weston_config_section_get_string(shell_section, "path", s, NULL);
223 if (0 != strcmp(name, "ivi-layout-rule"))
226 @@ -573,7 +644,7 @@ hmi_server_setting_create(struct weston_compositor *ec)
228 weston_config_section_get_int(shell_section, "order", &order, -1);
229 weston_config_section_get_int(shell_section, "mode", &mode, -1);
230 - weston_config_section_get_int(shell_section, "focus_on", &focus_on, -1);
231 + weston_config_section_get_int(shell_section, "focus_on", &focus_on, 0);
232 weston_config_section_get_int(shell_section, "screen", &screen_id, -1);
234 if (0 == weston_config_section_get_string(shell_section, "crop_rect",
235 @@ -631,8 +702,10 @@ hmi_controller_destroy(struct wl_listener *listener, void *data)
237 static void hmi_controller_launch_homescreen(struct hmi_controller *hmi_ctrl)
239 - if (hmi_ctrl->hmi_setting->homescreen_app) {
240 - if(system(hmi_ctrl->hmi_setting->homescreen_app)) {
243 + wl_array_for_each(app, &hmi_ctrl->hmi_setting->autolaunch_apps) {
248 @@ -674,6 +747,7 @@ hmi_controller_create(struct weston_compositor *ec)
249 &hmi_ctrl->destroy_listener);
251 wl_list_init(&hmi_ctrl->layers_list);
252 + wl_list_init(&hmi_ctrl->focus_history_list);
256 @@ -719,6 +793,57 @@ initialize(struct hmi_controller *hmi_ctrl)
261 +switch_focus_bindings(struct weston_keyboard *keyboard, uint32_t time,
262 + uint32_t key, void *data)
264 + struct hmi_controller *hmi_ctrl = data;
265 + struct hmi_controller_layer *hmi_ctrl_layer, *next_l, *cycle_l = NULL;
266 + struct hmi_controller_surface *hmi_ctrl_surf;
269 + wl_list_for_each(hmi_ctrl_layer, &hmi_ctrl->layers_list, link) {
270 + wl_list_for_each(hmi_ctrl_surf, &hmi_ctrl_layer->surfaces_list, link) {
271 + if (hmi_ctrl_surf->focus) {
277 + hmi_ctrl_surf = NULL;
281 + wl_list_for_each(next_l, &hmi_ctrl->layers_list, link) {
284 + if (next_l->rule && next_l->rule->autofocus) {
289 + if (next_l == hmi_ctrl_layer) {
293 + if (next_l->rule && next_l->rule->autofocus) {
304 + move_kbd_focus(container_of(cycle_l->surfaces_list.next
305 + , struct hmi_controller_surface
307 + , hmi_ctrl, false);
311 /*****************************************************************************
313 ****************************************************************************/
314 @@ -753,5 +878,9 @@ controller_module_init(struct weston_compositor *ec,
316 hmi_controller_launch_homescreen(hmi_ctrl);
318 + weston_compositor_add_key_binding(ec, KEY_TAB , MODIFIER_ALT,
319 + switch_focus_bindings, hmi_ctrl);
320 + weston_install_debug_key_binding(ec, 0);