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/weston-layout.h>
61 /* detail debug log */
62 #define UIFW_DETAIL_OUT 1 /* 1=detail debug log/0=no detail log */
64 #include <weston/weston-layout.h>
65 #include <weston/ivi-shell-ext.h>
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 weston_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_surface_destroy(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 weston_layout_surface *ivisurf,
202 /* hook for remove surface of ivi-shell */
203 static void ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf,
205 /* hook for property change of ivi-shell*/
206 static void ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf,
207 struct weston_layout_SurfaceProperties *prop,
208 enum weston_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 */
238 /* static management table */
239 static struct ico_win_mgr *_ico_win_mgr = NULL;
240 static int _ico_num_nodes = 0;
241 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
242 static struct weston_seat *touch_check_seat = NULL;
245 /*--------------------------------------------------------------------------*/
247 * @brief ico_ivi_optionflag: get option flags
250 * @return option flags
252 /*--------------------------------------------------------------------------*/
254 ico_ivi_optionflag(void)
256 return _ico_ivi_option_flag;
259 /*--------------------------------------------------------------------------*/
261 * @brief ico_ivi_debuglevel: answer debug output level.
264 * @return debug output level
265 * @retval 0 No debug output
266 * @retval 1 Only error output
267 * @retval 2 Error and Warning output
268 * @retval 3 Error, Warning and information output
269 * @retval 4 Error, Warning, information and Debug Trace output
270 * @retval 5 All output with debug write
272 /*--------------------------------------------------------------------------*/
274 ico_ivi_debuglevel(void)
276 return (_ico_ivi_debug_level & 0x0ffff);
279 /*--------------------------------------------------------------------------*/
281 * @brief ico_ivi_debugflag: get debug flags
284 * @return debug flags
286 /*--------------------------------------------------------------------------*/
288 ico_ivi_debugflag(void)
290 return ((_ico_ivi_debug_level >> 16) & 0x0ffff);
293 /*--------------------------------------------------------------------------*/
295 * @brief ico_ivi_default_animation_name: get default animation name
298 * @return Default animation name
300 /*--------------------------------------------------------------------------*/
301 WL_EXPORT const char *
302 ico_ivi_default_animation_name(void)
304 return _ico_ivi_animation_name;
307 /*--------------------------------------------------------------------------*/
309 * @brief ico_ivi_default_animation_time: get default animation time
312 * @return Default animation time(miri sec)
314 /*--------------------------------------------------------------------------*/
316 ico_ivi_default_animation_time(void)
318 return _ico_ivi_animation_time;
321 /*--------------------------------------------------------------------------*/
323 * @brief ico_ivi_get_mynode: Get my NodeId
326 * @return NodeId of my node
328 /*--------------------------------------------------------------------------*/
330 ico_ivi_get_mynode(void)
332 /* Reference Platform 0.90 only support 1 ECU */
336 /*--------------------------------------------------------------------------*/
338 * @brief ico_ivi_surface_buffer_width: get surface buffer width
340 * @param[in] es weston surface
341 * @return buffer width(if surface has no buffer, return 0)
343 /*--------------------------------------------------------------------------*/
345 ico_ivi_surface_buffer_width(struct weston_surface *es)
349 if (! es->buffer_ref.buffer) {
352 if (es->buffer_viewport.viewport_set) {
353 return es->buffer_viewport.dst_width;
355 switch (es->buffer_viewport.transform) {
356 case WL_OUTPUT_TRANSFORM_90:
357 case WL_OUTPUT_TRANSFORM_270:
358 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
359 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
360 v = es->buffer_ref.buffer->height;
363 v = es->buffer_ref.buffer->width;
366 return (v / es->buffer_viewport.scale);
369 /*--------------------------------------------------------------------------*/
371 * @brief ico_ivi_surface_buffer_height: get surface buffer height
373 * @param[in] es weston surface
374 * @return buffer height(if surface has no buffer, return 0)
376 /*--------------------------------------------------------------------------*/
378 ico_ivi_surface_buffer_height(struct weston_surface *es)
382 if (! es->buffer_ref.buffer) {
385 if (es->buffer_viewport.viewport_set) {
386 return es->buffer_viewport.dst_height;
388 switch (es->buffer_viewport.transform) {
389 case WL_OUTPUT_TRANSFORM_90:
390 case WL_OUTPUT_TRANSFORM_270:
391 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
392 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
393 v = es->buffer_ref.buffer->width;
396 v = es->buffer_ref.buffer->height;
399 return (v / es->buffer_viewport.scale);
402 /*--------------------------------------------------------------------------*/
404 * @brief ico_ivi_surface_buffer_size: get surface buffer size
406 * @param[in] es weston surface
407 * @param[out] width buffer width
408 * @param[out] height buffer height
411 /*--------------------------------------------------------------------------*/
413 ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height)
415 if (! es->buffer_ref.buffer) {
419 else if (es->buffer_viewport.viewport_set) {
420 *width = es->buffer_viewport.dst_width;
421 *height = es->buffer_viewport.dst_height;
424 switch (es->buffer_viewport.transform) {
425 case WL_OUTPUT_TRANSFORM_90:
426 case WL_OUTPUT_TRANSFORM_270:
427 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
428 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
429 *width = es->buffer_ref.buffer->height;
430 *height = es->buffer_ref.buffer->width;
433 *width = es->buffer_ref.buffer->width;
434 *height = es->buffer_ref.buffer->height;
437 *width = *width / es->buffer_viewport.scale;
438 *height = *height / es->buffer_viewport.scale;
442 /*--------------------------------------------------------------------------*/
444 * @brief ico_ivi_surface_buffer_size: get surface buffer size
446 * @param[in] es weston surface
447 * @param[out] width buffer width
448 * @param[out] height buffer height
451 /*--------------------------------------------------------------------------*/
452 WL_EXPORT struct weston_view *
453 ico_ivi_get_primary_view(struct uifw_win_surface *usurf)
455 struct weston_view *ev = NULL;
456 struct shell_surface *shsurf;
458 if (_ico_win_mgr->compositor->shell_interface.get_primary_view) {
459 shsurf = usurf->surface->configure_private;
461 ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view)(NULL, shsurf);
465 ev = weston_layout_get_weston_view(usurf->ivisurf);
468 uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view",
469 (int)usurf, usurf->surfaceid, (int)usurf->surface);
474 /*--------------------------------------------------------------------------*/
476 * @brief ico_window_mgr_set_weston_surface: set weston surface
478 * @param[in] usurf UIFW surface
479 * @param[in] x X coordinate on screen
480 * @param[in] y Y coordinate on screen
481 * @param[in] width width
482 * @param[in] height height
485 /*--------------------------------------------------------------------------*/
487 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
488 int x, int y, int width, int height)
490 struct weston_surface *es = usurf->surface;
491 struct weston_layout_SurfaceProperties prop;
492 int buf_width, buf_height;
494 if ((es == NULL) || (usurf->ivisurf == NULL)) {
495 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
500 if (es->buffer_ref.buffer != NULL) {
501 ico_ivi_surface_buffer_size(es, &buf_width, &buf_height);
502 if ((width <= 0) || (height <= 0)) {
504 usurf->width = buf_width;
506 usurf->height = buf_height;
508 if (usurf->width > buf_width) {
510 x += (usurf->width - buf_width)/2;
512 if (usurf->height > buf_height) {
514 y += (usurf->height - buf_height)/2;
516 if (usurf->visible) {
517 x += usurf->node_tbl->disp_x;
518 y += usurf->node_tbl->disp_y;
521 x = ICO_IVI_MAX_COORDINATE+1;
522 y = ICO_IVI_MAX_COORDINATE+1;
524 if (weston_layout_getPropertiesOfSurface(usurf->ivisurf, &prop) == 0) {
525 if ((prop.destX != x) || (prop.destY != y) ||
526 (prop.destWidth != (uint32_t)width) ||
527 (prop.destHeight != (uint32_t)height)) {
528 if (weston_layout_surfaceSetDestinationRectangle(
529 usurf->ivisurf, x, y, width, height) == 0) {
530 weston_layout_commitChanges();
534 weston_surface_damage(es);
538 /*--------------------------------------------------------------------------*/
540 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
542 * @param[in] surfaceid UIFW surface id
543 * @return UIFW surface table address
544 * @retval !=NULL success(surface table address)
545 * @retval NULL error(surface id dose not exist)
547 /*--------------------------------------------------------------------------*/
548 WL_EXPORT struct uifw_win_surface *
549 ico_window_mgr_get_usurf(const uint32_t surfaceid)
551 struct uifw_win_surface *usurf;
553 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
556 if (usurf->surfaceid == surfaceid) {
559 usurf = usurf->next_idhash;
561 uifw_trace("ico_window_mgr_get_usurf: NULL(%08x)", surfaceid);
565 /*--------------------------------------------------------------------------*/
567 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
569 * @param[in] surfaceid UIFW surface id
570 * @param[in] client Wayland client
571 * @return UIFW surface table address
572 * @retval !=NULL success(surface table address)
573 * @retval NULL error(surface id or client dose not exist)
575 /*--------------------------------------------------------------------------*/
576 WL_EXPORT struct uifw_win_surface *
577 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
579 struct uifw_win_surface *usurf;
580 struct uifw_client *uclient;
582 usurf = ico_window_mgr_get_usurf(surfaceid);
585 uclient = ico_window_mgr_find_uclient(client);
587 /* client dose not exist, error */
588 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x dose not exist",
592 if (&uclient->surface_link == uclient->surface_link.next) {
593 /* client has no surface */
594 uifw_trace("ico_window_mgr_get_usurf_client: client=%08x has no surface",
598 usurf = (struct uifw_win_surface *)uclient->surface_link.next;
603 /*--------------------------------------------------------------------------*/
605 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
607 * @param[in] wsurf Weston surface
608 * @return UIFW surface table address
609 * @retval !=NULL success(surface table address)
610 * @retval NULL error(surface dose not exist)
612 /*--------------------------------------------------------------------------*/
613 static struct uifw_win_surface *
614 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
616 struct uifw_win_surface *usurf;
618 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
621 if (usurf->surface == wsurf) {
624 usurf = usurf->next_wshash;
626 uifw_trace("find_uifw_win_surface_by_ws: NULL");
630 /*--------------------------------------------------------------------------*/
632 * @brief ico_window_mgr_find_uclient: find UIFW client by wayland client
634 * @param[in] client Wayland client
635 * @return UIFW client table address
636 * @retval !=NULL success(client table address)
637 * @retval NULL error(client dose not exist)
639 /*--------------------------------------------------------------------------*/
640 WL_EXPORT struct uifw_client*
641 ico_window_mgr_find_uclient(struct wl_client *client)
643 struct uifw_client *uclient;
645 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
646 if (uclient->client == client) {
650 uifw_trace("ico_window_mgr_find_uclient: client.%08x is NULL", (int)client);
654 /*--------------------------------------------------------------------------*/
656 * @brief ico_window_mgr_get_appid: find application id by wayland client
658 * @param[in] client Wayland client
659 * @return application id
660 * @retval !=NULL success(application id)
661 * @retval NULL error(client dose not exist)
663 /*--------------------------------------------------------------------------*/
665 ico_window_mgr_get_appid(struct wl_client* client)
667 struct uifw_client *uclient;
669 uclient = ico_window_mgr_find_uclient(client);
674 return uclient->appid;
677 /*--------------------------------------------------------------------------*/
679 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
681 * @param[in] displayno display number
682 * @param[out] x relative X coordinate
683 * @param[out] y relative Y coordinate
686 /*--------------------------------------------------------------------------*/
688 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
690 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
693 *x = _ico_node_table[displayno].disp_x;
694 *y = _ico_node_table[displayno].disp_y;
697 /*--------------------------------------------------------------------------*/
699 * @brief win_mgr_bind_client: desktop_shell from client
701 * @param[in] client Wayland client
702 * @param[in] shell shell table address
705 /*--------------------------------------------------------------------------*/
707 win_mgr_bind_client(struct wl_client *client, void *shell)
709 struct uifw_client *uclient;
715 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
716 (int)client, (int)shell);
718 /* save shell table address */
720 _ico_win_mgr->shell = shell;
724 uclient = ico_window_mgr_find_uclient(client);
726 /* client not exist, create client management table */
727 uifw_trace("win_mgr_bind_client: Create Client");
728 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
730 uifw_error("win_mgr_bind_client: Error, No Memory");
733 memset(uclient, 0, sizeof(struct uifw_client));
734 uclient->client = client;
735 wl_list_init(&uclient->surface_link);
737 uclient->destroy_listener.notify = win_mgr_destroy_client;
738 wl_client_add_destroy_listener(client, &uclient->destroy_listener);
743 wl_client_get_credentials(client, &pid, &uid, &gid);
744 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
745 (int)client, (int)pid, (int)uid, (int)gid);
747 uclient->pid = (int)pid;
748 /* get applicationId from AppCore(AUL) */
749 win_mgr_get_client_appid(uclient);
752 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
756 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
758 uifw_trace("win_mgr_bind_client: Leave");
761 /*--------------------------------------------------------------------------*/
763 * @brief win_mgr_destroy_client: destroy client
765 * @param[in] listener listener
766 * @param[in] data listener
769 /*--------------------------------------------------------------------------*/
771 win_mgr_destroy_client(struct wl_listener *listener, void *data)
773 struct uifw_client *uclient;
774 struct uifw_win_surface *usurf;
775 struct uifw_win_surface *usurf_tmp;
777 uclient = container_of(listener, struct uifw_client, destroy_listener);
779 uifw_trace("win_mgr_destroy_client: Enter(uclient=%08x)", (int)uclient);
782 /* Client exist, Destory client surfaces */
783 wl_list_for_each_safe (usurf, usurf_tmp, &uclient->surface_link, client_link) {
784 win_mgr_destroy_surface(usurf->surface);
786 /* Destory client management table */
787 wl_list_remove(&uclient->link);
790 uifw_trace("win_mgr_destroy_client: Leave");
793 #if 0 /* work around: Walk through child processes until app ID is found */
794 /*--------------------------------------------------------------------------*/
796 * @brief win_mgr_get_ppid: Get parent process ID.
798 * Similar to getppid(), except that this implementation accepts an
799 * arbitrary process ID.
801 * @param[in] pid Process ID of child process
802 * @return parent process ID on success, -1 on failure
804 /*--------------------------------------------------------------------------*/
806 win_mgr_get_ppid(pid_t pid)
809 char procpath[PATH_MAX] = { 0 };
811 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid);
813 /* We better have read permissions! */
814 int const fd = open(procpath, O_RDONLY);
819 char buffer[1024] = { 0 };
821 ssize_t const size = read(fd, buffer, sizeof(buffer));
827 /* Find line containing the parent process ID. */
828 char const * const ppid_line = strstr(buffer, "PPid");
830 if (ppid_line != NULL)
831 sscanf(ppid_line, "PPid: %d", &ppid);
835 #endif /* work around: Walk through child processes until app ID is found */
837 /*--------------------------------------------------------------------------*/
839 * @brief win_mgr_get_client_appid: get applicationId from pid
841 * @param[in] uclient UIFW client management table
844 /*--------------------------------------------------------------------------*/
846 win_mgr_get_client_appid(struct uifw_client *uclient)
848 int status = AUL_R_ERROR;
850 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
852 #if 0 /* work around: Walk through child processes until app ID is found */
854 * Walk the parent process chain until we find a parent process
859 for (pid = uclient->pid;
860 pid > 1 && status != AUL_R_OK;
861 pid = win_mgr_get_ppid(pid)) {
863 status = aul_app_get_appid_bypid(pid,
865 ICO_IVI_APPID_LENGTH);
867 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
868 "pid=%d appid=<%s>", status, pid, uclient->appid);
871 * Walk the child process chain as well since app ID was not yet found
873 if (status != AUL_R_OK) {
882 dr = opendir("/proc/");
885 wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
887 while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
889 char fullpath[PATH_MAX] = { 0 };
893 snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
895 if (stat(fullpath, &ps) == -1) {
899 /* find pid dirs for this user (uid) only */
900 if (ps.st_uid != uid)
903 pid = atoi(de->d_name);
905 /* check if it's a valid child */
906 if (pid < uclient->pid)
909 /* scan up to pid to find if a chain exists */
910 for (tmppid = pid; tmppid > uclient->pid;) {
911 tmppid = win_mgr_get_ppid(tmppid);
912 if (tmppid == uclient->pid)
917 status = aul_app_get_appid_bypid(pid, uclient->appid,
918 ICO_IVI_APPID_LENGTH);
920 uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid "
921 "ret=%d pid=%d appid=<%s>", status, pid,
926 #else /* work around: Walk through child processes until app ID is found */
927 status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
928 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
929 "pid=%d appid=<%s>", status, uclient->pid, uclient->appid);
930 #endif /* work around: Walk through child processes until app ID is found */
932 if (uclient->appid[0] != 0) {
933 /* OK, end of get appid */
934 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
937 /* client does not exist in AppCore, search Linux process table */
945 uclient->fixed_appid ++;
946 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
947 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
948 fd = open(procpath, O_RDONLY);
950 size = read(fd, procpath, sizeof(procpath));
951 for (; size > 0; size--) {
952 if (procpath[size-1]) break;
955 /* get program base name */
957 for (j = 0; j < size; j++) {
958 if (procpath[j] == 0) break;
959 if (procpath[j] == '/') i = j + 1;
962 for (; i < size; i++) {
963 uclient->appid[j] = procpath[i];
964 if ((uclient->appid[j] == 0) ||
965 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
968 /* search application number in apprication start option */
969 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
970 for (; i < size; i++) {
971 if ((procpath[i] == 0) &&
972 (procpath[i+1] == '@')) {
973 strncpy(&uclient->appid[j], &procpath[i+1],
974 ICO_IVI_APPID_LENGTH - j - 2);
981 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
982 if (uclient->appid[i] != ' ') break;
984 uclient->appid[i+1] = 0;
985 if (uclient->appid[0]) {
986 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
988 uclient->pid, uclient->appid, uclient->fixed_appid );
991 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
993 sprintf(uclient->appid, "?%d?", uclient->pid);
998 /*--------------------------------------------------------------------------*/
1000 * @brief ico_get_animation_name: convert animation name to Id value
1002 * @param[in] animation animation name
1003 * @return animation Id value
1005 /*--------------------------------------------------------------------------*/
1007 ico_get_animation_name(const char *animation)
1009 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1011 if (strcasecmp(animation, "none") == 0) {
1012 return ICO_WINDOW_MGR_ANIMATION_NONE;
1015 if (win_mgr_hook_animation) {
1016 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
1019 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1024 /*--------------------------------------------------------------------------*/
1026 * @brief win_mgr_send_event: send event to controller
1028 * @param[in] event event code
1029 * @param[in] surfaceid surface id
1030 * @param[in] arg1 argument 1
1033 /*--------------------------------------------------------------------------*/
1035 win_mgr_send_event(int event, uint32_t surfaceid, uint32_t arg1)
1037 struct uifw_manager *mgr;
1039 /* send event to manager */
1040 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1042 case ICO_WINDOW_MGR_WINDOW_ACTIVE: /* active event */
1043 uifw_trace("win_mgr_send_event: Send ACTIVE(surf=%08x, select=%x)",
1045 ico_window_mgr_send_window_active(mgr->resource, surfaceid, arg1);
1047 case ICO_WINDOW_MGR_DESTROY_SURFACE: /* surface destroy event */
1048 uifw_trace("win_mgr_send_event: Send DESTROY_SURFACE(surf=%08x) mgr=%08x",
1049 surfaceid, (int)mgr);
1050 ico_window_mgr_send_destroy_surface(mgr->resource, surfaceid);
1053 uifw_error("win_mgr_send_event: Unknown event(%d)", event);
1059 /*--------------------------------------------------------------------------*/
1061 * @brief win_mgr_select_surface: select surface by mouse click
1063 * @param[in] seat weston seat
1064 * @param[in] focus selected surface
1065 * @param[in] select selected device
1068 /*--------------------------------------------------------------------------*/
1070 win_mgr_select_surface(struct weston_seat *seat, struct weston_surface *focus, int select)
1072 struct weston_surface *surface;
1073 struct uifw_win_surface *usurf;
1074 struct uifw_manager *mgr;
1076 surface = weston_surface_get_main_surface(focus);
1078 uifw_trace("win_mgr_select_surface: Enter(%08x,%d)", (int)surface, select);
1081 uifw_trace("win_mgr_select_surface: Leave(no surface)");
1085 usurf = find_uifw_win_surface_by_ws(surface);
1087 uifw_trace("win_mgr_select_surface: Leave(usurf not exist)");
1090 /* surface active */
1091 weston_surface_activate(surface, seat);
1093 /* send active event to manager */
1094 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1095 uifw_trace("win_mgr_select_surface: Send Manager ACTIVE(surf=%08x)",
1097 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
1100 uifw_trace("win_mgr_select_surface: Leave");
1103 /*--------------------------------------------------------------------------*/
1105 * @brief win_mgr_click_to_activate: select surface by mouse click
1107 * @param[in] seat weston seat
1108 * @param[in] time click time(current time)
1109 * @param[in] button click button
1110 * @param[in] data user data(unused)
1113 /*--------------------------------------------------------------------------*/
1115 win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
1116 uint32_t button, void *data)
1118 if (seat->pointer->grab != &seat->pointer->default_grab)
1120 if (seat->pointer->focus == NULL)
1123 win_mgr_select_surface(seat, seat->pointer->focus->surface,
1124 ICO_WINDOW_MGR_SELECT_POINTER);
1127 /*--------------------------------------------------------------------------*/
1129 * @brief win_mgr_touch_to_activate: select surface by touch touch-panel
1131 * @param[in] seat weston seat
1132 * @param[in] time click time(current time)
1133 * @param[in] data user data(unused)
1136 /*--------------------------------------------------------------------------*/
1138 win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time, void *data)
1140 if (seat->touch->grab != &seat->touch->default_grab)
1142 if (seat->touch->focus == NULL)
1145 win_mgr_select_surface(seat, seat->touch->focus->surface, ICO_WINDOW_MGR_SELECT_TOUCH);
1148 /*--------------------------------------------------------------------------*/
1150 * @brief ico_ivi_surfaceCreateNotification: create ivi-surface
1152 * @param[in] ivisurf ivi surface
1153 * @param[in] userdata User Data(Unused)
1156 /*--------------------------------------------------------------------------*/
1158 ico_ivi_surfaceCreateNotification(struct weston_layout_surface *ivisurf, void *userdata)
1160 uint32_t id_surface;
1161 struct weston_view *ev;
1162 struct weston_surface *es;
1163 struct wl_client *client;
1165 id_surface = weston_layout_getIdOfSurface(ivisurf);
1166 uifw_trace("ico_ivi_surfaceCreateNotification: Create %x", id_surface);
1168 /* set property notification */
1169 if (weston_layout_surfaceAddNotification(ivisurf, ico_ivi_surfacePropertyNotification, NULL) != 0) {
1170 uifw_error("ico_ivi_surfaceCreateNotification: weston_layout_surfaceAddNotification Error");
1172 ev = weston_layout_get_weston_view(ivisurf);
1174 uifw_error("ico_ivi_surfaceCreateNotification: weston_layout_get_weston_view Error");
1179 uifw_error("ico_ivi_surfaceCreateNotification: no weston_surface");
1182 client = wl_resource_get_client(es->resource);
1184 uifw_error("ico_ivi_surfaceCreateNotification: no wl_client");
1187 win_mgr_register_surface(id_surface, es, client, ivisurf);
1193 /*--------------------------------------------------------------------------*/
1195 * @brief ico_ivi_surfaceRemoveNotification: remove ivi-surface
1197 * @param[in] ivisurf ivi surface
1198 * @param[in] userdata User Data(Unused)
1201 /*--------------------------------------------------------------------------*/
1203 ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf, void *userdata)
1205 uint32_t id_surface;
1206 struct weston_view *ev;
1207 struct weston_surface *es;
1209 id_surface = weston_layout_getIdOfSurface(ivisurf);
1210 uifw_trace("ico_ivi_surfaceRemoveNotification: Remove %x", id_surface);
1212 ev = weston_layout_get_weston_view(ivisurf);
1214 uifw_error("ico_ivi_surfaceRemoveNotification: weston_layout_get_weston_view Error");
1219 uifw_error("ico_ivi_surfaceRemoveNotification: no weston_surface");
1222 win_mgr_destroy_surface(es);
1227 /*--------------------------------------------------------------------------*/
1229 * @brief ico_ivi_surfacePropertyNotification: property change ivi-surface
1231 * @param[in] ivisurf ivi surface
1232 * @param[in] userdata User Data(Unused)
1235 /*--------------------------------------------------------------------------*/
1237 ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf,
1238 struct weston_layout_SurfaceProperties *prop,
1239 enum weston_layout_notification_mask mask,
1242 struct uifw_manager *mgr;
1243 uint32_t id_surface;
1246 struct uifw_win_surface *usurf;
1247 struct weston_view *ev;
1249 newmask = ((uint32_t)mask) & (~(IVI_NOTIFICATION_OPACITY|IVI_NOTIFICATION_ORIENTATION|
1250 IVI_NOTIFICATION_PIXELFORMAT));
1251 id_surface = weston_layout_getIdOfSurface(ivisurf);
1252 usurf = ico_window_mgr_get_usurf(id_surface);
1254 if ((newmask != 0) && (usurf != NULL)) {
1255 uifw_trace("ico_ivi_surfacePropertyNotification: Property %x(%08x) usurf=%08x",
1256 id_surface, newmask, (int)usurf);
1257 if (newmask & (IVI_NOTIFICATION_SOURCE_RECT|IVI_NOTIFICATION_DEST_RECT|
1258 IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION)) {
1259 /* change position or size */
1260 uifw_trace("ico_ivi_surfacePropertyNotification: %08x x/y=%d/%d->%d/%d "
1261 "w/h=%d/%d->%d/%d(%d/%d)", id_surface, usurf->x, usurf->y,
1262 prop->destX, prop->destY, usurf->width, usurf->height,
1263 prop->destWidth, prop->destHeight,
1264 prop->sourceWidth, prop->sourceHeight);
1265 if ((usurf->client_width == prop->sourceWidth) &&
1266 (usurf->client_height == prop->sourceHeight)) {
1267 newmask &= (~IVI_NOTIFICATION_SOURCE_RECT);
1270 usurf->client_width = prop->sourceWidth;
1271 usurf->client_height = prop->sourceHeight;
1273 if ((usurf->x == prop->destX) && (usurf->y == prop->destY) &&
1274 (usurf->width == prop->destWidth) && (usurf->height == prop->destHeight)) {
1275 newmask &= (~(IVI_NOTIFICATION_DEST_RECT|
1276 IVI_NOTIFICATION_POSITION|IVI_NOTIFICATION_DIMENSION));
1279 usurf->x = prop->destX;
1280 usurf->y = prop->destY;
1281 usurf->width = prop->destWidth;
1282 usurf->height = prop->destHeight;
1283 if ((usurf->width != usurf->configure_width) ||
1284 (usurf->height != usurf->configure_height)) {
1285 /* send configure to client(App) */
1286 uifw_trace("ico_ivi_surfacePropertyNotification: send configure "
1287 "%08x(%d,%d->%d,%d)", usurf->surfaceid,
1288 usurf->configure_width, usurf->configure_height,
1289 usurf->width, usurf->height);
1290 usurf->configure_width = usurf->width;
1291 usurf->configure_height = usurf->height;
1293 struct wl_array surfaces;
1294 struct shell_surface;
1296 if (! usurf->shsurf_resource) {
1297 /* get shell surface if not get */
1298 ivi_shell_get_shell_surfaces(&surfaces);
1299 wl_array_for_each(shsurf, &surfaces) {
1300 if (shell_surface_get_surface(*shsurf) == usurf->surface) {
1301 usurf->shsurf_resource = *((struct wl_resource **)*shsurf);
1305 wl_array_release(&surfaces);
1307 if (usurf->shsurf_resource) {
1308 uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
1310 usurf->surfaceid, (int)usurf->shsurf_resource);
1311 wl_shell_surface_send_configure(usurf->shsurf_resource,
1312 WL_SHELL_SURFACE_RESIZE_RIGHT|
1313 WL_SHELL_SURFACE_RESIZE_BOTTOM,
1314 usurf->configure_width, usurf->configure_height);
1317 uifw_trace("ico_ivi_surfacePropertyNotification: surface %08x "
1318 "shell_surface resource not found", usurf->surfaceid);
1323 if (newmask & IVI_NOTIFICATION_VISIBILITY) {
1324 if ((usurf->animation.state == ICO_WINDOW_MGR_ANIMATION_STATE_NONE) &&
1325 (win_mgr_hook_animation != NULL)) {
1326 /* start animation, save original position of surface */
1327 usurf->animation.pos_x = usurf->x;
1328 usurf->animation.pos_y = usurf->y;
1329 usurf->animation.pos_width = usurf->width;
1330 usurf->animation.pos_height = usurf->height;
1331 ev = weston_layout_get_weston_view(ivisurf);
1333 usurf->animation.alpha = ev->alpha;
1336 usurf->animation.alpha = 1.0;
1339 if ((usurf->visible == 0) && (prop->visibility)) {
1340 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1",
1343 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1344 (win_mgr_hook_animation != NULL)) {
1345 /* show with animation */
1347 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1349 uifw_trace("ico_ivi_surfacePropertyNotification: ret call anima = %d",
1353 else if ((usurf->visible != 0) && (! prop->visibility)) {
1354 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0",
1357 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1358 (win_mgr_hook_animation != NULL)) {
1359 /* hide with animation */
1361 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1365 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1367 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1369 uifw_trace("ico_ivi_surfacePropertyNotification: Change to UnVisible");
1373 uifw_trace("ico_ivi_surfacePropertyNotification: Change to Visible");
1374 weston_layout_surfaceSetVisibility(ivisurf, 1);
1375 weston_layout_commitChanges();
1379 uifw_trace("ico_ivi_surfacePropertyNotification: visible no change");
1380 newmask &= (~IVI_NOTIFICATION_VISIBILITY);
1385 /* surface changed, send event to controller */
1386 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1387 uifw_trace("win_mgr_send_event: Send UPDATE_SURFACE(surf=%08x) "
1388 "v=%d src=%d/%d dest=%d/%d(%d/%d) mgr=%08x", id_surface,
1389 usurf->visible, usurf->client_width, usurf->client_height,
1390 usurf->x, usurf->y, usurf->width, usurf->height, (int)mgr);
1391 ico_window_mgr_send_update_surface(mgr->resource, id_surface,
1392 usurf->visible, usurf->client_width,
1393 usurf->client_height, usurf->x, usurf->y,
1394 usurf->width, usurf->height);
1400 /*--------------------------------------------------------------------------*/
1402 * @brief win_mgr_register_surface: create UIFW surface
1404 * @param[in] id_surface surface id (by ivi-shell)
1405 * @param[in] surface Weston surface
1406 * @param[in] client Wayland client
1407 * @param[in] ivisurf weston layout surface
1410 /*--------------------------------------------------------------------------*/
1412 win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
1413 struct wl_client *client, struct weston_layout_surface *ivisurf)
1415 struct weston_layout_SurfaceProperties prop;
1416 struct uifw_win_surface *usurf;
1417 struct uifw_win_surface *phash;
1418 struct uifw_win_surface *bhash;
1421 uifw_trace("win_mgr_register_surface: Enter(surf=%x[%08x],client=%08x,ivisurf=%08x)",
1422 id_surface, (int)surface, (int)client, (int)ivisurf);
1424 /* check new surface */
1425 if (find_uifw_win_surface_by_ws(surface)) {
1426 /* surface exist, NOP */
1427 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
1431 /* set default color and shader */
1432 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
1434 /* create UIFW surface management table */
1435 usurf = malloc(sizeof(struct uifw_win_surface));
1437 uifw_error("win_mgr_register_surface: No Memory");
1441 memset(usurf, 0, sizeof(struct uifw_win_surface));
1443 usurf->surfaceid = id_surface;
1444 usurf->surface = surface;
1445 usurf->ivisurf = ivisurf;
1446 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
1448 if (weston_layout_getPropertiesOfSurface(ivisurf, &prop) == 0) {
1449 usurf->x = prop.destX;
1450 usurf->y = prop.destY;
1451 usurf->width = prop.destWidth;
1452 usurf->height = prop.destHeight;
1453 usurf->client_width = prop.sourceWidth;
1454 usurf->client_height = prop.sourceHeight;
1455 usurf->configure_width = usurf->client_width;
1456 usurf->configure_height = usurf->client_height;
1458 wl_list_init(&usurf->surface_destroy_listener.link);
1459 usurf->surface_destroy_listener.notify = win_mgr_surface_destroy;
1460 wl_signal_add(&surface->destroy_signal, &usurf->surface_destroy_listener);
1462 wl_list_init(&usurf->client_link);
1463 wl_list_init(&usurf->animation.animation.link);
1464 wl_list_init(&usurf->surf_map);
1465 wl_list_init(&usurf->input_region);
1466 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
1467 usurf->animation.hide_time = ico_ivi_default_animation_time();
1468 usurf->animation.show_anima = usurf->animation.hide_anima;
1469 usurf->animation.show_time = usurf->animation.hide_time;
1470 usurf->animation.move_anima = usurf->animation.hide_anima;
1471 usurf->animation.move_time = usurf->animation.hide_time;
1472 usurf->animation.resize_anima = usurf->animation.hide_anima;
1473 usurf->animation.resize_time = usurf->animation.hide_time;
1477 usurf->uclient = ico_window_mgr_find_uclient(client);
1478 if (! usurf->uclient) {
1479 /* client not exist, create client management table */
1480 uifw_trace("win_mgr_register_surface: Create Client");
1481 win_mgr_bind_client(client, NULL);
1482 usurf->uclient = ico_window_mgr_find_uclient(client);
1483 if (! usurf->uclient) {
1484 uifw_error("win_mgr_register_surface: No Memory");
1488 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1490 /* make surface id hash table */
1491 hash = MAKE_IDHASH(usurf->surfaceid);
1492 phash = _ico_win_mgr->idhash[hash];
1496 phash = phash->next_idhash;
1499 bhash->next_idhash = usurf;
1502 _ico_win_mgr->idhash[hash] = usurf;
1505 /* make weston surface hash table */
1506 hash = MAKE_WSHASH(usurf->surface);
1507 phash = _ico_win_mgr->wshash[hash];
1511 phash = phash->next_wshash;
1514 bhash->next_wshash = usurf;
1517 _ico_win_mgr->wshash[hash] = usurf;
1519 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1522 /*--------------------------------------------------------------------------*/
1524 * @brief uifw_set_animation: set animation of surface visible/unvisible
1526 * @param[in] client Weyland client
1527 * @param[in] resource resource of request
1528 * @param[in] surfaceid UIFW surface id
1529 * @param[in] type how to change surface
1530 * @param[in] anmation animation name
1531 * @param[in] time animation time(ms), if 0, default time
1534 /*--------------------------------------------------------------------------*/
1536 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1537 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1540 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1542 uifw_trace("uifw_set_animation: surf=%08x,type=%x,anim=%s,time=%d",
1543 surfaceid, type, animation, time);
1546 if ((*animation != 0) && (*animation != ' ')) {
1547 animaid = ico_get_animation_name(animation);
1548 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1549 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) {
1550 if (! usurf->org_animation.saved) {
1551 usurf->org_animation.type = usurf->animation.type;
1552 usurf->org_animation.anima = usurf->animation.anima;
1553 usurf->org_animation.next_anima = usurf->animation.next_anima;
1554 usurf->org_animation.hide_anima = usurf->animation.hide_anima;
1555 usurf->org_animation.hide_time = usurf->animation.hide_time;
1556 usurf->org_animation.show_anima = usurf->animation.show_anima;
1557 usurf->org_animation.show_time = usurf->animation.show_time;
1558 usurf->org_animation.move_anima = usurf->animation.move_anima;
1559 usurf->org_animation.move_time = usurf->animation.move_time;
1560 usurf->org_animation.resize_anima = usurf->animation.resize_anima;
1561 usurf->org_animation.resize_time = usurf->animation.resize_time;
1562 usurf->org_animation.saved = 1;
1565 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1566 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1567 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1568 usurf->animation.next_anima = animaid;
1569 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1570 usurf->org_animation.next_anima = animaid;
1573 usurf->animation.hide_anima = animaid;
1574 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1575 usurf->org_animation.hide_anima = animaid;
1578 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1579 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1580 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1581 usurf->animation.next_anima = animaid;
1582 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1583 usurf->org_animation.next_anima = animaid;
1586 usurf->animation.show_anima = animaid;
1587 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1588 usurf->org_animation.show_anima = animaid;
1591 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1592 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
1593 usurf->animation.next_anima = animaid;
1594 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1595 usurf->org_animation.next_anima = animaid;
1598 usurf->animation.move_anima = animaid;
1599 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1600 usurf->org_animation.move_anima = animaid;
1603 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1604 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
1605 usurf->animation.next_anima = animaid;
1606 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1607 usurf->org_animation.next_anima = animaid;
1610 usurf->animation.resize_anima = animaid;
1611 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1612 usurf->org_animation.resize_anima = animaid;
1616 if ((time > 0) && (time < 10000)) {
1617 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1618 usurf->animation.hide_time = time;
1619 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1620 usurf->org_animation.hide_time = time;
1622 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1623 usurf->animation.show_time = time;
1624 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1625 usurf->org_animation.show_time = time;
1627 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1628 usurf->animation.move_time = time;
1629 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1630 usurf->org_animation.move_time = time;
1632 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1633 usurf->animation.resize_time = time;
1634 if ((type & ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT) == 0)
1635 usurf->org_animation.resize_time = time;
1640 uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid);
1644 /*--------------------------------------------------------------------------*/
1646 * @brief win_mgr_check_mapsurface: check and change all surface
1648 * @param[in] animation weston animation table(unused)
1649 * @param[in] outout weston output table(unused)
1650 * @param[in] mseces current time(unused)
1653 /*--------------------------------------------------------------------------*/
1655 win_mgr_check_mapsurface(struct weston_animation *animation,
1656 struct weston_output *output, uint32_t msecs)
1658 struct uifw_surface_map *sm, *sm_tmp;
1660 int wait = 99999999;
1662 /* check touch down counter */
1663 if ((touch_check_seat) &&
1664 (touch_check_seat->touch)) {
1665 if (touch_check_seat->touch->num_tp > 10) {
1666 uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset",
1667 (int)touch_check_seat->touch->num_tp);
1668 touch_check_seat->touch->num_tp = 0;
1672 /* check all mapped surfaces */
1673 curtime = weston_compositor_get_time();
1674 wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) {
1675 #if 0 /* too many log */
1676 uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x",
1677 (int)sm, sm->usurf->surfaceid);
1679 if ((sm->interval >= 0) || (sm->eventque == 0)) {
1680 win_mgr_change_mapsurface(sm, 0, curtime);
1682 if ((sm->interval >= 0) && (sm->eventque != 0)) {
1683 if (sm->interval < wait) {
1684 wait = sm->interval;
1689 /* check frame interval */
1696 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait);
1699 /*--------------------------------------------------------------------------*/
1701 * @brief win_mgr_timer_mapsurface: mapped surface check timer
1703 * @param[in] data user data(unused)
1706 /*--------------------------------------------------------------------------*/
1708 win_mgr_timer_mapsurface(void *data)
1710 win_mgr_check_mapsurface(NULL, NULL, 0);
1714 /*--------------------------------------------------------------------------*/
1716 * @brief win_mgr_change_mapsurface: check and change mapped surface
1718 * @param[in] sm map surface table
1719 * @param[in] event send event (if 0, send if changed)
1720 * @param[in] curtime current time(ms)
1723 /*--------------------------------------------------------------------------*/
1725 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime)
1727 struct weston_surface *es;
1728 struct wl_shm_buffer *shm_buffer;
1734 #if 0 /* too many log */
1735 uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event);
1738 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
1741 /* check if buffered */
1742 es = sm->usurf->surface;
1744 ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) &&
1745 ((es->buffer_ref.buffer == NULL) ||
1746 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) {
1747 /* surface has no buffer */
1748 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x",
1749 sm->usurf->surfaceid, (int)es,
1750 es ? (int)es->buffer_ref.buffer : 0);
1752 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1758 else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1759 if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) {
1760 if ((void *)wl_resource_get_user_data(
1761 (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer)
1763 /* surface has no buffer */
1764 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer",
1765 sm->usurf->surfaceid);
1767 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1776 if (es->buffer_ref.buffer != NULL) {
1777 shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource);
1779 format = wl_shm_buffer_get_format(shm_buffer);
1780 if (format != WL_SHM_FORMAT_ARGB8888) {
1781 uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x",
1782 sm->usurf->surfaceid, format);
1783 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1789 if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) {
1791 if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1792 format = EGL_TEXTURE_RGBA; /* currently only support RGBA */
1793 width = es->buffer_ref.buffer->width;
1794 height = es->buffer_ref.buffer->height;
1795 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1797 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1798 #if PERFORMANCE_EVALUATIONS > 0
1799 uifw_perf("SWAP_BUFFER appid=%s surface=%08x MAP",
1800 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1801 #endif /*PERFORMANCE_EVALUATIONS*/
1803 else if ((width <= 0) || (height <= 0)) {
1806 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1807 if ((sm->width != width) || (sm->height != height) ||
1808 (format != sm->format)) {
1809 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1810 #if PERFORMANCE_EVALUATIONS > 0
1811 uifw_perf("SWAP_BUFFER appid=%s surface=%08x RESIZE",
1812 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1813 #endif /*PERFORMANCE_EVALUATIONS*/
1816 if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) {
1817 #if PERFORMANCE_EVALUATIONS > 0
1818 uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
1819 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1820 #endif /*PERFORMANCE_EVALUATIONS*/
1821 if (sm->interval < 0) {
1825 else if (sm->interval > 0) {
1826 dtime = (int)(curtime - sm->lasttime);
1827 if (dtime < sm->interval) {
1833 else if (sm->eventque) {
1834 if (sm->interval < 0) {
1837 else if (sm->interval > 0) {
1838 dtime = (int)(curtime - sm->lasttime);
1839 if (dtime < sm->interval) {
1850 sm->height = height;
1851 sm->stride = width * 4;
1852 sm->format = format;
1853 sm->curbuf = es->buffer_ref.buffer->legacy_buffer;
1856 if ((sm->eventque != 0) ||
1857 (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) {
1858 sm->curbuf = es->buffer_ref.buffer;
1859 if (es->buffer_ref.buffer != NULL) {
1860 width = es->buffer_ref.buffer->width;
1861 height = es->buffer_ref.buffer->height;
1865 height = es->height;
1867 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1869 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1870 uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x",
1871 sm->usurf->surfaceid);
1874 if ((width <= 0) || (height <= 0)) {
1877 uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0",
1878 sm->usurf->surfaceid);
1880 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1881 #if PERFORMANCE_EVALUATIONS > 0
1882 if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) {
1883 uifw_perf("SWAP_BUFFER appid=%s surface=%08x CONTENTS",
1884 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1886 #endif /*PERFORMANCE_EVALUATIONS*/
1887 if ((sm->width != width) || (sm->height != height)) {
1888 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1891 if (sm->interval < 0) {
1895 else if (sm->interval > 0) {
1896 dtime = (int)(curtime - sm->lasttime);
1897 if (dtime < sm->interval) {
1906 sm->height = height;
1907 sm->stride = width * 4;
1908 sm->format = EGL_TEXTURE_RGBA;
1917 uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d "
1918 "w/h/s=%d/%d/%d format=%x file=<%s>",
1919 event, sm->usurf->surfaceid, sm->type,
1920 sm->width, sm->height, sm->stride, sm->format, sm->filepath);
1921 sm->lasttime = curtime;
1923 if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) &&
1924 (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP) &&
1925 (sm->filepath[0] != 0)) {
1926 #if 1 /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1927 if (win_mgr_takeSurfaceScreenshot(sm->filepath, sm->usurf,
1928 sm->width, sm->height) != 0)
1929 #else /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1930 if (weston_layout_takeSurfaceScreenshot(sm->filepath,
1931 sm->usurf->ivisurf) != 0)
1932 #endif /* weston_layout_takeSurfaceScreenshot(GENIVI) is slowly */
1934 uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error",
1935 sm->usurf->surfaceid, sm->filepath);
1936 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
1939 uifw_trace("win_mgr_change_mapsurface: surface.%08x image read(%s) OK",
1940 sm->usurf->surfaceid, sm->filepath);
1943 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
1944 sm->usurf->surfaceid, sm->type,
1945 sm->width, sm->height, sm->stride, sm->format);
1946 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
1947 /* free map table if error */
1948 wl_list_remove(&sm->surf_link);
1949 wl_list_remove(&sm->map_link);
1950 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
1951 _ico_win_mgr->free_maptable = sm;
1956 /*--------------------------------------------------------------------------*/
1958 * @brief uifw_map_surface: mapped surface buffer to system application
1960 * @param[in] client Weyland client
1961 * @param[in] resource resource of request
1962 * @param[in] surfaceid surface id
1963 * @param[in] framerate frame rate of surface update(frame/sec)
1964 * if over 999, no change
1965 * @param[in] filepath surface image file path(if NULL, not create file)
1968 /*--------------------------------------------------------------------------*/
1970 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
1971 uint32_t surfaceid, int32_t framerate, const char *filepath)
1973 struct uifw_win_surface *usurf;
1974 struct weston_surface *es;
1975 struct uifw_surface_map *sm;
1976 struct weston_buffer *buffer;
1977 struct wl_shm_buffer *shm_buffer;
1978 struct uifw_client *uclient;
1979 struct uifw_gl_surface_state *gl_state;
1983 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d,file=%s)",
1984 surfaceid, framerate, filepath ? filepath : "(null)");
1986 uclient = ico_window_mgr_find_uclient(client);
1987 usurf = ico_window_mgr_get_usurf(surfaceid);
1989 /* surface dose not exist, error */
1990 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
1991 surfaceid, 1, 0, 0, 0, 0);
1992 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
1996 /* check if buffered */
1997 es = usurf->surface;
1999 /* surface has no buffer, error */
2000 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2001 surfaceid, 2, 0, 0, 0, 0);
2002 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid);
2005 buffer = es->buffer_ref.buffer;
2007 /* check buffer type */
2008 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2009 if (gl_state == NULL) {
2010 ico_window_mgr_send_map_surface(resource,
2011 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2012 surfaceid, 3, 0, 0, 0, 0);
2013 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no gl_state)", surfaceid);
2016 else if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2019 if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) {
2020 if (buffer != NULL) {
2021 shm_buffer = wl_shm_buffer_get(buffer->resource);
2023 format = wl_shm_buffer_get_format(shm_buffer);
2024 uifw_detail("uifw_map_surface: %08x shm_buffer type %x",
2026 if (format == WL_SHM_FORMAT_ARGB8888) {
2027 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
2032 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
2036 ico_window_mgr_send_map_surface(resource,
2037 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2038 surfaceid, 4, 0, 0, 0, 0);
2039 uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))",
2045 maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL;
2048 /* maximum framerate */
2049 if (framerate >= 0) {
2050 if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2051 if (framerate > 30) framerate = 30;
2054 if ((framerate <= 0) || (framerate > 5)) framerate = 5;
2058 /* check same surface */
2059 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2060 if ((sm->usurf == usurf) && (sm->uclient == uclient)) {
2065 if (&sm->surf_link == &usurf->surf_map) {
2066 /* create map table */
2067 sm = _ico_win_mgr->free_maptable;
2069 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
2072 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
2074 ico_window_mgr_send_map_surface(resource,
2075 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2076 surfaceid, 5, 0, 0, 0, 0);
2077 uifw_trace("uifw_map_surface: Leave(malloc error)");
2081 memset(sm, 0, sizeof(struct uifw_surface_map));
2083 wl_list_init(&sm->map_link);
2084 wl_list_init(&sm->surf_link);
2086 sm->uclient = uclient;
2088 sm->framerate = framerate;
2089 if (framerate < 0) sm->interval = -1;
2090 else sm->interval = (1000 / sm->framerate) - 1;
2091 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
2092 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
2095 /* change frame rate */
2096 uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d",
2097 sm->framerate, framerate);
2098 if (sm->framerate != framerate) {
2099 sm->framerate = framerate;
2100 if (framerate < 0) sm->interval = -1;
2101 else sm->interval = (1000 / sm->framerate) - 1;
2102 win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time());
2107 memset(sm->filepath, 0, ICO_IVI_FILEPATH_LENGTH);
2108 if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) {
2109 strncpy(sm->filepath, filepath, ICO_IVI_FILEPATH_LENGTH-1);
2112 if (buffer != NULL) {
2113 sm->width = buffer->width;
2114 sm->height = buffer->height;
2115 if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2116 sm->stride = sm->width * 4;
2117 sm->format = EGL_TEXTURE_RGBA;
2118 if ((sm->width > 0) && (sm->height > 0)) {
2121 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
2122 maptype, surfaceid, framerate, buffer->width, buffer->height);
2125 if (wl_resource_get_user_data((struct wl_resource *)buffer->legacy_buffer)
2127 sm->format = EGL_TEXTURE_RGBA;
2128 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
2129 (gl_state != NULL)) {
2132 uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d",
2133 surfaceid, framerate, buffer->width, buffer->height);
2136 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
2137 surfaceid, framerate);
2141 else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
2142 sm->width = es->width;
2143 sm->height = es->height;
2144 sm->stride = sm->width * 4;
2145 sm->format = EGL_TEXTURE_RGBA;
2146 if ((sm->width > 0) && (sm->height > 0)) {
2149 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
2150 maptype, surfaceid, framerate, sm->width, sm->height);
2153 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
2154 surfaceid, framerate);
2157 /* send map event */
2159 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP,
2160 weston_compositor_get_time());
2162 uifw_trace("uifw_map_surface: Leave");
2165 /*--------------------------------------------------------------------------*/
2167 * @brief uifw_unmap_surface: unmap surface buffer
2169 * @param[in] client Weyland client
2170 * @param[in] resource resource of request
2171 * @param[in] surfaceid surface id
2174 /*--------------------------------------------------------------------------*/
2176 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2179 struct uifw_win_surface *usurf;
2180 struct uifw_surface_map *sm, *sm_tmp;
2181 struct uifw_client *uclient;
2183 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2185 usurf = ico_window_mgr_get_usurf(surfaceid);
2187 /* surface dose not exist, error */
2188 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2192 uclient = ico_window_mgr_find_uclient(client);
2193 if ((! uclient) || (! uclient->mgr)) {
2194 /* client dose not exist, error */
2195 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2201 wl_list_for_each (sm, &usurf->surf_map, surf_link) {
2202 if (sm->uclient->mgr != NULL) {
2203 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x "
2204 "w/h/s=%d/%d/%d format=%x",
2205 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2206 sm->width, sm->height, sm->stride, sm->format);
2207 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2208 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2209 surfaceid, sm->type, sm->width,
2210 sm->height, sm->stride, sm->format);
2214 wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) {
2215 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2216 wl_list_remove(&sm->surf_link);
2217 wl_list_remove(&sm->map_link);
2218 if (sm->filepath[0]) {
2219 unlink(sm->filepath);
2221 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2222 _ico_win_mgr->free_maptable = sm;
2224 uifw_trace("uifw_unmap_surface: Leave");
2227 /*--------------------------------------------------------------------------*/
2229 * @brief uifw_layout_surface: direct layout surface
2231 * @param[in] client Weyland client
2232 * @param[in] resource resource of request
2233 * @param[in] surfaceid surface id
2234 * @param[in] layerid layer id
2237 * @param[in] width width
2238 * @param[in] height height
2239 * @param[in] visible visiblity
2242 /*--------------------------------------------------------------------------*/
2244 uifw_layout_surface(struct wl_client *client, struct wl_resource *resource,
2245 uint32_t surfaceid, uint32_t layerid, int x, int y,
2246 int width, int height, int visible)
2248 struct uifw_win_surface *usurf;
2249 struct weston_layout_layer *layout_layer;
2250 int32_t position[2];
2251 uint32_t dimension[2];
2253 uifw_trace("uifw_layout_surface: Enter(surf=%08x,layer=%d,x/y=%d/%d,w/h=%d,%d,vis=%d)",
2254 surfaceid, layerid, x, y, width, height, visible);
2256 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2258 /* surface dose not exist, error */
2259 uifw_trace("uifw_layout_surface: Leave(surface=%08x dose not exist)", surfaceid);
2263 layout_layer = weston_layout_getLayerFromId(layerid);
2264 if (! layout_layer) {
2265 /* layer dose not exist */
2266 uifw_trace("uifw_layout_surface: Leave(layer=%d dose not exist)", layerid);
2269 if (weston_layout_layerAddSurface(layout_layer, usurf->ivisurf) == 0) {
2270 if (weston_layout_layerSetVisibility(layout_layer, 1) != 0) {
2271 uifw_warn("uifw_layout_surface: layer(%d) visible Error", layerid);
2275 uifw_warn("uifw_layout_surface: can not add surface(%08x) to layer(%d)",
2276 usurf->surfaceid, layerid);
2280 if ((x >= 0) && (y >= 0) && (width > 0) && (height > 0)) {
2281 if (weston_layout_surfaceSetSourceRectangle(usurf->ivisurf,
2282 0, 0, width, height) != 0) {
2283 uifw_warn("uifw_layout_surface: surface(%08x) can not set source",
2286 if (weston_layout_surfaceSetDestinationRectangle(usurf->ivisurf,
2287 x, y, width, height) != 0) {
2288 uifw_warn("uifw_layout_surface: surface(%08x) can not set destination",
2292 else if ((x >= 0) && (y >= 0)) {
2295 if (weston_layout_surfaceSetPosition(usurf->ivisurf, position) != 0) {
2296 uifw_warn("uifw_layout_surface: surface(%08x) can not set source position",
2300 else if ((width > 0) && (height > 0)) {
2301 if (weston_layout_surfaceSetSourceRectangle(usurf->ivisurf,
2302 0, 0, width, height) != 0) {
2303 uifw_warn("uifw_layout_surface: surface(%08x) can not set source",
2306 dimension[0] = width;
2307 dimension[1] = height;
2308 if (weston_layout_surfaceSetDimension(usurf->ivisurf, dimension) != 0) {
2309 uifw_warn("uifw_layout_surface: surface(%08x) can not set destination size",
2314 if (weston_layout_surfaceSetVisibility(usurf->ivisurf, visible) != 0) {
2315 uifw_warn("uifw_layout_surface: surface(%08x) can not set visibility",
2319 if (weston_layout_commitChanges() != 0) {
2320 uifw_warn("uifw_layout_surface: surface(%08x) commit Error", usurf->surfaceid);
2322 uifw_trace("uifw_layout_surface: Leave");
2325 /*--------------------------------------------------------------------------*/
2327 * @brief win_mgr_destroy_surface: surface destroy
2329 * @param[in] surface Weston surface
2332 /*--------------------------------------------------------------------------*/
2334 win_mgr_destroy_surface(struct weston_surface *surface)
2336 struct uifw_win_surface *usurf;
2337 struct uifw_win_surface *phash;
2338 struct uifw_win_surface *bhash;
2341 usurf = find_uifw_win_surface_by_ws(surface);
2343 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
2346 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
2348 /* remove notification listener */
2349 if (weston_layout_surfaceRemoveNotification(usurf->ivisurf) != 0) {
2350 uifw_warn("win_mgr_destroy_surface: weston_layout_surfaceRemoveNotification(%08x)"
2351 " Error", usurf->surfaceid);
2354 /* destory input region */
2355 if (win_mgr_hook_destory) {
2356 (*win_mgr_hook_destory)(usurf);
2360 if (&usurf->surf_map != usurf->surf_map.next) {
2361 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
2364 /* destroy animation extenson */
2365 if (win_mgr_hook_animation) {
2366 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
2369 /* remove destroy listener */
2370 wl_list_remove(&usurf->surface_destroy_listener.link);
2372 /* send destroy event to controller */
2373 win_mgr_send_event(ICO_WINDOW_MGR_DESTROY_SURFACE, usurf->surfaceid, 0);
2375 /* delete from cleint list */
2376 wl_list_remove(&usurf->client_link);
2378 /* delete from hash table */
2379 hash = MAKE_IDHASH(usurf->surfaceid);
2380 phash = _ico_win_mgr->idhash[hash];
2382 while ((phash) && (phash != usurf)) {
2384 phash = phash->next_idhash;
2387 bhash->next_idhash = usurf->next_idhash;
2390 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
2393 hash = MAKE_WSHASH(usurf->surface);
2394 phash = _ico_win_mgr->wshash[hash];
2396 while ((phash) && (phash != usurf)) {
2398 phash = phash->next_wshash;
2401 bhash->next_wshash = usurf->next_wshash;
2404 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
2408 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
2411 /*--------------------------------------------------------------------------*/
2413 * @brief win_mgr_surface_destroy: weston_surface destroy listener
2415 * @param[in] listener listener
2416 * @param[in] data data (unused)
2419 /*--------------------------------------------------------------------------*/
2421 win_mgr_surface_destroy(struct wl_listener *listener, void *data)
2423 struct uifw_win_surface *usurf = container_of(listener, struct uifw_win_surface,
2424 surface_destroy_listener);
2426 uifw_trace("win_mgr_surface_destroy: Enter(%08x)", usurf->surfaceid);
2428 win_mgr_destroy_surface(usurf->surface);
2430 uifw_trace("win_mgr_surface_destroy: Leave");
2433 /*--------------------------------------------------------------------------*/
2435 * @brief win_mgr_takeSurfaceScreenshot: take screen image pixel
2437 * @param[in] filename output file path
2438 * @param[in] usurf UIFW surface
2439 * @param[in] width surface width
2440 * @param[in] height surface height
2445 /*--------------------------------------------------------------------------*/
2447 win_mgr_takeSurfaceScreenshot(const char *filename, struct uifw_win_surface *usurf,
2448 int width, int height)
2459 #pragma pack(push, 1)
2480 uifw_trace("win_mgr_takeSurfaceScreenshot: Enter(%08x) <%s>",
2481 usurf->surfaceid, filename);
2483 if (! _ico_win_mgr->compositor->renderer->read_surface_pixels) {
2484 uifw_trace("win_mgr_takeSurfaceScreenshot: Leave(no read_surface_pixels)");
2487 bitperpixel = PIXMAN_FORMAT_BPP(_ico_win_mgr->compositor->read_format);
2488 bmphead_size = ((sizeof(struct _bmphead) + 31) / 32) * 32;
2489 datasize = (width * bitperpixel / 8) * height;
2490 bufsize = datasize + bmphead_size;
2491 if ((_ico_win_mgr->pixel_readbuf != NULL) &&
2492 (bufsize > _ico_win_mgr->pixel_readsize)) {
2493 free(_ico_win_mgr->pixel_readbuf);
2494 _ico_win_mgr->pixel_readbuf = NULL;
2496 if (_ico_win_mgr->pixel_readbuf == NULL) {
2497 _ico_win_mgr->pixel_readbuf = malloc(bufsize);
2498 if (! _ico_win_mgr->pixel_readbuf) {
2499 uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
2502 _ico_win_mgr->pixel_readsize = bufsize;
2504 pathlen = strlen(filename);
2505 if ((pathlen >= 4) && (strcmp(&filename[pathlen-4], ".bmp") == 0)) {
2507 wkbuf = malloc(datasize);
2509 uifw_error("win_mgr_takeSurfaceScreenshot: Leave(can not allocate buffer)");
2513 fd = open(filename, O_WRONLY|O_CREAT, 0644);
2515 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> open Error<%d>)",
2521 uifw_detail("win_mgr_takeSurfaceScreenshot: call read_surface_pixels(%d,%d)",
2523 if ((*(_ico_win_mgr->compositor->
2524 renderer->read_surface_pixels))(usurf->surface, PIXMAN_a8r8g8b8,
2526 (_ico_win_mgr->pixel_readbuf + bmphead_size),
2527 0, 0, width, height) != 0) {
2529 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(read_surface_pixels Error)");
2533 uifw_detail("win_mgr_takeSurfaceScreenshot: end read_surface_pixels");
2537 bmphead = (struct _bmphead *)(_ico_win_mgr->pixel_readbuf +
2538 (bmphead_size - sizeof(struct _bmphead)));
2539 memset(bmphead, 0, sizeof(struct _bmphead));
2540 bmphead->magic = 0x4d42;
2541 bmphead->fullsize = sizeof(struct _bmphead) + datasize;
2542 bmphead->offset = 54;
2543 bmphead->headsize = 40;
2544 bmphead->width = width;
2545 bmphead->height = height;
2546 bmphead->planes = 1;
2547 bmphead->bitperpixel = bitperpixel;
2548 bmphead->compress = 0;
2549 bmphead->datasize = datasize;
2550 bmphead->xp = 100000;
2551 bmphead->yp = 100000;
2554 linesize = width * bitperpixel / 8;
2556 dp = _ico_win_mgr->pixel_readbuf + bmphead_size + (linesize * (height-1));
2557 for (pathlen = 0; pathlen < height; pathlen++) {
2558 memcpy(dp, sp, linesize);
2564 if (write(fd, bmphead, sizeof(struct _bmphead) + datasize) < 0) {
2565 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
2573 if (write(fd, _ico_win_mgr->pixel_readbuf + bmphead_size, datasize) < 0) {
2574 uifw_warn("win_mgr_takeSurfaceScreenshot: Leave(file<%s> write Error<%d>)",
2582 uifw_trace("win_mgr_takeSurfaceScreenshot: Leave");
2586 /*--------------------------------------------------------------------------*/
2588 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
2590 * @param[in] client client
2591 * @param[in] data user data(unused)
2592 * @param[in] version protocol version(unused)
2593 * @param[in] id client object id
2596 /*--------------------------------------------------------------------------*/
2598 bind_ico_win_mgr(struct wl_client *client,
2599 void *data, uint32_t version, uint32_t id)
2601 struct wl_resource *add_resource;
2602 struct uifw_manager *mgr;
2603 struct uifw_client *uclient;
2605 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
2607 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
2609 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
2610 _ico_win_mgr, unbind_ico_win_mgr);
2613 /* Create client management tabel */
2614 uclient = ico_window_mgr_find_uclient(client);
2616 win_mgr_bind_client(client, NULL);
2617 uclient = ico_window_mgr_find_uclient(client);
2621 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
2623 uifw_error("bind_ico_win_mgr: Error, No Memory");
2626 memset(mgr, 0, sizeof(struct uifw_manager));
2627 mgr->resource = add_resource;
2631 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
2633 uifw_trace("bind_ico_win_mgr: Leave");
2636 /*--------------------------------------------------------------------------*/
2638 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
2640 * @param[in] resource client resource
2643 /*--------------------------------------------------------------------------*/
2645 unbind_ico_win_mgr(struct wl_resource *resource)
2647 struct uifw_manager *mgr, *itmp;
2649 uifw_trace("unbind_ico_win_mgr: Enter");
2651 /* Remove manager from manager list */
2652 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
2653 if (mgr->resource == resource) {
2654 wl_list_remove(&mgr->link);
2658 uifw_trace("unbind_ico_win_mgr: Leave");
2661 /*--------------------------------------------------------------------------*/
2663 * @brief ico_window_mgr_get_uclient: get UIFW client table
2665 * @param[in] appid application Id
2666 * @return UIFW client table
2667 * @retval !=NULL success(UIFW client table address)
2668 * @retval = NULL error(appid not exist)
2670 /*--------------------------------------------------------------------------*/
2671 WL_EXPORT struct uifw_client *
2672 ico_window_mgr_get_uclient(const char *appid)
2674 struct uifw_client *uclient;
2676 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2677 if (strcmp(uclient->appid, appid) == 0) {
2684 /*--------------------------------------------------------------------------*/
2686 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
2688 * @param[in] target surface window name and application Id(winname@appid)
2689 * @return UIFW surface table
2690 * @retval !=NULL success(UIFW surface table address)
2691 * @retval = NULL error(appid or winname not exist)
2693 /*--------------------------------------------------------------------------*/
2694 WL_EXPORT struct uifw_win_surface *
2695 ico_window_mgr_get_client_usurf(const char *target)
2697 struct uifw_client *uclient;
2698 struct uifw_win_surface *usurf;
2700 char winname[ICO_IVI_WINNAME_LENGTH];
2701 char appid[ICO_IVI_APPID_LENGTH];
2703 /* get window name and application id */
2705 for (i = 0; target[i]; i++) {
2706 if (target[i] == '@') {
2707 if (target[i+1] != '@') break;
2710 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
2711 winname[j++] = target[i];
2715 if (target[i] == '@') {
2723 for ( ; target[i]; i++) {
2724 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
2725 if (j < (ICO_IVI_APPID_LENGTH-1)) {
2726 appid[j++] = target[i];
2730 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
2731 target, appid, winname);
2733 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2734 if (strcmp(uclient->appid, appid) == 0) {
2735 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
2736 if ((winname[0] == 0) ||
2737 (strcmp(winname, usurf->winname) == 0)) {
2746 /*--------------------------------------------------------------------------*/
2748 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
2750 * @param[in] hook_animation hook routine
2753 /*--------------------------------------------------------------------------*/
2755 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
2757 win_mgr_hook_animation = hook_animation;
2760 /*--------------------------------------------------------------------------*/
2762 * @brief ico_window_mgr_set_hook_change: set input region hook routine
2764 * @param[in] hook_change hook routine
2767 /*--------------------------------------------------------------------------*/
2769 ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf))
2771 win_mgr_hook_change = hook_change;
2774 /*--------------------------------------------------------------------------*/
2776 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
2778 * @param[in] hook_destroy hook routine
2781 /*--------------------------------------------------------------------------*/
2783 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
2785 win_mgr_hook_destory = hook_destroy;
2788 /*--------------------------------------------------------------------------*/
2790 * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine
2792 * @param[in] hook_inputregion hook routine
2795 /*--------------------------------------------------------------------------*/
2797 ico_window_mgr_set_hook_inputregion(
2798 void (*hook_inputregion)(int set, struct uifw_win_surface *usurf,
2799 int32_t x, int32_t y, int32_t width,
2800 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
2801 int32_t cursor_x, int32_t cursor_y, int32_t cursor_width,
2802 int32_t cursor_height, uint32_t attr))
2804 win_mgr_hook_inputregion = hook_inputregion;
2807 /*--------------------------------------------------------------------------*/
2809 * @brief module_init: initialize ico_window_mgr
2810 * this function called from ico_pluign_loader
2812 * @param[in] es weston compositor
2813 * @param[in] argc number of arguments(unused)
2814 * @param[in] argv argument list(unused)
2819 /*--------------------------------------------------------------------------*/
2821 module_init(struct weston_compositor *ec, int *argc, char *argv[])
2826 struct weston_output *output;
2827 struct weston_config_section *section;
2828 char *displayno = NULL;
2830 struct wl_event_loop *loop;
2832 uifw_info("ico_window_mgr: Enter(module_init)");
2834 /* get ivi debug level */
2835 section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL);
2837 weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0);
2838 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
2841 /* get display number */
2842 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
2844 weston_config_section_get_string(section, "displayno", &displayno, NULL);
2847 /* get animation default */
2848 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
2850 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
2851 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500);
2853 if (_ico_ivi_animation_name == NULL)
2854 _ico_ivi_animation_name = (char *)"fade";
2855 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500;
2857 /* create ico_window_mgr management table */
2858 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
2859 if (_ico_win_mgr == NULL) {
2860 uifw_error("ico_window_mgr: malloc failed");
2864 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
2866 _ico_win_mgr->compositor = ec;
2868 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
2869 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
2870 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
2871 uifw_error("ico_window_mgr: Error(wl_global_create)");
2875 wl_list_init(&_ico_win_mgr->client_list);
2876 wl_list_init(&_ico_win_mgr->manager_list);
2877 wl_list_init(&_ico_win_mgr->map_list);
2878 _ico_win_mgr->free_maptable = NULL;
2880 /* create display list */
2881 if (displayno != NULL) {
2888 wl_list_for_each (output, &ec->output_list, link) {
2889 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
2890 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurface;
2891 wl_list_insert(output->animation_list.prev,
2892 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
2894 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
2896 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
2898 wl_list_for_each (output, &ec->output_list, link) {
2901 idx = strtol(p, (char **)0, 0);
2902 uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx);
2904 if ((idx < 0) || (idx >= _ico_num_nodes)) {
2911 if (_ico_node_table[idx].node) {
2912 for (idx = 0; idx < _ico_num_nodes; idx++) {
2913 if (_ico_node_table[idx].node == 0) break;
2915 if (idx >= _ico_num_nodes) {
2916 uifw_error("ico_window_mgr: number of display overflow");
2920 _ico_node_table[idx].node = idx + 0x100;
2921 _ico_node_table[idx].displayno = i;
2922 _ico_node_table[idx].output = output;
2923 _ico_node_table[idx].disp_x = output->x;
2924 _ico_node_table[idx].disp_y = output->y;
2925 _ico_node_table[idx].disp_width = output->width;
2926 _ico_node_table[idx].disp_height = output->height;
2928 if (i >= _ico_num_nodes) break;
2931 for (i = 0; i < _ico_num_nodes; i++) {
2932 _ico_node_table[i].node &= 0x0ff;
2933 uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
2934 i, _ico_node_table[i].displayno,
2935 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
2936 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
2940 /* my node Id ... this version fixed 0 */
2941 nodeId = ico_ivi_get_mynode();
2943 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
2944 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
2945 nodeId, _ico_win_mgr->surface_head);
2947 /* get seat for touch down counter check */
2948 touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link);
2949 loop = wl_display_get_event_loop(ec->wl_display);
2950 _ico_win_mgr->wait_mapevent =
2951 wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL);
2952 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000);
2954 uifw_info("ico_window_mgr: animation name=%s time=%d",
2955 _ico_ivi_animation_name, _ico_ivi_animation_time);
2956 uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x",
2957 _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff,
2958 (_ico_ivi_debug_level >> 16) & 0x0ffff);
2960 /* touch/click binding for select surface */
2961 weston_compositor_add_button_binding(ec, BTN_LEFT, 0, win_mgr_click_to_activate, NULL);
2962 weston_compositor_add_touch_binding(ec, 0, win_mgr_touch_to_activate, NULL);
2964 /* set Notification function for GENIVI ivi-shell */
2965 if (weston_layout_setNotificationCreateSurface(ico_ivi_surfaceCreateNotification, NULL) != 0) {
2966 uifw_error("ico_window_mgr: weston_layout_setNotificationCreateSurface Error");
2968 if (weston_layout_setNotificationRemoveSurface(ico_ivi_surfaceRemoveNotification, NULL) != 0) {
2969 uifw_error("ico_window_mgr: weston_layout_setNotificationRemoveSurface Error");
2971 uifw_info("ico_window_mgr: Leave(module_init)");