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-private.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 extern WL_EXPORT struct ivi_layout_interface ivi_layout_interface;
72 /* gl_surface_state (inport from weston-1.4.0/src/gl-renderer.c */
78 struct uifw_gl_surface_state { /* struct gl_surface_state */
80 struct gl_shader *shader;
84 int needs_full_upload;
85 pixman_region32_t texture_damage;
87 void *images[3]; /* EGLImageKHR */
91 struct weston_buffer_reference buffer_ref;
92 enum buffer_type buffer_type;
93 int pitch; /* in pixels */
94 int height; /* in pixels */
95 int y_inverted; /* add weston 1.3.x */
99 #define UIFW_HASH 64 /* Hash value (2's compliment) */
100 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId hash mask pattern */
102 /* Internal fixed value */
103 #define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */
104 /* show/hide animation with position */
105 #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000
107 /* Waiting time for updating of livethumbnail(ms) */
108 #define ICO_WINDOW_MGR_THUMBNAIL_WAITTIME 1000
110 /* Multi Windiw Manager */
112 struct weston_compositor *compositor; /* Weston compositor */
113 void *shell; /* shell table address */
114 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
116 struct wl_list client_list; /* Clients */
117 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
119 struct wl_list map_list; /* surface map list */
120 struct uifw_surface_map *free_maptable; /* free maped surface table list */
121 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
122 /* animation for map check */
123 struct wl_event_source *wait_mapevent; /* map event send wait timer */
125 char *pixel_readbuf; /* surface pixel image read buffer */
126 int pixel_readsize; /* surface pixel image read buffer size */
127 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
128 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
130 char shell_init; /* shell initialize flag */
131 char res[3]; /* (unused) */
134 /* Internal macros */
136 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
138 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
140 /* function prototype */
141 /* get surface table from weston surface*/
142 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
143 struct weston_surface *wsurf);
144 /* bind shell client */
145 static void win_mgr_bind_client(struct wl_client *client, void *shell);
147 static void win_mgr_destroy_client(struct wl_listener *listener, void *data);
148 #if 0 /* work around: Walk through child processes until app ID is found */
150 static pid_t win_mgr_get_ppid(pid_t pid);
151 #endif /* work around: Walk through child processes until app ID is found */
152 /* get appid from pid */
153 static void win_mgr_get_client_appid(struct uifw_client *uclient);
154 /* create new surface */
155 static void win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
156 struct wl_client *client,
157 struct ivi_layout_surface *ivisurf);
158 /* surface destroy */
159 static void win_mgr_destroy_surface(struct weston_surface *surface);
160 /* weston_surface destroy listener */
161 static void win_mgr_surf_destroylistener(struct wl_listener *listener, void *data);
162 /* read surface pixel */
163 static int win_mgr_takeSurfaceScreenshot(const char *filename,
164 struct uifw_win_surface *usurf,
165 int width, int height);
166 /* set surface animation */
167 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
168 uint32_t surfaceid, int32_t type,
169 const char *animation, int32_t time);
170 /* check and change all mapped surface */
171 static void win_mgr_check_mapsurface(struct weston_animation *animation,
172 struct weston_output *output, uint32_t msecs);
173 /* check timer of mapped surface */
174 static int win_mgr_timer_mapsurface(void *data);
175 /* check and change mapped surface */
176 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event,
178 /* map surface to system application */
179 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
180 uint32_t surfaceid, int32_t framerate, const char *filepath);
182 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
184 /* direct layout surface */
185 static void uifw_layout_surface(struct wl_client *client, struct wl_resource *resource,
186 uint32_t surfaceid, uint32_t layerid, int x, int y,
187 int width, int height, int visible);
189 static void bind_ico_win_mgr(struct wl_client *client,
190 void *data, uint32_t version, uint32_t id);
192 static void unbind_ico_win_mgr(struct wl_resource *resource);
193 /* convert animation name to Id value */
194 static int ico_get_animation_name(const char *animation);
195 /* send event to controller */
196 static void win_mgr_send_event(int event, uint32_t surfaceid, uint32_t arg1);
197 /* touch/click select surface */
198 static void win_mgr_select_surface(struct weston_seat *seat,
199 struct weston_surface *focus, int target);
200 static void win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
201 uint32_t button, void *data);
202 static void win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time,
204 /* hook for create surface of ivi-shell */
205 static void ico_ivi_surfaceCreateNotification(struct ivi_layout_surface *ivisurf,
207 /* hook for remove surface of ivi-shell */
208 static void ico_ivi_surfaceRemoveNotification(struct ivi_layout_surface *ivisurf,
210 /* hook for property change of ivi-shell*/
211 static void ico_ivi_surfacePropertyNotification(struct ivi_layout_surface *ivisurf,
212 const struct ivi_layout_surface_properties *prop,
213 enum ivi_layout_notification_mask mask,
215 /* hook for animation */
216 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
217 /* hook for input region */
218 static void (*win_mgr_hook_change)(struct uifw_win_surface *usurf) = NULL;
219 static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL;
220 static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf,
221 int32_t x, int32_t y, int32_t width,
222 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
223 int32_t cursor_x, int32_t cursor_y,
224 int32_t cursor_width, int32_t cursor_height,
225 uint32_t attr) = NULL;
228 /* Multi Window Manager interface */
229 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
237 /* plugin common value(without ico_plugin_loader) */
238 static int _ico_ivi_option_flag = 0; /* option flags */
239 static int _ico_ivi_debug_level = 3; /* debug Level */
240 static char *_ico_ivi_animation_name = NULL; /* default animation name */
241 static int _ico_ivi_animation_time = 500; /* default animation time */
242 static int _ico_ivi_animation_fps = 30; /* animation frame rate */
244 /* static management table */
245 static struct ico_win_mgr *_ico_win_mgr = NULL;
246 static int _ico_num_nodes = 0;
247 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
248 static struct weston_seat *touch_check_seat = NULL;
251 /*--------------------------------------------------------------------------*/
253 * @brief ico_ivi_optionflag: get option flags
256 * @return option flags
258 /*--------------------------------------------------------------------------*/
260 ico_ivi_optionflag(void)
262 return _ico_ivi_option_flag;
265 /*--------------------------------------------------------------------------*/
267 * @brief ico_ivi_debuglevel: answer debug output level.
270 * @return debug output level
271 * @retval 0 No debug output
272 * @retval 1 Only error output
273 * @retval 2 Error and Warning output
274 * @retval 3 Error, Warning and information output
275 * @retval 4 Error, Warning, information and Debug Trace output
276 * @retval 5 All output with debug write
278 /*--------------------------------------------------------------------------*/
280 ico_ivi_debuglevel(void)
282 return (_ico_ivi_debug_level & 0x0ffff);
285 /*--------------------------------------------------------------------------*/
287 * @brief ico_ivi_debugflag: get debug flags
290 * @return debug flags
292 /*--------------------------------------------------------------------------*/
294 ico_ivi_debugflag(void)
296 return ((_ico_ivi_debug_level >> 16) & 0x0ffff);
299 /*--------------------------------------------------------------------------*/
301 * @brief ico_ivi_default_animation_name: get default animation name
304 * @return Default animation name
306 /*--------------------------------------------------------------------------*/
307 WL_EXPORT const char *
308 ico_ivi_default_animation_name(void)
310 return _ico_ivi_animation_name;
313 /*--------------------------------------------------------------------------*/
315 * @brief ico_ivi_default_animation_time: get default animation time
318 * @return Default animation time(miri sec)
320 /*--------------------------------------------------------------------------*/
322 ico_ivi_default_animation_time(void)
324 return _ico_ivi_animation_time;
327 /*--------------------------------------------------------------------------*/
329 * @brief ico_ivi_default_animation_fps: get default animation frame rate
332 * @return Default animation frame rate(frames/sec)
334 /*--------------------------------------------------------------------------*/
336 ico_ivi_default_animation_fps(void)
338 return _ico_ivi_animation_fps;
341 /*--------------------------------------------------------------------------*/
343 * @brief ico_ivi_get_mynode: Get my NodeId
346 * @return NodeId of my node
348 /*--------------------------------------------------------------------------*/
350 ico_ivi_get_mynode(void)
352 /* Reference Platform 0.90 only support 1 ECU */
356 /*--------------------------------------------------------------------------*/
358 * @brief ico_ivi_surface_buffer_width: get surface buffer width
360 * @param[in] es weston surface
361 * @return buffer width(if surface has no buffer, return 0)
363 /*--------------------------------------------------------------------------*/
365 ico_ivi_surface_buffer_width(struct weston_surface *es)
369 if (! es->buffer_ref.buffer) {
372 if (es->buffer_viewport.surface.width >= 0 ) {
373 return es->buffer_viewport.surface.width;
375 switch (es->buffer_viewport.buffer.transform) {
376 case WL_OUTPUT_TRANSFORM_90:
377 case WL_OUTPUT_TRANSFORM_270:
378 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
379 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
380 v = es->buffer_ref.buffer->height;
383 v = es->buffer_ref.buffer->width;
386 return (v / es->buffer_viewport.buffer.scale);
389 /*--------------------------------------------------------------------------*/
391 * @brief ico_ivi_surface_buffer_height: get surface buffer height
393 * @param[in] es weston surface
394 * @return buffer height(if surface has no buffer, return 0)
396 /*--------------------------------------------------------------------------*/
398 ico_ivi_surface_buffer_height(struct weston_surface *es)
402 if (! es->buffer_ref.buffer) {
405 if (es->buffer_viewport.surface.width >= 0) {
406 return es->buffer_viewport.surface.height;
408 switch (es->buffer_viewport.buffer.transform) {
409 case WL_OUTPUT_TRANSFORM_90:
410 case WL_OUTPUT_TRANSFORM_270:
411 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
412 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
413 v = es->buffer_ref.buffer->width;
416 v = es->buffer_ref.buffer->height;
419 return (v / es->buffer_viewport.buffer.scale);
422 /*--------------------------------------------------------------------------*/
424 * @brief ico_ivi_surface_buffer_size: get surface buffer size
426 * @param[in] es weston surface
427 * @param[out] width buffer width
428 * @param[out] height buffer height
431 /*--------------------------------------------------------------------------*/
433 ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height)
435 if (! es->buffer_ref.buffer) {
439 else if (es->buffer_viewport.surface.width >=0 ) {
440 *width = es->buffer_viewport.surface.width;
441 *height = es->buffer_viewport.surface.height;
444 switch (es->buffer_viewport.buffer.transform) {
445 case WL_OUTPUT_TRANSFORM_90:
446 case WL_OUTPUT_TRANSFORM_270:
447 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
448 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
449 *width = es->buffer_ref.buffer->height;
450 *height = es->buffer_ref.buffer->width;
453 *width = es->buffer_ref.buffer->width;
454 *height = es->buffer_ref.buffer->height;
457 *width = *width / es->buffer_viewport.buffer.scale;
458 *height = *height / es->buffer_viewport.buffer.scale;
462 /*--------------------------------------------------------------------------*/
464 * @brief ico_ivi_surface_buffer_size: get surface buffer size
466 * @param[in] es weston surface
467 * @param[out] width buffer width
468 * @param[out] height buffer height
471 /*--------------------------------------------------------------------------*/
472 WL_EXPORT struct weston_view *
473 ico_ivi_get_primary_view(struct uifw_win_surface *usurf)
475 struct weston_view *ev = NULL;
476 struct shell_surface *shsurf;
478 if (_ico_win_mgr->compositor->shell_interface.get_primary_view) {
479 shsurf = usurf->surface->configure_private;
481 ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view)(NULL, shsurf);
485 ev = ivi_layout_interface.get_weston_view(usurf->ivisurf);
488 uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view",
489 (int)usurf, usurf->surfaceid, (int)usurf->surface);
494 /*--------------------------------------------------------------------------*/
496 * @brief ico_window_mgr_set_weston_surface: set weston surface
498 * @param[in] usurf UIFW surface
499 * @param[in] x X coordinate on screen
500 * @param[in] y Y coordinate on screen
501 * @param[in] width width
502 * @param[in] height height
505 /*--------------------------------------------------------------------------*/
507 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
508 int x, int y, int width, int height)
510 struct weston_surface *es = usurf->surface;
511 const struct ivi_layout_surface_properties *prop;
512 int buf_width, buf_height;
514 if ((es == NULL) || (usurf->ivisurf == NULL)) {
515 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
520 if (es->buffer_ref.buffer != NULL) {
521 ico_ivi_surface_buffer_size(es, &buf_width, &buf_height);
522 if ((width <= 0) || (height <= 0)) {
524 usurf->width = buf_width;
526 usurf->height = buf_height;
528 if (usurf->width > buf_width) {
530 x += (usurf->width - buf_width)/2;
532 if (usurf->height > buf_height) {
534 y += (usurf->height - buf_height)/2;
536 if (usurf->visible) {
537 x += usurf->node_tbl->disp_x;
538 y += usurf->node_tbl->disp_y;
541 x = ICO_IVI_MAX_COORDINATE+1;
542 y = ICO_IVI_MAX_COORDINATE+1;
544 if ((prop = ivi_layout_get_properties_of_surface(usurf->ivisurf))) {
545 if ((prop->dest_x != x) || (prop->dest_y != y) ||
546 (prop->dest_width != (int32_t)width) ||
547 (prop->dest_height != (int32_t)height)) {
548 if (ivi_layout_surface_set_destination_rectangle(
549 usurf->ivisurf, x, y, width, height) == 0) {
550 ivi_layout_commit_changes();
554 weston_surface_damage(es);
558 /*--------------------------------------------------------------------------*/
560 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
562 * @param[in] surfaceid UIFW surface id
563 * @return UIFW surface table address
564 * @retval !=NULL success(surface table address)
565 * @retval NULL error(surface id dose not exist)
567 /*--------------------------------------------------------------------------*/
568 WL_EXPORT struct uifw_win_surface *
569 ico_window_mgr_get_usurf(const uint32_t surfaceid)
571 struct uifw_win_surface *usurf;
573 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
576 if (usurf->surfaceid == surfaceid) {
579 usurf = usurf->next_idhash;
584 /*--------------------------------------------------------------------------*/
586 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
588 * @param[in] surfaceid UIFW surface id
589 * @param[in] client Wayland client
590 * @return UIFW surface table address
591 * @retval !=NULL success(surface table address)
592 * @retval NULL error(surface id or client dose not exist)
594 /*--------------------------------------------------------------------------*/
595 WL_EXPORT struct uifw_win_surface *
596 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
598 struct uifw_win_surface *usurf;
599 struct uifw_client *uclient;
601 usurf = ico_window_mgr_get_usurf(surfaceid);
604 uclient = ico_window_mgr_find_uclient(client);
606 /* client dose not exist, error */
607 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x dose not exist",
611 if (&uclient->surface_link == uclient->surface_link.next) {
612 /* client has no surface */
613 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x has no surface",
617 usurf = (struct uifw_win_surface *)uclient->surface_link.next;
618 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x 1st surface=%08x",
619 (int)client, usurf->surfaceid);
624 /*--------------------------------------------------------------------------*/
626 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
628 * @param[in] wsurf Weston surface
629 * @return UIFW surface table address
630 * @retval !=NULL success(surface table address)
631 * @retval NULL error(surface dose not exist)
633 /*--------------------------------------------------------------------------*/
634 static struct uifw_win_surface *
635 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
637 struct uifw_win_surface *usurf;
639 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
642 if (usurf->surface == wsurf) {
645 usurf = usurf->next_wshash;
647 uifw_trace("find_uifw_win_surface_by_ws: NULL");
651 /*--------------------------------------------------------------------------*/
653 * @brief ico_window_mgr_find_uclient: find UIFW client by wayland client
655 * @param[in] client Wayland client
656 * @return UIFW client table address
657 * @retval !=NULL success(client table address)
658 * @retval NULL error(client dose not exist)
660 /*--------------------------------------------------------------------------*/
661 WL_EXPORT struct uifw_client*
662 ico_window_mgr_find_uclient(struct wl_client *client)
664 struct uifw_client *uclient;
666 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
667 if (uclient->client == client) {
671 uifw_trace("ico_window_mgr_find_uclient: client.%08x is NULL", (int)client);
675 /*--------------------------------------------------------------------------*/
677 * @brief ico_window_mgr_get_appid: find application id by wayland client
679 * @param[in] client Wayland client
680 * @return application id
681 * @retval !=NULL success(application id)
682 * @retval NULL error(client dose not exist)
684 /*--------------------------------------------------------------------------*/
686 ico_window_mgr_get_appid(struct wl_client* client)
688 struct uifw_client *uclient;
690 uclient = ico_window_mgr_find_uclient(client);
695 return uclient->appid;
698 /*--------------------------------------------------------------------------*/
700 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
702 * @param[in] displayno display number
703 * @param[out] x relative X coordinate
704 * @param[out] y relative Y coordinate
707 /*--------------------------------------------------------------------------*/
709 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
711 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
714 *x = _ico_node_table[displayno].disp_x;
715 *y = _ico_node_table[displayno].disp_y;
718 /*--------------------------------------------------------------------------*/
720 * @brief win_mgr_bind_client: desktop_shell from client
722 * @param[in] client Wayland client
723 * @param[in] shell shell table address
726 /*--------------------------------------------------------------------------*/
728 win_mgr_bind_client(struct wl_client *client, void *shell)
730 struct uifw_client *uclient;
736 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
737 (int)client, (int)shell);
739 /* save shell table address */
741 _ico_win_mgr->shell = shell;
745 uclient = ico_window_mgr_find_uclient(client);
747 /* client not exist, create client management table */
748 uifw_trace("win_mgr_bind_client: Create Client");
749 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
751 uifw_error("win_mgr_bind_client: Error, No Memory");
754 memset(uclient, 0, sizeof(struct uifw_client));
755 uclient->client = client;
756 wl_list_init(&uclient->surface_link);
758 uclient->destroy_listener.notify = win_mgr_destroy_client;
759 wl_client_add_destroy_listener(client, &uclient->destroy_listener);
764 wl_client_get_credentials(client, &pid, &uid, &gid);
765 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
766 (int)client, (int)pid, (int)uid, (int)gid);
768 uclient->pid = (int)pid;
769 /* get applicationId from AppCore(AUL) */
770 win_mgr_get_client_appid(uclient);
773 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
777 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
779 uifw_trace("win_mgr_bind_client: Leave");
782 /*--------------------------------------------------------------------------*/
784 * @brief win_mgr_destroy_client: destroy client
786 * @param[in] listener listener
787 * @param[in] data listener
790 /*--------------------------------------------------------------------------*/
792 win_mgr_destroy_client(struct wl_listener *listener, void *data)
794 struct uifw_client *uclient;
795 struct uifw_win_surface *usurf;
796 struct uifw_win_surface *usurf_tmp;
798 uclient = container_of(listener, struct uifw_client, destroy_listener);
800 uifw_trace("win_mgr_destroy_client: Enter(uclient=%08x)", (int)uclient);
803 /* Client exist, Destory client surfaces */
804 wl_list_for_each_safe (usurf, usurf_tmp, &uclient->surface_link, client_link) {
805 win_mgr_destroy_surface(usurf->surface);
807 /* Destory client management table */
808 wl_list_remove(&uclient->link);
811 uifw_trace("win_mgr_destroy_client: Leave");
814 #if 0 /* work around: Walk through child processes until app ID is found */
815 /*--------------------------------------------------------------------------*/
817 * @brief win_mgr_get_ppid: Get parent process ID.
819 * Similar to getppid(), except that this implementation accepts an
820 * arbitrary process ID.
822 * @param[in] pid Process ID of child process
823 * @return parent process ID on success, -1 on failure
825 /*--------------------------------------------------------------------------*/
827 win_mgr_get_ppid(pid_t pid)
830 char procpath[PATH_MAX] = { 0 };
832 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid);
834 /* We better have read permissions! */
835 int const fd = open(procpath, O_RDONLY);
840 char buffer[1024] = { 0 };
842 ssize_t const size = read(fd, buffer, sizeof(buffer));
848 /* Find line containing the parent process ID. */
849 char const * const ppid_line = strstr(buffer, "PPid");
851 if (ppid_line != NULL)
852 sscanf(ppid_line, "PPid: %d", &ppid);
856 #endif /* work around: Walk through child processes until app ID is found */
858 /*--------------------------------------------------------------------------*/
860 * @brief win_mgr_get_client_appid: get applicationId from pid
862 * @param[in] uclient UIFW client management table
865 /*--------------------------------------------------------------------------*/
867 win_mgr_get_client_appid(struct uifw_client *uclient)
869 int status = AUL_R_ERROR;
871 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
873 #if 0 /* work around: Walk through child processes until app ID is found */
875 * Walk the parent process chain until we find a parent process
880 for (pid = uclient->pid;
881 pid > 1 && status != AUL_R_OK;
882 pid = win_mgr_get_ppid(pid)) {
884 status = aul_app_get_appid_bypid(pid,
886 ICO_IVI_APPID_LENGTH);
888 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
889 "pid=%d appid=<%s>", status, pid, uclient->appid);
892 * Walk the child process chain as well since app ID was not yet found
894 if (status != AUL_R_OK) {
903 dr = opendir("/proc/");
906 wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
908 while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
910 char fullpath[PATH_MAX] = { 0 };
914 snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
916 if (stat(fullpath, &ps) == -1) {
920 /* find pid dirs for this user (uid) only */
921 if (ps.st_uid != uid)
924 pid = atoi(de->d_name);
926 /* check if it's a valid child */
927 if (pid < uclient->pid)
930 /* scan up to pid to find if a chain exists */
931 for (tmppid = pid; tmppid > uclient->pid;) {
932 tmppid = win_mgr_get_ppid(tmppid);
933 if (tmppid == uclient->pid)
938 status = aul_app_get_appid_bypid(pid, uclient->appid,
939 ICO_IVI_APPID_LENGTH);
941 uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid "
942 "ret=%d pid=%d appid=<%s>", status, pid,
947 #else /* work around: Walk through child processes until app ID is found */
948 status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
949 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
950 "pid=%d appid=<%s>", status, uclient->pid, uclient->appid);
951 #endif /* work around: Walk through child processes until app ID is found */
953 if (uclient->appid[0] != 0) {
954 /* OK, end of get appid */
955 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
958 /* client does not exist in AppCore, search Linux process table */
966 uclient->fixed_appid ++;
967 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
968 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
969 fd = open(procpath, O_RDONLY);
971 size = read(fd, procpath, sizeof(procpath));
972 for (; size > 0; size--) {
973 if (procpath[size-1]) break;
976 /* get program base name */
978 for (j = 0; j < size; j++) {
979 if (procpath[j] == 0) break;
980 if (procpath[j] == '/') i = j + 1;
983 for (; i < size; i++) {
984 uclient->appid[j] = procpath[i];
985 if ((uclient->appid[j] == 0) ||
986 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
989 /* search application number in apprication start option */
990 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
991 for (; i < size; i++) {
992 if ((procpath[i] == 0) &&
993 (procpath[i+1] == '@')) {
994 strncpy(&uclient->appid[j], &procpath[i+1],
995 ICO_IVI_APPID_LENGTH - j - 2);
1002 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
1003 if (uclient->appid[i] != ' ') break;
1005 uclient->appid[i+1] = 0;
1006 if (uclient->appid[0]) {
1007 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
1008 "Process table(%d)",
1009 uclient->pid, uclient->appid, uclient->fixed_appid );
1012 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
1014 sprintf(uclient->appid, "?%d?", uclient->pid);
1019 /*--------------------------------------------------------------------------*/
1021 * @brief ico_get_animation_name: convert animation name to Id value
1023 * @param[in] animation animation name
1024 * @return animation Id value
1026 /*--------------------------------------------------------------------------*/
1028 ico_get_animation_name(const char *animation)
1030 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1032 if (strcasecmp(animation, "none") == 0) {
1033 return ICO_WINDOW_MGR_ANIMATION_NONE;
1036 if (win_mgr_hook_animation) {
1037 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
1040 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1045 /*--------------------------------------------------------------------------*/
1047 * @brief win_mgr_send_event: send event to controller
1049 * @param[in] event event code
1050 * @param[in] surfaceid surface id
1051 * @param[in] arg1 argument 1
1054 /*--------------------------------------------------------------------------*/
1056 win_mgr_send_event(int event, uint32_t surfaceid, uint32_t arg1)
1058 struct uifw_manager *mgr;
1060 /* send event to manager */
1061 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1063 case ICO_WINDOW_MGR_WINDOW_ACTIVE: /* active event */
1064 uifw_trace("win_mgr_send_event: Send ACTIVE(surf=%08x, select=%x)",
1066 ico_window_mgr_send_window_active(mgr->resource, surfaceid, arg1);
1068 case ICO_WINDOW_MGR_DESTROY_SURFACE: /* surface destroy event */
1069 uifw_trace("win_mgr_send_event: Send DESTROY_SURFACE(surf=%08x) mgr=%08x",
1070 surfaceid, (int)mgr);
1071 ico_window_mgr_send_destroy_surface(mgr->resource, surfaceid);
1074 uifw_error("win_mgr_send_event: Unknown event(%d)", event);
1080 /*--------------------------------------------------------------------------*/
1082 * @brief win_mgr_select_surface: select surface by mouse click
1084 * @param[in] seat weston seat
1085 * @param[in] focus selected surface
1086 * @param[in] select selected device
1089 /*--------------------------------------------------------------------------*/
1091 win_mgr_select_surface(struct weston_seat *seat, struct weston_surface *focus, int select)
1093 struct weston_surface *surface;
1094 struct uifw_win_surface *usurf;
1095 struct uifw_manager *mgr;
1097 surface = weston_surface_get_main_surface(focus);
1099 uifw_trace("win_mgr_select_surface: Enter(%08x,%d)", (int)surface, select);
1102 uifw_trace("win_mgr_select_surface: Leave(no surface)");
1106 usurf = find_uifw_win_surface_by_ws(surface);
1108 uifw_trace("win_mgr_select_surface: Leave(usurf not exist)");
1111 /* surface active */
1112 weston_surface_activate(surface, seat);
1114 /* send active event to manager */
1115 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1116 uifw_trace("win_mgr_select_surface: Send Manager ACTIVE(surf=%08x)",
1118 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
1121 uifw_trace("win_mgr_select_surface: Leave");
1124 /*--------------------------------------------------------------------------*/
1126 * @brief win_mgr_click_to_activate: select surface by mouse click
1128 * @param[in] seat weston seat
1129 * @param[in] time click time(current time)
1130 * @param[in] button click button
1131 * @param[in] data user data(unused)
1134 /*--------------------------------------------------------------------------*/
1136 win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
1137 uint32_t button, void *data)
1139 if (seat->pointer->grab != &seat->pointer->default_grab)
1141 if (seat->pointer->focus == NULL)
1144 win_mgr_select_surface(seat, seat->pointer->focus->surface,
1145 ICO_WINDOW_MGR_SELECT_POINTER);
1148 /*--------------------------------------------------------------------------*/
1150 * @brief win_mgr_touch_to_activate: select surface by touch touch-panel
1152 * @param[in] seat weston seat
1153 * @param[in] time click time(current time)
1154 * @param[in] data user data(unused)
1157 /*--------------------------------------------------------------------------*/
1159 win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time, void *data)
1161 if (seat->touch->grab != &seat->touch->default_grab)
1163 if (seat->touch->focus == NULL)
1166 win_mgr_select_surface(seat, seat->touch->focus->surface, ICO_WINDOW_MGR_SELECT_TOUCH);
1169 /*--------------------------------------------------------------------------*/
1171 * @brief ico_ivi_surfaceCreateNotification: create ivi-surface
1173 * @param[in] ivisurf ivi surface
1174 * @param[in] userdata User Data(Unused)
1177 /*--------------------------------------------------------------------------*/
1179 ico_ivi_surfaceCreateNotification(struct ivi_layout_surface *ivisurf, void *userdata)
1181 uint32_t id_surface;
1182 struct weston_view *ev;
1183 struct weston_surface *es;
1184 struct wl_client *client;
1186 id_surface = ivi_layout_get_id_of_surface(ivisurf);
1187 uifw_trace("ico_ivi_surfaceCreateNotification: Create %x", id_surface);
1189 /* set property notification */
1190 if (ivi_layout_surface_add_notification(ivisurf, ico_ivi_surfacePropertyNotification, NULL) != 0) {
1191 uifw_error("ico_ivi_surfaceCreateNotification: ivi_layout_surface_add_notification Error");
1193 ev = ivi_layout_interface.get_weston_view(ivisurf);
1195 uifw_error("ico_ivi_surfaceCreateNotification: ivi_layout_interface.get_weston_view Error");
1200 uifw_error("ico_ivi_surfaceCreateNotification: no weston_surface");
1203 client = wl_resource_get_client(es->resource);
1205 uifw_error("ico_ivi_surfaceCreateNotification: no wl_client");
1208 win_mgr_register_surface(id_surface, es, client, ivisurf);
1214 /*--------------------------------------------------------------------------*/
1216 * @brief ico_ivi_surfaceRemoveNotification: remove ivi-surface
1218 * @param[in] ivisurf ivi surface
1219 * @param[in] userdata User Data(Unused)
1222 /*--------------------------------------------------------------------------*/
1224 ico_ivi_surfaceRemoveNotification(struct ivi_layout_surface *ivisurf, void *userdata)
1226 uint32_t id_surface;
1227 struct weston_surface *es;
1228 struct uifw_win_surface *usurf;
1230 id_surface = ivi_layout_get_id_of_surface(ivisurf);
1231 uifw_trace("ico_ivi_surfaceRemoveNotification: Remove %x", id_surface);
1233 usurf = ico_window_mgr_get_usurf(id_surface);
1235 uifw_trace("ico_ivi_surfaceRemoveNotification: surface %08x dose not exist", id_surface);
1238 es = usurf->surface;
1240 uifw_trace("ico_ivi_surfaceRemoveNotification: no weston_surface");
1243 win_mgr_destroy_surface(es);
1248 /*--------------------------------------------------------------------------*/
1250 * @brief ico_ivi_surfacePropertyNotification: property change ivi-surface
1252 * @param[in] ivisurf ivi surface
1253 * @param[in] userdata User Data(Unused)
1256 /*--------------------------------------------------------------------------*/
1258 ico_ivi_surfacePropertyNotification(struct ivi_layout_surface *ivisurf,
1259 const struct ivi_layout_surface_properties *prop,
1260 enum ivi_layout_notification_mask mask,
1263 struct uifw_manager *mgr;
1264 uint32_t id_surface;
1269 struct uifw_win_surface *usurf;
1270 struct weston_view *ev;
1272 newmask = ((uint32_t)mask) & (~(IVI_NOTIFICATION_OPACITY|IVI_NOTIFICATION_ORIENTATION|
1273 IVI_NOTIFICATION_PIXELFORMAT));
1274 id_surface = ivi_layout_get_id_of_surface(ivisurf);
1275 usurf = ico_window_mgr_get_usurf(id_surface);
1277 if ((usurf != NULL) && (newmask != 0) && (usurf->internal_propchange == 0)) {
1278 uifw_trace("ico_ivi_surfacePropertyNotification: Property %x(%08x) usurf=%08x",
1279 id_surface, newmask, (int)usurf);
1282 send_visible = usurf->visible;
1283 if (newmask & (IVI_NOTIFICATION_SOURCE_RECT|IVI_NOTIFICATION_DEST_RECT|
1284 IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION)) {
1285 /* change position or size */
1286 uifw_trace("ico_ivi_surfacePropertyNotification: %08x x/y=%d/%d->%d/%d "
1287 "w/h=%d/%d->%d/%d(%d/%d)", id_surface, usurf->x, usurf->y,
1288 prop->dest_x, prop->dest_y, usurf->width, usurf->height,
1289 prop->dest_width, prop->dest_height,
1290 prop->source_width, prop->source_height);
1291 if ((usurf->client_width == prop->source_width) &&
1292 (usurf->client_height == prop->source_height)) {
1293 newmask &= (~IVI_NOTIFICATION_SOURCE_RECT);
1296 usurf->client_width = prop->source_width;
1297 usurf->client_height = prop->source_height;
1300 if ((usurf->x == prop->dest_x) && (usurf->y == prop->dest_y) &&
1301 (usurf->width == prop->dest_width) && (usurf->height == prop->dest_height)) {
1302 newmask &= (~(IVI_NOTIFICATION_DEST_RECT|
1303 IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION));
1307 usurf->x = prop->dest_x;
1308 usurf->y = prop->dest_y;
1309 usurf->width = prop->dest_width;
1310 usurf->height = prop->dest_height;
1311 if ((usurf->width != usurf->configure_width) ||
1312 (usurf->height != usurf->configure_height)) {
1313 /* send configure to client(App) */
1314 uifw_trace("ico_ivi_surfacePropertyNotification: send configure "
1315 "%08x(%d,%d->%d,%d)", usurf->surfaceid,
1316 usurf->configure_width, usurf->configure_height,
1317 usurf->width, usurf->height);
1318 usurf->configure_width = usurf->width;
1319 usurf->configure_height = usurf->height;
1321 struct wl_array surfaces;
1322 struct shell_surface;
1324 if (! usurf->shsurf_resource) {
1325 /* get shell surface if not get */
1326 ivi_shell_get_shell_surfaces(&surfaces);
1327 wl_array_for_each(shsurf, &surfaces) {
1328 if (shell_surface_get_surface(*shsurf) == usurf->surface) {
1329 usurf->shsurf_resource = *((struct wl_resource **)*shsurf);
1333 wl_array_release(&surfaces);
1336 if (usurf->shsurf_resource) {
1337 uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
1339 usurf->surfaceid, (int)usurf->shsurf_resource);
1340 wl_shell_surface_send_configure(usurf->shsurf_resource,
1341 WL_SHELL_SURFACE_RESIZE_RIGHT|
1342 WL_SHELL_SURFACE_RESIZE_BOTTOM,
1343 usurf->configure_width, usurf->configure_height);
1346 uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
1347 "shell_surface resource not found", usurf->surfaceid);
1352 if (newmask & IVI_NOTIFICATION_VISIBILITY) {
1353 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1354 (win_mgr_hook_animation != NULL)) {
1355 /* start animation, save original position of surface */
1356 usurf->animation.pos_x = usurf->x;
1357 usurf->animation.pos_y = usurf->y;
1358 usurf->animation.pos_width = usurf->width;
1359 usurf->animation.pos_height = usurf->height;
1360 ev = ivi_layout_interface.get_weston_view(ivisurf);
1362 usurf->animation.alpha = ev->alpha;
1365 usurf->animation.alpha = 1.0;
1368 if ((prop->visibility != 0) &&
1369 ((usurf->org_animation.saved !=0) ||
1370 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1371 (usurf->visible == 0)) ||
1372 ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1373 (usurf->animation.visible == ICO_WINDOW_MGR_ANIMA_HIDE_AT_END)))) {
1374 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1",
1379 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1380 (win_mgr_hook_animation != NULL)) {
1381 /* show with animation */
1383 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1385 uifw_trace("ico_ivi_surfacePropertyNotification: ret call anima = %d",
1389 else if ((prop->visibility == 0) &&
1390 ((usurf->org_animation.saved !=0) ||
1391 ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1392 (usurf->visible != 0)) ||
1393 ((usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1394 (usurf->animation.visible == ICO_WINDOW_MGR_ANIMA_SHOW_AT_END)))) {
1395 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0",
1400 if ((usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1401 (win_mgr_hook_animation != NULL)) {
1402 /* hide with animation */
1404 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1408 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1410 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1412 uifw_trace("ico_ivi_surfacePropertyNotification: Change to UnVisible");
1416 uifw_trace("ico_ivi_surfacePropertyNotification: Change to Visible");
1417 usurf->internal_propchange |= 0x01;
1418 ivi_layout_surface_set_visibility(ivisurf, 1);
1419 ivi_layout_commit_changes();
1420 usurf->internal_propchange &= ~0x01;
1424 uifw_trace("ico_ivi_surfacePropertyNotification: visible no change");
1425 newmask &= (~IVI_NOTIFICATION_VISIBILITY);
1429 if (send_event > 0) {
1430 /* surface changed, send event to controller */
1431 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1432 uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x) "
1433 "v=%d src=%d/%d dest=%d/%d(%d/%d) mgr=%08x", id_surface,
1434 send_visible, usurf->client_width, usurf->client_height,
1435 usurf->x, usurf->y, usurf->width, usurf->height, (int)mgr);
1436 ico_window_mgr_send_update_surface(mgr->resource, id_surface,
1437 send_visible, usurf->client_width,
1438 usurf->client_height, usurf->x, usurf->y,
1439 usurf->width, usurf->height);
1445 /*--------------------------------------------------------------------------*/
1447 * @brief win_mgr_register_surface: create UIFW surface
1449 * @param[in] id_surface surface id (by ivi-shell)
1450 * @param[in] surface Weston surface
1451 * @param[in] client Wayland client
1452 * @param[in] ivisurf weston layout surface
1455 /*--------------------------------------------------------------------------*/
1457 win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
1458 struct wl_client *client, struct ivi_layout_surface *ivisurf)
1460 const struct ivi_layout_surface_properties *prop;
1461 struct uifw_win_surface *usurf;
1462 struct uifw_win_surface *phash;
1463 struct uifw_win_surface *bhash;
1466 uifw_trace("win_mgr_register_surface: Enter(surf=%x[%08x],client=%08x,ivisurf=%08x)",
1467 id_surface, (int)surface, (int)client, (int)ivisurf);
1469 /* check new surface */
1470 if (find_uifw_win_surface_by_ws(surface)) {
1471 /* surface exist, NOP */
1472 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
1476 /* create UIFW surface management table */
1477 usurf = malloc(sizeof(struct uifw_win_surface));
1479 uifw_error("win_mgr_register_surface: No Memory");
1483 memset(usurf, 0, sizeof(struct uifw_win_surface));
1485 usurf->surfaceid = id_surface;
1486 usurf->surface = surface;
1487 usurf->ivisurf = ivisurf;
1488 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
1490 if ((prop = ivi_layout_get_properties_of_surface(ivisurf))) {
1491 usurf->x = prop->dest_x;
1492 usurf->y = prop->dest_y;
1493 usurf->width = prop->dest_width;
1494 usurf->height = prop->dest_height;
1495 usurf->client_width = prop->source_width;
1496 usurf->client_height = prop->source_height;
1497 usurf->configure_width = usurf->client_width;
1498 usurf->configure_height = usurf->client_height;
1500 wl_list_init(&usurf->surface_destroy_listener.link);
1501 usurf->surface_destroy_listener.notify = win_mgr_surf_destroylistener;
1502 wl_signal_add(&surface->destroy_signal, &usurf->surface_destroy_listener);
1504 wl_list_init(&usurf->client_link);
1505 wl_list_init(&usurf->animation.animation.link);
1506 wl_list_init(&usurf->surf_map);
1507 wl_list_init(&usurf->input_region);
1508 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
1509 usurf->animation.hide_time = ico_ivi_default_animation_time();
1510 usurf->animation.show_anima = usurf->animation.hide_anima;
1511 usurf->animation.show_time = usurf->animation.hide_time;
1512 usurf->animation.move_anima = usurf->animation.hide_anima;
1513 usurf->animation.move_time = usurf->animation.hide_time;
1514 usurf->animation.resize_anima = usurf->animation.hide_anima;
1515 usurf->animation.resize_time = usurf->animation.hide_time;
1519 usurf->uclient = ico_window_mgr_find_uclient(client);
1520 if (! usurf->uclient) {
1521 /* client not exist, create client management table */
1522 uifw_trace("win_mgr_register_surface: Create Client");
1523 win_mgr_bind_client(client, NULL);
1524 usurf->uclient = ico_window_mgr_find_uclient(client);
1525 if (! usurf->uclient) {
1526 uifw_error("win_mgr_register_surface: No Memory");
1530 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1532 /* make surface id hash table */
1533 hash = MAKE_IDHASH(usurf->surfaceid);
1534 phash = _ico_win_mgr->idhash[hash];
1538 phash = phash->next_idhash;
1541 bhash->next_idhash = usurf;
1544 _ico_win_mgr->idhash[hash] = usurf;
1547 /* make weston surface hash table */
1548 hash = MAKE_WSHASH(usurf->surface);
1549 phash = _ico_win_mgr->wshash[hash];
1553 phash = phash->next_wshash;
1556 bhash->next_wshash = usurf;
1559 _ico_win_mgr->wshash[hash] = usurf;
1561 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1564 /*--------------------------------------------------------------------------*/
1566 * @brief uifw_set_animation: set animation of surface visible/unvisible
1568 * @param[in] client Weyland client
1569 * @param[in] resource resource of request
1570 * @param[in] surfaceid UIFW surface id
1571 * @param[in] type how to change surface
1572 * @param[in] anmation animation name
1573 * @param[in] time animation time(ms), if 0, default time
1576 /*--------------------------------------------------------------------------*/
1578 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1579 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1582 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1584 uifw_trace("uifw_set_animation: surf=%08x,type=%x,anim=%s,time=%d",
1585 surfaceid, type, animation, time);
1588 if ((*animation != 0) && (*animation != ' ')) {
1589 animaid = ico_get_animation_name(animation);
1590 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1591 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) {
1592 if (! usurf->org_animation.saved) {
1593 usurf->org_animation.type = usurf->animation.type;
1594 usurf->org_animation.anima = usurf->animation.anima;
1595 usurf->org_animation.next_anima = usurf->animation.next_anima;
1596 usurf->org_animation.hide_anima = usurf->animation.hide_anima;
1597 usurf->org_animation.hide_time = usurf->animation.hide_time;
1598 usurf->org_animation.show_anima = usurf->animation.show_anima;
1599 usurf->org_animation.show_time = usurf->animation.show_time;
1600 usurf->org_animation.move_anima = usurf->animation.move_anima;
1601 usurf->org_animation.move_time = usurf->animation.move_time;
1602 usurf->org_animation.resize_anima = usurf->animation.resize_anima;
1603 usurf->org_animation.resize_time = usurf->animation.resize_time;
1604 usurf->org_animation.saved = 1;
1607 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1608 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1609 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1610 usurf->animation.next_anima = animaid;
1611 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1612 usurf->org_animation.next_anima = animaid;
1615 usurf->animation.hide_anima = animaid;
1616 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1617 usurf->org_animation.hide_anima = animaid;
1620 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1621 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1622 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1623 usurf->animation.next_anima = animaid;
1624 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1625 usurf->org_animation.next_anima = animaid;
1628 usurf->animation.show_anima = animaid;
1629 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1630 usurf->org_animation.show_anima = animaid;
1633 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1634 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
1635 usurf->animation.next_anima = animaid;
1636 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1637 usurf->org_animation.next_anima = animaid;
1640 usurf->animation.move_anima = animaid;
1641 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1642 usurf->org_animation.move_anima = animaid;
1645 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1646 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
1647 usurf->animation.next_anima = animaid;
1648 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1649 usurf->org_animation.next_anima = animaid;
1652 usurf->animation.resize_anima = animaid;
1653 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1654 usurf->org_animation.resize_anima = animaid;
1658 if ((time > 0) && (time < 10000)) {
1659 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1660 usurf->animation.hide_time = time;
1661 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1662 usurf->org_animation.hide_time = time;
1664 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1665 usurf->animation.show_time = time;
1666 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1667 usurf->org_animation.show_time = time;
1669 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1670 usurf->animation.move_time = time;
1671 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1672 usurf->org_animation.move_time = time;
1674 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1675 usurf->animation.resize_time = time;
1676 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1677 usurf->org_animation.resize_time = time;
1682 uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid);
1686 /*--------------------------------------------------------------------------*/
1688 * @brief win_mgr_check_mapsurface: check and change all surface
1690 * @param[in] animation weston animation table(unused)
1691 * @param[in] outout weston output table(unused)
1692 * @param[in] mseces current time(unused)
1695 /*--------------------------------------------------------------------------*/
1697 win_mgr_check_mapsurface(struct weston_animation *animation,
1698 struct weston_output *output, uint32_t msecs)
1700 struct uifw_surface_map *sm, *sm_tmp;
1702 int wait = 99999999;
1704 /* check touch down counter */
1705 if ((touch_check_seat) &&
1706 (touch_check_seat->touch)) {
1707 if (touch_check_seat->touch->num_tp > 10) {
1708 uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset",
1709 (int)touch_check_seat->touch->num_tp);
1710 touch_check_seat->touch->num_tp = 0;
1714 /* check all mapped surfaces */
1715 curtime = weston_compositor_get_time();
1716 wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) {
1717 #if 0 /* too many log */
1718 uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x",
1719 (int)sm, sm->usurf->surfaceid);
1721 if ((sm->interval >= 0) || (sm->eventque == 0)) {
1722 win_mgr_change_mapsurface(sm, 0, curtime);
1723 if (sm->interval < wait) {
1724 wait = sm->interval;
1729 /* check frame interval */
1732 if (wait < 33) wait = 33; /* mimimum 33ms (30fsp) */
1735 wait = ICO_WINDOW_MGR_THUMBNAIL_WAITTIME; /* maximum 1000ms */
1737 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait);
1740 /*--------------------------------------------------------------------------*/
1742 * @brief win_mgr_timer_mapsurface: mapped surface check timer
1744 * @param[in] data user data(unused)
1747 /*--------------------------------------------------------------------------*/
1749 win_mgr_timer_mapsurface(void *data)
1751 win_mgr_check_mapsurface(NULL, NULL, 0);
1755 /*--------------------------------------------------------------------------*/
1757 * @brief win_mgr_change_mapsurface: check and change mapped surface
1759 * @param[in] sm map surface table
1760 * @param[in] event send event (if 0, send if changed)
1761 * @param[in] curtime current time(ms)
1764 /*--------------------------------------------------------------------------*/
1766 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime)
1768 struct weston_surface *es;
1769 struct wl_shm_buffer *shm_buffer;
1775 #if 0 /* too many log */
1776 uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event);
1779 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
1782 /* check if buffered */
1783 es = sm->usurf->surface;
1785 ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) &&
1786 ((es->buffer_ref.buffer == NULL) ||
1787 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) {
1788 /* surface has no buffer */
1789 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x",
1790 sm->usurf->surfaceid, (int)es,
1791 es ? (int)es->buffer_ref.buffer : 0);
1793 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1799 else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1800 if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) {
1801 if ((void *)wl_resource_get_user_data(
1802 (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer)
1804 /* surface has no buffer */
1805 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer",
1806 sm->usurf->surfaceid);
1808 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1817 if (es->buffer_ref.buffer != NULL) {
1818 shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource);
1820 format = wl_shm_buffer_get_format(shm_buffer);
1821 if (format != WL_SHM_FORMAT_ARGB8888) {
1822 uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x",
1823 sm->usurf->surfaceid, format);
1824 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1830 if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) {
1832 if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1833 format = EGL_TEXTURE_RGBA; /* currently only support RGBA */
1834 width = es->buffer_ref.buffer->width;
1835 height = es->buffer_ref.buffer->height;
1836 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1838 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1839 #if PERFORMANCE_EVALUATIONS > 0
1840 uifw_perf("SWAP_BUFFER appid=%s surface=%08x MAP",
1841 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1842 #endif /*PERFORMANCE_EVALUATIONS*/
1844 else if ((width <= 0) || (height <= 0)) {
1847 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1848 if ((sm->width != width) || (sm->height != height) ||
1849 (format != sm->format)) {
1850 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1851 #if PERFORMANCE_EVALUATIONS > 0
1852 uifw_perf("SWAP_BUFFER appid=%s surface=%08x RESIZE",
1853 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1854 #endif /*PERFORMANCE_EVALUATIONS*/
1857 dtime = (int)((curtime - sm->lasttime) & 0x7fffffff);
1858 if ((es->buffer_ref.buffer->legacy_buffer != sm->curbuf) ||
1859 ((sm->interval >= 0) &&
1860 (dtime >= ICO_WINDOW_MGR_THUMBNAIL_WAITTIME))) {
1861 #if PERFORMANCE_EVALUATIONS > 0
1862 if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) {
1863 uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
1864 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1866 #endif /*PERFORMANCE_EVALUATIONS*/
1867 if (sm->interval < 0) {
1871 else if (sm->interval > 0) {
1872 if (dtime < sm->interval) {
1878 else if (sm->eventque) {
1879 if (sm->interval < 0) {
1882 else if (sm->interval > 0) {
1883 if (dtime < sm->interval) {
1894 sm->height = height;
1895 sm->stride = width * 4;
1896 sm->format = format;
1897 sm->curbuf = es->buffer_ref.buffer->legacy_buffer;
1900 dtime = (int)((curtime - sm->lasttime) & 0x7fffffff);
1901 if ((sm->eventque != 0) ||
1902 (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf) ||
1903 ((sm->interval >= 0) &&
1904 (dtime >= ICO_WINDOW_MGR_THUMBNAIL_WAITTIME))) {
1905 sm->curbuf = es->buffer_ref.buffer;
1906 if (es->buffer_ref.buffer != NULL) {
1907 width = es->buffer_ref.buffer->width;
1908 height = es->buffer_ref.buffer->height;
1912 height = es->height;
1914 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1916 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1917 uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x",
1918 sm->usurf->surfaceid);
1921 if ((width <= 0) || (height <= 0)) {
1924 uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0",
1925 sm->usurf->surfaceid);
1927 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1928 #if PERFORMANCE_EVALUATIONS > 0
1929 if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) {
1930 uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
1931 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1933 #endif /*PERFORMANCE_EVALUATIONS*/
1934 if ((sm->width != width) || (sm->height != height)) {
1935 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1938 if (sm->interval < 0) {
1942 else if (sm->interval > 0) {
1943 if (dtime < sm->interval) {
1952 sm->height = height;
1953 sm->stride = width * 4;
1954 sm->format = EGL_TEXTURE_RGBA;
1963 uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d "
1964 "w/h/s=%d/%d/%d format=%x file=<%s>",
1965 event, sm->usurf->surfaceid, sm->type,
1966 sm->width, sm->height, sm->stride, sm->format, sm->filepath);
1967 sm->lasttime = curtime;
1969 if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) &&
1970 (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP) &&
1971 (sm->filepath[0] != 0)) {
1972 #if 1 /* ivi_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1973 if (win_mgr_takeSurfaceScreenshot(sm->filepath, sm->usurf,
1974 sm->width, sm->height) != 0)
1975 #else /* ivi_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1976 if (ivi_layout_takeSurfaceScreenshot(sm->filepath,
1977 sm->usurf->ivisurf) != 0)
1978 #endif /* ivi_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1980 uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error",
1981 sm->usurf->surfaceid, sm->filepath);
1982 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
1985 uifw_trace("win_mgr_change_mapsurface: surface.%08x image read(%s) OK",
1986 sm->usurf->surfaceid, sm->filepath);
1989 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
1990 sm->usurf->surfaceid, sm->type,
1991 sm->width, sm->height, sm->stride, sm->format);
1992 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
1993 /* free map table if error */
1994 wl_list_remove(&sm->surf_link);
1995 wl_list_remove(&sm->map_link);
1996 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
1997 _ico_win_mgr->free_maptable = sm;
2002 /*--------------------------------------------------------------------------*/
2004 * @brief uifw_map_surface: mapped surface buffer to system application
2006 * @param[in] client Weyland client
2007 * @param[in] resource resource of request
2008 * @param[in] surfaceid surface id
2009 * @param[in] framerate frame rate of surface update(frame/sec)
2010 * if over 999, no change
2011 * @param[in] filepath surface image file path(if NULL, not create file)
2014 /*--------------------------------------------------------------------------*/
2016 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
2017 uint32_t surfaceid, int32_t framerate, const char *filepath)
2019 struct uifw_win_surface *usurf;
2020 struct weston_surface *es;
2021 struct uifw_surface_map *sm;
2022 struct weston_buffer *buffer;
2023 struct wl_shm_buffer *shm_buffer;
2024 struct uifw_client *uclient;
2025 struct uifw_gl_surface_state *gl_state;
2029 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d,file=%s)",
2030 surfaceid, framerate, filepath ? filepath : "(null)");
2032 uclient = ico_window_mgr_find_uclient(client);
2033 usurf = ico_window_mgr_get_usurf(surfaceid);
2035 /* surface dose not exist, error */
2036 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2037 surfaceid, 1, 0, 0, 0, 0);
2038 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
2042 /* check if buffered */
2043 es = usurf->surface;
2045 /* surface has no buffer, error */
2046 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2047 surfaceid, 2, 0, 0, 0, 0);
2048 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid);
2051 buffer = es->buffer_ref.buffer;
2053 /* check buffer type */
2054 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2055 if (gl_state == NULL) {
2056 ico_window_mgr_send_map_surface(resource,
2057 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2058 surfaceid, 3, 0, 0, 0, 0);
2059 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no gl_state)", surfaceid);
2062 else if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2065 if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) {
2066 if (buffer != NULL) {
2067 shm_buffer = wl_shm_buffer_get(buffer->resource);
2069 format = wl_shm_buffer_get_format(shm_buffer);
2070 uifw_detail("uifw_map_surface: %08x shm_buffer type %x",
2072 if (format == WL_SHM_FORMAT_ARGB8888) {
2073 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
2078 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
2082 ico_window_mgr_send_map_surface(resource,
2083 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2084 surfaceid, 4, 0, 0, 0, 0);
2085 uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))",
2091 maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL;
2094 /* maximum framerate */
2095 if (framerate >= 0) {
2096 if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2097 if (framerate > 30) framerate = 30;
2100 if ((framerate <= 0) || (framerate > 5)) framerate = 5;
2104 /* check same surface */
2105 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2106 if ((sm->usurf == usurf) && (sm->uclient == uclient)) {
2111 if (&sm->surf_link == &usurf->surf_map) {
2112 /* create map table */
2113 sm = _ico_win_mgr->free_maptable;
2115 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
2118 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
2120 ico_window_mgr_send_map_surface(resource,
2121 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2122 surfaceid, 5, 0, 0, 0, 0);
2123 uifw_trace("uifw_map_surface: Leave(malloc error)");
2127 memset(sm, 0, sizeof(struct uifw_surface_map));
2129 wl_list_init(&sm->map_link);
2130 wl_list_init(&sm->surf_link);
2132 sm->uclient = uclient;
2134 sm->framerate = framerate;
2135 if (framerate < 0) sm->interval = -1;
2136 else sm->interval = (1000 / sm->framerate) - 1;
2137 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
2138 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
2141 /* change frame rate */
2142 uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d",
2143 sm->framerate, framerate);
2144 if (sm->framerate != framerate) {
2145 sm->framerate = framerate;
2146 if (framerate < 0) sm->interval = -1;
2147 else sm->interval = (1000 / sm->framerate) - 1;
2148 win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time());
2153 memset(sm->filepath, 0, ICO_IVI_FILEPATH_LENGTH);
2154 if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) {
2155 strncpy(sm->filepath, filepath, ICO_IVI_FILEPATH_LENGTH-1);
2158 if (buffer != NULL) {
2159 sm->width = buffer->width;
2160 sm->height = buffer->height;
2161 if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2162 sm->stride = sm->width * 4;
2163 sm->format = EGL_TEXTURE_RGBA;
2164 if ((sm->width > 0) && (sm->height > 0)) {
2167 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
2168 maptype, surfaceid, framerate, buffer->width, buffer->height);
2171 if (wl_resource_get_user_data((struct wl_resource *)buffer->legacy_buffer)
2173 sm->format = EGL_TEXTURE_RGBA;
2174 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
2175 (gl_state != NULL)) {
2178 uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d",
2179 surfaceid, framerate, buffer->width, buffer->height);
2182 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
2183 surfaceid, framerate);
2187 else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2188 sm->width = es->width;
2189 sm->height = es->height;
2190 sm->stride = sm->width * 4;
2191 sm->format = EGL_TEXTURE_RGBA;
2192 if ((sm->width > 0) && (sm->height > 0)) {
2195 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
2196 maptype, surfaceid, framerate, sm->width, sm->height);
2199 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
2200 surfaceid, framerate);
2203 /* send map event */
2205 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP,
2206 weston_compositor_get_time());
2208 uifw_trace("uifw_map_surface: Leave");
2211 /*--------------------------------------------------------------------------*/
2213 * @brief uifw_unmap_surface: unmap surface buffer
2215 * @param[in] client Weyland client
2216 * @param[in] resource resource of request
2217 * @param[in] surfaceid surface id
2220 /*--------------------------------------------------------------------------*/
2222 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2225 struct uifw_win_surface *usurf;
2226 struct uifw_surface_map *sm, *sm_tmp;
2227 struct uifw_client *uclient;
2229 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2231 usurf = ico_window_mgr_get_usurf(surfaceid);
2233 /* surface dose not exist, error */
2234 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2238 uclient = ico_window_mgr_find_uclient(client);
2239 if ((! uclient) || (! uclient->mgr)) {
2240 /* client dose not exist, error */
2241 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2247 wl_list_for_each (sm, &usurf->surf_map, surf_link) {
2248 if (sm->uclient->mgr != NULL) {
2249 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x "
2250 "w/h/s=%d/%d/%d format=%x",
2251 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2252 sm->width, sm->height, sm->stride, sm->format);
2253 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2254 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2255 surfaceid, sm->type, sm->width,
2256 sm->height, sm->stride, sm->format);
2260 wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) {
2261 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2262 wl_list_remove(&sm->surf_link);
2263 wl_list_remove(&sm->map_link);
2264 if (sm->filepath[0]) {
2265 unlink(sm->filepath);
2267 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2268 _ico_win_mgr->free_maptable = sm;
2270 uifw_trace("uifw_unmap_surface: Leave");
2273 /*--------------------------------------------------------------------------*/
2275 * @brief uifw_layout_surface: direct layout surface
2277 * @param[in] client Weyland client
2278 * @param[in] resource resource of request
2279 * @param[in] surfaceid surface id
2280 * @param[in] layerid layer id
2283 * @param[in] width width
2284 * @param[in] height height
2285 * @param[in] visible visiblity
2288 /*--------------------------------------------------------------------------*/
2290 uifw_layout_surface(struct wl_client *client, struct wl_resource *resource,
2291 uint32_t surfaceid, uint32_t layerid, int x, int y,
2292 int width, int height, int visible)
2294 struct uifw_win_surface *usurf;
2295 struct ivi_layout_layer *layout_layer;
2296 int32_t position[2];
2297 uint32_t dimension[2];
2299 uifw_trace("uifw_layout_surface: Enter(surf=%08x,layer=%d,x/y=%d/%d,w/h=%d,%d,vis=%d)",
2300 surfaceid, layerid, x, y, width, height, visible);
2302 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2304 /* surface dose not exist, error */
2305 uifw_trace("uifw_layout_surface: Leave(surface=%08x dose not exist)", surfaceid);
2309 layout_layer = ivi_layout_get_layer_from_id(layerid);
2310 if (! layout_layer) {
2311 /* layer dose not exist */
2312 uifw_trace("uifw_layout_surface: Leave(layer=%d dose not exist)", layerid);
2315 if (ivi_layout_layer_add_surface(layout_layer, usurf->ivisurf) == 0) {
2316 if (ivi_layout_layer_set_visibility(layout_layer, 1) != 0) {
2317 uifw_warn("uifw_layout_surface: layer(%d) visible Error", layerid);
2321 uifw_warn("uifw_layout_surface: can not add surface(%08x) to layer(%d)",
2322 usurf->surfaceid, layerid);
2326 if ((x >= 0) && (y >= 0) && (width > 0) && (height > 0)) {
2327 if (ivi_layout_surface_set_source_rectangle(usurf->ivisurf,
2328 0, 0, width, height) != 0) {
2329 uifw_warn("uifw_layout_surface: surface(%08x) can not set source",
2332 if (ivi_layout_surface_set_destination_rectangle(usurf->ivisurf,
2333 x, y, width, height) != 0) {
2334 uifw_warn("uifw_layout_surface: surface(%08x) can not set destination",
2338 else if ((x >= 0) && (y >= 0)) {
2341 if (ivi_layout_surface_set_position(usurf->ivisurf, position[0], position[1]) != 0) {
2342 uifw_warn("uifw_layout_surface: surface(%08x) can not set source position",
2346 else if ((width > 0) && (height > 0)) {
2347 if (ivi_layout_surface_set_source_rectangle(usurf->ivisurf,
2348 0, 0, width, height) != 0) {
2349 uifw_warn("uifw_layout_surface: surface(%08x) can not set source",
2352 dimension[0] = width;
2353 dimension[1] = height;
2354 if (ivi_layout_surface_set_dimension(usurf->ivisurf, dimension[0], dimension[1]) != 0) {
2355 uifw_warn("uifw_layout_surface: surface(%08x) can not set destination size",
2359 usurf->internal_propchange |= 0x02;
2361 if (ivi_layout_surface_set_visibility(usurf->ivisurf, visible) != 0) {
2362 uifw_warn("uifw_layout_surface: surface(%08x) can not set visibility",
2366 if (ivi_layout_commit_changes() != 0) {
2367 uifw_warn("uifw_layout_surface: surface(%08x) commit Error", usurf->surfaceid);
2369 usurf->internal_propchange &= ~0x02;
2370 uifw_trace("uifw_layout_surface: Leave");
2373 /*--------------------------------------------------------------------------*/
2375 * @brief win_mgr_destroy_surface: surface destroy
2377 * @param[in] surface Weston surface
2380 /*--------------------------------------------------------------------------*/
2382 win_mgr_destroy_surface(struct weston_surface *surface)
2384 struct uifw_win_surface *usurf;
2385 struct uifw_win_surface *phash;
2386 struct uifw_win_surface *bhash;
2389 usurf = find_uifw_win_surface_by_ws(surface);
2391 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
2394 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
2396 /* remove notification listener */
2397 ivi_layout_surface_remove_notification(usurf->ivisurf);
2399 /* destory input region */
2400 if (win_mgr_hook_destory) {
2401 (*win_mgr_hook_destory)(usurf);
2405 if (&usurf->surf_map != usurf->surf_map.next) {
2406 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
2409 /* destroy animation extenson */
2410 if (win_mgr_hook_animation) {
2411 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
2414 /* remove destroy listener */
2415 wl_list_remove(&usurf->surface_destroy_listener.link);
2417 /* send destroy event to controller */
2418 win_mgr_send_event(ICO_WINDOW_MGR_DESTROY_SURFACE, usurf->surfaceid, 0);
2420 /* delete from cleint list */
2421 wl_list_remove(&usurf->client_link);
2423 /* delete from hash table */
2424 hash = MAKE_IDHASH(usurf->surfaceid);
2425 phash = _ico_win_mgr->idhash[hash];
2427 while ((phash) && (phash != usurf)) {
2429 phash = phash->next_idhash;
2432 bhash->next_idhash = usurf->next_idhash;
2435 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
2438 hash = MAKE_WSHASH(usurf->surface);
2439 phash = _ico_win_mgr->wshash[hash];
2441 while ((phash) && (phash != usurf)) {
2443 phash = phash->next_wshash;
2446 bhash->next_wshash = usurf->next_wshash;
2449 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
2453 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
2456 /*--------------------------------------------------------------------------*/
2458 * @brief win_mgr_surf_destroylistener: weston_surface destroy listener
2460 * @param[in] listener listener
2461 * @param[in] data data (unused)
2464 /*--------------------------------------------------------------------------*/
2466 win_mgr_surf_destroylistener(struct wl_listener *listener, void *data)
2468 struct uifw_win_surface *usurf = container_of(listener, struct uifw_win_surface,
2469 surface_destroy_listener);
2471 if (usurf && usurf->surface && usurf->ivisurf) {
2472 uifw_trace("win_mgr_surf_destroylistener: Enter(%08x)", usurf->surfaceid);
2473 ivi_layout_surface_remove(usurf->ivisurf);
2474 uifw_trace("win_mgr_surf_destroylistener: Leave");
2478 /*--------------------------------------------------------------------------*/
2480 * @brief win_mgr_takeSurfaceScreenshot: take screen image pixel
2482 * @param[in] filename output file path
2483 * @param[in] usurf UIFW surface
2484 * @param[in] width surface width
2485 * @param[in] height surface height
2490 /*--------------------------------------------------------------------------*/
2492 win_mgr_takeSurfaceScreenshot(const char *filename, struct uifw_win_surface *usurf,
2493 int width, int height)
2504 #pragma pack(push, 1)
2525 uifw_trace("win_mgr_takeSurfaceScreenshot: Enter(%08x) <%s>",
2526 usurf->surfaceid, filename);
2528 if (! _ico_win_mgr->compositor->renderer->read_surface_pixels) {
2529 uifw_trace("win_mgr_takeSurfaceScreenshot: Leave(no read_surface_pixels)");
2532 bitperpixel = PIXMAN_FORMAT_BPP(_ico_win_mgr->compositor->read_format);
2533 bmphead_size = ((sizeof(struct _bmphead) + 31) / 32) * 32;
2534 datasize = (width * bitperpixel / 8) * height;
2535 bufsize = datasize + bmphead_size;
2536 if ((_ico_win_mgr->pixel_readbuf != NULL) &&
2537 (bufsize > _ico_win_mgr->pixel_readsize)) {
2538 free(_ico_win_mgr->pixel_readbuf);
2539 _ico_win_mgr->pixel_readbuf = NULL;
2541 if (_ico_win_mgr->pixel_readbuf == NULL) {
2542 _ico_win_mgr->pixel_readbuf = malloc(bufsize);
2543 if (! _ico_win_mgr->pixel_readbuf) {
2544 uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
2547 _ico_win_mgr->pixel_readsize = bufsize;
2549 pathlen = strlen(filename);
2550 if ((pathlen >= 4) && (strcmp(&filename[pathlen-4], ".bmp") == 0)) {
2552 wkbuf = malloc(datasize);
2554 uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
2558 fd = open(filename, O_WRONLY|O_CREAT, 0644);
2560 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> open Error<%d>)",
2566 uifw_detail("win_mgr_takeSurfaceScreenshot: call read_surface_pixels(%d,%d)",
2568 if ((*(_ico_win_mgr->compositor->
2569 renderer->read_surface_pixels))(usurf->surface, PIXMAN_a8r8g8b8,
2571 (_ico_win_mgr->pixel_readbuf + bmphead_size),
2572 0, 0, width, height) != 0) {
2574 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(read_surface_pixels Error)");
2578 uifw_detail("win_mgr_takeSurfaceScreenshot: end read_surface_pixels");
2582 bmphead = (struct _bmphead *)(_ico_win_mgr->pixel_readbuf +
2583 (bmphead_size - sizeof(struct _bmphead)));
2584 memset(bmphead, 0, sizeof(struct _bmphead));
2585 bmphead->magic = 0x4d42;
2586 bmphead->fullsize = sizeof(struct _bmphead) + datasize;
2587 bmphead->offset = 54;
2588 bmphead->headsize = 40;
2589 bmphead->width = width;
2590 bmphead->height = height;
2591 bmphead->planes = 1;
2592 bmphead->bitperpixel = bitperpixel;
2593 bmphead->compress = 0;
2594 bmphead->datasize = datasize;
2595 bmphead->xp = 100000;
2596 bmphead->yp = 100000;
2599 linesize = width * bitperpixel / 8;
2601 dp = _ico_win_mgr->pixel_readbuf + bmphead_size + (linesize * (height-1));
2602 for (pathlen = 0; pathlen < height; pathlen++) {
2603 memcpy(dp, sp, linesize);
2609 if (write(fd, bmphead, sizeof(struct _bmphead) + datasize) < 0) {
2610 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
2618 if (write(fd, _ico_win_mgr->pixel_readbuf + bmphead_size, datasize) < 0) {
2619 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
2627 uifw_trace("win_mgr_takeSurfaceScreenshot: Leave");
2631 /*--------------------------------------------------------------------------*/
2633 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
2635 * @param[in] client client
2636 * @param[in] data user data(unused)
2637 * @param[in] version protocol version(unused)
2638 * @param[in] id client object id
2641 /*--------------------------------------------------------------------------*/
2643 bind_ico_win_mgr(struct wl_client *client,
2644 void *data, uint32_t version, uint32_t id)
2646 struct wl_resource *add_resource;
2647 struct uifw_manager *mgr;
2648 struct uifw_client *uclient;
2650 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
2652 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
2654 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
2655 _ico_win_mgr, unbind_ico_win_mgr);
2658 /* Create client management tabel */
2659 uclient = ico_window_mgr_find_uclient(client);
2661 win_mgr_bind_client(client, NULL);
2662 uclient = ico_window_mgr_find_uclient(client);
2666 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
2668 uifw_error("bind_ico_win_mgr: Error, No Memory");
2671 memset(mgr, 0, sizeof(struct uifw_manager));
2672 mgr->resource = add_resource;
2676 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
2678 uifw_trace("bind_ico_win_mgr: Leave");
2681 /*--------------------------------------------------------------------------*/
2683 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
2685 * @param[in] resource client resource
2688 /*--------------------------------------------------------------------------*/
2690 unbind_ico_win_mgr(struct wl_resource *resource)
2692 struct uifw_manager *mgr, *itmp;
2694 uifw_trace("unbind_ico_win_mgr: Enter");
2696 /* Remove manager from manager list */
2697 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
2698 if (mgr->resource == resource) {
2699 wl_list_remove(&mgr->link);
2703 uifw_trace("unbind_ico_win_mgr: Leave");
2706 /*--------------------------------------------------------------------------*/
2708 * @brief ico_window_mgr_get_uclient: get UIFW client table
2710 * @param[in] appid application Id
2711 * @return UIFW client table
2712 * @retval !=NULL success(UIFW client table address)
2713 * @retval = NULL error(appid not exist)
2715 /*--------------------------------------------------------------------------*/
2716 WL_EXPORT struct uifw_client *
2717 ico_window_mgr_get_uclient(const char *appid)
2719 struct uifw_client *uclient;
2721 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2722 if (strcmp(uclient->appid, appid) == 0) {
2729 /*--------------------------------------------------------------------------*/
2731 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
2733 * @param[in] target surface window name and application Id(winname@appid)
2734 * @return UIFW surface table
2735 * @retval !=NULL success(UIFW surface table address)
2736 * @retval = NULL error(appid or winname not exist)
2738 /*--------------------------------------------------------------------------*/
2739 WL_EXPORT struct uifw_win_surface *
2740 ico_window_mgr_get_client_usurf(const char *target)
2742 struct uifw_client *uclient;
2743 struct uifw_win_surface *usurf;
2745 char winname[ICO_IVI_WINNAME_LENGTH];
2746 char appid[ICO_IVI_APPID_LENGTH];
2748 /* get window name and application id */
2750 for (i = 0; target[i]; i++) {
2751 if (target[i] == '@') {
2752 if (target[i+1] != '@') break;
2755 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
2756 winname[j++] = target[i];
2760 if (target[i] == '@') {
2768 for ( ; target[i]; i++) {
2769 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
2770 if (j < (ICO_IVI_APPID_LENGTH-1)) {
2771 appid[j++] = target[i];
2775 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
2776 target, appid, winname);
2778 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2779 if (strcmp(uclient->appid, appid) == 0) {
2780 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
2781 if ((winname[0] == 0) ||
2782 (strcmp(winname, usurf->winname) == 0)) {
2791 /*--------------------------------------------------------------------------*/
2793 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
2795 * @param[in] hook_animation hook routine
2798 /*--------------------------------------------------------------------------*/
2800 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
2802 win_mgr_hook_animation = hook_animation;
2805 /*--------------------------------------------------------------------------*/
2807 * @brief ico_window_mgr_set_hook_change: set input region hook routine
2809 * @param[in] hook_change hook routine
2812 /*--------------------------------------------------------------------------*/
2814 ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf))
2816 win_mgr_hook_change = hook_change;
2819 /*--------------------------------------------------------------------------*/
2821 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
2823 * @param[in] hook_destroy hook routine
2826 /*--------------------------------------------------------------------------*/
2828 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
2830 win_mgr_hook_destory = hook_destroy;
2833 /*--------------------------------------------------------------------------*/
2835 * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine
2837 * @param[in] hook_inputregion hook routine
2840 /*--------------------------------------------------------------------------*/
2842 ico_window_mgr_set_hook_inputregion(
2843 void (*hook_inputregion)(int set, struct uifw_win_surface *usurf,
2844 int32_t x, int32_t y, int32_t width,
2845 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
2846 int32_t cursor_x, int32_t cursor_y, int32_t cursor_width,
2847 int32_t cursor_height, uint32_t attr))
2849 win_mgr_hook_inputregion = hook_inputregion;
2852 /*--------------------------------------------------------------------------*/
2854 * @brief module_init: initialize ico_window_mgr
2855 * this function called from ico_pluign_loader
2857 * @param[in] es weston compositor
2858 * @param[in] argc number of arguments(unused)
2859 * @param[in] argv argument list(unused)
2864 /*--------------------------------------------------------------------------*/
2866 module_init(struct weston_compositor *ec, int *argc, char *argv[])
2871 struct weston_output *output;
2872 struct weston_config_section *section;
2873 char *displayno = NULL;
2875 struct wl_event_loop *loop;
2877 uifw_info("ico_window_mgr: Enter(module_init)");
2879 /* get ivi debug level */
2880 section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL);
2882 weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0);
2883 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
2886 /* get display number */
2887 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
2889 weston_config_section_get_string(section, "displayno", &displayno, NULL);
2892 /* get animation default */
2893 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
2895 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
2896 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500);
2897 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30);
2899 if (_ico_ivi_animation_name == NULL)
2900 _ico_ivi_animation_name = (char *)"fade";
2901 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500;
2902 if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30;
2904 /* create ico_window_mgr management table */
2905 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
2906 if (_ico_win_mgr == NULL) {
2907 uifw_error("ico_window_mgr: malloc failed");
2911 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
2913 _ico_win_mgr->compositor = ec;
2915 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
2916 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
2917 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
2918 uifw_error("ico_window_mgr: Error(wl_global_create)");
2922 wl_list_init(&_ico_win_mgr->client_list);
2923 wl_list_init(&_ico_win_mgr->manager_list);
2924 wl_list_init(&_ico_win_mgr->map_list);
2925 _ico_win_mgr->free_maptable = NULL;
2927 /* create display list */
2928 if (displayno != NULL) {
2935 wl_list_for_each (output, &ec->output_list, link) {
2936 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
2937 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurface;
2938 wl_list_insert(output->animation_list.prev,
2939 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
2941 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
2943 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
2945 wl_list_for_each (output, &ec->output_list, link) {
2948 idx = strtol(p, (char **)0, 0);
2949 uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx);
2951 if ((idx < 0) || (idx >= _ico_num_nodes)) {
2958 if (_ico_node_table[idx].node) {
2959 for (idx = 0; idx < _ico_num_nodes; idx++) {
2960 if (_ico_node_table[idx].node == 0) break;
2962 if (idx >= _ico_num_nodes) {
2963 uifw_error("ico_window_mgr: number of display overflow");
2967 _ico_node_table[idx].node = idx + 0x100;
2968 _ico_node_table[idx].displayno = i;
2969 _ico_node_table[idx].output = output;
2970 _ico_node_table[idx].disp_x = output->x;
2971 _ico_node_table[idx].disp_y = output->y;
2972 _ico_node_table[idx].disp_width = output->width;
2973 _ico_node_table[idx].disp_height = output->height;
2975 if (i >= _ico_num_nodes) break;
2978 for (i = 0; i < _ico_num_nodes; i++) {
2979 _ico_node_table[i].node &= 0x0ff;
2980 uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
2981 i, _ico_node_table[i].displayno,
2982 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
2983 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
2987 /* my node Id ... this version fixed 0 */
2988 nodeId = ico_ivi_get_mynode();
2990 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
2991 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
2992 nodeId, _ico_win_mgr->surface_head);
2994 /* get seat for touch down counter check */
2995 touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link);
2996 loop = wl_display_get_event_loop(ec->wl_display);
2997 _ico_win_mgr->wait_mapevent =
2998 wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL);
2999 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000);
3001 uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d",
3002 _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps);
3003 uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x",
3004 _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff,
3005 (_ico_ivi_debug_level >> 16) & 0x0ffff);
3007 /* touch/click binding for select surface */
3008 weston_compositor_add_button_binding(ec, BTN_LEFT, 0, win_mgr_click_to_activate, NULL);
3009 weston_compositor_add_touch_binding(ec, 0, win_mgr_touch_to_activate, NULL);
3011 /* set Notification function for GENIVI ivi-shell */
3012 if (ivi_layout_add_notification_create_surface(ico_ivi_surfaceCreateNotification, NULL) != 0) {
3013 uifw_error("ico_window_mgr: ivi_layout_setNotificationCreateSurface Error");
3015 if (ivi_layout_add_notification_remove_surface(ico_ivi_surfaceRemoveNotification, NULL) != 0) {
3016 uifw_error("ico_window_mgr: ivi_layout_setNotificationRemoveSurface Error");
3019 uifw_info("ico_window_mgr: Leave(module_init)");