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 "ico_input_mgr.h"
50 #include "test-common.h"
53 #define SHM_SIZE (16*1024*1024)
54 #define MAX_CON_NAME 127
58 struct surface_name *next;
61 char appid[MAX_APPID];
71 struct wl_display *display;
72 struct wl_registry *registry;
73 struct wl_compositor *compositor;
74 struct wl_shell *shell;
75 struct ico_window_mgr *ico_window_mgr;
76 struct ico_input_mgr_control *ico_input_mgr;
77 struct ico_input_mgr_device *ico_input_device;
78 struct ico_exinput *ico_exinput;
81 struct output *output[MAX_OUTPUT];
82 struct surface *surface;
83 struct surface_name *surface_name;
84 struct surface_name *bgsurface_name;
90 int surface_destroyed;
92 int visible_on_create;
93 char connect[MAX_CON_NAME+1];
97 struct display *display;
99 struct wl_pointer *pointer;
100 struct wl_keyboard *keyboard;
101 struct wl_touch *touch;
103 uint32_t button_mask;
104 struct surface *pointer_focus;
105 struct surface *keyboard_focus;
106 uint32_t last_key, last_key_state;
110 struct display *display;
111 struct wl_output *output;
117 struct display *display;
118 struct wl_surface *surface;
119 struct wl_shell_surface *shell_surface;
120 struct output *output;
124 EGLSurface egl_surface;
127 static void clear_surface(struct display *display);
130 pointer_handle_enter(void *data, struct wl_pointer *pointer,
131 uint32_t serial, struct wl_surface *surface,
132 wl_fixed_t x, wl_fixed_t y)
134 struct input *input = data;
136 input->pointer_focus = wl_surface_get_user_data(surface);
137 input->x = wl_fixed_to_double(x);
138 input->y = wl_fixed_to_double(y);
139 print_log("HOMESCREEN: got pointer enter (%d,%d), surface %p",
140 (int)input->x, (int)input->y, surface);
144 pointer_handle_leave(void *data, struct wl_pointer *pointer,
145 uint32_t serial, struct wl_surface *surface)
147 struct input *input = data;
149 input->pointer_focus = NULL;
151 print_log("HOMESCREEN: got pointer leave, surface %p", surface);
155 pointer_handle_motion(void *data, struct wl_pointer *pointer,
156 uint32_t time, wl_fixed_t x, wl_fixed_t y)
158 struct input *input = data;
160 input->x = wl_fixed_to_double(x);
161 input->y = wl_fixed_to_double(y);
163 print_log("HOMESCREEN: got pointer motion (%d,%d)", (int)input->x, (int)input->y);
167 pointer_handle_button(void *data, struct wl_pointer *pointer,
168 uint32_t serial, uint32_t time, uint32_t button, uint32_t state_w)
170 struct input *input = data;
172 enum wl_pointer_button_state state = state_w;
174 bit = 1 << (button - BTN_LEFT);
175 if (state == WL_POINTER_BUTTON_STATE_PRESSED)
176 input->button_mask |= bit;
178 input->button_mask &= ~bit;
179 print_log("HOMESCREEN: got pointer button %u %u", button, state_w);
183 pointer_handle_axis(void *data, struct wl_pointer *pointer,
184 uint32_t time, uint32_t axis, wl_fixed_t value)
186 print_log("HOMESCREEN: got pointer axis %u %d", axis, value);
190 keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
191 uint32_t format, int fd, uint32_t size)
194 print_log("HOMESCREEN: got keyboard keymap");
198 keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
199 uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
201 struct input *input = data;
203 input->keyboard_focus = wl_surface_get_user_data(surface);
204 print_log("HOMESCREEN: got keyboard enter, surface %p", surface);
208 keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
209 uint32_t serial, struct wl_surface *surface)
211 struct input *input = data;
213 input->keyboard_focus = NULL;
214 print_log("HOMESCREEN: got keyboard leave, surface %p", surface);
218 keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
219 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
221 struct input *input = data;
223 input->last_key = key;
224 input->last_key_state = state;
226 print_log("HOMESCREEN: got keyboard key %u %u", key, state);
230 keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
231 uint32_t serial, uint32_t mods_depressed,
232 uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
234 print_log("HOMESCREEN: got keyboard modifier");
238 touch_handle_down(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time,
239 struct wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y)
241 print_log("HOMESCREEN: got touch down %d (%d,%d)", id, x/256, y/256);
245 touch_handle_up(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time,
248 print_log("HOMESCREEN: got touch up %d", id);
252 touch_handle_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
253 int32_t id, wl_fixed_t x, wl_fixed_t y)
255 print_log("HOMESCREEN: got touch motion %d (%d,%d)", id, x/256, y/256);
259 touch_handle_frame(void *data, struct wl_touch *wl_touch)
261 print_log("HOMESCREEN: got touch frame");
265 touch_handle_cancel(void *data, struct wl_touch *wl_touch)
267 print_log("HOMESCREEN: got touch cancel");
270 static const struct wl_pointer_listener pointer_listener = {
271 pointer_handle_enter,
272 pointer_handle_leave,
273 pointer_handle_motion,
274 pointer_handle_button,
278 static const struct wl_keyboard_listener keyboard_listener = {
279 keyboard_handle_keymap,
280 keyboard_handle_enter,
281 keyboard_handle_leave,
283 keyboard_handle_modifiers,
286 static const struct wl_touch_listener touch_listener = {
295 seat_handle_capabilities(void *data, struct wl_seat *seat,
296 enum wl_seat_capability caps)
298 struct input *input = data;
300 print_log("HOMESCREEN: seat_handle_capabilities caps=%x", caps);
302 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
303 input->pointer = wl_seat_get_pointer(seat);
304 print_log("HOMESCREEN: seat_handle_capabilities add pointer=%x", (int)input->pointer);
305 wl_pointer_set_user_data(input->pointer, input);
306 wl_pointer_add_listener(input->pointer, &pointer_listener, input);
308 else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
309 print_log("HOMESCREEN: seat_handle_capabilities delete 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 print_log("HOMESCREEN: seat_handle_capabilities add keyboard=%x", (int)input->keyboard);
317 wl_keyboard_set_user_data(input->keyboard, input);
318 wl_keyboard_add_listener(input->keyboard, &keyboard_listener, input);
320 else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
321 print_log("HOMESCREEN: seat_handle_capabilities delete keyboard");
322 wl_keyboard_destroy(input->keyboard);
323 input->keyboard = NULL;
326 if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) {
327 input->touch = wl_seat_get_touch(seat);
328 print_log("HOMESCREEN: seat_handle_capabilities add touch=%x", (int)input->touch);
329 wl_touch_set_user_data(input->touch, input);
330 wl_touch_add_listener(input->touch, &touch_listener, input);
332 else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
333 print_log("HOMESCREEN: seat_handle_capabilities delete touch");
334 wl_touch_destroy(input->touch);
339 static const struct wl_seat_listener seat_listener = {
340 seat_handle_capabilities,
344 surface_enter(void *data, struct wl_surface *wl_surface, struct wl_output *output)
346 struct surface *surface = data;
348 surface->output = wl_output_get_user_data(output);
350 print_log("HOMESCREEN: got surface enter, output %p", surface->output);
354 surface_leave(void *data, struct wl_surface *wl_surface, struct wl_output *output)
356 struct surface *surface = data;
358 surface->output = NULL;
360 print_log("HOMESCREEN: got surface leave, output %p",
361 wl_output_get_user_data(output));
364 static const struct wl_surface_listener surface_listener = {
370 create_surface(struct display *display, const char *title)
372 struct surface *surface;
375 surface = malloc(sizeof *surface);
377 surface->display = display;
378 display->surface = surface;
379 surface->surface = wl_compositor_create_surface(display->compositor);
380 wl_surface_add_listener(surface->surface, &surface_listener, surface);
382 if (display->shell) {
383 surface->shell_surface =
384 wl_shell_get_shell_surface(display->shell, surface->surface);
385 if (surface->shell_surface) {
386 wl_shell_surface_set_toplevel(surface->shell_surface);
387 wl_shell_surface_set_title(surface->shell_surface, title);
390 wl_display_flush(display->display);
392 id = wl_proxy_get_id((struct wl_proxy *) surface->surface);
393 print_log("HOMESCREEN: create surface = %d", id);
395 poll(NULL, 0, 100); /* Wait for next frame where we'll get events. */
397 wl_display_roundtrip(display->display);
399 surface->dpy = opengl_init(display->display, &surface->conf, &surface->ctx);
401 surface->egl_surface = opengl_create_window(display->display, surface->surface,
402 surface->dpy, surface->conf,
403 surface->ctx, display->init_width,
404 display->init_height,
405 display->init_color);
406 clear_surface(display);
407 print_log("HOMESCREEN: created egl_surface %08x", (int)surface->egl_surface);
412 clear_surface(struct display *display)
414 if (! display->surface) {
415 create_surface(display, "HomeScreen-BG");
418 opengl_clear_window(display->init_color);
419 opengl_swap_buffer(display->display,
420 display->surface->dpy, display->surface->egl_surface);
425 output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
426 int physical_width, int physical_height, int subpixel,
427 const char *make, const char *model, int32_t transform)
429 struct output *output = data;
431 print_log("HOMESCREEN: Event[handle_geometry] %08x x/y=%d/%d p.w/h=%d/%d trans=%d",
432 (int)wl_output, x, y, physical_width, physical_height, transform);
439 output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
440 int width, int height, int refresh)
442 struct output *output = data;
444 print_log("HOMESCREEN: Event[handle_mode] %08x x/y=%d/%d flags=%08x refresh=%d",
445 (int)wl_output, width, height, flags, refresh);
447 if (flags & WL_OUTPUT_MODE_CURRENT) {
448 struct display *display = output->display;
450 output->width = width;
451 output->height = height;
453 display->init_width = width;
454 display->init_height = height;
456 if (display->bgsurface_name) {
457 ico_window_mgr_set_positionsize(display->ico_window_mgr,
458 display->bgsurface_name->surfaceid,
459 0, 0, 0, 0, width, height);
461 else if (display->bg_created == 0) {
462 display->bg_created = 9;
463 create_surface(display, "HomeScreen-BG");
468 static const struct wl_output_listener output_listener = {
469 output_handle_geometry,
474 search_surface(struct display *display, const char *surfname)
476 struct surface_name *p;
478 p = display->surface_name;
480 if (strcmp(p->appid, surfname) == 0) break;
488 if ((strcasecmp(surfname, "all") == 0) ||
489 (strcasecmp(surfname, "main") == 0)) {
490 return ICO_WINDOW_MGR_V_MAINSURFACE;
496 static struct surface_name *
497 search_surfacename(struct display *display, const char *surfname)
499 struct surface_name *p;
501 p = display->surface_name;
503 if (strcmp(p->appid, surfname) == 0) break;
507 print_log("HOMESCREEN: app(%s) dose not exist", surfname);
512 static struct surface_name *
513 search_surfaceid(struct display *display, const int surfaceid)
515 struct surface_name *p;
517 p = display->surface_name;
519 if (p->surfaceid == surfaceid) {
528 window_created(void *data, struct ico_window_mgr *ico_window_mgr,
529 uint32_t surfaceid, const char *winname, int32_t pid,
530 const char *appid, int32_t layertype)
532 struct display *display = data;
533 struct surface_name *p;
534 struct surface_name *fp;
536 display->surface_created = 1;
537 p = display->surface_name;
540 if (p->surfaceid == (int)surfaceid) break;
545 print_log("HOMESCREEN: Event[window_created] "
546 "surface=%08x(app=%s,name=%s,type=%x) exist",
547 (int)surfaceid, appid, winname, layertype);
550 print_log("HOMESCREEN: Event[window_created] "
551 "new surface=%08x(app=%s) winname=%s layertype=%x",
552 (int)surfaceid, appid, winname, layertype);
553 p = malloc(sizeof(struct surface_name));
557 memset(p, 0, sizeof(struct surface_name));
562 display->surface_name = p;
565 p->surfaceid = surfaceid;
567 strncpy(p->appid, appid, MAX_APPID-1);
569 /* Set default size and show */
571 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
572 0, p->x, p->y, p->width, p->height, 0);
575 print_log("HOMESCREEN: Created window[%08x] (app=%s)", (int)surfaceid, appid);
577 if (strncasecmp(appid, "test-homescreen", 15) == 0) {
578 display->bgsurface_name = p;
579 if (display->bg_created == 1) {
580 display->bg_created = 9;
581 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
583 display->init_width, display->init_height, 0);
585 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid, 1, 0, 0);
586 print_log("HOMESCREEN: Created window[%08x] (app=%s) Visible",
587 (int)surfaceid, appid);
593 window_name(void *data, struct ico_window_mgr *ico_window_mgr,
594 uint32_t surfaceid, const char *winname)
596 print_log("HOMESCREEN: Window Name[%08x] (name=%s)", (int)surfaceid, winname);
600 window_destroyed(void *data, struct ico_window_mgr *ico_window_mgr, uint32_t surfaceid)
602 struct display *display = data;
603 struct surface_name *p;
604 struct surface_name *fp;
606 display->surface_destroyed = 1;
607 p = search_surfaceid(display, (int)surfaceid);
609 print_log("HOMESCREEN: Event[window_destroyed] surface=%08x dose not exist",
613 print_log("HOMESCREEN: Event[window_destroyed] surface=%08x", (int)surfaceid);
614 if (p == display->surface_name) {
615 display->surface_name = p->next;
618 fp = display->surface_name;
632 window_visible(void *data, struct ico_window_mgr *ico_window_mgr,
633 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t hint)
635 struct display *display = data;
636 struct surface_name *p;
638 p = search_surfaceid(display, (int)surfaceid);
640 print_log("HOMESCREEN: Event[window_visible] surface=%08x dose not exist",
644 print_log("HOMESCREEN: Event[window_visible] surface=%08x "
645 "visible=%d raise=%d hint=%d", (int)surfaceid, visible, raise, hint);
646 p->visible = visible;
648 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
649 visible, ICO_WINDOW_MGR_V_NOCHANGE, 0);
655 window_configure(void *data, struct ico_window_mgr *ico_window_mgr,
656 uint32_t surfaceid, uint32_t node, int32_t layertype, uint32_t layer,
657 int32_t x, int32_t y, int32_t width, int32_t height, int32_t hint)
659 struct display *display = data;
660 struct surface_name *p;
662 print_log("HOMESCREEN: Event[window_configure] surface=%08x "
663 "node=%x layer=%x.%x x/y=%d/%d w/h=%d/%d hint=%d",
664 (int)surfaceid, node, layertype, layer, x, y, width, height, hint);
666 p = search_surfaceid(display, (int)surfaceid);
668 print_log("HOMESCREEN: Event[window_configure] surface=%08x dose not exist",
677 window_layer_visible(void *data, struct ico_window_mgr *ico_window_mgr,
678 uint32_t layer, int32_t visible)
680 print_log("HOMESCREEN: Event[layer_visible]layer=%x visible=%d",
681 (int)layer, visible);
685 window_active(void *data, struct ico_window_mgr *ico_window_mgr,
686 uint32_t surfaceid, const int32_t active)
688 print_log("HOMESCREEN: Event[window_active] surface=%08x acive=%d",
689 (int)surfaceid, (int)active);
690 if ((surfaceid & 0x0000ffff) == 0x0001) {
691 ico_window_mgr_set_visible(ico_window_mgr, surfaceid,
692 ICO_WINDOW_MGR_V_NOCHANGE, 0, 0);
697 window_surfaces(void *data, struct ico_window_mgr *ico_window_mgr,
698 const char *appid, int32_t pid, struct wl_array *surfaces)
700 print_log("HOMESCREEN: Event[app_surfaces] app=%s pid=%d", appid, pid);
704 window_map(void *data, struct ico_window_mgr *ico_window_mgr,
705 int32_t event, uint32_t surfaceid, uint32_t type, uint32_t target,
706 int32_t width, int32_t height, int32_t stride, uint32_t format)
711 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
712 strcpy(sevt, "Contents"); break;
713 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
714 strcpy(sevt, "Resize"); break;
715 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
716 strcpy(sevt, "Map"); break;
717 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
718 strcpy(sevt, "Unmap"); break;
719 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
720 sprintf(sevt, "Error %d", type); break;
722 sprintf(sevt, "??%d??", event); break;
724 print_log("HOMESCREEN: Event[map_surface] ev=%s(%d) surf=%08x type=%d target=%x "
725 "w/h/s/f=%d/%d/%d/%x",
726 sevt, event, (int)surfaceid, type, target, width, height, stride, format);
729 static const struct ico_window_mgr_listener window_mgr_listener = {
736 window_layer_visible,
742 cb_input_capabilities(void *data, struct ico_exinput *ico_exinput,
743 const char *device, int32_t type, const char *swname, int32_t input,
744 const char *codename, int32_t code)
746 print_log("HOMESCREEN: Event[input_capabilities] device=%s type=%d sw=%s input=%d "
747 "code=%s[%d]", device, type, swname, input, codename, code);
751 cb_input_code(void *data, struct ico_exinput *ico_exinput,
752 const char *device, int32_t input, const char *codename, int32_t code)
754 print_log("HOMESCREEN: Event[input_code] device=%s input=%d code=%s[%d]",
755 device, input, codename, code);
759 cb_input_input(void *data, struct ico_exinput *ico_exinput, uint32_t time,
760 const char *device, int32_t input, int32_t code, int32_t state)
762 print_log("HOMESCREEN: Event[input_input] device=%s input=%d code=%d state=%d",
763 device, input, code, state);
766 static const struct ico_exinput_listener exinput_listener = {
767 cb_input_capabilities,
773 cb_input_regions(void *data, struct ico_input_mgr_device *ico_input_mgr_device,
774 struct wl_array *regions)
776 struct ico_uifw_input_region *region;
782 wl_array_for_each(region, regions) {
785 print_log("HOMESCREEN: Event[input_regions] number of regions=%d", n);
787 wl_array_for_each(region, regions) {
789 switch (region->change) {
790 case ICO_INPUT_MGR_DEVICE_REGION_ADD:
791 strcpy(schange, "Add");
793 case ICO_INPUT_MGR_DEVICE_REGION_REMOVE:
794 strcpy(schange, "Remove");
796 case ICO_INPUT_MGR_DEVICE_REGION_REMOVEALL:
797 strcpy(schange, "RemoveAll");
800 sprintf(schange, "?%d?", region->change);
803 print_log("HOMESCREEN:%2d. %s %d.%08x(%d/%d) %d/%d-%d/%d "
804 "hot=%d/%d cur=%d/%d-%d/%d attr=%x",
805 n, schange, region->node, region->surfaceid, region->surface_x,
806 region->surface_y, region->x, region->y, region->width,
807 region->height, region->hotspot_x, region->hotspot_y,
808 region->cursor_x, region->cursor_y, region->cursor_width,
809 region->cursor_height, region->attr);
813 print_log("HOMESCREEN: Event[input_regions] no region");
817 static const struct ico_input_mgr_device_listener device_listener = {
823 handle_global(void *data, struct wl_registry *registry, uint32_t id,
824 const char *interface, uint32_t version)
826 struct display *display = data;
828 struct output *output;
830 print_log("HOMESCREEN: handle_global: interface=<%s> id=%d", interface, (int)id);
832 if (strcmp(interface, "wl_compositor") == 0) {
833 display->compositor =
834 wl_registry_bind(display->registry, id, &wl_compositor_interface, 1);
836 else if (strcmp(interface, "wl_seat") == 0) {
837 input = calloc(1, sizeof *input);
838 input->display = display;
839 input->seat = wl_registry_bind(display->registry, id, &wl_seat_interface, 1);
840 input->pointer_focus = NULL;
841 input->keyboard_focus = NULL;
843 wl_seat_add_listener(input->seat, &seat_listener, input);
844 display->input = input;
846 else if (strcmp(interface, "wl_output") == 0) {
847 if (display->num_output < MAX_OUTPUT) {
848 output = malloc(sizeof *output);
849 output->display = display;
850 output->output = wl_registry_bind(display->registry, id, &wl_output_interface, 1);
851 wl_output_add_listener(output->output, &output_listener, output);
852 display->output[display->num_output] = output;
854 print_log("HOMESCREEN: created output[%d] global %p",
855 display->num_output, display->output[display->num_output]);
856 display->num_output ++;
859 else if (strcmp(interface, "wl_shell") == 0) {
861 wl_registry_bind(display->registry, id, &wl_shell_interface, 1);
863 else if (strcmp(interface, "ico_window_mgr") == 0) {
864 display->ico_window_mgr =
865 wl_registry_bind(display->registry, id, &ico_window_mgr_interface, 1);
866 ico_window_mgr_add_listener(display->ico_window_mgr, &window_mgr_listener, display);
867 print_log("HOMESCREEN: created window_mgr global %p", display->ico_window_mgr);
869 ico_window_mgr_declare_manager(display->ico_window_mgr, 1);
871 else if (strcmp(interface, "ico_input_mgr_control") == 0) {
872 display->ico_input_mgr = wl_registry_bind(display->registry, id,
873 &ico_input_mgr_control_interface, 1);
874 print_log("HOMESCREEN: created input_mgr global %p", display->ico_input_mgr);
876 else if (strcmp(interface, "ico_input_mgr_device") == 0) {
877 display->ico_input_device = wl_registry_bind(display->registry, id,
878 &ico_input_mgr_device_interface, 1);
879 ico_input_mgr_device_add_listener(display->ico_input_device,
880 &device_listener, display);
881 print_log("HOMESCREEN: created input_device global %p", display->ico_input_device);
883 else if (strcmp(interface, "ico_exinput") == 0) {
884 display->ico_exinput =
885 wl_registry_bind(display->registry, id, &ico_exinput_interface, 1);
886 ico_exinput_add_listener(display->ico_exinput, &exinput_listener, display);
887 print_log("HOMESCREEN: created exinput global %p", display->ico_exinput);
889 ico_window_mgr_declare_manager(display->ico_window_mgr, 1);
891 display->bg_created = 1;
892 create_surface(display, "HomeScreen-BG");
896 static const struct wl_registry_listener registry_listener = {
901 launch_app(struct display *display, char *buf)
905 display->surface_created = 0;
906 display->surface_destroyed = 0;
907 snprintf(sbuf, sizeof(sbuf)-1, "%s &", skip_spaces(buf));
908 if (system(sbuf) < 0) {
909 print_log("HOMESCREEN: Can not launch application[%s]", sbuf);
912 sleep_with_wayland(display->display, 500);
917 kill_app(struct display *display, char *buf)
921 struct surface_name *p;
922 struct surface_name *fp;
924 narg = pars_command(buf, args, 10);
926 p = search_surfacename(display, args[0]);
928 print_log("HOMESCREEN: kill[%s] Application dose not exist", args[0]);
930 else if (kill(p->pid, SIGINT) < 0) {
931 print_log("HOMESCREEN: kill[%s.%d] Application dose not exist",
935 sleep_with_wayland(display->display, 300);
936 p = search_surfacename(display, args[0]);
937 if ((p != NULL) && (kill(p->pid, SIGTERM) >= 0)) {
938 sleep_with_wayland(display->display, 200);
939 p = search_surfacename(display, args[0]);
941 kill(p->pid, SIGKILL);
942 sleep_with_wayland(display->display, 200);
946 p = search_surfacename(display, args[0]);
948 if (p == display->surface_name) {
949 display->surface_name = p->next;
952 fp = display->surface_name;
964 print_log("HOMESCREEN: kill command[kill appid] has no argument");
969 layer_surface(struct display *display, char *buf)
976 narg = pars_command(buf, args, 10);
978 surfaceid = search_surface(display, args[0]);
979 layerid = strtol(args[1], (char **)0, 0);
980 if ((surfaceid >= 0) && (layerid >= 0)) {
981 print_log("HOMESCREEN: set_window_layer(%s,%08x)",
982 args[0], surfaceid, layerid);
983 ico_window_mgr_set_window_layer(display->ico_window_mgr, surfaceid, layerid);
986 print_log("HOMESCREEN: Unknown surface(%s) at layer command", args[0]);
990 print_log("HOMESCREEN: layer command[layer appid layerid] has no argument");
995 positionsize_surface(struct display *display, char *buf)
998 struct surface_name *p;
1001 int x, y, width, height;
1005 narg = pars_command(buf, args, 10);
1007 surfaceid = search_surface(display, args[0]);
1008 p = search_surfacename(display, args[0]);
1009 x = strtol(args[1], (char **)0, 0);
1010 y = strtol(args[2], (char **)0, 0);
1011 width = strtol(args[3], (char **)0, 0);
1012 height = strtol(args[4], (char **)0, 0);
1014 node = strtol(args[5], (char **)0, 0);
1023 anima = strtol(args[6], (char **)0, 0);
1025 if ((surfaceid >= 0) && (x >= 0) && (y >=0) && (width >= 0) && (height >=0)) {
1026 print_log("HOMESCREEN: set_positionsize(%s,%08x,%d,%d,%d,%d,%d)",
1027 args[0], surfaceid, node, x, y, width, height);
1028 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1029 node, x, y, width, height, anima);
1032 print_log("HOMESCREEN: Unknown surface(%s) at positionsize command", args[0]);
1036 print_log("HOMESCREEN: positionsize command"
1037 "[positionsize appid x y width heigh node anima] has no argument");
1042 move_surface(struct display *display, char *buf)
1045 struct surface_name *p;
1052 narg = pars_command(buf, args, 10);
1054 surfaceid = search_surface(display, args[0]);
1055 p = search_surfacename(display, args[0]);
1056 x = strtol(args[1], (char **)0, 0);
1057 y = strtol(args[2], (char **)0, 0);
1059 node = strtol(args[3], (char **)0, 0);
1061 if (p) node = p->node;
1064 if (p) p->node = node;
1070 anima = strtol(args[4], (char **)0, 0);
1073 if ((surfaceid >= 0) && (x >= 0) && (y >=0)) {
1074 print_log("HOMESCREEN: move(%s,%08x,%d.%d,%d anima=%d)", args[0], surfaceid,
1076 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1078 ICO_WINDOW_MGR_V_NOCHANGE,
1079 ICO_WINDOW_MGR_V_NOCHANGE, anima);
1082 print_log("HOMESCREEN: Unknown surface(%s) at move command", args[0]);
1086 print_log("HOMESCREEN: move command[positionsize appid x y node anima] has no argument");
1091 resize_surface(struct display *display, char *buf)
1094 struct surface_name *p;
1101 narg = pars_command(buf, args, 10);
1103 surfaceid = search_surface(display, args[0]);
1104 p = search_surfacename(display, args[0]);
1108 width = strtol(args[1], (char **)0, 0);
1109 height = strtol(args[2], (char **)0, 0);
1111 anima = strtol(args[3], (char **)0, 0);
1114 if ((surfaceid >= 0) && (width >= 0) && (height >=0)) {
1115 print_log("HOMESCREEN: resize(%s,%08x,%d.%d,%d,anima=%d)",
1116 args[0], surfaceid, node, width, height, anima);
1117 ico_window_mgr_set_positionsize(display->ico_window_mgr, surfaceid,
1118 node, ICO_WINDOW_MGR_V_NOCHANGE,
1119 ICO_WINDOW_MGR_V_NOCHANGE, width, height, anima);
1122 print_log("HOMESCREEN: Unknown surface(%s) at resize command", args[0]);
1126 print_log("HOMESCREEN: positionsize command"
1127 "[resize appid width heigh anima] has no argument");
1132 visible_surface(struct display *display, char *buf)
1141 narg = pars_command(buf, args, 10);
1143 surfaceid = search_surface(display, args[0]);
1144 visible = strtol(args[1], (char **)0, 0);
1145 raise = strtol(args[2], (char **)0, 0);
1147 anima = strtol(args[3], (char **)0, 0);
1149 if ((surfaceid >= 0) && (visible >= 0) && (raise >=0)) {
1150 print_log("HOMESCREEN: visible(%s,%08x,%d,%d,%d)",
1151 args[0], surfaceid, visible, raise, anima);
1152 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1153 visible, raise, anima);
1156 print_log("HOMESCREEN: Unknown surface(%s) at visible command", args[0]);
1160 print_log("HOMESCREEN: visible command[visible appid visible raise] "
1166 show_surface(struct display *display, char *buf, const int show)
1177 narg = pars_command(buf, args, 10);
1179 surfaceid = search_surface(display, args[0]);
1181 anima = strtol(args[1], (char **)0, 0);
1187 if (narg >= 3) ax = strtol(args[2], (char **)0, 0);
1188 if (narg >= 4) ay = strtol(args[3], (char **)0, 0);
1189 if (narg >= 5) awidth = strtol(args[4], (char **)0, 0);
1190 if (narg >= 6) aheight = strtol(args[5], (char **)0, 0);
1193 if (surfaceid >= 0) {
1196 print_log("HOMESCREEN: show anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)",
1197 args[0], surfaceid, ax, ay, awidth, aheight);
1198 ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid,
1199 1, ax, ay, awidth, aheight);
1202 print_log("HOMESCREEN: show(%s,%08x,anima=%d)",
1203 args[0], surfaceid, anima);
1204 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1205 1, ICO_WINDOW_MGR_V_NOCHANGE, anima);
1210 print_log("HOMESCREEN: hide anima(%s,%08x,x/y=%d/%d,w/h=%d/%d)",
1211 args[0], surfaceid, ax, ay, awidth, aheight);
1212 ico_window_mgr_visible_animation(display->ico_window_mgr, surfaceid,
1213 0, ax, ay, awidth, aheight);
1216 print_log("HOMESCREEN: hide(%s,%08x,anima=%d)",
1217 args[0], surfaceid, anima);
1218 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1219 0, ICO_WINDOW_MGR_V_NOCHANGE, anima);
1224 print_log("HOMESCREEN: Unknown surface(%s) at show/hide command", args[0]);
1228 print_log("HOMESCREEN: show command[show/hide appid anima x y width height]"
1229 " has no argument");
1234 raise_surface(struct display *display, char *buf, const int raise)
1241 narg = pars_command(buf, args, 10);
1243 surfaceid = search_surface(display, args[0]);
1245 anima = strtol(args[1], (char **)0, 0);
1247 if (surfaceid >= 0) {
1249 print_log("HOMESCREEN: raise(%s,%08x,anima=%d)", args[0], surfaceid, anima);
1250 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1251 ICO_WINDOW_MGR_V_NOCHANGE, 1, anima);
1254 print_log("HOMESCREEN: lower(%s,%08x,anima=%d)", args[0], surfaceid, anima);
1255 ico_window_mgr_set_visible(display->ico_window_mgr, surfaceid,
1256 ICO_WINDOW_MGR_V_NOCHANGE, 0, anima);
1260 print_log("HOMESCREEN: Unknown surface(%s) at raise/lower command", args[0]);
1264 print_log("HOMESCREEN: show command[raise/lower appid anima] has no argument");
1269 active_window(struct display *display, char *buf)
1276 narg = pars_command(buf, args, 10);
1278 surfaceid = search_surface(display, args[0]);
1280 target = strtol(args[1], (char **)0, 0);
1283 target = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1285 if (surfaceid >= 0) {
1286 print_log("HOMESCREEN: active(%s,%08x,target=%x)", args[0], surfaceid, target);
1287 ico_window_mgr_set_active(display->ico_window_mgr, surfaceid, target);
1290 print_log("HOMESCREEN: Unknown surface(%s) at active command", args[0]);
1294 print_log("HOMESCREEN: active command[active appid[target]] has no argument");
1300 animation_surface(struct display *display, char *buf)
1307 narg = pars_command(buf, args, 10);
1309 surfaceid = search_surface(display, args[0]);
1310 if (surfaceid >= 0) {
1312 time = strtol(args[2], (char **)0, 0);
1317 print_log("HOMESCREEN: animation(%s,%08x,%s,%d)",
1318 args[0], surfaceid, args[1], time);
1319 ico_window_mgr_set_animation(display->ico_window_mgr, surfaceid, 0x7fffffff,
1323 print_log("HOMESCREEN: Unknown surface(%s) at animation command", args[0]);
1327 print_log("HOMESCREEN: animation command"
1328 "[animation appid animation time] has no argument");
1333 map_surface(struct display *display, char *buf, int map)
1340 narg = pars_command(buf, args, 10);
1342 surfaceid = search_surface(display, args[0]);
1343 if (surfaceid >= 0) {
1345 fps = strtol(args[1], (char **)0, 0);
1351 print_log("HOMESCREEN: map surface(%s,%08x,%d)",
1352 args[0], surfaceid, fps);
1353 ico_window_mgr_map_surface(display->ico_window_mgr, surfaceid, fps);
1356 print_log("HOMESCREEN: unmap surface(%s,%08x)", args[0], surfaceid);
1357 ico_window_mgr_unmap_surface(display->ico_window_mgr, surfaceid);
1361 print_log("HOMESCREEN: Unknown surface(%s) at %s command", args[0],
1362 map ? "map" : "unmap");
1367 print_log("HOMESCREEN: map surface command"
1368 "[map surface framerate] has no argument");
1371 print_log("HOMESCREEN: unmap surface command"
1372 "[unmap surface] has no argument");
1378 visible_layer(struct display *display, char *buf)
1385 narg = pars_command(buf, args, 10);
1387 layer = strtol(args[0], (char **)0, 0);
1388 visible = strtol(args[1], (char **)0, 0);
1389 ico_window_mgr_set_layer_visible(display->ico_window_mgr, layer, visible);
1392 print_log("HOMESCREEN: layer_visible command"
1393 "[layer_visible layer visible] has no argument");
1398 input_add(struct display *display, char *buf)
1405 narg = pars_command(buf, args, 10);
1407 input = strtol(args[1], (char **)0, 0);
1409 fix = strtol(args[3], (char **)0, 0);
1414 if ((input >= 0) && (fix >=0)) {
1415 print_log("HOMESCREEN: input_add(%s.%d to %s[%d])",
1416 args[0], input, args[2], fix);
1417 ico_input_mgr_control_add_input_app(display->ico_input_mgr,
1418 args[2], args[0], input, fix, 0);
1421 print_log("HOMESCREEN: Unknown input(%s) at input_add command", args[1]);
1425 print_log("HOMESCREEN: input_add command[input_add device inputId appid fix] "
1431 input_del(struct display *display, char *buf)
1436 char wk1[32], wk2[32];
1438 narg = pars_command(buf, args, 10);
1440 input = strtol(args[1], (char **)0, 0);
1441 if (args[0][0] == '@') {
1445 if (args[2][0] == '@') {
1449 print_log("HOMESCREEN: input_del(%s.%d to %s)", args[0], input, args[2]);
1450 ico_input_mgr_control_del_input_app(display->ico_input_mgr,
1451 args[2], args[0], input);
1454 print_log("HOMESCREEN: input_del command[input_del device inputId appid] "
1460 input_send(struct display *display, char *buf)
1471 narg = pars_command(buf, args, 10);
1473 memset(appid, 0, sizeof(appid));
1474 if (args[0][0] == '@') {
1475 strncpy(appid, &args[0][1], sizeof(appid)-1);
1479 surfaceid = search_surface(display, args[0]);
1481 if (strcasecmp(args[1], "POINTER") == 0) {
1482 type = ICO_INPUT_MGR_DEVICE_TYPE_POINTER;
1484 else if (strcasecmp(args[1], "KEYBOARD") == 0) {
1485 type = ICO_INPUT_MGR_DEVICE_TYPE_KEYBOARD;
1487 else if (strcasecmp(args[1], "TOUCH") == 0) {
1488 type = ICO_INPUT_MGR_DEVICE_TYPE_TOUCH;
1490 else if (strcasecmp(args[1], "SWITCH") == 0) {
1491 type = ICO_INPUT_MGR_DEVICE_TYPE_SWITCH;
1493 else if (strcasecmp(args[1], "HAPTIC") == 0) {
1494 type = ICO_INPUT_MGR_DEVICE_TYPE_HAPTIC;
1497 type = strtol(args[1], (char **)0, 0);
1499 no = strtol(args[2], (char **)0, 0);
1500 if (strcasecmp(args[3], "ABS_X") == 0) {
1503 else if (strcasecmp(args[3], "ABS_Y") == 0) {
1506 else if (strcasecmp(args[3], "ABS_Z") == 0) {
1509 else if (strcasecmp(args[3], "REL_X") == 0) {
1510 code = REL_X | (EV_REL << 16);
1512 else if (strcasecmp(args[3], "REL_Y") == 0) {
1513 code = REL_Y | (EV_REL << 16);
1515 else if (strcasecmp(args[3], "REL_Z") == 0) {
1516 code = REL_Z | (EV_REL << 16);
1518 else if (strcasecmp(args[3], "BTN_TOUCH") == 0) {
1521 else if (strcasecmp(args[3], "BTN_LEFT") == 0) {
1524 else if (strcasecmp(args[3], "BTN_RIGHT") == 0) {
1527 else if (strcasecmp(args[3], "BTN_MIDDLE") == 0) {
1530 else if (strcasecmp(args[3], "BTN_RIGHT") == 0) {
1534 code = strtol(args[3], (char **)0, 0);
1536 value = strtol(args[4], (char **)0, 0);
1538 value = (value << 16) + strtol(args[5], (char **)0, 0);
1540 print_log("HOMESCREEN: input_send(%s.%x,%d,%d,%x,%d)",
1541 appid, surfaceid, type, no, code, value);
1542 ico_input_mgr_control_send_input_event(display->ico_input_mgr,
1543 appid, surfaceid, type, no, 0, code, value);
1546 print_log("HOMESCREEN: input_send command[input_send {@app/serface} type no code "
1547 "value [value2]] has no argument");
1552 input_conf(struct display *display, char *buf)
1559 char wk1[32], wk2[32];
1561 narg = pars_command(buf, args, 10);
1563 type = strtol(args[1], (char **)0, 0);
1564 input = strtol(args[3], (char **)0, 0);
1566 code = strtol(args[5], (char **)0, 0);
1571 strcpy(wk1, args[2]);
1575 if ((type >= 0) && (input >= 0) && (code >=0)) {
1576 ico_input_mgr_device_configure_input(display->ico_input_device, args[0], type,
1577 args[2], input, args[4], code);
1580 print_log("HOMESCREEN: Unknown type(%s),input(%s) or code(%s) "
1581 "at input_conf command", args[1], args[3], args[5]);
1585 print_log("HOMESCREEN: input_conf command[input_conf device type swname input "
1586 "codename code] has no argument");
1591 input_code(struct display *display, char *buf)
1598 narg = pars_command(buf, args, 10);
1600 input = strtol(args[1], (char **)0, 0);
1601 code = strtol(args[3], (char **)0, 0);
1602 if ((input >= 0) && (code >= 0)) {
1603 ico_input_mgr_device_configure_code(display->ico_input_device, args[0], input,
1607 print_log("HOMESCREEN: Unknown input(%s) or code(%s) "
1608 "at input_code command", args[1], args[3]);
1612 print_log("HOMESCREEN: input_conf command[input_code device input codename code] "
1618 input_sw(struct display *display, char *buf)
1628 narg = pars_command(buf, args, 10);
1630 input = strtol(args[1], (char **)0, 0);
1631 code = strtol(args[2], (char **)0, 0);
1632 state = strtol(args[3], (char **)0, 0);
1633 if ((input >= 0) && (state >= 0)) {
1634 gettimeofday(&stv, (struct timezone *)NULL);
1635 timems = (stv.tv_sec % 1000) * 1000 + (stv.tv_usec / 1000);
1636 ico_input_mgr_device_input_event(display->ico_input_device,
1637 timems, args[0], input, code, state);
1640 print_log("HOMESCREEN: Unknown input(%s),code(%s) or state(%s) "
1641 "at input_sw command", args[1], args[2], args[3]);
1645 print_log("HOMESCREEN: input_sw command[input_sw device input code, state] "
1651 send_event(const char *cmd)
1653 static int nmqinfo = 0;
1670 for (pt = 0; cmd[pt]; pt++) {
1671 if ((cmd[pt] >= '0') && (cmd[pt] <= '9')) {
1672 mqkey = mqkey * 10 + cmd[pt] - '0';
1678 for (; cmd[pt] == ' '; pt++) ;
1684 for (i = 0; i < nmqinfo; i++) {
1685 if (mqinfo[i].mqkey == mqkey) {
1686 mqid = mqinfo[i].mqid;
1691 if (nmqinfo >= 10) {
1692 fprintf(stderr, "HOMESCREEN: message queue(%d) overflow\n", mqkey);
1695 mqid = msgget(mqkey, 0);
1697 fprintf(stderr, "HOMESCREEN: message queue(%d(0x%x)) get error[%d]\n",
1698 mqkey, mqkey, errno);
1701 mqinfo[nmqinfo].mqkey = mqkey;
1702 mqinfo[nmqinfo].mqid = mqid;
1706 memset(&mqbuf, 0, sizeof(mqbuf));
1708 strncpy(mqbuf.buf, &cmd[pt], sizeof(mqbuf)-sizeof(long));
1710 if (msgsnd(mqid, &mqbuf, sizeof(mqbuf)-sizeof(long), 0) < 0) {
1711 fprintf(stderr, "HOMESCREEN: message queue(%d(0x%x)) send error[%d]\n",
1712 mqkey, mqkey, errno);
1718 set_region(struct display *display, char *buf)
1722 int x, y, width, height;
1724 int c_x, c_y, c_width, c_height;
1726 narg = pars_command(buf, args, 10);
1728 x = strtol(args[1], (char **)0, 0);
1729 y = strtol(args[2], (char **)0, 0);
1730 width = strtol(args[3], (char **)0, 0);
1731 height = strtol(args[4], (char **)0, 0);
1732 hot_x = x + (width / 2);
1733 hot_y = y + (height / 2);
1736 c_width = width - 10;
1737 if (c_width <= 0) c_width = 2;
1738 c_height = height - 10;
1739 if (c_height <= 0) c_height = 2;
1740 print_log("HOMESCREEN: ico_exinput_set_input_region(%s,%d,%d-%d,%d,"
1741 "hot=%d,%d,cur=%d,%d-%d,%d,attr=0)",
1742 args[0] ? args[0] : "(null)", x, y, width, height,
1743 hot_x, hot_y, c_x, c_y, c_width, c_height);
1744 if (strcasecmp(args[0], "NULL") == 0) {
1745 ico_exinput_set_input_region(display->ico_exinput, "", x, y,
1746 width, height, hot_x, hot_y, c_x, c_y,
1747 c_width, c_height, 0);
1750 ico_exinput_set_input_region(display->ico_exinput, args[0], x, y,
1751 width, height, hot_x, hot_y, c_x, c_y,
1752 c_width, c_height, 0);
1756 print_log("HOMESCREEN: set_region command[set_region winname@appid x y "
1757 "width height] has no argument");
1762 unset_region(struct display *display, char *buf)
1766 int x, y, width, height;
1768 narg = pars_command(buf, args, 10);
1771 x = strtol(args[1], (char **)0, 0);
1772 y = strtol(args[2], (char **)0, 0);
1773 width = strtol(args[3], (char **)0, 0);
1774 height = strtol(args[4], (char **)0, 0);
1782 print_log("HOMESCREEN: ico_exinput_unset_input_region(%s,08x,%d,%d-%d,%d)",
1783 args[0] ? args[0] : "(null)", x, y, width, height);
1784 if (strcasecmp(args[0], "NULL") == 0) {
1785 ico_exinput_unset_input_region(display->ico_exinput, "", x, y,
1789 ico_exinput_unset_input_region(display->ico_exinput, args[0],
1790 x, y, width, height);
1794 print_log("HOMESCREEN: unset_region command[unset_region winname@appid x y "
1795 "width height] has no argument");
1803 * test-homescreen < test-case-data-file > test-result-output
1805 int main(int argc, char *argv[])
1807 struct display *display;
1811 #if 1 /* use mkostemp */
1812 extern int mkostemp(char *template, int flags);
1813 #else /* use mkostemp */
1815 #endif /* use mkostemp */
1817 display = malloc(sizeof *display);
1819 memset((char *)display, 0, sizeof *display);
1821 display->init_width = 640;
1822 display->init_height = 480;
1823 display->init_color = 0xFF304010;
1825 for (fd = 1; fd < argc; fd++) {
1826 if (argv[fd][0] == '-') {
1827 if (strncasecmp(argv[fd], "-visible=", 9) == 0) {
1828 display->visible_on_create = argv[fd][9] & 1;
1830 else if (strncasecmp(argv[fd], "-display=", 9) == 0) {
1831 strncpy(display->connect, &argv[fd][9], MAX_CON_NAME);
1833 else if (strncasecmp(argv[fd], "-prompt=", 8) == 0) {
1834 display->prompt = argv[fd][8] & 1;
1839 if (display->connect[0]) {
1840 display->display = wl_display_connect(display->connect);
1843 display->display = wl_display_connect(NULL);
1845 assert(display->display);
1847 display->registry = wl_display_get_registry(display->display);
1848 wl_registry_add_listener(display->registry, ®istry_listener, display);
1849 wl_display_dispatch(display->display);
1854 sleep_with_wayland(display->display, 20);
1855 if (display->prompt) {
1856 printf("HOMESCREEN> "); fflush(stdout);
1858 ret = getdata(display->ico_window_mgr, "HOMESCREEN> ", fd, buf, sizeof(buf));
1860 fprintf(stderr, "HOMESCREEN: read error: fd %d, %m\n", fd);
1863 if (ret == 0) continue;
1864 wl_display_flush(display->display);
1866 if ((strncasecmp(buf, "bye", 3) == 0) ||
1867 (strncasecmp(buf, "quit", 4) == 0) ||
1868 (strncasecmp(buf, "end", 3) == 0)) {
1869 /* Exit, end of test */
1872 else if (strncasecmp(buf, "launch", 6) == 0) {
1873 /* Launch test application */
1874 launch_app(display, &buf[6]);
1876 else if (strncasecmp(buf, "kill", 4) == 0) {
1877 /* Launch test application */
1878 kill_app(display, &buf[4]);
1880 else if (strncasecmp(buf, "layer_visible", 13) == 0) {
1881 /* Change layer visiblety */
1882 visible_layer(display, &buf[13]);
1884 else if (strncasecmp(buf, "layer", 5) == 0) {
1885 /* layer change surface window */
1886 layer_surface(display, &buf[5]);
1888 else if (strncasecmp(buf, "positionsize", 12) == 0) {
1889 /* Move and Ressize surface window*/
1890 positionsize_surface(display, &buf[12]);
1892 else if (strncasecmp(buf, "move", 4) == 0) {
1893 /* Move surface window */
1894 move_surface(display, &buf[4]);
1896 else if (strncasecmp(buf, "resize", 6) == 0) {
1897 /* Resize surface window */
1898 resize_surface(display, &buf[6]);
1900 else if (strncasecmp(buf, "visible", 7) == 0) {
1901 /* Visible and Raise surface window*/
1902 visible_surface(display, &buf[7]);
1904 else if (strncasecmp(buf, "show", 4) == 0) {
1905 /* Show/Hide surface window */
1906 show_surface(display, &buf[4], 1);
1908 else if (strncasecmp(buf, "hide", 4) == 0) {
1909 /* Show/Hide surface window */
1910 show_surface(display, &buf[4], 0);
1912 else if (strncasecmp(buf, "raise", 5) == 0) {
1913 /* Raise/Lower surface window */
1914 raise_surface(display, &buf[5], 1);
1916 else if (strncasecmp(buf, "lower", 5) == 0) {
1917 /* Raise/Lower surface window */
1918 raise_surface(display, &buf[5], 0);
1920 else if (strncasecmp(buf, "active", 6) == 0) {
1921 /* Active surface window */
1922 active_window(display, &buf[6]);
1924 else if (strncasecmp(buf, "animation", 9) == 0) {
1925 /* Set animation surface window */
1926 animation_surface(display, &buf[9]);
1928 else if (strncasecmp(buf, "map", 3) == 0) {
1930 map_surface(display, &buf[3], 1);
1932 else if (strncasecmp(buf, "unmap", 5) == 0) {
1934 map_surface(display, &buf[5], 0);
1936 else if (strncasecmp(buf, "input_add", 9) == 0) {
1937 /* Set input switch to application */
1938 input_add(display, &buf[9]);
1940 else if (strncasecmp(buf, "input_del", 9) == 0) {
1941 /* Reset input switch to application*/
1942 input_del(display, &buf[9]);
1944 else if (strncasecmp(buf, "input_send", 10) == 0) {
1945 /* Input event send to application*/
1946 input_send(display, &buf[10]);
1948 else if (strncasecmp(buf, "input_conf", 10) == 0) {
1949 /* input switch configuration */
1950 input_conf(display, &buf[10]);
1952 else if (strncasecmp(buf, "input_code", 10) == 0) {
1953 /* input code configuration */
1954 input_code(display, &buf[10]);
1956 else if (strncasecmp(buf, "input_sw", 8) == 0) {
1957 /* input switch event */
1958 input_sw(display, &buf[8]);
1960 else if (strncasecmp(buf, "set_region", 10) == 0) {
1961 /* set input region */
1962 set_region(display, &buf[10]);
1964 else if (strncasecmp(buf, "unset_region", 12) == 0) {
1965 /* unset input region */
1966 unset_region(display, &buf[12]);
1968 else if (strncasecmp(buf, "input_sw", 8) == 0) {
1969 /* input switch event */
1970 input_sw(display, &buf[8]);
1972 else if (strncasecmp(buf, "sleep", 5) == 0) {
1974 msec = sec_str_2_value(&buf[6]);
1975 sleep_with_wayland(display->display, msec);
1977 else if (strncasecmp(buf, "waitcreate", 10) == 0) {
1978 /* Wait surface create */
1979 msec = sec_str_2_value(&buf[11]);
1980 wait_with_wayland(display->display, msec, &display->surface_created);
1982 else if (strncasecmp(buf, "waitdestroy", 11) == 0) {
1983 /* Wait surface destrpy */
1984 msec = sec_str_2_value(&buf[12]);
1985 wait_with_wayland(display->display, msec, &display->surface_destroyed);
1987 else if (strncasecmp(buf, "event", 5) == 0) {
1988 /* Send touch panel event to Weston */
1989 send_event(&buf[6]);
1992 print_log("HOMESCREEN: unknown command[%s]", buf);
1997 print_log("HOMESCREEN: end");