2 * Copyright © 2012 Intel Corporation
3 * Copyright © 2013 TOYOTA MOTOR CORPORATION
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting documentation, and
9 * that the name of the copyright holders not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no representations
12 * about the suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * @brief HomeScreen for unit test of Weston(Wayland) IVI plugins
36 #include <sys/ioctl.h>
40 #include <sys/types.h>
45 #include <linux/input.h>
46 #include <wayland-client.h>
47 #include <ilm_control.h>
48 #include "ico_window_mgr-client-protocol.h"
49 #include "ico_input_mgr-client-protocol.h"
50 #include "ico_input_mgr.h"
51 #include "test-common.h"
54 #define SHM_SIZE (16*1024*1024)
55 #define MAX_CON_NAME 127
59 struct surface_name *next;
62 char appid[MAX_APPID];
72 struct wl_display *display;
73 struct wl_registry *registry;
74 struct wl_compositor *compositor;
75 struct wl_shell *shell;
76 struct ico_window_mgr *ico_window_mgr;
77 struct ico_input_mgr_control *ico_input_mgr;
78 struct ico_input_mgr_device *ico_input_device;
79 struct ico_exinput *ico_exinput;
82 struct output *output[MAX_OUTPUT];
83 struct surface *surface;
84 struct surface_name *surface_name;
85 struct surface_name *bgsurface_name;
91 int surface_destroyed;
93 int visible_on_create;
94 char connect[MAX_CON_NAME+1];
98 struct display *display;
100 struct wl_pointer *pointer;
101 struct wl_keyboard *keyboard;
102 struct wl_touch *touch;
104 uint32_t button_mask;
105 struct surface *pointer_focus;
106 struct surface *keyboard_focus;
107 uint32_t last_key, last_key_state;
111 struct display *display;
112 struct wl_output *output;
118 struct display *display;
119 struct wl_surface *surface;
120 struct wl_shell_surface *shell_surface;
121 struct output *output;
125 EGLSurface egl_surface;
128 static void clear_surface(struct display *display);
131 pointer_handle_enter(void *data, struct wl_pointer *pointer,
132 uint32_t serial, struct wl_surface *surface,
133 wl_fixed_t x, wl_fixed_t y)
135 struct input *input = data;
137 input->pointer_focus = wl_surface_get_user_data(surface);
138 input->x = wl_fixed_to_double(x);
139 input->y = wl_fixed_to_double(y);
140 print_log("HOMESCREEN: got pointer enter (%d,%d), surface %p",
141 (int)input->x, (int)input->y, surface);
145 pointer_handle_leave(void *data, struct wl_pointer *pointer,
146 uint32_t serial, struct wl_surface *surface)
148 struct input *input = data;
150 input->pointer_focus = NULL;
152 print_log("HOMESCREEN: got pointer leave, surface %p", surface);
156 pointer_handle_motion(void *data, struct wl_pointer *pointer,
157 uint32_t time, wl_fixed_t x, wl_fixed_t y)
159 struct input *input = data;
161 input->x = wl_fixed_to_double(x);
162 input->y = wl_fixed_to_double(y);
164 print_log("HOMESCREEN: got pointer motion (%d,%d)", (int)input->x, (int)input->y);
168 pointer_handle_button(void *data, struct wl_pointer *pointer,
169 uint32_t serial, uint32_t time, uint32_t button, uint32_t state_w)
171 struct input *input = data;
173 enum wl_pointer_button_state state = state_w;
175 bit = 1 << (button - BTN_LEFT);
176 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
177 input->button_mask |= bit;
179 input->button_mask &= ~bit;
180 print_log("HOMESCREEN: got pointer button %u %u", button, state_w);
184 pointer_handle_axis(void *data, struct wl_pointer *pointer,
185 uint32_t time, uint32_t axis, wl_fixed_t value)
187 print_log("HOMESCREEN: got pointer axis %u %d", axis, value);
191 keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
192 uint32_t format, int fd, uint32_t size)
195 print_log("HOMESCREEN: got keyboard keymap");
199 keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
200 uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
202 struct input *input = data;
204 input->keyboard_focus = wl_surface_get_user_data(surface);
205 print_log("HOMESCREEN: got keyboard enter, surface %p", surface);
209 keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
210 uint32_t serial, struct wl_surface *surface)
212 struct input *input = data;
214 input->keyboard_focus = NULL;
215 print_log("HOMESCREEN: got keyboard leave, surface %p", surface);
219 keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
220 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
222 struct input *input = data;
224 input->last_key = key;
225 input->last_key_state = state;
227 print_log("HOMESCREEN: got keyboard key %u %u", key, state);
231 keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
232 uint32_t serial, uint32_t mods_depressed,
233 uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
235 print_log("HOMESCREEN: got keyboard modifier");
239 touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time,
240 struct wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y)
242 print_log("HOMESCREEN: got touch down %d (%d,%d)", id, x/256, y/256);
246 touch_handle_up(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time,
249 print_log("HOMESCREEN: got touch up %d", id);
253 touch_handle_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
254 int32_t id, wl_fixed_t x, wl_fixed_t y)
256 print_log("HOMESCREEN: got touch motion %d (%d,%d)", id, x/256, y/256);
260 touch_handle_frame(void *data, struct wl_touch *wl_touch)
262 print_log("HOMESCREEN: got touch frame");
266 touch_handle_cancel(void *data, struct wl_touch *wl_touch)
268 print_log("HOMESCREEN: got touch cancel");
271 static const struct wl_pointer_listener pointer_listener = {
272 pointer_handle_enter,
273 pointer_handle_leave,
274 pointer_handle_motion,
275 pointer_handle_button,
279 static const struct wl_keyboard_listener keyboard_listener = {
280 keyboard_handle_keymap,
281 keyboard_handle_enter,
282 keyboard_handle_leave,
284 keyboard_handle_modifiers,
287 static const struct wl_touch_listener touch_listener = {
296 seat_handle_capabilities(void *data, struct wl_seat *seat,
297 enum wl_seat_capability caps)
299 struct input *input = data;
301 print_log("HOMESCREEN: seat_handle_capabilities caps=%x", caps);
303 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
304 input->pointer = wl_seat_get_pointer(seat);
305 print_log("HOMESCREEN: seat_handle_capabilities add pointer=%x", (int)input->pointer);
306 wl_pointer_set_user_data(input->pointer, input);
307 wl_pointer_add_listener(input->pointer, &pointer_listener, input);
309 else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
310 print_log("HOMESCREEN: seat_handle_capabilities delete pointer");
311 wl_pointer_destroy(input->pointer);
312 input->pointer = NULL;
315 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
316 input->keyboard = wl_seat_get_keyboard(seat);
317 print_log("HOMESCREEN: seat_handle_capabilities add keyboard=%x", (int)input->keyboard);
318 wl_keyboard_set_user_data(input->keyboard, input);
319 wl_keyboard_add_listener(input->keyboard, &keyboard_listener, input);
321 else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
322 print_log("HOMESCREEN: seat_handle_capabilities delete keyboard");
323 wl_keyboard_destroy(input->keyboard);
324 input->keyboard = NULL;
327 if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) {
328 input->touch = wl_seat_get_touch(seat);
329 print_log("HOMESCREEN: seat_handle_capabilities add touch=%x", (int)input->touch);
330 wl_touch_set_user_data(input->touch, input);
331 wl_touch_add_listener(input->touch, &touch_listener, input);
333 else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
334 print_log("HOMESCREEN: seat_handle_capabilities delete touch");
335 wl_touch_destroy(input->touch);
340 static const struct wl_seat_listener seat_listener = {
341 seat_handle_capabilities,
345 surface_enter(void *data, struct wl_surface *wl_surface, struct wl_output *output)
347 struct surface *surface = data;
349 surface->output = wl_output_get_user_data(output);
351 print_log("HOMESCREEN: got surface enter, output %p", surface->output);
355 surface_leave(void *data, struct wl_surface *wl_surface, struct wl_output *output)
357 struct surface *surface = data;
359 surface->output = NULL;
361 print_log("HOMESCREEN: got surface leave, output %p",
362 wl_output_get_user_data(output));
365 static const struct wl_surface_listener surface_listener = {
371 create_surface(struct display *display, const char *title)
373 struct surface *surface;
376 surface = malloc(sizeof *surface);
378 surface->display = display;
379 display->surface = surface;
380 surface->surface = wl_compositor_create_surface(display->compositor);
381 wl_surface_add_listener(surface->surface, &surface_listener, surface);
383 if (display->shell) {
384 surface->shell_surface =
385 wl_shell_get_shell_surface(display->shell, surface->surface);
386 if (surface->shell_surface) {
387 wl_shell_surface_set_toplevel(surface->shell_surface);
388 wl_shell_surface_set_title(surface->shell_surface, title);
391 wl_display_flush(display->display);
393 id = wl_proxy_get_id((struct wl_proxy *) surface->surface);
394 print_log("HOMESCREEN: create surface = %d", id);
396 poll(NULL, 0, 100); /* Wait for next frame where we'll get events. */
398 wl_display_roundtrip(display->display);
400 surface->dpy = opengl_init(display->display, &surface->conf, &surface->ctx);
402 surface->egl_surface = opengl_create_window(display->display, surface->surface,
403 surface->dpy, surface->conf,
404 surface->ctx, display->init_width,
405 display->init_height,
406 display->init_color);
407 clear_surface(display);
408 print_log("HOMESCREEN: created egl_surface %08x", (int)surface->egl_surface);
413 clear_surface(struct display *display)
415 if (! display->surface) {
416 create_surface(display, "HomeScreen-BG");
419 opengl_clear_window(display->init_color);
420 opengl_swap_buffer(display->display,
421 display->surface->dpy, display->surface->egl_surface);
426 output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
427 int physical_width, int physical_height, int subpixel,
428 const char *make, const char *model, int32_t transform)
430 struct output *output = data;
432 print_log("HOMESCREEN: Event[handle_geometry] %08x x/y=%d/%d p.w/h=%d/%d trans=%d",
433 (int)wl_output, x, y, physical_width, physical_height, transform);
440 output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
441 int width, int height, int refresh)
443 struct output *output = data;
445 print_log("HOMESCREEN: Event[handle_mode] %08x x/y=%d/%d flags=%08x refresh=%d",
446 (int)wl_output, width, height, flags, refresh);
448 if (flags & WL_OUTPUT_MODE_CURRENT) {
449 struct display *display = output->display;
451 output->width = width;
452 output->height = height;
454 display->init_width = width;
455 display->init_height = height;
457 if (display->bgsurface_name) {
458 /* ico_window_mgr_set_positionsize(display->ico_window_mgr,
459 display->bgsurface_name->surfaceid,
460 0, 0, 0, 0, width, height); */
462 else if (display->bg_created == 0) {
463 display->bg_created = 9;
464 create_surface(display, "HomeScreen-BG");
469 static const struct wl_output_listener output_listener = {
470 output_handle_geometry,
475 search_surface(struct display *display, const char *surfname)
477 struct surface_name *p;
479 p = display->surface_name;
481 if (strcmp(p->appid, surfname) == 0) break;
491 static struct surface_name *
492 search_surfacename(struct display *display, const char *surfname)
494 struct surface_name *p;
496 p = display->surface_name;
498 if (strcmp(p->appid, surfname) == 0) break;
502 print_log("HOMESCREEN: app(%s) dose not exist", surfname);
508 static struct surface_name *
509 search_surfaceid(struct display *display, const int surfaceid)
511 struct surface_name *p;
513 p = display->surface_name;
515 if (p->surfaceid == surfaceid) {
526 window_created(void *data, struct ico_window_mgr *ico_window_mgr,
527 uint32_t surfaceid, const char *winname, int32_t pid,
528 const char *appid, int32_t layertype)
530 struct display *display = data;
531 struct surface_name *p;
532 struct surface_name *fp;
534 display->surface_created = 1;
535 p = display->surface_name;
538 if (p->surfaceid == (int)surfaceid) break;
543 print_log("HOMESCREEN: Event[window_created] "
544 "surface=%08x(app=%s,name=%s,type=%x) exist",
545 (int)surfaceid, appid, winname, layertype);
548 print_log("HOMESCREEN: Event[window_created] "
549 "new surface=%08x(app=%s) winname=%s layertype=%x",
550 (int)surfaceid, appid, winname, layertype);
551 p = malloc(sizeof(struct surface_name));
555 memset(p, 0, sizeof(struct surface_name));
560 display->surface_name = p;
563 p->surfaceid = surfaceid;
565 strncpy(p->appid, appid, MAX_APPID-1);
567 /* Set default size and show */
569 /* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
570 0, p->x, p->y, p->width, p->height, 0); */
573 print_log("HOMESCREEN: Created window[%08x] (app=%s)", (int)surfaceid, appid);
575 if (strncasecmp(appid, "test-homescreen", 15) == 0) {
576 display->bgsurface_name = p;
577 if (display->bg_created == 1) {
578 display->bg_created = 9;
579 /* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
581 display->init_width, display->init_height, 0);*/
583 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, 1, 0, 0); */
584 print_log("HOMESCREEN: Created window[%08x] (app=%s) Visible",
585 (int)surfaceid, appid);
591 window_name(void *data, struct ico_window_mgr *ico_window_mgr,
592 uint32_t surfaceid, const char *winname)
594 print_log("HOMESCREEN: Window Name[%08x] (name=%s)", (int)surfaceid, winname);
598 window_destroyed(void *data, struct ico_window_mgr *ico_window_mgr, uint32_t surfaceid)
600 struct display *display = data;
601 struct surface_name *p;
602 struct surface_name *fp;
604 display->surface_destroyed = 1;
605 p = search_surfaceid(display, (int)surfaceid);
607 print_log("HOMESCREEN: Event[window_destroyed] surface=%08x dose not exist",
611 print_log("HOMESCREEN: Event[window_destroyed] surface=%08x", (int)surfaceid);
612 if (p == display->surface_name) {
613 display->surface_name = p->next;
616 fp = display->surface_name;
630 window_visible(void *data, struct ico_window_mgr *ico_window_mgr,
631 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t hint)
633 struct display *display = data;
634 struct surface_name *p;
636 p = search_surfaceid(display, (int)surfaceid);
638 print_log("HOMESCREEN: Event[window_visible] surface=%08x dose not exist",
642 print_log("HOMESCREEN: Event[window_visible] surface=%08x "
643 "visible=%d raise=%d hint=%d", (int)surfaceid, visible, raise, hint);
644 p->visible = visible;
646 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
647 visible, ICO_WINDOW_MGR_V_NOCHANGE, 0); */
653 window_configure(void *data, struct ico_window_mgr *ico_window_mgr,
654 uint32_t surfaceid, uint32_t node, int32_t layertype, uint32_t layer,
655 int32_t x, int32_t y, int32_t width, int32_t height, int32_t hint)
657 struct display *display = data;
658 struct surface_name *p;
660 print_log("HOMESCREEN: Event[window_configure] surface=%08x "
661 "node=%x layer=%x.%x x/y=%d/%d w/h=%d/%d hint=%d",
662 (int)surfaceid, node, layertype, layer, x, y, width, height, hint);
664 p = search_surfaceid(display, (int)surfaceid);
666 print_log("HOMESCREEN: Event[window_configure] surface=%08x dose not exist",
675 window_layer_visible(void *data, struct ico_window_mgr *ico_window_mgr,
676 uint32_t layer, int32_t visible)
678 print_log("HOMESCREEN: Event[layer_visible]layer=%x visible=%d",
679 (int)layer, visible);
683 window_active(void *data, struct ico_window_mgr *ico_window_mgr,
684 uint32_t surfaceid, const int32_t active)
686 print_log("HOMESCREEN: Event[window_active] surface=%08x acive=%d",
687 (int)surfaceid, (int)active);
688 if ((surfaceid & 0x0000ffff) == 0x0001) {
689 /* ico_window_mgr_set_visible(ico_window_mgr, surfaceid,
690 ICO_WINDOW_MGR_V_NOCHANGE, 0, 0); */
695 window_surfaces(void *data, struct ico_window_mgr *ico_window_mgr,
696 const char *appid, int32_t pid, struct wl_array *surfaces)
698 print_log("HOMESCREEN: Event[app_surfaces] app=%s pid=%d", appid, pid);
702 window_map(void *data, struct ico_window_mgr *ico_window_mgr,
703 int32_t event, uint32_t surfaceid, uint32_t type, uint32_t target,
704 int32_t width, int32_t height, int32_t stride, uint32_t format)
706 struct display *display = data;
710 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
711 strcpy(sevt, "Contents"); break;
712 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
713 strcpy(sevt, "Resize"); break;
714 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
715 strcpy(sevt, "Map"); break;
716 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
717 strcpy(sevt, "Unmap"); break;
718 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
719 sprintf(sevt, "Error %d", type); break;
721 sprintf(sevt, "??%d??", event); break;
723 print_log("HOMESCREEN: Event[map_surface] ev=%s(%d) surf=%08x type=%d target=%x "
724 "w/h/s/f=%d/%d/%d/%x",
725 sevt, event, (int)surfaceid, type, target, width, height, stride, format);
726 /* if ((event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP) ||
727 (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS)) { */
728 opengl_thumbnail(display->display, surfaceid, display->surface->dpy,
729 display->surface->conf, display->surface->egl_surface,
730 display->surface->ctx, target, width, height, stride, format);
736 static const struct ico_window_mgr_listener window_mgr_listener = {
743 window_layer_visible,
750 cb_input_capabilities(void *data, struct ico_exinput *ico_exinput,
751 const char *device, int32_t type, const char *swname, int32_t input,
752 const char *codename, int32_t code)
754 print_log("HOMESCREEN: Event[input_capabilities] device=%s type=%d sw=%s input=%d "
755 "code=%s[%d]", device, type, swname, input, codename, code);
759 cb_input_code(void *data, struct ico_exinput *ico_exinput,
760 const char *device, int32_t input, const char *codename, int32_t code)
762 print_log("HOMESCREEN: Event[input_code] device=%s input=%d code=%s[%d]",
763 device, input, codename, code);
767 cb_input_input(void *data, struct ico_exinput *ico_exinput, uint32_t time,
768 const char *device, int32_t input, int32_t code, int32_t state)
770 print_log("HOMESCREEN: Event[input_input] device=%s input=%d code=%d state=%d",
771 device, input, code, state);
774 static const struct ico_exinput_listener exinput_listener = {
775 cb_input_capabilities,
781 cb_input_regions(void *data, struct ico_input_mgr_device *ico_input_mgr_device,
782 struct wl_array *regions)
784 struct ico_uifw_input_region *region;
790 wl_array_for_each(region, regions) {
793 print_log("HOMESCREEN: Event[input_regions] number of regions=%d", n);
795 wl_array_for_each(region, regions) {
797 switch (region->change) {
798 case ICO_INPUT_MGR_DEVICE_REGION_ADD:
799 strcpy(schange, "Add");
801 case ICO_INPUT_MGR_DEVICE_REGION_REMOVE:
802 strcpy(schange, "Remove");
804 case ICO_INPUT_MGR_DEVICE_REGION_REMOVEALL:
805 strcpy(schange, "RemoveAll");
808 sprintf(schange, "?%d?", region->change);
811 print_log("HOMESCREEN:%2d. %s %d.%08x(%d/%d) %d/%d-%d/%d "
812 "hot=%d/%d cur=%d/%d-%d/%d attr=%x",
813 n, schange, region->node, region->surfaceid, region->surface_x,
814 region->surface_y, region->x, region->y, region->width,
815 region->height, region->hotspot_x, region->hotspot_y,
816 region->cursor_x, region->cursor_y, region->cursor_width,
817 region->cursor_height, region->attr);
821 print_log("HOMESCREEN: Event[input_regions] no region");
825 static const struct ico_input_mgr_device_listener device_listener = {
831 handle_global(void *data, struct wl_registry *registry, uint32_t id,
832 const char *interface, uint32_t version)
834 struct display *display = data;
836 struct output *output;
838 print_log("HOMESCREEN: handle_global: interface=<%s> id=%d", interface, (int)id);
840 if (strcmp(interface, "wl_compositor") == 0) {
841 display->compositor =
842 wl_registry_bind(display->registry, id, &wl_compositor_interface, 1);
844 else if (strcmp(interface, "wl_seat") == 0) {
845 input = calloc(1, sizeof *input);
846 input->display = display;
847 input->seat = wl_registry_bind(display->registry, id, &wl_seat_interface, 1);
848 input->pointer_focus = NULL;
849 input->keyboard_focus = NULL;
851 wl_seat_add_listener(input->seat, &seat_listener, input);
852 display->input = input;
854 else if (strcmp(interface, "wl_output") == 0) {
855 if (display->num_output < MAX_OUTPUT) {
856 output = malloc(sizeof *output);
857 output->display = display;
858 output->output = wl_registry_bind(display->registry, id, &wl_output_interface, 1);
859 wl_output_add_listener(output->output, &output_listener, output);
860 display->output[display->num_output] = output;
862 print_log("HOMESCREEN: created output[%d] global %p",
863 display->num_output, display->output[display->num_output]);
864 display->num_output ++;
867 else if (strcmp(interface, "wl_shell") == 0) {
869 wl_registry_bind(display->registry, id, &wl_shell_interface, 1);
871 else if (strcmp(interface, "ico_window_mgr") == 0) {
872 display->ico_window_mgr =
873 wl_registry_bind(display->registry, id, &ico_window_mgr_interface, 1);
874 /* ico_window_mgr_add_listener(display->ico_window_mgr, &window_mgr_listener, display); */
875 print_log("HOMESCREEN: created window_mgr global %p", display->ico_window_mgr);
877 /* ico_window_mgr_declare_manager(display->ico_window_mgr, 1); */
879 else if (strcmp(interface, "ico_input_mgr_control") == 0) {
880 display->ico_input_mgr = wl_registry_bind(display->registry, id,
881 &ico_input_mgr_control_interface, 1);
882 print_log("HOMESCREEN: created input_mgr global %p", display->ico_input_mgr);
884 else if (strcmp(interface, "ico_input_mgr_device") == 0) {
885 display->ico_input_device = wl_registry_bind(display->registry, id,
886 &ico_input_mgr_device_interface, 1);
887 ico_input_mgr_device_add_listener(display->ico_input_device,
888 &device_listener, display);
889 print_log("HOMESCREEN: created input_device global %p", display->ico_input_device);
891 else if (strcmp(interface, "ico_exinput") == 0) {
892 display->ico_exinput =
893 wl_registry_bind(display->registry, id, &ico_exinput_interface, 1);
894 ico_exinput_add_listener(display->ico_exinput, &exinput_listener, display);
895 print_log("HOMESCREEN: created exinput global %p", display->ico_exinput);
897 /* ico_window_mgr_declare_manager(display->ico_window_mgr, 1); */
899 display->bg_created = 1;
900 create_surface(display, "HomeScreen-BG");
904 static const struct wl_registry_listener registry_listener = {
909 launch_app(struct display *display, char *buf)
913 display->surface_created = 0;
914 display->surface_destroyed = 0;
915 snprintf(sbuf, sizeof(sbuf)-1, "%s &", skip_spaces(buf));
916 if (system(sbuf) < 0) {
917 print_log("HOMESCREEN: Can not launch application[%s]", sbuf);
920 sleep_with_wayland(display->display, 500);
925 kill_app(struct display *display, char *buf)
929 struct surface_name *p;
930 struct surface_name *fp;
932 narg = pars_command(buf, args, 10);
934 p = search_surfacename(display, args[0]);
936 print_log("HOMESCREEN: kill[%s] Application dose not exist", args[0]);
938 else if (kill(p->pid, SIGINT) < 0) {
939 print_log("HOMESCREEN: kill[%s.%d] Application dose not exist",
943 sleep_with_wayland(display->display, 300);
944 p = search_surfacename(display, args[0]);
945 if ((p != NULL) && (kill(p->pid, SIGTERM) >= 0)) {
946 sleep_with_wayland(display->display, 200);
947 p = search_surfacename(display, args[0]);
949 kill(p->pid, SIGKILL);
950 sleep_with_wayland(display->display, 200);
954 p = search_surfacename(display, args[0]);
956 if (p == display->surface_name) {
957 display->surface_name = p->next;
960 fp = display->surface_name;
972 print_log("HOMESCREEN: kill command[kill appid] has no argument");
977 layer_surface(struct display *display, char *buf)
984 narg = pars_command(buf, args, 10);
986 surfaceid = search_surface(display, args[0]);
987 layerid = strtol(args[1], (char **)0, 0);
988 if ((surfaceid >= 0) && (layerid >= 0)) {
989 print_log("HOMESCREEN: set_window_layer(%s,%08x)",
990 args[0], surfaceid, layerid);
991 /* ico_window_mgr_set_window_layer(display->ico_window_mgr, surfaceid, layerid); */
994 print_log("HOMESCREEN: Unknown surface(%s) at layer command", args[0]);
998 print_log("HOMESCREEN: layer command[layer appid layerid] has no argument");
1003 positionsize_surface(struct display *display, char *buf)
1006 struct surface_name *p;
1009 int x, y, width, height;
1010 /* int anima = 0; */
1013 narg = pars_command(buf, args, 10);
1015 surfaceid = search_surface(display, args[0]);
1016 p = search_surfacename(display, args[0]);
1017 x = strtol(args[1], (char **)0, 0);
1018 y = strtol(args[2], (char **)0, 0);
1019 width = strtol(args[3], (char **)0, 0);
1020 height = strtol(args[4], (char **)0, 0);
1022 node = strtol(args[5], (char **)0, 0);
1031 /* anima = strtol(args[6], (char **)0, 0); */
1033 if ((surfaceid >= 0) && (x >= 0) && (y >=0) && (width >= 0) && (height >=0)) {
1034 print_log("HOMESCREEN: set_positionsize(%s,%08x,%d,%d,%d,%d,%d)",
1035 args[0], surfaceid, node, x, y, width, height);
1036 /* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1037 node, x, y, width, height, anima); */
1040 print_log("HOMESCREEN: Unknown surface(%s) at positionsize command", args[0]);
1044 print_log("HOMESCREEN: positionsize command"
1045 "[positionsize appid x y width heigh node anima] has no argument");
1050 move_surface(struct display *display, char *buf)
1053 struct surface_name *p;
1060 narg = pars_command(buf, args, 10);
1062 surfaceid = search_surface(display, args[0]);
1063 p = search_surfacename(display, args[0]);
1064 x = strtol(args[1], (char **)0, 0);
1065 y = strtol(args[2], (char **)0, 0);
1067 node = strtol(args[3], (char **)0, 0);
1069 if (p) node = p->node;
1072 if (p) p->node = node;
1078 anima = strtol(args[4], (char **)0, 0);
1081 if ((surfaceid >= 0) && (x >= 0) && (y >=0)) {
1082 print_log("HOMESCREEN: move(%s,%08x,%d.%d,%d anima=%d)", args[0], surfaceid,
1084 /* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1086 ICO_WINDOW_MGR_V_NOCHANGE,
1087 ICO_WINDOW_MGR_V_NOCHANGE, anima); */
1090 print_log("HOMESCREEN: Unknown surface(%s) at move command", args[0]);
1094 print_log("HOMESCREEN: move command[positionsize appid x y node anima] has no argument");
1099 resize_surface(struct display *display, char *buf)
1102 struct surface_name *p;
1109 narg = pars_command(buf, args, 10);
1111 surfaceid = search_surface(display, args[0]);
1112 p = search_surfacename(display, args[0]);
1116 width = strtol(args[1], (char **)0, 0);
1117 height = strtol(args[2], (char **)0, 0);
1119 anima = strtol(args[3], (char **)0, 0);
1122 if ((surfaceid >= 0) && (width >= 0) && (height >=0)) {
1123 print_log("HOMESCREEN: resize(%s,%08x,%d.%d,%d,anima=%d)",
1124 args[0], surfaceid, node, width, height, anima);
1125 /* ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1126 node, ICO_WINDOW_MGR_V_NOCHANGE,
1127 ICO_WINDOW_MGR_V_NOCHANGE, width, height, anima); */
1130 print_log("HOMESCREEN: Unknown surface(%s) at resize command", args[0]);
1134 print_log("HOMESCREEN: positionsize command"
1135 "[resize appid width heigh anima] has no argument");
1140 visible_surface(struct display *display, char *buf)
1149 narg = pars_command(buf, args, 10);
1151 surfaceid = search_surface(display, args[0]);
1152 visible = strtol(args[1], (char **)0, 0);
1153 raise = strtol(args[2], (char **)0, 0);
1155 anima = strtol(args[3], (char **)0, 0);
1157 if ((surfaceid >= 0) && (visible >= 0) && (raise >=0)) {
1158 print_log("HOMESCREEN: visible(%s,%08x,%d,%d,%d)",
1159 args[0], surfaceid, visible, raise, anima);
1160 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1161 visible, raise, anima); */
1164 print_log("HOMESCREEN: Unknown surface(%s) at visible command", args[0]);
1168 print_log("HOMESCREEN: visible command[visible appid visible raise] "
1174 show_surface(struct display *display, char *buf, const int show)
1185 narg = pars_command(buf, args, 10);
1187 surfaceid = search_surface(display, args[0]);
1189 anima = strtol(args[1], (char **)0, 0);
1195 if (narg >= 3) ax = strtol(args[2], (char **)0, 0);
1196 if (narg >= 4) ay = strtol(args[3], (char **)0, 0);
1197 if (narg >= 5) awidth = strtol(args[4], (char **)0, 0);
1198 if (narg >= 6) aheight = strtol(args[5], (char **)0, 0);
1201 if (surfaceid >= 0) {
1204 print_log("HOMESCREEN: show anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)",
1205 args[0], surfaceid, ax, ay, awidth, aheight);
1206 /* ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid,
1207 1, ax, ay, awidth, aheight); */
1210 print_log("HOMESCREEN: show(%s,%08x,anima=%d)",
1211 args[0], surfaceid, anima);
1212 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1213 1, ICO_WINDOW_MGR_V_NOCHANGE, anima); */
1218 print_log("HOMESCREEN: hide anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)",
1219 args[0], surfaceid, ax, ay, awidth, aheight);
1220 /* ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid,
1221 0, ax, ay, awidth, aheight); */
1224 print_log("HOMESCREEN: hide(%s,%08x,anima=%d)",
1225 args[0], surfaceid, anima);
1226 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1227 0, ICO_WINDOW_MGR_V_NOCHANGE, anima); */
1232 print_log("HOMESCREEN: Unknown surface(%s) at show/hide command", args[0]);
1236 print_log("HOMESCREEN: show command[show/hide appid anima x y width height]"
1237 " has no argument");
1242 raise_surface(struct display *display, char *buf, const int raise)
1249 narg = pars_command(buf, args, 10);
1251 surfaceid = search_surface(display, args[0]);
1253 anima = strtol(args[1], (char **)0, 0);
1255 if (surfaceid >= 0) {
1257 print_log("HOMESCREEN: raise(%s,%08x,anima=%d)", args[0], surfaceid, anima);
1258 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1259 ICO_WINDOW_MGR_V_NOCHANGE, 1, anima); */
1262 print_log("HOMESCREEN: lower(%s,%08x,anima=%d)", args[0], surfaceid, anima);
1263 /* ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1264 ICO_WINDOW_MGR_V_NOCHANGE, 0, anima); */
1268 print_log("HOMESCREEN: Unknown surface(%s) at raise/lower command", args[0]);
1272 print_log("HOMESCREEN: show command[raise/lower appid anima] has no argument");
1277 active_window(struct display *display, char *buf)
1284 narg = pars_command(buf, args, 10);
1286 surfaceid = search_surface(display, args[0]);
1288 target = strtol(args[1], (char **)0, 0);
1293 if (surfaceid >= 0) {
1294 print_log("HOMESCREEN: active(%s,%08x,target=%x)", args[0], surfaceid, target);
1295 /* ico_window_mgr_set_active(display->ico_window_mgr, surfaceid, target); */
1298 print_log("HOMESCREEN: Unknown surface(%s) at active command", args[0]);
1302 print_log("HOMESCREEN: active command[active appid[target]] has no argument");
1308 animation_surface(struct display *display, char *buf)
1315 narg = pars_command(buf, args, 10);
1317 surfaceid = search_surface(display, args[0]);
1318 if (surfaceid >= 0) {
1320 time = strtol(args[2], (char **)0, 0);
1325 print_log("HOMESCREEN: animation(%s,%08x,%s,%d)",
1326 args[0], surfaceid, args[1], time);
1327 ico_window_mgr_set_animation(display->ico_window_mgr, surfaceid, 0x7fffffff,
1331 print_log("HOMESCREEN: Unknown surface(%s) at animation command", args[0]);
1335 print_log("HOMESCREEN: animation command"
1336 "[animation appid animation time] has no argument");
1341 map_surface(struct display *display, char *buf, int map)
1348 narg = pars_command(buf, args, 10);
1350 surfaceid = search_surface(display, args[0]);
1351 if (surfaceid >= 0) {
1353 fps = strtol(args[1], (char **)0, 0);
1359 print_log("HOMESCREEN: map surface(%s,%08x,%d)",
1360 args[0], surfaceid, fps);
1361 /* ico_window_mgr_map_surface(display->ico_window_mgr, surfaceid, fps); */
1364 print_log("HOMESCREEN: unmap surface(%s,%08x)", args[0], surfaceid);
1365 /* ico_window_mgr_unmap_surface(display->ico_window_mgr, surfaceid); */
1369 print_log("HOMESCREEN: Unknown surface(%s) at %s command", args[0],
1370 map ? "map" : "unmap");
1375 print_log("HOMESCREEN: map surface command"
1376 "[map surface framerate] has no argument");
1379 print_log("HOMESCREEN: unmap surface command"
1380 "[unmap surface] has no argument");
1386 visible_layer(struct display *display, char *buf)
1393 narg = pars_command(buf, args, 10);
1395 /* layer = strtol(args[0], (char **)0, 0); */
1396 /* visible = strtol(args[1], (char **)0, 0); */
1397 /* ico_window_mgr_set_layer_visible(display->ico_window_mgr, layer, visible); */
1400 print_log("HOMESCREEN: layer_visible command"
1401 "[layer_visible layer visible] has no argument");
1406 input_add(struct display *display, char *buf)
1413 narg = pars_command(buf, args, 10);
1415 input = strtol(args[1], (char **)0, 0);
1417 fix = strtol(args[3], (char **)0, 0);
1422 if ((input >= 0) && (fix >=0)) {
1423 print_log("HOMESCREEN: input_add(%s.%d to %s[%d])",
1424 args[0], input, args[2], fix);
1425 ico_input_mgr_control_add_input_app(display->ico_input_mgr,
1426 args[2], args[0], input, fix, 0);
1429 print_log("HOMESCREEN: Unknown input(%s) at input_add command", args[1]);
1433 print_log("HOMESCREEN: input_add command[input_add device inputId appid fix] "
1439 input_del(struct display *display, char *buf)
1444 char wk1[32], wk2[32];
1446 narg = pars_command(buf, args, 10);
1448 input = strtol(args[1], (char **)0, 0);
1449 if (args[0][0] == '@') {
1453 if (args[2][0] == '@') {
1457 print_log("HOMESCREEN: input_del(%s.%d to %s)", args[0], input, args[2]);
1458 ico_input_mgr_control_del_input_app(display->ico_input_mgr,
1459 args[2], args[0], input);
1462 print_log("HOMESCREEN: input_del command[input_del device inputId appid] "
1468 input_conf(struct display *display, char *buf)
1475 char wk1[32], wk2[32];
1477 narg = pars_command(buf, args, 10);
1479 type = strtol(args[1], (char **)0, 0);
1480 input = strtol(args[3], (char **)0, 0);
1482 code = strtol(args[5], (char **)0, 0);
1487 strcpy(wk1, args[2]);
1491 if ((type >= 0) && (input >= 0) && (code >=0)) {
1492 ico_input_mgr_device_configure_input(display->ico_input_device, args[0], type,
1493 args[2], input, args[4], code);
1496 print_log("HOMESCREEN: Unknown type(%s),input(%s) or code(%s) "
1497 "at input_conf command", args[1], args[3], args[5]);
1501 print_log("HOMESCREEN: input_conf command[input_conf device type swname input "
1502 "codename code] has no argument");
1507 input_code(struct display *display, char *buf)
1514 narg = pars_command(buf, args, 10);
1516 input = strtol(args[1], (char **)0, 0);
1517 code = strtol(args[3], (char **)0, 0);
1518 if ((input >= 0) && (code >= 0)) {
1519 ico_input_mgr_device_configure_code(display->ico_input_device, args[0], input,
1523 print_log("HOMESCREEN: Unknown input(%s) or code(%s) "
1524 "at input_code command", args[1], args[3]);
1528 print_log("HOMESCREEN: input_conf command[input_code device input codename code] "
1534 input_sw(struct display *display, char *buf)
1544 narg = pars_command(buf, args, 10);
1546 input = strtol(args[1], (char **)0, 0);
1547 code = strtol(args[2], (char **)0, 0);
1548 state = strtol(args[3], (char **)0, 0);
1549 if ((input >= 0) && (state >= 0)) {
1550 gettimeofday(&stv, (struct timezone *)NULL);
1551 timems = (stv.tv_sec % 1000) * 1000 + (stv.tv_usec / 1000);
1552 ico_input_mgr_device_input_event(display->ico_input_device,
1553 timems, args[0], input, code, state);
1556 print_log("HOMESCREEN: Unknown input(%s),code(%s) or state(%s) "
1557 "at input_sw command", args[1], args[2], args[3]);
1561 print_log("HOMESCREEN: input_sw command[input_sw device input code, state] "
1567 send_event(const char *cmd)
1569 static int nmqinfo = 0;
1586 for (pt = 0; cmd[pt]; pt++) {
1587 if ((cmd[pt] >= '0') && (cmd[pt] <= '9')) {
1588 mqkey = mqkey * 10 + cmd[pt] - '0';
1594 for (; cmd[pt] == ' '; pt++) ;
1600 for (i = 0; i < nmqinfo; i++) {
1601 if (mqinfo[i].mqkey == mqkey) {
1602 mqid = mqinfo[i].mqid;
1607 if (nmqinfo >= 10) {
1608 fprintf(stderr, "HOMESCREEN: message queue(%d) overflow\n", mqkey);
1611 mqid = msgget(mqkey, 0);
1613 fprintf(stderr, "HOMESCREEN: message queue(%d(0x%x)) get error[%d]\n",
1614 mqkey, mqkey, errno);
1617 mqinfo[nmqinfo].mqkey = mqkey;
1618 mqinfo[nmqinfo].mqid = mqid;
1622 memset(&mqbuf, 0, sizeof(mqbuf));
1624 strncpy(mqbuf.buf, &cmd[pt], sizeof(mqbuf)-sizeof(long));
1626 if (msgsnd(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0) < 0) {
1627 fprintf(stderr, "HOMESCREEN: message queue(%d(0x%x)) send error[%d]\n",
1628 mqkey, mqkey, errno);
1634 set_region(struct display *display, char *buf)
1638 int x, y, width, height;
1640 int c_x, c_y, c_width, c_height;
1642 narg = pars_command(buf, args, 10);
1644 x = strtol(args[1], (char **)0, 0);
1645 y = strtol(args[2], (char **)0, 0);
1646 width = strtol(args[3], (char **)0, 0);
1647 height = strtol(args[4], (char **)0, 0);
1648 hot_x = x + (width / 2);
1649 hot_y = y + (height / 2);
1652 c_width = width - 10;
1653 if (c_width <= 0) c_width = 2;
1654 c_height = height - 10;
1655 if (c_height <= 0) c_height = 2;
1656 print_log("HOMESCREEN: ico_exinput_set_input_region(%s,%d,%d-%d,%d,"
1657 "hot=%d,%d,cur=%d,%d-%d,%d,attr=0)",
1658 args[0] ? args[0] : "(null)", x, y, width, height,
1659 hot_x, hot_y, c_x, c_y, c_width, c_height);
1660 if (strcasecmp(args[0], "NULL") == 0) {
1661 ico_exinput_set_input_region(display->ico_exinput, "", x, y,
1662 width, height, hot_x, hot_y, c_x, c_y,
1663 c_width, c_height, 0);
1666 ico_exinput_set_input_region(display->ico_exinput, args[0], x, y,
1667 width, height, hot_x, hot_y, c_x, c_y,
1668 c_width, c_height, 0);
1672 print_log("HOMESCREEN: set_region command[set_region winname@appid x y "
1673 "width height] has no argument");
1678 unset_region(struct display *display, char *buf)
1682 int x, y, width, height;
1684 narg = pars_command(buf, args, 10);
1687 x = strtol(args[1], (char **)0, 0);
1688 y = strtol(args[2], (char **)0, 0);
1689 width = strtol(args[3], (char **)0, 0);
1690 height = strtol(args[4], (char **)0, 0);
1698 print_log("HOMESCREEN: ico_exinput_unset_input_region(%s,08x,%d,%d-%d,%d)",
1699 args[0] ? args[0] : "(null)", x, y, width, height);
1700 if (strcasecmp(args[0], "NULL") == 0) {
1701 ico_exinput_unset_input_region(display->ico_exinput, "", x, y,
1705 ico_exinput_unset_input_region(display->ico_exinput, args[0],
1706 x, y, width, height);
1710 print_log("HOMESCREEN: unset_region command[unset_region winname@appid x y "
1711 "width height] has no argument");
1719 * test-homescreen < test-case-data-file > test-result-output
1721 int main(int argc, char *argv[])
1723 struct display *display;
1727 #if 1 /* use mkostemp */
1728 extern int mkostemp(char *template, int flags);
1729 #else /* use mkostemp */
1731 #endif /* use mkostemp */
1733 if (ilm_init() != ILM_SUCCESS) {
1734 fprintf(stderr, "HOMESCREEN: GENIVI-ILM(ilm_init) Error\n");
1738 display = malloc(sizeof *display);
1740 memset((char *)display, 0, sizeof *display);
1742 display->init_width = 640;
1743 display->init_height = 480;
1744 display->init_color = 0xFF304010;
1746 for (fd = 1; fd < argc; fd++) {
1747 if (argv[fd][0] == '-') {
1748 if (strncasecmp(argv[fd], "-visible=", 9) == 0) {
1749 display->visible_on_create = argv[fd][9] & 1;
1751 else if (strncasecmp(argv[fd], "-display=", 9) == 0) {
1752 strncpy(display->connect, &argv[fd][9], MAX_CON_NAME);
1754 else if (strncasecmp(argv[fd], "-prompt=", 8) == 0) {
1755 display->prompt = argv[fd][8] & 1;
1760 if (display->connect[0]) {
1761 display->display = wl_display_connect(display->connect);
1764 display->display = wl_display_connect(NULL);
1766 if (! display->display) {
1767 fprintf(stderr, "HOMESCREEN: can not connect to weston\n");
1771 display->registry = wl_display_get_registry(display->display);
1772 wl_registry_add_listener(display->registry, ®istry_listener, display);
1773 wl_display_dispatch(display->display);
1778 sleep_with_wayland(display->display, 20);
1779 if (display->prompt) {
1780 printf("HOMESCREEN> "); fflush(stdout);
1782 ret = getdata(display->ico_window_mgr, "HOMESCREEN> ", fd, buf, sizeof(buf));
1784 fprintf(stderr, "HOMESCREEN: read error: fd %d, %m\n", fd);
1787 if (ret == 0) continue;
1788 wl_display_flush(display->display);
1790 if ((strncasecmp(buf, "bye", 3) == 0) ||
1791 (strncasecmp(buf, "quit", 4) == 0) ||
1792 (strncasecmp(buf, "end", 3) == 0)) {
1793 /* Exit, end of test */
1796 else if (strncasecmp(buf, "launch", 6) == 0) {
1797 /* Launch test application */
1798 launch_app(display, &buf[6]);
1800 else if (strncasecmp(buf, "kill", 4) == 0) {
1801 /* Launch test application */
1802 kill_app(display, &buf[4]);
1804 else if (strncasecmp(buf, "layer_visible", 13) == 0) {
1805 /* Change layer visiblety */
1806 visible_layer(display, &buf[13]);
1808 else if (strncasecmp(buf, "layer", 5) == 0) {
1809 /* layer change surface window */
1810 layer_surface(display, &buf[5]);
1812 else if (strncasecmp(buf, "positionsize", 12) == 0) {
1813 /* Move and Ressize surface window*/
1814 positionsize_surface(display, &buf[12]);
1816 else if (strncasecmp(buf, "move", 4) == 0) {
1817 /* Move surface window */
1818 move_surface(display, &buf[4]);
1820 else if (strncasecmp(buf, "resize", 6) == 0) {
1821 /* Resize surface window */
1822 resize_surface(display, &buf[6]);
1824 else if (strncasecmp(buf, "visible", 7) == 0) {
1825 /* Visible and Raise surface window*/
1826 visible_surface(display, &buf[7]);
1828 else if (strncasecmp(buf, "show", 4) == 0) {
1829 /* Show/Hide surface window */
1830 show_surface(display, &buf[4], 1);
1832 else if (strncasecmp(buf, "hide", 4) == 0) {
1833 /* Show/Hide surface window */
1834 show_surface(display, &buf[4], 0);
1836 else if (strncasecmp(buf, "raise", 5) == 0) {
1837 /* Raise/Lower surface window */
1838 raise_surface(display, &buf[5], 1);
1840 else if (strncasecmp(buf, "lower", 5) == 0) {
1841 /* Raise/Lower surface window */
1842 raise_surface(display, &buf[5], 0);
1844 else if (strncasecmp(buf, "active", 6) == 0) {
1845 /* Active surface window */
1846 active_window(display, &buf[6]);
1848 else if (strncasecmp(buf, "animation", 9) == 0) {
1849 /* Set animation surface window */
1850 animation_surface(display, &buf[9]);
1852 else if (strncasecmp(buf, "map", 3) == 0) {
1854 map_surface(display, &buf[3], 1);
1856 else if (strncasecmp(buf, "unmap", 5) == 0) {
1858 map_surface(display, &buf[5], 0);
1860 else if (strncasecmp(buf, "input_add", 9) == 0) {
1861 /* Set input switch to application */
1862 input_add(display, &buf[9]);
1864 else if (strncasecmp(buf, "input_del", 9) == 0) {
1865 /* Reset input switch to application*/
1866 input_del(display, &buf[9]);
1868 else if (strncasecmp(buf, "input_conf", 10) == 0) {
1869 /* input switch configuration */
1870 input_conf(display, &buf[10]);
1872 else if (strncasecmp(buf, "input_code", 10) == 0) {
1873 /* input code configuration */
1874 input_code(display, &buf[10]);
1876 else if (strncasecmp(buf, "input_sw", 8) == 0) {
1877 /* input switch event */
1878 input_sw(display, &buf[8]);
1880 else if (strncasecmp(buf, "set_region", 10) == 0) {
1881 /* set input region */
1882 set_region(display, &buf[10]);
1884 else if (strncasecmp(buf, "unset_region", 12) == 0) {
1885 /* unset input region */
1886 unset_region(display, &buf[12]);
1888 else if (strncasecmp(buf, "input_sw", 8) == 0) {
1889 /* input switch event */
1890 input_sw(display, &buf[8]);
1892 else if (strncasecmp(buf, "sleep", 5) == 0) {
1894 msec = sec_str_2_value(&buf[6]);
1895 sleep_with_wayland(display->display, msec);
1897 else if (strncasecmp(buf, "waitcreate", 10) == 0) {
1898 /* Wait surface create */
1899 msec = sec_str_2_value(&buf[11]);
1900 wait_with_wayland(display->display, msec, &display->surface_created);
1902 else if (strncasecmp(buf, "waitdestroy", 11) == 0) {
1903 /* Wait surface destrpy */
1904 msec = sec_str_2_value(&buf[12]);
1905 wait_with_wayland(display->display, msec, &display->surface_destroyed);
1907 else if (strncasecmp(buf, "event", 5) == 0) {
1908 /* Send touch panel event to Weston */
1909 send_event(&buf[6]);
1912 print_log("HOMESCREEN: unknown command[%s]", buf);
1916 (void) ilm_destroy();
1918 print_log("HOMESCREEN: end");