2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Multi Window Manager (Weston(Wayland) PlugIn)
37 #include <linux/input.h>
43 #include <sys/types.h>
49 #include <wayland-server.h>
50 #include <wayland-server.h>
56 #include <GLES2/gl2.h>
58 #include <weston/compositor.h>
59 #include <weston/ivi-layout.h>
60 #include <weston/ivi-layout-export.h>
62 /* detail debug log */
63 #define UIFW_DETAIL_OUT 1 /* 1=detail debug log/0=no detail log */
66 #include "ico_ivi_common_private.h"
67 #include "ico_window_mgr_private.h"
68 #include "ico_window_mgr-server-protocol.h"
70 /* gl_surface_state (inport from weston-1.4.0/src/gl-renderer.c */
76 struct uifw_gl_surface_state { /* struct gl_surface_state */
78 struct gl_shader *shader;
82 int needs_full_upload;
83 pixman_region32_t texture_damage;
85 void *images[3]; /* EGLImageKHR */
89 struct weston_buffer_reference buffer_ref;
90 enum buffer_type buffer_type;
91 int pitch; /* in pixels */
92 int height; /* in pixels */
93 int y_inverted; /* add weston 1.3.x */
97 #define UIFW_HASH 64 /* Hash value (2's compliment) */
98 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId hash mask pattern */
100 /* Internal fixed value */
101 #define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */
102 /* show/hide animation with position */
103 #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000
105 /* Multi Windiw Manager */
107 struct weston_compositor *compositor; /* Weston compositor */
108 void *shell; /* shell table address */
109 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
111 struct wl_list client_list; /* Clients */
112 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
114 struct wl_list map_list; /* surface map list */
115 struct uifw_surface_map *free_maptable; /* free maped surface table list */
116 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
117 /* animation for map check */
118 struct wl_event_source *wait_mapevent; /* map event send wait timer */
120 char *pixel_readbuf; /* surface pixel image read buffer */
121 int pixel_readsize; /* surface pixel image read buffer size */
122 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
123 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
125 char shell_init; /* shell initialize flag */
126 char res[3]; /* (unused) */
129 /* Internal macros */
131 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
133 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
135 /* function prototype */
136 /* get surface table from weston surface*/
137 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
138 struct weston_surface *wsurf);
139 /* bind shell client */
140 static void win_mgr_bind_client(struct wl_client *client, void *shell);
142 static void win_mgr_destroy_client(struct wl_listener *listener, void *data);
143 #if 0 /* work around: Walk through child processes until app ID is found */
145 static pid_t win_mgr_get_ppid(pid_t pid);
146 #endif /* work around: Walk through child processes until app ID is found */
147 /* get appid from pid */
148 static void win_mgr_get_client_appid(struct uifw_client *uclient);
149 /* create new surface */
150 static void win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
151 struct wl_client *client,
152 struct ivi_layout_surface *ivisurf);
153 /* surface destroy */
154 static void win_mgr_destroy_surface(struct weston_surface *surface);
155 /* weston_surface destroy listener */
156 static void win_mgr_surf_destroylistener(struct wl_listener *listener, void *data);
157 /* read surface pixel */
158 static int win_mgr_takeSurfaceScreenshot(const char *filename,
159 struct uifw_win_surface *usurf,
160 int width, int height);
161 /* set surface animation */
162 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
163 uint32_t surfaceid, int32_t type,
164 const char *animation, int32_t time);
165 /* check and change all mapped surface */
166 static void win_mgr_check_mapsurface(struct weston_animation *animation,
167 struct weston_output *output, uint32_t msecs);
168 /* check timer of mapped surface */
169 static int win_mgr_timer_mapsurface(void *data);
170 /* check and change mapped surface */
171 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event,
173 /* map surface to system application */
174 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
175 uint32_t surfaceid, int32_t framerate, const char *filepath);
177 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
179 /* direct layout surface */
180 static void uifw_layout_surface(struct wl_client *client, struct wl_resource *resource,
181 uint32_t surfaceid, uint32_t layerid, int x, int y,
182 int width, int height, int visible);
184 static void bind_ico_win_mgr(struct wl_client *client,
185 void *data, uint32_t version, uint32_t id);
187 static void unbind_ico_win_mgr(struct wl_resource *resource);
188 /* convert animation name to Id value */
189 static int ico_get_animation_name(const char *animation);
190 /* send event to controller */
191 static void win_mgr_send_event(int event, uint32_t surfaceid, uint32_t arg1);
192 /* touch/click select surface */
193 static void win_mgr_select_surface(struct weston_seat *seat,
194 struct weston_surface *focus, int target);
195 static void win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
196 uint32_t button, void *data);
197 static void win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time,
199 /* hook for create surface of ivi-shell */
200 static void ico_ivi_surfaceCreateNotification(struct ivi_layout_surface *ivisurf,
202 /* hook for remove surface of ivi-shell */
203 static void ico_ivi_surfaceRemoveNotification(struct ivi_layout_surface *ivisurf,
205 /* hook for property change of ivi-shell*/
206 static void ico_ivi_surfacePropertyNotification(struct ivi_layout_surface *ivisurf,
207 struct ivi_layout_SurfaceProperties *prop,
208 enum ivi_layout_notification_mask mask,
210 /* hook for animation */
211 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
212 /* hook for input region */
213 static void (*win_mgr_hook_change)(struct uifw_win_surface *usurf) = NULL;
214 static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL;
215 static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf,
216 int32_t x, int32_t y, int32_t width,
217 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
218 int32_t cursor_x, int32_t cursor_y,
219 int32_t cursor_width, int32_t cursor_height,
220 uint32_t attr) = NULL;
223 /* Multi Window Manager interface */
224 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
232 /* plugin common value(without ico_plugin_loader) */
233 static int _ico_ivi_option_flag = 0; /* option flags */
234 static int _ico_ivi_debug_level = 3; /* debug Level */
235 static char *_ico_ivi_animation_name = NULL; /* default animation name */
236 static int _ico_ivi_animation_time = 500; /* default animation time */
237 static int _ico_ivi_animation_fps = 30; /* animation frame rate */
239 /* static management table */
240 static struct ico_win_mgr *_ico_win_mgr = NULL;
241 static int _ico_num_nodes = 0;
242 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
243 static struct weston_seat *touch_check_seat = NULL;
246 /*--------------------------------------------------------------------------*/
248 * @brief ico_ivi_optionflag: get option flags
251 * @return option flags
253 /*--------------------------------------------------------------------------*/
255 ico_ivi_optionflag(void)
257 return _ico_ivi_option_flag;
260 /*--------------------------------------------------------------------------*/
262 * @brief ico_ivi_debuglevel: answer debug output level.
265 * @return debug output level
266 * @retval 0 No debug output
267 * @retval 1 Only error output
268 * @retval 2 Error and Warning output
269 * @retval 3 Error, Warning and information output
270 * @retval 4 Error, Warning, information and Debug Trace output
271 * @retval 5 All output with debug write
273 /*--------------------------------------------------------------------------*/
275 ico_ivi_debuglevel(void)
277 return (_ico_ivi_debug_level & 0x0ffff);
280 /*--------------------------------------------------------------------------*/
282 * @brief ico_ivi_debugflag: get debug flags
285 * @return debug flags
287 /*--------------------------------------------------------------------------*/
289 ico_ivi_debugflag(void)
291 return ((_ico_ivi_debug_level >> 16) & 0x0ffff);
294 /*--------------------------------------------------------------------------*/
296 * @brief ico_ivi_default_animation_name: get default animation name
299 * @return Default animation name
301 /*--------------------------------------------------------------------------*/
302 WL_EXPORT const char *
303 ico_ivi_default_animation_name(void)
305 return _ico_ivi_animation_name;
308 /*--------------------------------------------------------------------------*/
310 * @brief ico_ivi_default_animation_time: get default animation time
313 * @return Default animation time(miri sec)
315 /*--------------------------------------------------------------------------*/
317 ico_ivi_default_animation_time(void)
319 return _ico_ivi_animation_time;
322 /*--------------------------------------------------------------------------*/
324 * @brief ico_ivi_default_animation_fps: get default animation frame rate
327 * @return Default animation frame rate(frames/sec)
329 /*--------------------------------------------------------------------------*/
331 ico_ivi_default_animation_fps(void)
333 return _ico_ivi_animation_fps;
336 /*--------------------------------------------------------------------------*/
338 * @brief ico_ivi_get_mynode: Get my NodeId
341 * @return NodeId of my node
343 /*--------------------------------------------------------------------------*/
345 ico_ivi_get_mynode(void)
347 /* Reference Platform 0.90 only support 1 ECU */
351 /*--------------------------------------------------------------------------*/
353 * @brief ico_ivi_surface_buffer_width: get surface buffer width
355 * @param[in] es weston surface
356 * @return buffer width(if surface has no buffer, return 0)
358 /*--------------------------------------------------------------------------*/
360 ico_ivi_surface_buffer_width(struct weston_surface *es)
364 if (! es->buffer_ref.buffer) {
367 if (es->buffer_viewport.surface.width >= 0 ) {
368 return es->buffer_viewport.surface.width;
370 switch (es->buffer_viewport.buffer.transform) {
371 case WL_OUTPUT_TRANSFORM_90:
372 case WL_OUTPUT_TRANSFORM_270:
373 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
374 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
375 v = es->buffer_ref.buffer->height;
378 v = es->buffer_ref.buffer->width;
381 return (v / es->buffer_viewport.buffer.scale);
384 /*--------------------------------------------------------------------------*/
386 * @brief ico_ivi_surface_buffer_height: get surface buffer height
388 * @param[in] es weston surface
389 * @return buffer height(if surface has no buffer, return 0)
391 /*--------------------------------------------------------------------------*/
393 ico_ivi_surface_buffer_height(struct weston_surface *es)
397 if (! es->buffer_ref.buffer) {
400 if (es->buffer_viewport.surface.width >= 0) {
401 return es->buffer_viewport.surface.height;
403 switch (es->buffer_viewport.buffer.transform) {
404 case WL_OUTPUT_TRANSFORM_90:
405 case WL_OUTPUT_TRANSFORM_270:
406 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
407 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
408 v = es->buffer_ref.buffer->width;
411 v = es->buffer_ref.buffer->height;
414 return (v / es->buffer_viewport.buffer.scale);
417 /*--------------------------------------------------------------------------*/
419 * @brief ico_ivi_surface_buffer_size: get surface buffer size
421 * @param[in] es weston surface
422 * @param[out] width buffer width
423 * @param[out] height buffer height
426 /*--------------------------------------------------------------------------*/
428 ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height)
430 if (! es->buffer_ref.buffer) {
434 else if (es->buffer_viewport.surface.width >=0 ) {
435 *width = es->buffer_viewport.surface.width;
436 *height = es->buffer_viewport.surface.height;
439 switch (es->buffer_viewport.buffer.transform) {
440 case WL_OUTPUT_TRANSFORM_90:
441 case WL_OUTPUT_TRANSFORM_270:
442 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
443 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
444 *width = es->buffer_ref.buffer->height;
445 *height = es->buffer_ref.buffer->width;
448 *width = es->buffer_ref.buffer->width;
449 *height = es->buffer_ref.buffer->height;
452 *width = *width / es->buffer_viewport.buffer.scale;
453 *height = *height / es->buffer_viewport.buffer.scale;
457 /*--------------------------------------------------------------------------*/
459 * @brief ico_ivi_surface_buffer_size: get surface buffer size
461 * @param[in] es weston surface
462 * @param[out] width buffer width
463 * @param[out] height buffer height
466 /*--------------------------------------------------------------------------*/
467 WL_EXPORT struct weston_view *
468 ico_ivi_get_primary_view(struct uifw_win_surface *usurf)
470 struct weston_view *ev = NULL;
471 struct shell_surface *shsurf;
473 if (_ico_win_mgr->compositor->shell_interface.get_primary_view) {
474 shsurf = usurf->surface->configure_private;
476 ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view)(NULL, shsurf);
480 ev = ivi_layout_interface.get_weston_view(usurf->ivisurf);
483 uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view",
484 (int)usurf, usurf->surfaceid, (int)usurf->surface);
489 /*--------------------------------------------------------------------------*/
491 * @brief ico_window_mgr_set_weston_surface: set weston surface
493 * @param[in] usurf UIFW surface
494 * @param[in] x X coordinate on screen
495 * @param[in] y Y coordinate on screen
496 * @param[in] width width
497 * @param[in] height height
500 /*--------------------------------------------------------------------------*/
502 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
503 int x, int y, int width, int height)
505 struct weston_surface *es = usurf->surface;
506 struct ivi_layout_SurfaceProperties prop;
507 int buf_width, buf_height;
509 if ((es == NULL) || (usurf->ivisurf == NULL)) {
510 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
515 if (es->buffer_ref.buffer != NULL) {
516 ico_ivi_surface_buffer_size(es, &buf_width, &buf_height);
517 if ((width <= 0) || (height <= 0)) {
519 usurf->width = buf_width;
521 usurf->height = buf_height;
523 if (usurf->width > buf_width) {
525 x += (usurf->width - buf_width)/2;
527 if (usurf->height > buf_height) {
529 y += (usurf->height - buf_height)/2;
531 if (usurf->visible) {
532 x += usurf->node_tbl->disp_x;
533 y += usurf->node_tbl->disp_y;
536 x = ICO_IVI_MAX_COORDINATE+1;
537 y = ICO_IVI_MAX_COORDINATE+1;
539 if (ivi_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) {
540 if ((prop.destX != x) || (prop.destY != y) ||
541 (prop.destWidth != (uint32_t)width) ||
542 (prop.destHeight != (uint32_t)height)) {
543 if (ivi_layout_surfaceSetDestinationRectangle(
544 usurf->ivisurf, x, y, width, height) == 0) {
545 ivi_layout_commitChanges();
549 weston_surface_damage(es);
553 /*--------------------------------------------------------------------------*/
555 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
557 * @param[in] surfaceid UIFW surface id
558 * @return UIFW surface table address
559 * @retval !=NULL success(surface table address)
560 * @retval NULL error(surface id dose not exist)
562 /*--------------------------------------------------------------------------*/
563 WL_EXPORT struct uifw_win_surface *
564 ico_window_mgr_get_usurf(const uint32_t surfaceid)
566 struct uifw_win_surface *usurf;
568 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
571 if (usurf->surfaceid == surfaceid) {
574 usurf = usurf->next_idhash;
579 /*--------------------------------------------------------------------------*/
581 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
583 * @param[in] surfaceid UIFW surface id
584 * @param[in] client Wayland client
585 * @return UIFW surface table address
586 * @retval !=NULL success(surface table address)
587 * @retval NULL error(surface id or client dose not exist)
589 /*--------------------------------------------------------------------------*/
590 WL_EXPORT struct uifw_win_surface *
591 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
593 struct uifw_win_surface *usurf;
594 struct uifw_client *uclient;
596 usurf = ico_window_mgr_get_usurf(surfaceid);
599 uclient = ico_window_mgr_find_uclient(client);
601 /* client dose not exist, error */
602 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x dose not exist",
606 if (&uclient->surface_link == uclient->surface_link.next) {
607 /* client has no surface */
608 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x has no surface",
612 usurf = (struct uifw_win_surface *)uclient->surface_link.next;
613 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x 1st surface=%08x",
614 (int)client, usurf->surfaceid);
619 /*--------------------------------------------------------------------------*/
621 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
623 * @param[in] wsurf Weston surface
624 * @return UIFW surface table address
625 * @retval !=NULL success(surface table address)
626 * @retval NULL error(surface dose not exist)
628 /*--------------------------------------------------------------------------*/
629 static struct uifw_win_surface *
630 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
632 struct uifw_win_surface *usurf;
634 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
637 if (usurf->surface == wsurf) {
640 usurf = usurf->next_wshash;
642 uifw_trace("find_uifw_win_surface_by_ws: NULL");
646 /*--------------------------------------------------------------------------*/
648 * @brief ico_window_mgr_find_uclient: find UIFW client by wayland client
650 * @param[in] client Wayland client
651 * @return UIFW client table address
652 * @retval !=NULL success(client table address)
653 * @retval NULL error(client dose not exist)
655 /*--------------------------------------------------------------------------*/
656 WL_EXPORT struct uifw_client*
657 ico_window_mgr_find_uclient(struct wl_client *client)
659 struct uifw_client *uclient;
661 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
662 if (uclient->client == client) {
666 uifw_trace("ico_window_mgr_find_uclient: client.%08x is NULL", (int)client);
670 /*--------------------------------------------------------------------------*/
672 * @brief ico_window_mgr_get_appid: find application id by wayland client
674 * @param[in] client Wayland client
675 * @return application id
676 * @retval !=NULL success(application id)
677 * @retval NULL error(client dose not exist)
679 /*--------------------------------------------------------------------------*/
681 ico_window_mgr_get_appid(struct wl_client* client)
683 struct uifw_client *uclient;
685 uclient = ico_window_mgr_find_uclient(client);
690 return uclient->appid;
693 /*--------------------------------------------------------------------------*/
695 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
697 * @param[in] displayno display number
698 * @param[out] x relative X coordinate
699 * @param[out] y relative Y coordinate
702 /*--------------------------------------------------------------------------*/
704 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
706 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
709 *x = _ico_node_table[displayno].disp_x;
710 *y = _ico_node_table[displayno].disp_y;
713 /*--------------------------------------------------------------------------*/
715 * @brief win_mgr_bind_client: desktop_shell from client
717 * @param[in] client Wayland client
718 * @param[in] shell shell table address
721 /*--------------------------------------------------------------------------*/
723 win_mgr_bind_client(struct wl_client *client, void *shell)
725 struct uifw_client *uclient;
731 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
732 (int)client, (int)shell);
734 /* save shell table address */
736 _ico_win_mgr->shell = shell;
740 uclient = ico_window_mgr_find_uclient(client);
742 /* client not exist, create client management table */
743 uifw_trace("win_mgr_bind_client: Create Client");
744 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
746 uifw_error("win_mgr_bind_client: Error, No Memory");
749 memset(uclient, 0, sizeof(struct uifw_client));
750 uclient->client = client;
751 wl_list_init(&uclient->surface_link);
753 uclient->destroy_listener.notify = win_mgr_destroy_client;
754 wl_client_add_destroy_listener(client, &uclient->destroy_listener);
759 wl_client_get_credentials(client, &pid, &uid, &gid);
760 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
761 (int)client, (int)pid, (int)uid, (int)gid);
763 uclient->pid = (int)pid;
764 /* get applicationId from AppCore(AUL) */
765 win_mgr_get_client_appid(uclient);
768 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
772 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
774 uifw_trace("win_mgr_bind_client: Leave");
777 /*--------------------------------------------------------------------------*/
779 * @brief win_mgr_destroy_client: destroy client
781 * @param[in] listener listener
782 * @param[in] data listener
785 /*--------------------------------------------------------------------------*/
787 win_mgr_destroy_client(struct wl_listener *listener, void *data)
789 struct uifw_client *uclient;
790 struct uifw_win_surface *usurf;
791 struct uifw_win_surface *usurf_tmp;
793 uclient = container_of(listener, struct uifw_client, destroy_listener);
795 uifw_trace("win_mgr_destroy_client: Enter(uclient=%08x)", (int)uclient);
798 /* Client exist, Destory client surfaces */
799 wl_list_for_each_safe (usurf, usurf_tmp, &uclient->surface_link, client_link) {
800 win_mgr_destroy_surface(usurf->surface);
802 /* Destory client management table */
803 wl_list_remove(&uclient->link);
806 uifw_trace("win_mgr_destroy_client: Leave");
809 #if 0 /* work around: Walk through child processes until app ID is found */
810 /*--------------------------------------------------------------------------*/
812 * @brief win_mgr_get_ppid: Get parent process ID.
814 * Similar to getppid(), except that this implementation accepts an
815 * arbitrary process ID.
817 * @param[in] pid Process ID of child process
818 * @return parent process ID on success, -1 on failure
820 /*--------------------------------------------------------------------------*/
822 win_mgr_get_ppid(pid_t pid)
825 char procpath[PATH_MAX] = { 0 };
827 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid);
829 /* We better have read permissions! */
830 int const fd = open(procpath, O_RDONLY);
835 char buffer[1024] = { 0 };
837 ssize_t const size = read(fd, buffer, sizeof(buffer));
843 /* Find line containing the parent process ID. */
844 char const * const ppid_line = strstr(buffer, "PPid");
846 if (ppid_line != NULL)
847 sscanf(ppid_line, "PPid: %d", &ppid);
851 #endif /* work around: Walk through child processes until app ID is found */
853 /*--------------------------------------------------------------------------*/
855 * @brief win_mgr_get_client_appid: get applicationId from pid
857 * @param[in] uclient UIFW client management table
860 /*--------------------------------------------------------------------------*/
862 win_mgr_get_client_appid(struct uifw_client *uclient)
864 int status = AUL_R_ERROR;
866 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
868 #if 0 /* work around: Walk through child processes until app ID is found */
870 * Walk the parent process chain until we find a parent process
875 for (pid = uclient->pid;
876 pid > 1 && status != AUL_R_OK;
877 pid = win_mgr_get_ppid(pid)) {
879 status = aul_app_get_appid_bypid(pid,
881 ICO_IVI_APPID_LENGTH);
883 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
884 "pid=%d appid=<%s>", status, pid, uclient->appid);
887 * Walk the child process chain as well since app ID was not yet found
889 if (status != AUL_R_OK) {
898 dr = opendir("/proc/");
901 wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
903 while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
905 char fullpath[PATH_MAX] = { 0 };
909 snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
911 if (stat(fullpath, &ps) == -1) {
915 /* find pid dirs for this user (uid) only */
916 if (ps.st_uid != uid)
919 pid = atoi(de->d_name);
921 /* check if it's a valid child */
922 if (pid < uclient->pid)
925 /* scan up to pid to find if a chain exists */
926 for (tmppid = pid; tmppid > uclient->pid;) {
927 tmppid = win_mgr_get_ppid(tmppid);
928 if (tmppid == uclient->pid)
933 status = aul_app_get_appid_bypid(pid, uclient->appid,
934 ICO_IVI_APPID_LENGTH);
936 uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid "
937 "ret=%d pid=%d appid=<%s>", status, pid,
942 #else /* work around: Walk through child processes until app ID is found */
943 status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
944 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
945 "pid=%d appid=<%s>", status, uclient->pid, uclient->appid);
946 #endif /* work around: Walk through child processes until app ID is found */
948 if (uclient->appid[0] != 0) {
949 /* OK, end of get appid */
950 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
953 /* client does not exist in AppCore, search Linux process table */
961 uclient->fixed_appid ++;
962 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
963 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
964 fd = open(procpath, O_RDONLY);
966 size = read(fd, procpath, sizeof(procpath));
967 for (; size > 0; size--) {
968 if (procpath[size-1]) break;
971 /* get program base name */
973 for (j = 0; j < size; j++) {
974 if (procpath[j] == 0) break;
975 if (procpath[j] == '/') i = j + 1;
978 for (; i < size; i++) {
979 uclient->appid[j] = procpath[i];
980 if ((uclient->appid[j] == 0) ||
981 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
984 /* search application number in apprication start option */
985 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
986 for (; i < size; i++) {
987 if ((procpath[i] == 0) &&
988 (procpath[i+1] == '@')) {
989 strncpy(&uclient->appid[j], &procpath[i+1],
990 ICO_IVI_APPID_LENGTH - j - 2);
997 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
998 if (uclient->appid[i] != ' ') break;
1000 uclient->appid[i+1] = 0;
1001 if (uclient->appid[0]) {
1002 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
1003 "Process table(%d)",
1004 uclient->pid, uclient->appid, uclient->fixed_appid );
1007 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
1009 sprintf(uclient->appid, "?%d?", uclient->pid);
1014 /*--------------------------------------------------------------------------*/
1016 * @brief ico_get_animation_name: convert animation name to Id value
1018 * @param[in] animation animation name
1019 * @return animation Id value
1021 /*--------------------------------------------------------------------------*/
1023 ico_get_animation_name(const char *animation)
1025 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1027 if (strcasecmp(animation, "none") == 0) {
1028 return ICO_WINDOW_MGR_ANIMATION_NONE;
1031 if (win_mgr_hook_animation) {
1032 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
1035 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1040 /*--------------------------------------------------------------------------*/
1042 * @brief win_mgr_send_event: send event to controller
1044 * @param[in] event event code
1045 * @param[in] surfaceid surface id
1046 * @param[in] arg1 argument 1
1049 /*--------------------------------------------------------------------------*/
1051 win_mgr_send_event(int event, uint32_t surfaceid, uint32_t arg1)
1053 struct uifw_manager *mgr;
1055 /* send event to manager */
1056 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1058 case ICO_WINDOW_MGR_WINDOW_ACTIVE: /* active event */
1059 uifw_trace("win_mgr_send_event: Send ACTIVE(surf=%08x, select=%x)",
1061 ico_window_mgr_send_window_active(mgr->resource, surfaceid, arg1);
1063 case ICO_WINDOW_MGR_DESTROY_SURFACE: /* surface destroy event */
1064 uifw_trace("win_mgr_send_event: Send DESTROY_SURFACE(surf=%08x) mgr=%08x",
1065 surfaceid, (int)mgr);
1066 ico_window_mgr_send_destroy_surface(mgr->resource, surfaceid);
1069 uifw_error("win_mgr_send_event: Unknown event(%d)", event);
1075 /*--------------------------------------------------------------------------*/
1077 * @brief win_mgr_select_surface: select surface by mouse click
1079 * @param[in] seat weston seat
1080 * @param[in] focus selected surface
1081 * @param[in] select selected device
1084 /*--------------------------------------------------------------------------*/
1086 win_mgr_select_surface(struct weston_seat *seat, struct weston_surface *focus, int select)
1088 struct weston_surface *surface;
1089 struct uifw_win_surface *usurf;
1090 struct uifw_manager *mgr;
1092 surface = weston_surface_get_main_surface(focus);
1094 uifw_trace("win_mgr_select_surface: Enter(%08x,%d)", (int)surface, select);
1097 uifw_trace("win_mgr_select_surface: Leave(no surface)");
1101 usurf = find_uifw_win_surface_by_ws(surface);
1103 uifw_trace("win_mgr_select_surface: Leave(usurf not exist)");
1106 /* surface active */
1107 weston_surface_activate(surface, seat);
1109 /* send active event to manager */
1110 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1111 uifw_trace("win_mgr_select_surface: Send Manager ACTIVE(surf=%08x)",
1113 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
1116 uifw_trace("win_mgr_select_surface: Leave");
1119 /*--------------------------------------------------------------------------*/
1121 * @brief win_mgr_click_to_activate: select surface by mouse click
1123 * @param[in] seat weston seat
1124 * @param[in] time click time(current time)
1125 * @param[in] button click button
1126 * @param[in] data user data(unused)
1129 /*--------------------------------------------------------------------------*/
1131 win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
1132 uint32_t button, void *data)
1134 if (seat->pointer->grab != &seat->pointer->default_grab)
1136 if (seat->pointer->focus == NULL)
1139 win_mgr_select_surface(seat, seat->pointer->focus->surface,
1140 ICO_WINDOW_MGR_SELECT_POINTER);
1143 /*--------------------------------------------------------------------------*/
1145 * @brief win_mgr_touch_to_activate: select surface by touch touch-panel
1147 * @param[in] seat weston seat
1148 * @param[in] time click time(current time)
1149 * @param[in] data user data(unused)
1152 /*--------------------------------------------------------------------------*/
1154 win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time, void *data)
1156 if (seat->touch->grab != &seat->touch->default_grab)
1158 if (seat->touch->focus == NULL)
1161 win_mgr_select_surface(seat, seat->touch->focus->surface, ICO_WINDOW_MGR_SELECT_TOUCH);
1164 /*--------------------------------------------------------------------------*/
1166 * @brief ico_ivi_surfaceCreateNotification: create ivi-surface
1168 * @param[in] ivisurf ivi surface
1169 * @param[in] userdata User Data(Unused)
1172 /*--------------------------------------------------------------------------*/
1174 ico_ivi_surfaceCreateNotification(struct ivi_layout_surface *ivisurf, void *userdata)
1176 uint32_t id_surface;
1177 struct weston_view *ev;
1178 struct weston_surface *es;
1179 struct wl_client *client;
1181 id_surface = ivi_layout_getIdOfSurface(ivisurf);
1182 uifw_trace("ico_ivi_surfaceCreateNotification: Create %x", id_surface);
1184 /* set property notification */
1185 if (ivi_layout_surfaceAddNotification(ivisurf, ico_ivi_surfacePropertyNotification, NULL) != 0) {
1186 uifw_error("ico_ivi_surfaceCreateNotification: ivi_layout_surfaceAddNotification Error");
1188 ev = ivi_layout_interface.get_weston_view(ivisurf);
1190 uifw_error("ico_ivi_surfaceCreateNotification: ivi_layout_interface.get_weston_view Error");
1195 uifw_error("ico_ivi_surfaceCreateNotification: no weston_surface");
1198 client = wl_resource_get_client(es->resource);
1200 uifw_error("ico_ivi_surfaceCreateNotification: no wl_client");
1203 win_mgr_register_surface(id_surface, es, client, ivisurf);
1209 /*--------------------------------------------------------------------------*/
1211 * @brief ico_ivi_surfaceRemoveNotification: remove ivi-surface
1213 * @param[in] ivisurf ivi surface
1214 * @param[in] userdata User Data(Unused)
1217 /*--------------------------------------------------------------------------*/
1219 ico_ivi_surfaceRemoveNotification(struct ivi_layout_surface *ivisurf, void *userdata)
1221 uint32_t id_surface;
1222 struct weston_surface *es;
1223 struct uifw_win_surface *usurf;
1225 id_surface = ivi_layout_getIdOfSurface(ivisurf);
1226 uifw_trace("ico_ivi_surfaceRemoveNotification: Remove %x", id_surface);
1228 usurf = ico_window_mgr_get_usurf(id_surface);
1230 uifw_trace("ico_ivi_surfaceRemoveNotification: surface %08x dose not exist", id_surface);
1233 es = usurf->surface;
1235 uifw_trace("ico_ivi_surfaceRemoveNotification: no weston_surface");
1238 win_mgr_destroy_surface(es);
1243 /*--------------------------------------------------------------------------*/
1245 * @brief ico_ivi_surfacePropertyNotification: property change ivi-surface
1247 * @param[in] ivisurf ivi surface
1248 * @param[in] userdata User Data(Unused)
1251 /*--------------------------------------------------------------------------*/
1253 ico_ivi_surfacePropertyNotification(struct ivi_layout_surface *ivisurf,
1254 struct ivi_layout_SurfaceProperties *prop,
1255 enum ivi_layout_notification_mask mask,
1258 struct uifw_manager *mgr;
1259 uint32_t id_surface;
1262 struct uifw_win_surface *usurf;
1263 struct weston_view *ev;
1265 newmask = ((uint32_t)mask) & (~(IVI_NOTIFICATION_OPACITY|IVI_NOTIFICATION_ORIENTATION|
1266 IVI_NOTIFICATION_PIXELFORMAT));
1267 id_surface = ivi_layout_getIdOfSurface(ivisurf);
1268 usurf = ico_window_mgr_get_usurf(id_surface);
1270 if ((newmask != 0) && (usurf != NULL)) {
1271 uifw_trace("ico_ivi_surfacePropertyNotification: Property %x(%08x) usurf=%08x",
1272 id_surface, newmask, (int)usurf);
1273 if (newmask & (IVI_NOTIFICATION_SOURCE_RECT|IVI_NOTIFICATION_DEST_RECT|
1274 IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION)) {
1275 /* change position or size */
1276 uifw_trace("ico_ivi_surfacePropertyNotification: %08x x/y=%d/%d->%d/%d "
1277 "w/h=%d/%d->%d/%d(%d/%d)", id_surface, usurf->x, usurf->y,
1278 prop->destX, prop->destY, usurf->width, usurf->height,
1279 prop->destWidth, prop->destHeight,
1280 prop->sourceWidth, prop->sourceHeight);
1281 if ((usurf->client_width == prop->sourceWidth) &&
1282 (usurf->client_height == prop->sourceHeight)) {
1283 newmask &= (~IVI_NOTIFICATION_SOURCE_RECT);
1286 usurf->client_width = prop->sourceWidth;
1287 usurf->client_height = prop->sourceHeight;
1289 if ((usurf->x == prop->destX) && (usurf->y == prop->destY) &&
1290 (usurf->width == prop->destWidth) && (usurf->height == prop->destHeight)) {
1291 newmask &= (~(IVI_NOTIFICATION_DEST_RECT|
1292 IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION));
1295 usurf->x = prop->destX;
1296 usurf->y = prop->destY;
1297 usurf->width = prop->destWidth;
1298 usurf->height = prop->destHeight;
1299 if ((usurf->width != usurf->configure_width) ||
1300 (usurf->height != usurf->configure_height)) {
1301 /* send configure to client(App) */
1302 uifw_trace("ico_ivi_surfacePropertyNotification: send configure "
1303 "%08x(%d,%d->%d,%d)", usurf->surfaceid,
1304 usurf->configure_width, usurf->configure_height,
1305 usurf->width, usurf->height);
1306 usurf->configure_width = usurf->width;
1307 usurf->configure_height = usurf->height;
1309 struct wl_array surfaces;
1310 struct shell_surface;
1312 if (! usurf->shsurf_resource) {
1313 /* get shell surface if not get */
1314 ivi_shell_get_shell_surfaces(&surfaces);
1315 wl_array_for_each(shsurf, &surfaces) {
1316 if (shell_surface_get_surface(*shsurf) == usurf->surface) {
1317 usurf->shsurf_resource = *((struct wl_resource **)*shsurf);
1321 wl_array_release(&surfaces);
1324 if (usurf->shsurf_resource) {
1325 uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
1327 usurf->surfaceid, (int)usurf->shsurf_resource);
1328 wl_shell_surface_send_configure(usurf->shsurf_resource,
1329 WL_SHELL_SURFACE_RESIZE_RIGHT|
1330 WL_SHELL_SURFACE_RESIZE_BOTTOM,
1331 usurf->configure_width, usurf->configure_height);
1334 uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
1335 "shell_surface resource not found", usurf->surfaceid);
1340 if (newmask & IVI_NOTIFICATION_VISIBILITY) {
1341 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1342 (win_mgr_hook_animation != NULL)) {
1343 /* start animation, save original position of surface */
1344 usurf->animation.pos_x = usurf->x;
1345 usurf->animation.pos_y = usurf->y;
1346 usurf->animation.pos_width = usurf->width;
1347 usurf->animation.pos_height = usurf->height;
1348 ev = ivi_layout_interface.get_weston_view(ivisurf);
1350 usurf->animation.alpha = ev->alpha;
1353 usurf->animation.alpha = 1.0;
1356 if ((usurf->visible == 0) && (prop->visibility)) {
1357 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1",
1360 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1361 (win_mgr_hook_animation != NULL)) {
1362 /* show with animation */
1364 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1366 uifw_trace("ico_ivi_surfacePropertyNotification: ret call anima = %d",
1370 else if ((usurf->visible != 0) && (! prop->visibility)) {
1371 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0",
1374 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1375 (win_mgr_hook_animation != NULL)) {
1376 /* hide with animation */
1378 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1382 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1384 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1386 uifw_trace("ico_ivi_surfacePropertyNotification: Change to UnVisible");
1390 uifw_trace("ico_ivi_surfacePropertyNotification: Change to Visible");
1391 ivi_layout_surfaceSetVisibility(ivisurf, 1);
1392 ivi_layout_commitChanges();
1396 uifw_trace("ico_ivi_surfacePropertyNotification: visible no change");
1397 newmask &= (~IVI_NOTIFICATION_VISIBILITY);
1402 /* surface changed, send event to controller */
1403 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1404 uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x) "
1405 "v=%d src=%d/%d dest=%d/%d(%d/%d) mgr=%08x", id_surface,
1406 usurf->visible, usurf->client_width, usurf->client_height,
1407 usurf->x, usurf->y, usurf->width, usurf->height, (int)mgr);
1408 ico_window_mgr_send_update_surface(mgr->resource, id_surface,
1409 usurf->visible, usurf->client_width,
1410 usurf->client_height, usurf->x, usurf->y,
1411 usurf->width, usurf->height);
1417 /*--------------------------------------------------------------------------*/
1419 * @brief win_mgr_register_surface: create UIFW surface
1421 * @param[in] id_surface surface id (by ivi-shell)
1422 * @param[in] surface Weston surface
1423 * @param[in] client Wayland client
1424 * @param[in] ivisurf weston layout surface
1427 /*--------------------------------------------------------------------------*/
1429 win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
1430 struct wl_client *client, struct ivi_layout_surface *ivisurf)
1432 struct ivi_layout_SurfaceProperties prop;
1433 struct uifw_win_surface *usurf;
1434 struct uifw_win_surface *phash;
1435 struct uifw_win_surface *bhash;
1438 uifw_trace("win_mgr_register_surface: Enter(surf=%x[%08x],client=%08x,ivisurf=%08x)",
1439 id_surface, (int)surface, (int)client, (int)ivisurf);
1441 /* check new surface */
1442 if (find_uifw_win_surface_by_ws(surface)) {
1443 /* surface exist, NOP */
1444 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
1448 /* create UIFW surface management table */
1449 usurf = malloc(sizeof(struct uifw_win_surface));
1451 uifw_error("win_mgr_register_surface: No Memory");
1455 memset(usurf, 0, sizeof(struct uifw_win_surface));
1457 usurf->surfaceid = id_surface;
1458 usurf->surface = surface;
1459 usurf->ivisurf = ivisurf;
1460 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
1462 if (ivi_layout_getPropertiesOfSurface(ivisurf, &prop) == 0) {
1463 usurf->x = prop.destX;
1464 usurf->y = prop.destY;
1465 usurf->width = prop.destWidth;
1466 usurf->height = prop.destHeight;
1467 usurf->client_width = prop.sourceWidth;
1468 usurf->client_height = prop.sourceHeight;
1469 usurf->configure_width = usurf->client_width;
1470 usurf->configure_height = usurf->client_height;
1472 wl_list_init(&usurf->surface_destroy_listener.link);
1473 usurf->surface_destroy_listener.notify = win_mgr_surf_destroylistener;
1474 wl_signal_add(&surface->destroy_signal, &usurf->surface_destroy_listener);
1476 wl_list_init(&usurf->client_link);
1477 wl_list_init(&usurf->animation.animation.link);
1478 wl_list_init(&usurf->surf_map);
1479 wl_list_init(&usurf->input_region);
1480 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
1481 usurf->animation.hide_time = ico_ivi_default_animation_time();
1482 usurf->animation.show_anima = usurf->animation.hide_anima;
1483 usurf->animation.show_time = usurf->animation.hide_time;
1484 usurf->animation.move_anima = usurf->animation.hide_anima;
1485 usurf->animation.move_time = usurf->animation.hide_time;
1486 usurf->animation.resize_anima = usurf->animation.hide_anima;
1487 usurf->animation.resize_time = usurf->animation.hide_time;
1491 usurf->uclient = ico_window_mgr_find_uclient(client);
1492 if (! usurf->uclient) {
1493 /* client not exist, create client management table */
1494 uifw_trace("win_mgr_register_surface: Create Client");
1495 win_mgr_bind_client(client, NULL);
1496 usurf->uclient = ico_window_mgr_find_uclient(client);
1497 if (! usurf->uclient) {
1498 uifw_error("win_mgr_register_surface: No Memory");
1502 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1504 /* make surface id hash table */
1505 hash = MAKE_IDHASH(usurf->surfaceid);
1506 phash = _ico_win_mgr->idhash[hash];
1510 phash = phash->next_idhash;
1513 bhash->next_idhash = usurf;
1516 _ico_win_mgr->idhash[hash] = usurf;
1519 /* make weston surface hash table */
1520 hash = MAKE_WSHASH(usurf->surface);
1521 phash = _ico_win_mgr->wshash[hash];
1525 phash = phash->next_wshash;
1528 bhash->next_wshash = usurf;
1531 _ico_win_mgr->wshash[hash] = usurf;
1533 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1536 /*--------------------------------------------------------------------------*/
1538 * @brief uifw_set_animation: set animation of surface visible/unvisible
1540 * @param[in] client Weyland client
1541 * @param[in] resource resource of request
1542 * @param[in] surfaceid UIFW surface id
1543 * @param[in] type how to change surface
1544 * @param[in] anmation animation name
1545 * @param[in] time animation time(ms), if 0, default time
1548 /*--------------------------------------------------------------------------*/
1550 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1551 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1554 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1556 uifw_trace("uifw_set_animation: surf=%08x,type=%x,anim=%s,time=%d",
1557 surfaceid, type, animation, time);
1560 if ((*animation != 0) && (*animation != ' ')) {
1561 animaid = ico_get_animation_name(animation);
1562 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1563 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) {
1564 if (! usurf->org_animation.saved) {
1565 usurf->org_animation.type = usurf->animation.type;
1566 usurf->org_animation.anima = usurf->animation.anima;
1567 usurf->org_animation.next_anima = usurf->animation.next_anima;
1568 usurf->org_animation.hide_anima = usurf->animation.hide_anima;
1569 usurf->org_animation.hide_time = usurf->animation.hide_time;
1570 usurf->org_animation.show_anima = usurf->animation.show_anima;
1571 usurf->org_animation.show_time = usurf->animation.show_time;
1572 usurf->org_animation.move_anima = usurf->animation.move_anima;
1573 usurf->org_animation.move_time = usurf->animation.move_time;
1574 usurf->org_animation.resize_anima = usurf->animation.resize_anima;
1575 usurf->org_animation.resize_time = usurf->animation.resize_time;
1576 usurf->org_animation.saved = 1;
1579 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1580 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1581 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1582 usurf->animation.next_anima = animaid;
1583 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1584 usurf->org_animation.next_anima = animaid;
1587 usurf->animation.hide_anima = animaid;
1588 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1589 usurf->org_animation.hide_anima = animaid;
1592 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1593 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1594 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1595 usurf->animation.next_anima = animaid;
1596 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1597 usurf->org_animation.next_anima = animaid;
1600 usurf->animation.show_anima = animaid;
1601 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1602 usurf->org_animation.show_anima = animaid;
1605 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1606 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
1607 usurf->animation.next_anima = animaid;
1608 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1609 usurf->org_animation.next_anima = animaid;
1612 usurf->animation.move_anima = animaid;
1613 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1614 usurf->org_animation.move_anima = animaid;
1617 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1618 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
1619 usurf->animation.next_anima = animaid;
1620 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1621 usurf->org_animation.next_anima = animaid;
1624 usurf->animation.resize_anima = animaid;
1625 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1626 usurf->org_animation.resize_anima = animaid;
1630 if ((time > 0) && (time < 10000)) {
1631 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1632 usurf->animation.hide_time = time;
1633 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1634 usurf->org_animation.hide_time = time;
1636 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1637 usurf->animation.show_time = time;
1638 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1639 usurf->org_animation.show_time = time;
1641 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1642 usurf->animation.move_time = time;
1643 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1644 usurf->org_animation.move_time = time;
1646 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1647 usurf->animation.resize_time = time;
1648 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1649 usurf->org_animation.resize_time = time;
1654 uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid);
1658 /*--------------------------------------------------------------------------*/
1660 * @brief win_mgr_check_mapsurface: check and change all surface
1662 * @param[in] animation weston animation table(unused)
1663 * @param[in] outout weston output table(unused)
1664 * @param[in] mseces current time(unused)
1667 /*--------------------------------------------------------------------------*/
1669 win_mgr_check_mapsurface(struct weston_animation *animation,
1670 struct weston_output *output, uint32_t msecs)
1672 struct uifw_surface_map *sm, *sm_tmp;
1674 int wait = 99999999;
1676 /* check touch down counter */
1677 if ((touch_check_seat) &&
1678 (touch_check_seat->touch)) {
1679 if (touch_check_seat->touch->num_tp > 10) {
1680 uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset",
1681 (int)touch_check_seat->touch->num_tp);
1682 touch_check_seat->touch->num_tp = 0;
1686 /* check all mapped surfaces */
1687 curtime = weston_compositor_get_time();
1688 wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) {
1689 #if 0 /* too many log */
1690 uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x",
1691 (int)sm, sm->usurf->surfaceid);
1693 if ((sm->interval >= 0) || (sm->eventque == 0)) {
1694 win_mgr_change_mapsurface(sm, 0, curtime);
1696 if ((sm->interval >= 0) && (sm->eventque != 0)) {
1697 if (sm->interval < wait) {
1698 wait = sm->interval;
1703 /* check frame interval */
1710 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait);
1713 /*--------------------------------------------------------------------------*/
1715 * @brief win_mgr_timer_mapsurface: mapped surface check timer
1717 * @param[in] data user data(unused)
1720 /*--------------------------------------------------------------------------*/
1722 win_mgr_timer_mapsurface(void *data)
1724 win_mgr_check_mapsurface(NULL, NULL, 0);
1728 /*--------------------------------------------------------------------------*/
1730 * @brief win_mgr_change_mapsurface: check and change mapped surface
1732 * @param[in] sm map surface table
1733 * @param[in] event send event (if 0, send if changed)
1734 * @param[in] curtime current time(ms)
1737 /*--------------------------------------------------------------------------*/
1739 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime)
1741 struct weston_surface *es;
1742 struct wl_shm_buffer *shm_buffer;
1748 #if 0 /* too many log */
1749 uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event);
1752 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
1755 /* check if buffered */
1756 es = sm->usurf->surface;
1758 ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) &&
1759 ((es->buffer_ref.buffer == NULL) ||
1760 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) {
1761 /* surface has no buffer */
1762 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x",
1763 sm->usurf->surfaceid, (int)es,
1764 es ? (int)es->buffer_ref.buffer : 0);
1766 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1772 else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1773 if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) {
1774 if ((void *)wl_resource_get_user_data(
1775 (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer)
1777 /* surface has no buffer */
1778 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer",
1779 sm->usurf->surfaceid);
1781 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1790 if (es->buffer_ref.buffer != NULL) {
1791 shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource);
1793 format = wl_shm_buffer_get_format(shm_buffer);
1794 if (format != WL_SHM_FORMAT_ARGB8888) {
1795 uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x",
1796 sm->usurf->surfaceid, format);
1797 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1803 if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) {
1805 if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1806 format = EGL_TEXTURE_RGBA; /* currently only support RGBA */
1807 width = es->buffer_ref.buffer->width;
1808 height = es->buffer_ref.buffer->height;
1809 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1811 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1812 #if PERFORMANCE_EVALUATIONS > 0
1813 uifw_perf("SWAP_BUFFER appid=%s surface=%08x MAP",
1814 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1815 #endif /*PERFORMANCE_EVALUATIONS*/
1817 else if ((width <= 0) || (height <= 0)) {
1820 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1821 if ((sm->width != width) || (sm->height != height) ||
1822 (format != sm->format)) {
1823 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1824 #if PERFORMANCE_EVALUATIONS > 0
1825 uifw_perf("SWAP_BUFFER appid=%s surface=%08x RESIZE",
1826 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1827 #endif /*PERFORMANCE_EVALUATIONS*/
1830 if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) {
1831 #if PERFORMANCE_EVALUATIONS > 0
1832 uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
1833 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1834 #endif /*PERFORMANCE_EVALUATIONS*/
1835 if (sm->interval < 0) {
1839 else if (sm->interval > 0) {
1840 dtime = (int)(curtime - sm->lasttime);
1841 if (dtime < sm->interval) {
1847 else if (sm->eventque) {
1848 if (sm->interval < 0) {
1851 else if (sm->interval > 0) {
1852 dtime = (int)(curtime - sm->lasttime);
1853 if (dtime < sm->interval) {
1864 sm->height = height;
1865 sm->stride = width * 4;
1866 sm->format = format;
1867 sm->curbuf = es->buffer_ref.buffer->legacy_buffer;
1870 if ((sm->eventque != 0) ||
1871 (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) {
1872 sm->curbuf = es->buffer_ref.buffer;
1873 if (es->buffer_ref.buffer != NULL) {
1874 width = es->buffer_ref.buffer->width;
1875 height = es->buffer_ref.buffer->height;
1879 height = es->height;
1881 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1883 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1884 uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x",
1885 sm->usurf->surfaceid);
1888 if ((width <= 0) || (height <= 0)) {
1891 uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0",
1892 sm->usurf->surfaceid);
1894 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1895 #if PERFORMANCE_EVALUATIONS > 0
1896 if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) {
1897 uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
1898 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1900 #endif /*PERFORMANCE_EVALUATIONS*/
1901 if ((sm->width != width) || (sm->height != height)) {
1902 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1905 if (sm->interval < 0) {
1909 else if (sm->interval > 0) {
1910 dtime = (int)(curtime - sm->lasttime);
1911 if (dtime < sm->interval) {
1920 sm->height = height;
1921 sm->stride = width * 4;
1922 sm->format = EGL_TEXTURE_RGBA;
1931 uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d "
1932 "w/h/s=%d/%d/%d format=%x file=<%s>",
1933 event, sm->usurf->surfaceid, sm->type,
1934 sm->width, sm->height, sm->stride, sm->format, sm->filepath);
1935 sm->lasttime = curtime;
1937 if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) &&
1938 (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP) &&
1939 (sm->filepath[0] != 0)) {
1940 #if 1 /* ivi_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1941 if (win_mgr_takeSurfaceScreenshot(sm->filepath, sm->usurf,
1942 sm->width, sm->height) != 0)
1943 #else /* ivi_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1944 if (ivi_layout_takeSurfaceScreenshot(sm->filepath,
1945 sm->usurf->ivisurf) != 0)
1946 #endif /* ivi_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1948 uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error",
1949 sm->usurf->surfaceid, sm->filepath);
1950 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
1953 uifw_trace("win_mgr_change_mapsurface: surface.%08x image read(%s) OK",
1954 sm->usurf->surfaceid, sm->filepath);
1957 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
1958 sm->usurf->surfaceid, sm->type,
1959 sm->width, sm->height, sm->stride, sm->format);
1960 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
1961 /* free map table if error */
1962 wl_list_remove(&sm->surf_link);
1963 wl_list_remove(&sm->map_link);
1964 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
1965 _ico_win_mgr->free_maptable = sm;
1970 /*--------------------------------------------------------------------------*/
1972 * @brief uifw_map_surface: mapped surface buffer to system application
1974 * @param[in] client Weyland client
1975 * @param[in] resource resource of request
1976 * @param[in] surfaceid surface id
1977 * @param[in] framerate frame rate of surface update(frame/sec)
1978 * if over 999, no change
1979 * @param[in] filepath surface image file path(if NULL, not create file)
1982 /*--------------------------------------------------------------------------*/
1984 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
1985 uint32_t surfaceid, int32_t framerate, const char *filepath)
1987 struct uifw_win_surface *usurf;
1988 struct weston_surface *es;
1989 struct uifw_surface_map *sm;
1990 struct weston_buffer *buffer;
1991 struct wl_shm_buffer *shm_buffer;
1992 struct uifw_client *uclient;
1993 struct uifw_gl_surface_state *gl_state;
1997 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d,file=%s)",
1998 surfaceid, framerate, filepath ? filepath : "(null)");
2000 uclient = ico_window_mgr_find_uclient(client);
2001 usurf = ico_window_mgr_get_usurf(surfaceid);
2003 /* surface dose not exist, error */
2004 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2005 surfaceid, 1, 0, 0, 0, 0);
2006 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
2010 /* check if buffered */
2011 es = usurf->surface;
2013 /* surface has no buffer, error */
2014 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2015 surfaceid, 2, 0, 0, 0, 0);
2016 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid);
2019 buffer = es->buffer_ref.buffer;
2021 /* check buffer type */
2022 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2023 if (gl_state == NULL) {
2024 ico_window_mgr_send_map_surface(resource,
2025 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2026 surfaceid, 3, 0, 0, 0, 0);
2027 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no gl_state)", surfaceid);
2030 else if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2033 if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) {
2034 if (buffer != NULL) {
2035 shm_buffer = wl_shm_buffer_get(buffer->resource);
2037 format = wl_shm_buffer_get_format(shm_buffer);
2038 uifw_detail("uifw_map_surface: %08x shm_buffer type %x",
2040 if (format == WL_SHM_FORMAT_ARGB8888) {
2041 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
2046 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
2050 ico_window_mgr_send_map_surface(resource,
2051 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2052 surfaceid, 4, 0, 0, 0, 0);
2053 uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))",
2059 maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL;
2062 /* maximum framerate */
2063 if (framerate >= 0) {
2064 if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2065 if (framerate > 30) framerate = 30;
2068 if ((framerate <= 0) || (framerate > 5)) framerate = 5;
2072 /* check same surface */
2073 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2074 if ((sm->usurf == usurf) && (sm->uclient == uclient)) {
2079 if (&sm->surf_link == &usurf->surf_map) {
2080 /* create map table */
2081 sm = _ico_win_mgr->free_maptable;
2083 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
2086 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
2088 ico_window_mgr_send_map_surface(resource,
2089 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2090 surfaceid, 5, 0, 0, 0, 0);
2091 uifw_trace("uifw_map_surface: Leave(malloc error)");
2095 memset(sm, 0, sizeof(struct uifw_surface_map));
2097 wl_list_init(&sm->map_link);
2098 wl_list_init(&sm->surf_link);
2100 sm->uclient = uclient;
2102 sm->framerate = framerate;
2103 if (framerate < 0) sm->interval = -1;
2104 else sm->interval = (1000 / sm->framerate) - 1;
2105 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
2106 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
2109 /* change frame rate */
2110 uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d",
2111 sm->framerate, framerate);
2112 if (sm->framerate != framerate) {
2113 sm->framerate = framerate;
2114 if (framerate < 0) sm->interval = -1;
2115 else sm->interval = (1000 / sm->framerate) - 1;
2116 win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time());
2121 memset(sm->filepath, 0, ICO_IVI_FILEPATH_LENGTH);
2122 if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) {
2123 strncpy(sm->filepath, filepath, ICO_IVI_FILEPATH_LENGTH-1);
2126 if (buffer != NULL) {
2127 sm->width = buffer->width;
2128 sm->height = buffer->height;
2129 if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2130 sm->stride = sm->width * 4;
2131 sm->format = EGL_TEXTURE_RGBA;
2132 if ((sm->width > 0) && (sm->height > 0)) {
2135 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
2136 maptype, surfaceid, framerate, buffer->width, buffer->height);
2139 if (wl_resource_get_user_data((struct wl_resource *)buffer->legacy_buffer)
2141 sm->format = EGL_TEXTURE_RGBA;
2142 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
2143 (gl_state != NULL)) {
2146 uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d",
2147 surfaceid, framerate, buffer->width, buffer->height);
2150 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
2151 surfaceid, framerate);
2155 else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2156 sm->width = es->width;
2157 sm->height = es->height;
2158 sm->stride = sm->width * 4;
2159 sm->format = EGL_TEXTURE_RGBA;
2160 if ((sm->width > 0) && (sm->height > 0)) {
2163 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
2164 maptype, surfaceid, framerate, sm->width, sm->height);
2167 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
2168 surfaceid, framerate);
2171 /* send map event */
2173 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP,
2174 weston_compositor_get_time());
2176 uifw_trace("uifw_map_surface: Leave");
2179 /*--------------------------------------------------------------------------*/
2181 * @brief uifw_unmap_surface: unmap surface buffer
2183 * @param[in] client Weyland client
2184 * @param[in] resource resource of request
2185 * @param[in] surfaceid surface id
2188 /*--------------------------------------------------------------------------*/
2190 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2193 struct uifw_win_surface *usurf;
2194 struct uifw_surface_map *sm, *sm_tmp;
2195 struct uifw_client *uclient;
2197 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2199 usurf = ico_window_mgr_get_usurf(surfaceid);
2201 /* surface dose not exist, error */
2202 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2206 uclient = ico_window_mgr_find_uclient(client);
2207 if ((! uclient) || (! uclient->mgr)) {
2208 /* client dose not exist, error */
2209 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2215 wl_list_for_each (sm, &usurf->surf_map, surf_link) {
2216 if (sm->uclient->mgr != NULL) {
2217 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x "
2218 "w/h/s=%d/%d/%d format=%x",
2219 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2220 sm->width, sm->height, sm->stride, sm->format);
2221 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2222 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2223 surfaceid, sm->type, sm->width,
2224 sm->height, sm->stride, sm->format);
2228 wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) {
2229 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2230 wl_list_remove(&sm->surf_link);
2231 wl_list_remove(&sm->map_link);
2232 if (sm->filepath[0]) {
2233 unlink(sm->filepath);
2235 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2236 _ico_win_mgr->free_maptable = sm;
2238 uifw_trace("uifw_unmap_surface: Leave");
2241 /*--------------------------------------------------------------------------*/
2243 * @brief uifw_layout_surface: direct layout surface
2245 * @param[in] client Weyland client
2246 * @param[in] resource resource of request
2247 * @param[in] surfaceid surface id
2248 * @param[in] layerid layer id
2251 * @param[in] width width
2252 * @param[in] height height
2253 * @param[in] visible visiblity
2256 /*--------------------------------------------------------------------------*/
2258 uifw_layout_surface(struct wl_client *client, struct wl_resource *resource,
2259 uint32_t surfaceid, uint32_t layerid, int x, int y,
2260 int width, int height, int visible)
2262 struct uifw_win_surface *usurf;
2263 struct ivi_layout_layer *layout_layer;
2264 int32_t position[2];
2265 uint32_t dimension[2];
2267 uifw_trace("uifw_layout_surface: Enter(surf=%08x,layer=%d,x/y=%d/%d,w/h=%d,%d,vis=%d)",
2268 surfaceid, layerid, x, y, width, height, visible);
2270 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2272 /* surface dose not exist, error */
2273 uifw_trace("uifw_layout_surface: Leave(surface=%08x dose not exist)", surfaceid);
2277 layout_layer = ivi_layout_getLayerFromId(layerid);
2278 if (! layout_layer) {
2279 /* layer dose not exist */
2280 uifw_trace("uifw_layout_surface: Leave(layer=%d dose not exist)", layerid);
2283 if (ivi_layout_layerAddSurface(layout_layer, usurf->ivisurf) == 0) {
2284 if (ivi_layout_layerSetVisibility(layout_layer, 1) != 0) {
2285 uifw_warn("uifw_layout_surface: layer(%d) visible Error", layerid);
2289 uifw_warn("uifw_layout_surface: can not add surface(%08x) to layer(%d)",
2290 usurf->surfaceid, layerid);
2294 if ((x >= 0) && (y >= 0) && (width > 0) && (height > 0)) {
2295 if (ivi_layout_surfaceSetSourceRectangle(usurf->ivisurf,
2296 0, 0, width, height) != 0) {
2297 uifw_warn("uifw_layout_surface: surface(%08x) can not set source",
2300 if (ivi_layout_surfaceSetDestinationRectangle(usurf->ivisurf,
2301 x, y, width, height) != 0) {
2302 uifw_warn("uifw_layout_surface: surface(%08x) can not set destination",
2306 else if ((x >= 0) && (y >= 0)) {
2309 if (ivi_layout_surfaceSetPosition(usurf->ivisurf, position) != 0) {
2310 uifw_warn("uifw_layout_surface: surface(%08x) can not set source position",
2314 else if ((width > 0) && (height > 0)) {
2315 if (ivi_layout_surfaceSetSourceRectangle(usurf->ivisurf,
2316 0, 0, width, height) != 0) {
2317 uifw_warn("uifw_layout_surface: surface(%08x) can not set source",
2320 dimension[0] = width;
2321 dimension[1] = height;
2322 if (ivi_layout_surfaceSetDimension(usurf->ivisurf, dimension) != 0) {
2323 uifw_warn("uifw_layout_surface: surface(%08x) can not set destination size",
2328 if (ivi_layout_surfaceSetVisibility(usurf->ivisurf, visible) != 0) {
2329 uifw_warn("uifw_layout_surface: surface(%08x) can not set visibility",
2333 if (ivi_layout_commitChanges() != 0) {
2334 uifw_warn("uifw_layout_surface: surface(%08x) commit Error", usurf->surfaceid);
2336 uifw_trace("uifw_layout_surface: Leave");
2339 /*--------------------------------------------------------------------------*/
2341 * @brief win_mgr_destroy_surface: surface destroy
2343 * @param[in] surface Weston surface
2346 /*--------------------------------------------------------------------------*/
2348 win_mgr_destroy_surface(struct weston_surface *surface)
2350 struct uifw_win_surface *usurf;
2351 struct uifw_win_surface *phash;
2352 struct uifw_win_surface *bhash;
2355 usurf = find_uifw_win_surface_by_ws(surface);
2357 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
2360 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
2362 /* remove notification listener */
2363 if (ivi_layout_surfaceRemoveNotification(usurf->ivisurf) != 0) {
2364 uifw_warn("win_mgr_destroy_surface: ivi_layout_surfaceRemoveNotification(%08x)"
2365 " Error", usurf->surfaceid);
2368 /* destory input region */
2369 if (win_mgr_hook_destory) {
2370 (*win_mgr_hook_destory)(usurf);
2374 if (&usurf->surf_map != usurf->surf_map.next) {
2375 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
2378 /* destroy animation extenson */
2379 if (win_mgr_hook_animation) {
2380 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
2383 /* remove destroy listener */
2384 wl_list_remove(&usurf->surface_destroy_listener.link);
2386 /* send destroy event to controller */
2387 win_mgr_send_event(ICO_WINDOW_MGR_DESTROY_SURFACE, usurf->surfaceid, 0);
2389 /* delete from cleint list */
2390 wl_list_remove(&usurf->client_link);
2392 /* delete from hash table */
2393 hash = MAKE_IDHASH(usurf->surfaceid);
2394 phash = _ico_win_mgr->idhash[hash];
2396 while ((phash) && (phash != usurf)) {
2398 phash = phash->next_idhash;
2401 bhash->next_idhash = usurf->next_idhash;
2404 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
2407 hash = MAKE_WSHASH(usurf->surface);
2408 phash = _ico_win_mgr->wshash[hash];
2410 while ((phash) && (phash != usurf)) {
2412 phash = phash->next_wshash;
2415 bhash->next_wshash = usurf->next_wshash;
2418 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
2422 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
2425 /*--------------------------------------------------------------------------*/
2427 * @brief win_mgr_surf_destroylistener: weston_surface destroy listener
2429 * @param[in] listener listener
2430 * @param[in] data data (unused)
2433 /*--------------------------------------------------------------------------*/
2435 win_mgr_surf_destroylistener(struct wl_listener *listener, void *data)
2437 struct uifw_win_surface *usurf = container_of(listener, struct uifw_win_surface,
2438 surface_destroy_listener);
2440 if (usurf && usurf->surface && usurf->ivisurf) {
2441 uifw_trace("win_mgr_surf_destroylistener: Enter(%08x)", usurf->surfaceid);
2442 if (ivi_layout_surfaceRemove(usurf->ivisurf) != 0) {
2443 uifw_trace("win_mgr_surf_destroylistener: ivi_layout_surfaceRemove() Error");
2445 uifw_trace("win_mgr_surf_destroylistener: Leave");
2449 /*--------------------------------------------------------------------------*/
2451 * @brief win_mgr_takeSurfaceScreenshot: take screen image pixel
2453 * @param[in] filename output file path
2454 * @param[in] usurf UIFW surface
2455 * @param[in] width surface width
2456 * @param[in] height surface height
2461 /*--------------------------------------------------------------------------*/
2463 win_mgr_takeSurfaceScreenshot(const char *filename, struct uifw_win_surface *usurf,
2464 int width, int height)
2475 #pragma pack(push, 1)
2496 uifw_trace("win_mgr_takeSurfaceScreenshot: Enter(%08x) <%s>",
2497 usurf->surfaceid, filename);
2499 if (! _ico_win_mgr->compositor->renderer->read_surface_pixels) {
2500 uifw_trace("win_mgr_takeSurfaceScreenshot: Leave(no read_surface_pixels)");
2503 bitperpixel = PIXMAN_FORMAT_BPP(_ico_win_mgr->compositor->read_format);
2504 bmphead_size = ((sizeof(struct _bmphead) + 31) / 32) * 32;
2505 datasize = (width * bitperpixel / 8) * height;
2506 bufsize = datasize + bmphead_size;
2507 if ((_ico_win_mgr->pixel_readbuf != NULL) &&
2508 (bufsize > _ico_win_mgr->pixel_readsize)) {
2509 free(_ico_win_mgr->pixel_readbuf);
2510 _ico_win_mgr->pixel_readbuf = NULL;
2512 if (_ico_win_mgr->pixel_readbuf == NULL) {
2513 _ico_win_mgr->pixel_readbuf = malloc(bufsize);
2514 if (! _ico_win_mgr->pixel_readbuf) {
2515 uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
2518 _ico_win_mgr->pixel_readsize = bufsize;
2520 pathlen = strlen(filename);
2521 if ((pathlen >= 4) && (strcmp(&filename[pathlen-4], ".bmp") == 0)) {
2523 wkbuf = malloc(datasize);
2525 uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
2529 fd = open(filename, O_WRONLY|O_CREAT, 0644);
2531 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> open Error<%d>)",
2537 uifw_detail("win_mgr_takeSurfaceScreenshot: call read_surface_pixels(%d,%d)",
2539 if ((*(_ico_win_mgr->compositor->
2540 renderer->read_surface_pixels))(usurf->surface, PIXMAN_a8r8g8b8,
2542 (_ico_win_mgr->pixel_readbuf + bmphead_size),
2543 0, 0, width, height) != 0) {
2545 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(read_surface_pixels Error)");
2549 uifw_detail("win_mgr_takeSurfaceScreenshot: end read_surface_pixels");
2553 bmphead = (struct _bmphead *)(_ico_win_mgr->pixel_readbuf +
2554 (bmphead_size - sizeof(struct _bmphead)));
2555 memset(bmphead, 0, sizeof(struct _bmphead));
2556 bmphead->magic = 0x4d42;
2557 bmphead->fullsize = sizeof(struct _bmphead) + datasize;
2558 bmphead->offset = 54;
2559 bmphead->headsize = 40;
2560 bmphead->width = width;
2561 bmphead->height = height;
2562 bmphead->planes = 1;
2563 bmphead->bitperpixel = bitperpixel;
2564 bmphead->compress = 0;
2565 bmphead->datasize = datasize;
2566 bmphead->xp = 100000;
2567 bmphead->yp = 100000;
2570 linesize = width * bitperpixel / 8;
2572 dp = _ico_win_mgr->pixel_readbuf + bmphead_size + (linesize * (height-1));
2573 for (pathlen = 0; pathlen < height; pathlen++) {
2574 memcpy(dp, sp, linesize);
2580 if (write(fd, bmphead, sizeof(struct _bmphead) + datasize) < 0) {
2581 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
2589 if (write(fd, _ico_win_mgr->pixel_readbuf + bmphead_size, datasize) < 0) {
2590 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
2598 uifw_trace("win_mgr_takeSurfaceScreenshot: Leave");
2602 /*--------------------------------------------------------------------------*/
2604 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
2606 * @param[in] client client
2607 * @param[in] data user data(unused)
2608 * @param[in] version protocol version(unused)
2609 * @param[in] id client object id
2612 /*--------------------------------------------------------------------------*/
2614 bind_ico_win_mgr(struct wl_client *client,
2615 void *data, uint32_t version, uint32_t id)
2617 struct wl_resource *add_resource;
2618 struct uifw_manager *mgr;
2619 struct uifw_client *uclient;
2621 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
2623 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
2625 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
2626 _ico_win_mgr, unbind_ico_win_mgr);
2629 /* Create client management tabel */
2630 uclient = ico_window_mgr_find_uclient(client);
2632 win_mgr_bind_client(client, NULL);
2633 uclient = ico_window_mgr_find_uclient(client);
2637 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
2639 uifw_error("bind_ico_win_mgr: Error, No Memory");
2642 memset(mgr, 0, sizeof(struct uifw_manager));
2643 mgr->resource = add_resource;
2647 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
2649 uifw_trace("bind_ico_win_mgr: Leave");
2652 /*--------------------------------------------------------------------------*/
2654 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
2656 * @param[in] resource client resource
2659 /*--------------------------------------------------------------------------*/
2661 unbind_ico_win_mgr(struct wl_resource *resource)
2663 struct uifw_manager *mgr, *itmp;
2665 uifw_trace("unbind_ico_win_mgr: Enter");
2667 /* Remove manager from manager list */
2668 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
2669 if (mgr->resource == resource) {
2670 wl_list_remove(&mgr->link);
2674 uifw_trace("unbind_ico_win_mgr: Leave");
2677 /*--------------------------------------------------------------------------*/
2679 * @brief ico_window_mgr_get_uclient: get UIFW client table
2681 * @param[in] appid application Id
2682 * @return UIFW client table
2683 * @retval !=NULL success(UIFW client table address)
2684 * @retval = NULL error(appid not exist)
2686 /*--------------------------------------------------------------------------*/
2687 WL_EXPORT struct uifw_client *
2688 ico_window_mgr_get_uclient(const char *appid)
2690 struct uifw_client *uclient;
2692 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2693 if (strcmp(uclient->appid, appid) == 0) {
2700 /*--------------------------------------------------------------------------*/
2702 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
2704 * @param[in] target surface window name and application Id(winname@appid)
2705 * @return UIFW surface table
2706 * @retval !=NULL success(UIFW surface table address)
2707 * @retval = NULL error(appid or winname not exist)
2709 /*--------------------------------------------------------------------------*/
2710 WL_EXPORT struct uifw_win_surface *
2711 ico_window_mgr_get_client_usurf(const char *target)
2713 struct uifw_client *uclient;
2714 struct uifw_win_surface *usurf;
2716 char winname[ICO_IVI_WINNAME_LENGTH];
2717 char appid[ICO_IVI_APPID_LENGTH];
2719 /* get window name and application id */
2721 for (i = 0; target[i]; i++) {
2722 if (target[i] == '@') {
2723 if (target[i+1] != '@') break;
2726 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
2727 winname[j++] = target[i];
2731 if (target[i] == '@') {
2739 for ( ; target[i]; i++) {
2740 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
2741 if (j < (ICO_IVI_APPID_LENGTH-1)) {
2742 appid[j++] = target[i];
2746 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
2747 target, appid, winname);
2749 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2750 if (strcmp(uclient->appid, appid) == 0) {
2751 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
2752 if ((winname[0] == 0) ||
2753 (strcmp(winname, usurf->winname) == 0)) {
2762 /*--------------------------------------------------------------------------*/
2764 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
2766 * @param[in] hook_animation hook routine
2769 /*--------------------------------------------------------------------------*/
2771 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
2773 win_mgr_hook_animation = hook_animation;
2776 /*--------------------------------------------------------------------------*/
2778 * @brief ico_window_mgr_set_hook_change: set input region hook routine
2780 * @param[in] hook_change hook routine
2783 /*--------------------------------------------------------------------------*/
2785 ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf))
2787 win_mgr_hook_change = hook_change;
2790 /*--------------------------------------------------------------------------*/
2792 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
2794 * @param[in] hook_destroy hook routine
2797 /*--------------------------------------------------------------------------*/
2799 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
2801 win_mgr_hook_destory = hook_destroy;
2804 /*--------------------------------------------------------------------------*/
2806 * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine
2808 * @param[in] hook_inputregion hook routine
2811 /*--------------------------------------------------------------------------*/
2813 ico_window_mgr_set_hook_inputregion(
2814 void (*hook_inputregion)(int set, struct uifw_win_surface *usurf,
2815 int32_t x, int32_t y, int32_t width,
2816 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
2817 int32_t cursor_x, int32_t cursor_y, int32_t cursor_width,
2818 int32_t cursor_height, uint32_t attr))
2820 win_mgr_hook_inputregion = hook_inputregion;
2823 /*--------------------------------------------------------------------------*/
2825 * @brief module_init: initialize ico_window_mgr
2826 * this function called from ico_pluign_loader
2828 * @param[in] es weston compositor
2829 * @param[in] argc number of arguments(unused)
2830 * @param[in] argv argument list(unused)
2835 /*--------------------------------------------------------------------------*/
2837 module_init(struct weston_compositor *ec, int *argc, char *argv[])
2842 struct weston_output *output;
2843 struct weston_config_section *section;
2844 char *displayno = NULL;
2846 struct wl_event_loop *loop;
2848 uifw_info("ico_window_mgr: Enter(module_init)");
2850 /* get ivi debug level */
2851 section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL);
2853 weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0);
2854 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
2857 /* get display number */
2858 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
2860 weston_config_section_get_string(section, "displayno", &displayno, NULL);
2863 /* get animation default */
2864 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
2866 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
2867 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500);
2868 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30);
2870 if (_ico_ivi_animation_name == NULL)
2871 _ico_ivi_animation_name = (char *)"fade";
2872 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500;
2873 if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30;
2875 /* create ico_window_mgr management table */
2876 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
2877 if (_ico_win_mgr == NULL) {
2878 uifw_error("ico_window_mgr: malloc failed");
2882 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
2884 _ico_win_mgr->compositor = ec;
2886 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
2887 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
2888 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
2889 uifw_error("ico_window_mgr: Error(wl_global_create)");
2893 wl_list_init(&_ico_win_mgr->client_list);
2894 wl_list_init(&_ico_win_mgr->manager_list);
2895 wl_list_init(&_ico_win_mgr->map_list);
2896 _ico_win_mgr->free_maptable = NULL;
2898 /* create display list */
2899 if (displayno != NULL) {
2906 wl_list_for_each (output, &ec->output_list, link) {
2907 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
2908 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurface;
2909 wl_list_insert(output->animation_list.prev,
2910 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
2912 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
2914 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
2916 wl_list_for_each (output, &ec->output_list, link) {
2919 idx = strtol(p, (char **)0, 0);
2920 uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx);
2922 if ((idx < 0) || (idx >= _ico_num_nodes)) {
2929 if (_ico_node_table[idx].node) {
2930 for (idx = 0; idx < _ico_num_nodes; idx++) {
2931 if (_ico_node_table[idx].node == 0) break;
2933 if (idx >= _ico_num_nodes) {
2934 uifw_error("ico_window_mgr: number of display overflow");
2938 _ico_node_table[idx].node = idx + 0x100;
2939 _ico_node_table[idx].displayno = i;
2940 _ico_node_table[idx].output = output;
2941 _ico_node_table[idx].disp_x = output->x;
2942 _ico_node_table[idx].disp_y = output->y;
2943 _ico_node_table[idx].disp_width = output->width;
2944 _ico_node_table[idx].disp_height = output->height;
2946 if (i >= _ico_num_nodes) break;
2949 for (i = 0; i < _ico_num_nodes; i++) {
2950 _ico_node_table[i].node &= 0x0ff;
2951 uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
2952 i, _ico_node_table[i].displayno,
2953 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
2954 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
2958 /* my node Id ... this version fixed 0 */
2959 nodeId = ico_ivi_get_mynode();
2961 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
2962 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
2963 nodeId, _ico_win_mgr->surface_head);
2965 /* get seat for touch down counter check */
2966 touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link);
2967 loop = wl_display_get_event_loop(ec->wl_display);
2968 _ico_win_mgr->wait_mapevent =
2969 wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL);
2970 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000);
2972 uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d",
2973 _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps);
2974 uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x",
2975 _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff,
2976 (_ico_ivi_debug_level >> 16) & 0x0ffff);
2978 /* touch/click binding for select surface */
2979 weston_compositor_add_button_binding(ec, BTN_LEFT, 0, win_mgr_click_to_activate, NULL);
2980 weston_compositor_add_touch_binding(ec, 0, win_mgr_touch_to_activate, NULL);
2982 /* set Notification function for GENIVI ivi-shell */
2983 if (ivi_layout_addNotificationCreateSurface(ico_ivi_surfaceCreateNotification, NULL) != 0) {
2984 uifw_error("ico_window_mgr: ivi_layout_setNotificationCreateSurface Error");
2986 if (ivi_layout_addNotificationRemoveSurface(ico_ivi_surfaceRemoveNotification, NULL) != 0) {
2987 uifw_error("ico_window_mgr: ivi_layout_setNotificationRemoveSurface Error");
2990 uifw_info("ico_window_mgr: Leave(module_init)");