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 "ico_window_mgr-client-protocol.h"
48 #include "ico_input_mgr-client-protocol.h"
49 #include "test-common.h"
52 #define SHM_SIZE (16*1024*1024)
53 #define MAX_CON_NAME 127
57 struct surface_name *next;
60 char appid[MAX_APPID];
70 struct wl_display *display;
71 struct wl_registry *registry;
72 struct wl_compositor *compositor;
73 struct wl_shell *shell;
74 struct ico_window_mgr *ico_window_mgr;
75 struct ico_input_mgr_control *ico_input_mgr;
76 struct ico_input_mgr_device *ico_input_device;
77 struct ico_exinput *ico_exinput;
80 struct output *output[MAX_OUTPUT];
81 #if 0 /* 2013/08/23 no need shm */
84 struct wl_shm_pool *shm_pool;
86 struct surface *surface;
87 struct surface_name *surface_name;
88 struct surface_name *bgsurface_name;
94 int surface_destroyed;
96 int visible_on_create;
97 char connect[MAX_CON_NAME+1];
101 struct display *display;
102 struct wl_seat *seat;
103 struct wl_pointer *pointer;
104 struct wl_keyboard *keyboard;
105 struct wl_touch *touch;
107 uint32_t button_mask;
108 struct surface *pointer_focus;
109 struct surface *keyboard_focus;
110 uint32_t last_key, last_key_state;
114 struct display *display;
115 struct wl_output *output;
121 struct display *display;
122 struct wl_surface *surface;
123 struct wl_shell_surface *shell_surface;
124 struct output *output;
128 EGLSurface egl_surface;
131 static void clear_surface(struct display *display);
134 pointer_handle_enter(void *data, struct wl_pointer *pointer,
135 uint32_t serial, struct wl_surface *surface,
136 wl_fixed_t x, wl_fixed_t y)
138 struct input *input = data;
140 input->pointer_focus = wl_surface_get_user_data(surface);
141 input->x = wl_fixed_to_double(x);
142 input->y = wl_fixed_to_double(y);
143 print_log("HOMESCREEN: got pointer enter (%d,%d), surface %p",
144 (int)input->x, (int)input->y, surface);
148 pointer_handle_leave(void *data, struct wl_pointer *pointer,
149 uint32_t serial, struct wl_surface *surface)
151 struct input *input = data;
153 input->pointer_focus = NULL;
155 print_log("HOMESCREEN: got pointer leave, surface %p", surface);
159 pointer_handle_motion(void *data, struct wl_pointer *pointer,
160 uint32_t time, wl_fixed_t x, wl_fixed_t y)
162 struct input *input = data;
164 input->x = wl_fixed_to_double(x);
165 input->y = wl_fixed_to_double(y);
167 print_log("HOMESCREEN: got pointer motion (%d,%d)", (int)input->x, (int)input->y);
171 pointer_handle_button(void *data, struct wl_pointer *pointer,
172 uint32_t serial, uint32_t time, uint32_t button, uint32_t state_w)
174 struct input *input = data;
176 enum wl_pointer_button_state state = state_w;
178 bit = 1 << (button - BTN_LEFT);
179 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
180 input->button_mask |= bit;
182 input->button_mask &= ~bit;
183 print_log("HOMESCREEN: got pointer button %u %u", button, state_w);
187 pointer_handle_axis(void *data, struct wl_pointer *pointer,
188 uint32_t time, uint32_t axis, wl_fixed_t value)
190 print_log("HOMESCREEN: got pointer axis %u %d", axis, value);
194 keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
195 uint32_t format, int fd, uint32_t size)
198 print_log("HOMESCREEN: got keyboard keymap");
202 keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
203 uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
205 struct input *input = data;
207 input->keyboard_focus = wl_surface_get_user_data(surface);
208 print_log("HOMESCREEN: got keyboard enter, surface %p", surface);
212 keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
213 uint32_t serial, struct wl_surface *surface)
215 struct input *input = data;
217 input->keyboard_focus = NULL;
218 print_log("HOMESCREEN: got keyboard leave, surface %p", surface);
222 keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
223 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
225 struct input *input = data;
227 input->last_key = key;
228 input->last_key_state = state;
230 print_log("HOMESCREEN: got keyboard key %u %u", key, state);
234 keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
235 uint32_t serial, uint32_t mods_depressed,
236 uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
238 print_log("HOMESCREEN: got keyboard modifier");
242 touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time,
243 struct wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y)
245 print_log("CLIENT: got touch down %d (%d,%d)", id, x/256, y/256);
249 touch_handle_up(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time,
252 print_log("CLIENT: got touch up %d", id);
256 touch_handle_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
257 int32_t id, wl_fixed_t x, wl_fixed_t y)
259 print_log("CLIENT: got touch motion %d (%d,%d)", id, x/256, y/256);
263 touch_handle_frame(void *data, struct wl_touch *wl_touch)
265 print_log("CLIENT: got touch frame");
269 touch_handle_cancel(void *data, struct wl_touch *wl_touch)
271 print_log("CLIENT: got touch cancel");
274 static const struct wl_pointer_listener pointer_listener = {
275 pointer_handle_enter,
276 pointer_handle_leave,
277 pointer_handle_motion,
278 pointer_handle_button,
282 static const struct wl_keyboard_listener keyboard_listener = {
283 keyboard_handle_keymap,
284 keyboard_handle_enter,
285 keyboard_handle_leave,
287 keyboard_handle_modifiers,
290 static const struct wl_touch_listener touch_listener = {
299 seat_handle_capabilities(void *data, struct wl_seat *seat,
300 enum wl_seat_capability caps)
302 struct input *input = data;
304 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
305 input->pointer = wl_seat_get_pointer(seat);
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 wl_pointer_destroy(input->pointer);
311 input->pointer = NULL;
314 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
315 input->keyboard = wl_seat_get_keyboard(seat);
316 wl_keyboard_set_user_data(input->keyboard, input);
317 wl_keyboard_add_listener(input->keyboard, &keyboard_listener, input);
319 else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
320 wl_keyboard_destroy(input->keyboard);
321 input->keyboard = NULL;
324 if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) {
325 input->touch = wl_seat_get_touch(seat);
326 wl_touch_set_user_data(input->touch, input);
327 wl_touch_add_listener(input->touch, &touch_listener, input);
329 else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
330 wl_touch_destroy(input->touch);
335 static const struct wl_seat_listener seat_listener = {
336 seat_handle_capabilities,
340 surface_enter(void *data, struct wl_surface *wl_surface, struct wl_output *output)
342 struct surface *surface = data;
344 surface->output = wl_output_get_user_data(output);
346 print_log("HOMESCREEN: got surface enter, output %p", surface->output);
350 surface_leave(void *data, struct wl_surface *wl_surface, struct wl_output *output)
352 struct surface *surface = data;
354 surface->output = NULL;
356 print_log("HOMESCREEN: got surface leave, output %p",
357 wl_output_get_user_data(output));
360 static const struct wl_surface_listener surface_listener = {
366 create_surface(struct display *display, const char *title)
368 struct surface *surface;
371 surface = malloc(sizeof *surface);
373 surface->display = display;
374 display->surface = surface;
375 surface->surface = wl_compositor_create_surface(display->compositor);
376 wl_surface_add_listener(surface->surface, &surface_listener, surface);
378 if (display->shell) {
379 surface->shell_surface =
380 wl_shell_get_shell_surface(display->shell, surface->surface);
381 if (surface->shell_surface) {
382 wl_shell_surface_set_toplevel(surface->shell_surface);
383 wl_shell_surface_set_title(surface->shell_surface, title);
386 wl_display_flush(display->display);
388 id = wl_proxy_get_id((struct wl_proxy *) surface->surface);
389 print_log("HOMESCREEN: create surface = %d", id);
391 poll(NULL, 0, 100); /* Wait for next frame where we'll get events. */
393 wl_display_roundtrip(display->display);
395 surface->dpy = opengl_init(display->display, &surface->conf, &surface->ctx);
397 surface->egl_surface = opengl_create_window(display->display, surface->surface,
398 surface->dpy, surface->conf,
399 surface->ctx, display->init_width,
400 display->init_height,
401 display->init_color);
402 clear_surface(display);
403 print_log("HOMESCREEN: created egl_surface %08x", (int)surface->egl_surface);
408 clear_surface(struct display *display)
410 if (! display->surface) {
411 create_surface(display, "HomeScreen-BG");
414 opengl_clear_window(display->init_color);
415 opengl_swap_buffer(display->display,
416 display->surface->dpy, display->surface->egl_surface);
421 output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
422 int physical_width, int physical_height, int subpixel,
423 const char *make, const char *model, int32_t transform)
425 struct output *output = data;
427 print_log("HOMESCREEN: Event[handle_geometry] %08x x/y=%d/%d p.w/h=%d/%d trans=%d",
428 (int)wl_output, x, y, physical_width, physical_height, transform);
435 output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
436 int width, int height, int refresh)
438 struct output *output = data;
440 print_log("HOMESCREEN: Event[handle_mode] %08x x/y=%d/%d flags=%08x refresh=%d",
441 (int)wl_output, width, height, flags, refresh);
443 if (flags & WL_OUTPUT_MODE_CURRENT) {
444 struct display *display = output->display;
446 output->width = width;
447 output->height = height;
449 display->init_width = width;
450 display->init_height = height;
452 if (display->bgsurface_name) {
453 ico_window_mgr_set_positionsize(display->ico_window_mgr,
454 display->bgsurface_name->surfaceid,
455 0, 0, 0, 0, width, height);
457 else if (display->bg_created == 0) {
458 display->bg_created = 9;
459 create_surface(display, "HomeScreen-BG");
464 static const struct wl_output_listener output_listener = {
465 output_handle_geometry,
470 search_surface(struct display *display, const char *surfname)
472 struct surface_name *p;
474 p = display->surface_name;
476 if (strcmp(p->appid, surfname) == 0) break;
481 return(p->surfaceid);
488 static struct surface_name *
489 search_surfacename(struct display *display, const char *surfname)
491 struct surface_name *p;
493 p = display->surface_name;
495 if (strcmp(p->appid, surfname) == 0) break;
499 print_log("HOMESCREEN: app(%s) dose not exist", surfname);
504 static struct surface_name *
505 search_surfaceid(struct display *display, const int surfaceid)
507 struct surface_name *p;
509 p = display->surface_name;
511 if (p->surfaceid == surfaceid) {
520 window_created(void *data, struct ico_window_mgr *ico_window_mgr,
521 uint32_t surfaceid, const char *winname, int32_t pid, const char *appid)
523 struct display *display = data;
524 struct surface_name *p;
525 struct surface_name *fp;
527 display->surface_created = 1;
528 p = display->surface_name;
531 if (p->surfaceid == (int)surfaceid) break;
536 print_log("HOMESCREEN: Event[window_created] surface=%08x(app=%s,name=%s) exist",
537 (int)surfaceid, appid, winname);
540 print_log("HOMESCREEN: Event[window_created] new surface=%08x(app=%s) winname=%s",
541 (int)surfaceid, appid, winname);
542 p = malloc(sizeof(struct surface_name));
546 memset(p, 0, sizeof(struct surface_name));
551 display->surface_name = p;
554 p->surfaceid = surfaceid;
556 strncpy(p->appid, appid, MAX_APPID-1);
558 /* Set default size and show */
560 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
561 0, p->x, p->y, p->width, p->height, 0);
564 print_log("HOMESCREEN: Created window[%08x] (app=%s)", (int)surfaceid, appid);
566 if (strncasecmp(appid, "test-homescreen", 15) == 0) {
567 display->bgsurface_name = p;
568 if (display->bg_created == 1) {
569 display->bg_created = 9;
570 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
572 display->init_width, display->init_height, 0);
574 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, 1, 0, 0);
575 print_log("HOMESCREEN: Created window[%08x] (app=%s) Visible",
576 (int)surfaceid, appid);
582 window_name(void *data, struct ico_window_mgr *ico_window_mgr,
583 uint32_t surfaceid, const char *winname)
585 print_log("HOMESCREEN: Window Name[%08x] (name=%s)", (int)surfaceid, winname);
589 window_destroyed(void *data, struct ico_window_mgr *ico_window_mgr, uint32_t surfaceid)
591 struct display *display = data;
592 struct surface_name *p;
593 struct surface_name *fp;
595 display->surface_destroyed = 1;
596 p = search_surfaceid(display, (int)surfaceid);
598 print_log("HOMESCREEN: Event[window_destroyed] surface=%08x dose not exist",
602 print_log("HOMESCREEN: Event[window_destroyed] surface=%08x", (int)surfaceid);
603 if (p == display->surface_name) {
604 display->surface_name = p->next;
607 fp = display->surface_name;
621 window_visible(void *data, struct ico_window_mgr *ico_window_mgr,
622 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t hint)
624 struct display *display = data;
625 struct surface_name *p;
627 p = search_surfaceid(display, (int)surfaceid);
629 print_log("HOMESCREEN: Event[window_visible] surface=%08x dose not exist",
633 print_log("HOMESCREEN: Event[window_visible] surface=%08x "
634 "visible=%d raise=%d hint=%d", (int)surfaceid, visible, raise, hint);
635 p->visible = visible;
637 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
638 visible, ICO_WINDOW_MGR_V_NOCHANGE, 0);
644 window_configure(void *data, struct ico_window_mgr *ico_window_mgr,
645 uint32_t surfaceid, uint32_t node, uint32_t layer,
646 int32_t x, int32_t y, int32_t width, int32_t height, int32_t hint)
648 struct display *display = data;
649 struct surface_name *p;
651 print_log("HOMESCREEN: Event[window_configure] surface=%08x "
652 "node=%x x/y=%d/%d w/h=%d/%d hint=%d",
653 (int)surfaceid, node, x, y, width, height, hint);
655 p = search_surfaceid(display, (int)surfaceid);
657 print_log("HOMESCREEN: Event[window_configure] surface=%08x dose not exist",
666 window_layer_visible(void *data, struct ico_window_mgr *ico_window_mgr,
667 uint32_t layer, int32_t visible)
669 print_log("HOMESCREEN: Event[layer_visible]layer=%x visible=%d",
670 (int)layer, visible);
674 window_active(void *data, struct ico_window_mgr *ico_window_mgr,
675 uint32_t surfaceid, const int32_t active)
677 print_log("HOMESCREEN: Event[window_active] surface=%08x acive=%d",
678 (int)surfaceid, (int)active);
679 if ((surfaceid & 0x0000ffff) == 0x0001) {
680 ico_window_mgr_set_visible(ico_window_mgr, surfaceid,
681 ICO_WINDOW_MGR_V_NOCHANGE, 0, 0);
686 window_surfaces(void *data, struct ico_window_mgr *ico_window_mgr,
687 const char *appid, struct wl_array *surfaces)
689 print_log("HOMESCREEN: Event[app_surfaces] app=%s", appid);
693 window_map(void *data, struct ico_window_mgr *ico_window_mgr,
694 int32_t event, uint32_t surfaceid, uint32_t type, uint32_t target,
695 int32_t width, int32_t height, int32_t stride, uint32_t format)
700 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
701 strcpy(sevt, "Contents"); break;
702 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
703 strcpy(sevt, "Resize"); break;
704 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
705 strcpy(sevt, "Map"); break;
706 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
707 strcpy(sevt, "Unmap"); break;
708 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
709 sprintf(sevt, "Error %d", target); break;
711 sprintf(sevt, "??%d??", event); break;
713 print_log("HOMESCREEN: Event[map_surface] ev=%s(%d) surf=%08x type=%d target=%x "
714 "w/h/s/f=%d/%d/%d/%x",
715 sevt, event, (int)surfaceid, type, target, width, height, stride, format);
718 static const struct ico_window_mgr_listener window_mgr_listener = {
725 window_layer_visible,
731 cb_input_capabilities(void *data, struct ico_exinput *ico_exinput,
732 const char *device, int32_t type, const char *swname, int32_t input,
733 const char *codename, int32_t code)
735 print_log("HOMESCREEN: Event[input_capabilities] device=%s type=%d sw=%s input=%d "
736 "code=%s[%d]", device, type, swname, input, codename, code);
740 cb_input_code(void *data, struct ico_exinput *ico_exinput,
741 const char *device, int32_t input, const char *codename, int32_t code)
743 print_log("HOMESCREEN: Event[input_code] device=%s input=%d code=%s[%d]",
744 device, input, codename, code);
748 cb_input_input(void *data, struct ico_exinput *ico_exinput, uint32_t time,
749 const char *device, int32_t input, int32_t code, int32_t state)
751 print_log("HOMESCREEN: Event[input_input] device=%s input=%d code=%d state=%d",
752 device, input, code, state);
755 static const struct ico_exinput_listener exinput_listener = {
756 cb_input_capabilities,
762 handle_global(void *data, struct wl_registry *registry, uint32_t id,
763 const char *interface, uint32_t version)
765 struct display *display = data;
767 struct output *output;
769 print_log("HOMESCREEN: handle_global: interface=<%s> id=%d", interface, (int)id);
771 if (strcmp(interface, "wl_compositor") == 0) {
772 display->compositor =
773 wl_registry_bind(display->registry, id, &wl_compositor_interface, 1);
775 else if (strcmp(interface, "wl_seat") == 0) {
776 input = calloc(1, sizeof *input);
777 input->display = display;
778 input->seat = wl_registry_bind(display->registry, id, &wl_seat_interface, 1);
779 input->pointer_focus = NULL;
780 input->keyboard_focus = NULL;
782 wl_seat_add_listener(input->seat, &seat_listener, input);
783 display->input = input;
785 else if (strcmp(interface, "wl_output") == 0) {
786 if (display->num_output < MAX_OUTPUT) {
787 output = malloc(sizeof *output);
788 output->display = display;
789 output->output = wl_registry_bind(display->registry, id, &wl_output_interface, 1);
790 wl_output_add_listener(output->output, &output_listener, output);
791 display->output[display->num_output] = output;
793 print_log("HOMESCREEN: created output[%d] global %p",
794 display->num_output, display->output[display->num_output]);
795 display->num_output ++;
798 else if (strcmp(interface, "wl_shell") == 0) {
800 wl_registry_bind(display->registry, id, &wl_shell_interface, 1);
802 else if (strcmp(interface, "ico_window_mgr") == 0) {
803 display->ico_window_mgr =
804 wl_registry_bind(display->registry, id, &ico_window_mgr_interface, 1);
805 ico_window_mgr_add_listener(display->ico_window_mgr, &window_mgr_listener, display);
806 print_log("HOMESCREEN: created window_mgr global %p", display->ico_window_mgr);
808 ico_window_mgr_declare_manager(display->ico_window_mgr, 1);
810 else if (strcmp(interface, "ico_input_mgr_control") == 0) {
811 display->ico_input_mgr = wl_registry_bind(display->registry, id,
812 &ico_input_mgr_control_interface, 1);
813 print_log("HOMESCREEN: created input_mgr global %p", display->ico_input_mgr);
815 else if (strcmp(interface, "ico_input_mgr_device") == 0) {
816 display->ico_input_device = wl_registry_bind(display->registry, id,
817 &ico_input_mgr_device_interface, 1);
818 print_log("HOMESCREEN: created input_device global %p", display->ico_input_device);
820 #if 0 /* 2013/08/23 no need shm */
821 else if (strcmp(interface, "wl_shm") == 0) {
822 display->shm = wl_registry_bind(display->registry, id,
823 &wl_shm_interface, 1);
824 print_log("HOMESCREEN: created wl_shm global %p", display->shm);
827 else if (strcmp(interface, "ico_exinput") == 0) {
828 display->ico_exinput =
829 wl_registry_bind(display->registry, id, &ico_exinput_interface, 1);
830 ico_exinput_add_listener(display->ico_exinput, &exinput_listener, display);
831 print_log("HOMESCREEN: created exinput global %p", display->ico_exinput);
833 ico_window_mgr_declare_manager(display->ico_window_mgr, 1);
835 display->bg_created = 1;
836 create_surface(display, "HomeScreen-BG");
840 static const struct wl_registry_listener registry_listener = {
845 skip_spaces(char *buf)
847 while ((*buf == ' ') || (*buf == '\t')) {
854 pars_command(char *buf, char *pt[], const int len)
859 memset(pt, 0, sizeof(int *)*10);
861 for (narg = 0; narg < len; narg++) {
866 if ((*p == ' ') || (*p == '\t') ||
867 (*p == '=') || (*p == ',')) break;
880 launch_app(struct display *display, char *buf)
884 display->surface_created = 0;
885 display->surface_destroyed = 0;
886 snprintf(sbuf, sizeof(sbuf)-1, "%s &", skip_spaces(buf));
887 if (system(sbuf) < 0) {
888 print_log("HOMESCREEN: Can not launch application[%s]", sbuf);
891 sleep_with_wayland(display->display, 500);
896 kill_app(struct display *display, char *buf)
900 struct surface_name *p;
901 struct surface_name *fp;
903 narg = pars_command(buf, args, 10);
905 p = search_surfacename(display, args[0]);
907 print_log("HOMESCREEN: kill[%s] Application dose not exist", args[0]);
909 else if (kill(p->pid, SIGINT) < 0) {
910 print_log("HOMESCREEN: kill[%s.%d] Application dose not exist",
914 sleep_with_wayland(display->display, 300);
915 p = search_surfacename(display, args[0]);
916 if ((p != NULL) && (kill(p->pid, SIGTERM) >= 0)) {
917 sleep_with_wayland(display->display, 200);
918 p = search_surfacename(display, args[0]);
920 kill(p->pid, SIGKILL);
921 sleep_with_wayland(display->display, 200);
925 p = search_surfacename(display, args[0]);
927 if (p == display->surface_name) {
928 display->surface_name = p->next;
931 fp = display->surface_name;
943 print_log("HOMESCREEN: kill command[kill appid] has no argument");
948 layer_surface(struct display *display, char *buf)
955 narg = pars_command(buf, args, 10);
957 surfaceid = search_surface(display, args[0]);
958 layerid = strtol(args[1], (char **)0, 0);
959 if ((surfaceid >= 0) && (layerid >= 0)) {
960 print_log("HOMESCREEN: set_window_layer(%s,%08x)",
961 args[0], surfaceid, layerid);
962 ico_window_mgr_set_window_layer(display->ico_window_mgr, surfaceid, layerid);
965 print_log("HOMESCREEN: Unknown surface(%s) at layer command", args[0]);
969 print_log("HOMESCREEN: layer command[layer appid layerid] has no argument");
974 positionsize_surface(struct display *display, char *buf)
977 struct surface_name *p;
980 int x, y, width, height;
984 narg = pars_command(buf, args, 10);
986 surfaceid = search_surface(display, args[0]);
987 p = search_surfacename(display, args[0]);
988 x = strtol(args[1], (char **)0, 0);
989 y = strtol(args[2], (char **)0, 0);
990 width = strtol(args[3], (char **)0, 0);
991 height = strtol(args[4], (char **)0, 0);
993 node = strtol(args[5], (char **)0, 0);
1002 anima = strtol(args[6], (char **)0, 0);
1004 if ((surfaceid >= 0) && (x >= 0) && (y >=0) && (width >= 0) && (height >=0)) {
1005 print_log("HOMESCREEN: set_positionsize(%s,%08x,%d,%d,%d,%d,%d)",
1006 args[0], surfaceid, node, x, y, width, height);
1007 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1008 node, x, y, width, height, anima);
1011 print_log("HOMESCREEN: Unknown surface(%s) at positionsize command", args[0]);
1015 print_log("HOMESCREEN: positionsize command"
1016 "[positionsize appid x y width heigh node anima] has no argument");
1021 move_surface(struct display *display, char *buf)
1024 struct surface_name *p;
1031 narg = pars_command(buf, args, 10);
1033 surfaceid = search_surface(display, args[0]);
1034 p = search_surfacename(display, args[0]);
1035 x = strtol(args[1], (char **)0, 0);
1036 y = strtol(args[2], (char **)0, 0);
1038 node = strtol(args[3], (char **)0, 0);
1040 if (p) node = p->node;
1043 if (p) p->node = node;
1049 anima = strtol(args[4], (char **)0, 0);
1052 if ((surfaceid >= 0) && (x >= 0) && (y >=0)) {
1053 print_log("HOMESCREEN: move(%s,%08x,%d.%d,%d anima=%d)", args[0], surfaceid,
1055 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1057 ICO_WINDOW_MGR_V_NOCHANGE,
1058 ICO_WINDOW_MGR_V_NOCHANGE, anima);
1061 print_log("HOMESCREEN: Unknown surface(%s) at move command", args[0]);
1065 print_log("HOMESCREEN: move command[positionsize appid x y node anima] has no argument");
1070 resize_surface(struct display *display, char *buf)
1073 struct surface_name *p;
1080 narg = pars_command(buf, args, 10);
1082 surfaceid = search_surface(display, args[0]);
1083 p = search_surfacename(display, args[0]);
1087 width = strtol(args[1], (char **)0, 0);
1088 height = strtol(args[2], (char **)0, 0);
1090 anima = strtol(args[3], (char **)0, 0);
1093 if ((surfaceid >= 0) && (width >= 0) && (height >=0)) {
1094 print_log("HOMESCREEN: resize(%s,%08x,%d.%d,%d,anima=%d)",
1095 args[0], surfaceid, node, width, height, anima);
1096 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1097 node, ICO_WINDOW_MGR_V_NOCHANGE,
1098 ICO_WINDOW_MGR_V_NOCHANGE, width, height, anima);
1101 print_log("HOMESCREEN: Unknown surface(%s) at resize command", args[0]);
1105 print_log("HOMESCREEN: positionsize command"
1106 "[resize appid width heigh anima] has no argument");
1111 visible_surface(struct display *display, char *buf)
1120 narg = pars_command(buf, args, 10);
1122 surfaceid = search_surface(display, args[0]);
1123 visible = strtol(args[1], (char **)0, 0);
1124 raise = strtol(args[2], (char **)0, 0);
1126 anima = strtol(args[3], (char **)0, 0);
1128 if ((surfaceid >= 0) && (visible >= 0) && (raise >=0)) {
1129 print_log("HOMESCREEN: visible(%s,%08x,%d,%d,%d)",
1130 args[0], surfaceid, visible, raise, anima);
1131 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1132 visible, raise, anima);
1135 print_log("HOMESCREEN: Unknown surface(%s) at visible command", args[0]);
1139 print_log("HOMESCREEN: visible command[visible appid visible raise] "
1145 show_surface(struct display *display, char *buf, const int show)
1156 narg = pars_command(buf, args, 10);
1158 surfaceid = search_surface(display, args[0]);
1160 anima = strtol(args[1], (char **)0, 0);
1166 if (narg >= 3) ax = strtol(args[2], (char **)0, 0);
1167 if (narg >= 4) ay = strtol(args[3], (char **)0, 0);
1168 if (narg >= 5) awidth = strtol(args[4], (char **)0, 0);
1169 if (narg >= 6) aheight = strtol(args[5], (char **)0, 0);
1172 if (surfaceid >= 0) {
1175 print_log("HOMESCREEN: show anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)",
1176 args[0], surfaceid, ax, ay, awidth, aheight);
1177 ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid,
1178 1, ax, ay, awidth, aheight);
1181 print_log("HOMESCREEN: show(%s,%08x,anima=%d)",
1182 args[0], surfaceid, anima);
1183 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1184 1, ICO_WINDOW_MGR_V_NOCHANGE, anima);
1189 print_log("HOMESCREEN: hide anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)",
1190 args[0], surfaceid, ax, ay, awidth, aheight);
1191 ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid,
1192 0, ax, ay, awidth, aheight);
1195 print_log("HOMESCREEN: hide(%s,%08x,anima=%d)",
1196 args[0], surfaceid, anima);
1197 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1198 0, ICO_WINDOW_MGR_V_NOCHANGE, anima);
1203 print_log("HOMESCREEN: Unknown surface(%s) at show/hide command", args[0]);
1207 print_log("HOMESCREEN: show command[show/hide appid anima x y width height]"
1208 " has no argument");
1213 raise_surface(struct display *display, char *buf, const int raise)
1220 narg = pars_command(buf, args, 10);
1222 surfaceid = search_surface(display, args[0]);
1224 anima = strtol(args[1], (char **)0, 0);
1226 if (surfaceid >= 0) {
1228 print_log("HOMESCREEN: raise(%s,%08x,anima=%d)", args[0], surfaceid, anima);
1229 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1230 ICO_WINDOW_MGR_V_NOCHANGE, 1, anima);
1233 print_log("HOMESCREEN: lower(%s,%08x,anima=%d)", args[0], surfaceid, anima);
1234 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1235 ICO_WINDOW_MGR_V_NOCHANGE, 0, anima);
1239 print_log("HOMESCREEN: Unknown surface(%s) at raise/lower command", args[0]);
1243 print_log("HOMESCREEN: show command[raise/lower appid anima] has no argument");
1248 active_window(struct display *display, char *buf)
1255 narg = pars_command(buf, args, 10);
1257 surfaceid = search_surface(display, args[0]);
1259 target = strtol(args[1], (char **)0, 0);
1262 target = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1264 if (surfaceid >= 0) {
1265 print_log("HOMESCREEN: active(%s,%08x,target=%x)", args[0], surfaceid, target);
1266 ico_window_mgr_set_active(display->ico_window_mgr, surfaceid, target);
1269 print_log("HOMESCREEN: Unknown surface(%s) at active command", args[0]);
1273 print_log("HOMESCREEN: active command[active appid[target]] has no argument");
1279 animation_surface(struct display *display, char *buf)
1286 narg = pars_command(buf, args, 10);
1288 surfaceid = search_surface(display, args[0]);
1289 if (surfaceid >= 0) {
1291 time = strtol(args[2], (char **)0, 0);
1296 print_log("HOMESCREEN: animation(%s,%08x,%s,%d)",
1297 args[0], surfaceid, args[1], time);
1298 ico_window_mgr_set_animation(display->ico_window_mgr, surfaceid, 0x7fffffff,
1302 print_log("HOMESCREEN: Unknown surface(%s) at animation command", args[0]);
1306 print_log("HOMESCREEN: animation command"
1307 "[animation appid animation time] has no argument");
1312 map_surface(struct display *display, char *buf, int map)
1319 narg = pars_command(buf, args, 10);
1321 surfaceid = search_surface(display, args[0]);
1322 if (surfaceid >= 0) {
1324 fps = strtol(args[1], (char **)0, 0);
1330 print_log("HOMESCREEN: map surface(%s,%08x,%d)",
1331 args[0], surfaceid, fps);
1332 ico_window_mgr_map_surface(display->ico_window_mgr, surfaceid, fps);
1335 print_log("HOMESCREEN: unmap surface(%s,%08x)", args[0], surfaceid);
1336 ico_window_mgr_unmap_surface(display->ico_window_mgr, surfaceid);
1340 print_log("HOMESCREEN: Unknown surface(%s) at %s command", args[0],
1341 map ? "map" : "unmap");
1346 print_log("HOMESCREEN: map surface command"
1347 "[map surface framerate] has no argument");
1350 print_log("HOMESCREEN: unmap surface command"
1351 "[unmap surface] has no argument");
1357 visible_layer(struct display *display, char *buf)
1364 narg = pars_command(buf, args, 10);
1366 layer = strtol(args[0], (char **)0, 0);
1367 visible = strtol(args[1], (char **)0, 0);
1368 ico_window_mgr_set_layer_visible(display->ico_window_mgr, layer, visible);
1371 print_log("HOMESCREEN: layer_visible command"
1372 "[layer_visible layer visible] has no argument");
1377 input_add(struct display *display, char *buf)
1384 narg = pars_command(buf, args, 10);
1386 input = strtol(args[1], (char **)0, 0);
1388 fix = strtol(args[3], (char **)0, 0);
1393 if ((input >= 0) && (fix >=0)) {
1394 print_log("HOMESCREEN: input_add(%s.%d to %s[%d])",
1395 args[0], input, args[2], fix);
1396 ico_input_mgr_control_add_input_app(display->ico_input_mgr,
1397 args[2], args[0], input, fix, 0);
1400 print_log("HOMESCREEN: Unknown input(%s) at input_add command", args[1]);
1404 print_log("HOMESCREEN: input_add command[input_add device inputId appid fix] "
1410 input_del(struct display *display, char *buf)
1415 char wk1[32], wk2[32];
1417 narg = pars_command(buf, args, 10);
1419 input = strtol(args[1], (char **)0, 0);
1420 if (args[0][0] == '@') {
1424 if (args[2][0] == '@') {
1428 print_log("HOMESCREEN: input_del(%s.%d to %s)", args[0], input, args[2]);
1429 ico_input_mgr_control_del_input_app(display->ico_input_mgr,
1430 args[2], args[0], input);
1433 print_log("HOMESCREEN: input_del command[input_del device inputId appid] "
1439 input_send(struct display *display, char *buf)
1450 narg = pars_command(buf, args, 10);
1452 memset(appid, 0, sizeof(appid));
1453 if (args[0][0] == '@') {
1454 strncpy(appid, &args[0][1], sizeof(appid)-1);
1458 surfaceid = search_surface(display, args[0]);
1460 if (strcasecmp(args[1], "POINTER") == 0) {
1461 type = ICO_INPUT_MGR_DEVICE_TYPE_POINTER;
1463 else if (strcasecmp(args[1], "KEYBOARD") == 0) {
1464 type = ICO_INPUT_MGR_DEVICE_TYPE_KEYBOARD;
1466 else if (strcasecmp(args[1], "TOUCH") == 0) {
1467 type = ICO_INPUT_MGR_DEVICE_TYPE_TOUCH;
1469 else if (strcasecmp(args[1], "SWITCH") == 0) {
1470 type = ICO_INPUT_MGR_DEVICE_TYPE_SWITCH;
1472 else if (strcasecmp(args[1], "HAPTIC") == 0) {
1473 type = ICO_INPUT_MGR_DEVICE_TYPE_HAPTIC;
1476 type = strtol(args[1], (char **)0, 0);
1478 no = strtol(args[2], (char **)0, 0);
1479 if (strcasecmp(args[3], "ABS_X") == 0) {
1482 else if (strcasecmp(args[3], "ABS_Y") == 0) {
1485 else if (strcasecmp(args[3], "ABS_Z") == 0) {
1488 else if (strcasecmp(args[3], "REL_X") == 0) {
1489 code = REL_X | (EV_REL << 16);
1491 else if (strcasecmp(args[3], "REL_Y") == 0) {
1492 code = REL_Y | (EV_REL << 16);
1494 else if (strcasecmp(args[3], "REL_Z") == 0) {
1495 code = REL_Z | (EV_REL << 16);
1497 else if (strcasecmp(args[3], "BTN_TOUCH") == 0) {
1500 else if (strcasecmp(args[3], "BTN_LEFT") == 0) {
1503 else if (strcasecmp(args[3], "BTN_RIGHT") == 0) {
1506 else if (strcasecmp(args[3], "BTN_MIDDLE") == 0) {
1509 else if (strcasecmp(args[3], "BTN_RIGHT") == 0) {
1513 code = strtol(args[3], (char **)0, 0);
1515 value = strtol(args[4], (char **)0, 0);
1517 value = (value << 16) + strtol(args[5], (char **)0, 0);
1519 print_log("HOMESCREEN: input_send(%s.%x,%d,%d,%x,%d)",
1520 appid, surfaceid, type, no, code, value);
1521 ico_input_mgr_control_send_input_event(display->ico_input_mgr,
1522 appid, surfaceid, type, no, code, value);
1525 print_log("HOMESCREEN: input_send command[input_send {@app/serface} type no code "
1526 "value [value2]] has no argument");
1531 input_conf(struct display *display, char *buf)
1538 char wk1[32], wk2[32];
1540 narg = pars_command(buf, args, 10);
1542 type = strtol(args[1], (char **)0, 0);
1543 input = strtol(args[3], (char **)0, 0);
1545 code = strtol(args[5], (char **)0, 0);
1550 strcpy(wk1, args[2]);
1554 if ((type >= 0) && (input >= 0) && (code >=0)) {
1555 ico_input_mgr_device_configure_input(display->ico_input_device, args[0], type,
1556 args[2], input, args[4], code);
1559 print_log("HOMESCREEN: Unknown type(%s),input(%s) or code(%s) "
1560 "at input_conf command", args[1], args[3], args[5]);
1564 print_log("HOMESCREEN: input_conf command[input_conf device type swname input "
1565 "codename code] has no argument");
1570 input_code(struct display *display, char *buf)
1577 narg = pars_command(buf, args, 10);
1579 input = strtol(args[1], (char **)0, 0);
1580 code = strtol(args[3], (char **)0, 0);
1581 if ((input >= 0) && (code >= 0)) {
1582 ico_input_mgr_device_configure_code(display->ico_input_device, args[0], input,
1586 print_log("HOMESCREEN: Unknown input(%s) or code(%s) "
1587 "at input_code command", args[1], args[3]);
1591 print_log("HOMESCREEN: input_conf command[input_code device input codename code] "
1597 input_sw(struct display *display, char *buf)
1607 narg = pars_command(buf, args, 10);
1609 input = strtol(args[1], (char **)0, 0);
1610 code = strtol(args[2], (char **)0, 0);
1611 state = strtol(args[3], (char **)0, 0);
1612 if ((input >= 0) && (state >= 0)) {
1613 gettimeofday(&stv, (struct timezone *)NULL);
1614 timems = (stv.tv_sec % 1000) * 1000 + (stv.tv_usec / 1000);
1615 ico_input_mgr_device_input_event(display->ico_input_device,
1616 timems, args[0], input, code, state);
1619 print_log("HOMESCREEN: Unknown input(%s),code(%s) or state(%s) "
1620 "at input_sw command", args[1], args[2], args[3]);
1624 print_log("HOMESCREEN: input_sw command[input_sw device input code, state] "
1630 send_event(const char *cmd)
1632 static int nmqinfo = 0;
1649 for (pt = 0; cmd[pt]; pt++) {
1650 if ((cmd[pt] >= '0') && (cmd[pt] <= '9')) {
1651 mqkey = mqkey * 10 + cmd[pt] - '0';
1657 for (; cmd[pt] == ' '; pt++) ;
1663 for (i = 0; i < nmqinfo; i++) {
1664 if (mqinfo[i].mqkey == mqkey) {
1665 mqid = mqinfo[i].mqid;
1670 if (nmqinfo >= 10) {
1671 fprintf(stderr, "HOMESCREEN: message queue(%d) overflow\n", mqkey);
1674 mqid = msgget(mqkey, 0);
1676 fprintf(stderr, "HOMESCREEN: message queue(%d(0x%x)) get error[%d]\n",
1677 mqkey, mqkey, errno);
1680 mqinfo[nmqinfo].mqkey = mqkey;
1681 mqinfo[nmqinfo].mqid = mqid;
1685 memset(&mqbuf, 0, sizeof(mqbuf));
1687 strncpy(mqbuf.buf, &cmd[pt], sizeof(mqbuf)-sizeof(long));
1689 if (msgsnd(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0) < 0) {
1690 fprintf(stderr, "HOMESCREEN: message queue(%d(0x%x)) send error[%d]\n",
1691 mqkey, mqkey, errno);
1700 * test-homescreen < test-case-data-file > test-result-output
1702 int main(int argc, char *argv[])
1704 struct display *display;
1708 #if 1 /* use mkostemp */
1709 extern int mkostemp(char *template, int flags);
1710 #else /* use mkostemp */
1712 #endif /* use mkostemp */
1714 display = malloc(sizeof *display);
1716 memset((char *)display, 0, sizeof *display);
1718 display->init_width = 640;
1719 display->init_height = 480;
1720 display->init_color = 0xFF304010;
1722 for (fd = 1; fd < argc; fd++) {
1723 if (argv[fd][0] == '-') {
1724 if (strncasecmp(argv[fd], "-visible=", 9) == 0) {
1725 display->visible_on_create = argv[fd][9] & 1;
1727 else if (strncasecmp(argv[fd], "-display=", 9) == 0) {
1728 strncpy(display->connect, &argv[fd][9], MAX_CON_NAME);
1730 else if (strncasecmp(argv[fd], "-prompt=", 8) == 0) {
1731 display->prompt = argv[fd][8] & 1;
1736 if (display->connect[0]) {
1737 display->display = wl_display_connect(display->connect);
1740 display->display = wl_display_connect(NULL);
1742 assert(display->display);
1744 display->registry = wl_display_get_registry(display->display);
1745 wl_registry_add_listener(display->registry, ®istry_listener, display);
1746 wl_display_dispatch(display->display);
1748 #if 0 /* 2013/08/23 no need shm */
1751 sleep_with_wayland(display->display, 20);
1752 } while(! display->shm);
1754 strcpy(buf, "/tmp/test-homescreen-shm-XXXXXX");
1755 #if 1 /* use mkostemp */
1756 fd = mkostemp(buf, O_CLOEXEC);
1758 fprintf(stderr, "test-homescreen: can not make temp file for shm\n");
1761 #else /* use mkostemp */
1764 fprintf(stderr, "test-homescreen: can not make temp file for shm\n");
1767 flags = fcntl(fd, F_GETFD);
1769 fprintf(stderr, "test-homescreen: can not get file flags\n");
1773 if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
1774 fprintf(stderr, "test-homescreen: can not set file flags to FD_CLOEXEC\n");
1778 #endif /* use mkostemp */
1780 if (ftruncate(fd, SHM_SIZE) < 0) {
1781 fprintf(stderr, "test-homescreen: can not truncate temp file for shm\n");
1785 display->shm_buf = mmap(NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
1786 if (display->shm_buf == MAP_FAILED) {
1787 fprintf(stderr, "test-homescreen: can not mmap temp file for shm\n");
1791 display->shm_pool = wl_shm_create_pool(display->shm, fd, SHM_SIZE);
1793 if (! display->shm_pool) {
1794 fprintf(stderr, "test-homescreen: wayland can not make shm_pool\n");
1797 print_log("HOMESCREEN: shm pool=%08x addr=%08x",
1798 (int)display->shm_pool, (int)display->shm_buf);
1803 sleep_with_wayland(display->display, 20);
1804 if (display->prompt) {
1805 printf("HOMESCREEN> "); fflush(stdout);
1807 ret = getdata(display->ico_window_mgr, "HOMESCREEN> ", fd, buf, sizeof(buf));
1809 fprintf(stderr, "HOMESCREEN: read error: fd %d, %m\n", fd);
1812 if (ret == 0) continue;
1813 wl_display_flush(display->display);
1815 if ((strncasecmp(buf, "bye", 3) == 0) ||
1816 (strncasecmp(buf, "quit", 4) == 0) ||
1817 (strncasecmp(buf, "end", 3) == 0)) {
1818 /* Exit, end of test */
1821 else if (strncasecmp(buf, "launch", 6) == 0) {
1822 /* Launch test application */
1823 launch_app(display, &buf[6]);
1825 else if (strncasecmp(buf, "kill", 4) == 0) {
1826 /* Launch test application */
1827 kill_app(display, &buf[4]);
1829 else if (strncasecmp(buf, "layer_visible", 13) == 0) {
1830 /* Change layer visiblety */
1831 visible_layer(display, &buf[13]);
1833 else if (strncasecmp(buf, "layer", 5) == 0) {
1834 /* layer change surface window */
1835 layer_surface(display, &buf[5]);
1837 else if (strncasecmp(buf, "positionsize", 12) == 0) {
1838 /* Move and Ressize surface window*/
1839 positionsize_surface(display, &buf[12]);
1841 else if (strncasecmp(buf, "move", 4) == 0) {
1842 /* Move surface window */
1843 move_surface(display, &buf[4]);
1845 else if (strncasecmp(buf, "resize", 6) == 0) {
1846 /* Resize surface window */
1847 resize_surface(display, &buf[6]);
1849 else if (strncasecmp(buf, "visible", 7) == 0) {
1850 /* Visible and Raise surface window*/
1851 visible_surface(display, &buf[7]);
1853 else if (strncasecmp(buf, "show", 4) == 0) {
1854 /* Show/Hide surface window */
1855 show_surface(display, &buf[4], 1);
1857 else if (strncasecmp(buf, "hide", 4) == 0) {
1858 /* Show/Hide surface window */
1859 show_surface(display, &buf[4], 0);
1861 else if (strncasecmp(buf, "raise", 5) == 0) {
1862 /* Raise/Lower surface window */
1863 raise_surface(display, &buf[5], 1);
1865 else if (strncasecmp(buf, "lower", 5) == 0) {
1866 /* Raise/Lower surface window */
1867 raise_surface(display, &buf[5], 0);
1869 else if (strncasecmp(buf, "active", 6) == 0) {
1870 /* Active surface window */
1871 active_window(display, &buf[6]);
1873 else if (strncasecmp(buf, "animation", 9) == 0) {
1874 /* Set animation surface window */
1875 animation_surface(display, &buf[9]);
1877 else if (strncasecmp(buf, "map", 3) == 0) {
1879 map_surface(display, &buf[3], 1);
1881 else if (strncasecmp(buf, "unmap", 5) == 0) {
1883 map_surface(display, &buf[5], 0);
1885 else if (strncasecmp(buf, "input_add", 9) == 0) {
1886 /* Set input switch to application */
1887 input_add(display, &buf[9]);
1889 else if (strncasecmp(buf, "input_del", 9) == 0) {
1890 /* Reset input switch to application*/
1891 input_del(display, &buf[9]);
1893 else if (strncasecmp(buf, "input_send", 10) == 0) {
1894 /* Input event send to application*/
1895 input_send(display, &buf[10]);
1897 else if (strncasecmp(buf, "input_conf", 10) == 0) {
1898 /* input switch configuration */
1899 input_conf(display, &buf[10]);
1901 else if (strncasecmp(buf, "input_code", 10) == 0) {
1902 /* input code configuration */
1903 input_code(display, &buf[10]);
1905 else if (strncasecmp(buf, "input_sw", 8) == 0) {
1906 /* input switch event */
1907 input_sw(display, &buf[8]);
1909 else if (strncasecmp(buf, "sleep", 5) == 0) {
1911 msec = sec_str_2_value(&buf[6]);
1912 sleep_with_wayland(display->display, msec);
1914 else if (strncasecmp(buf, "waitcreate", 10) == 0) {
1915 /* Wait surface create */
1916 msec = sec_str_2_value(&buf[11]);
1917 wait_with_wayland(display->display, msec, &display->surface_created);
1919 else if (strncasecmp(buf, "waitdestroy", 11) == 0) {
1920 /* Wait surface destrpy */
1921 msec = sec_str_2_value(&buf[12]);
1922 wait_with_wayland(display->display, msec, &display->surface_destroyed);
1924 else if (strncasecmp(buf, "event", 5) == 0) {
1925 /* Send touch panel event to Weston */
1926 send_event(&buf[6]);
1929 print_log("HOMESCREEN: unknown command[%s]", buf);
1934 print_log("HOMESCREEN: end");