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>
48 #include <wayland-server.h>
54 #include <GLES2/gl2.h>
56 #include <weston/compositor.h>
58 /* detail debug log */
59 #define UIFW_DETAIL_OUT 0 /* 1=detail debug log/0=no detail log */
61 #include <weston/weston-layout.h>
62 #include "ico_ivi_common_private.h"
63 #include "ico_window_mgr_private.h"
64 #include "ico_window_mgr-server-protocol.h"
66 /* gl_surface_state (inport from weston-1.4.0/src/gl-renderer.c */
72 struct uifw_gl_surface_state { /* struct gl_surface_state */
74 struct gl_shader *shader;
78 int needs_full_upload;
79 pixman_region32_t texture_damage;
81 void *images[3]; /* EGLImageKHR */
85 struct weston_buffer_reference buffer_ref;
86 enum buffer_type buffer_type;
87 int pitch; /* in pixels */
88 int height; /* in pixels */
89 int y_inverted; /* add weston 1.3.x */
93 #define UIFW_HASH 64 /* Hash value (2's compliment) */
94 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId hash mask pattern */
96 /* Internal fixed value */
97 #define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */
98 /* show/hide animation with position */
99 #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000
101 /* Multi Windiw Manager */
103 struct weston_compositor *compositor; /* Weston compositor */
104 void *shell; /* shell table address */
105 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
107 struct wl_list client_list; /* Clients */
108 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
110 struct wl_list map_list; /* surface map list */
111 struct uifw_surface_map *free_maptable; /* free maped surface table list */
112 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
113 /* animation for map check */
114 struct wl_event_source *wait_mapevent; /* map event send wait timer */
116 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
117 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
119 char shell_init; /* shell initialize flag */
120 char res[3]; /* (unused) */
123 /* Internal macros */
125 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
127 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
129 /* function prototype */
130 /* get surface table from weston surface*/
131 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
132 struct weston_surface *wsurf);
133 /* bind shell client */
134 static void win_mgr_bind_client(struct wl_client *client, void *shell);
136 static void win_mgr_destroy_client(struct wl_listener *listener, void *data);
137 #if 0 /* work around: Walk through child processes until app ID is found */
139 static pid_t win_mgr_get_ppid(pid_t pid);
140 #endif /* work around: Walk through child processes until app ID is found */
141 /* get appid from pid */
142 static void win_mgr_get_client_appid(struct uifw_client *uclient);
143 /* create new surface */
144 static void win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
145 struct wl_client *client,
146 struct weston_layout_surface *ivisurf);
147 /* surface destroy */
148 static void win_mgr_destroy_surface(struct weston_surface *surface);
149 /* window manager surface configure */
150 static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
151 int x, int y, int width, int height);
152 /* set surface animation */
153 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
154 uint32_t surfaceid, int32_t type,
155 const char *animation, int32_t time);
156 /* check and change all mapped surface */
157 static void win_mgr_check_mapsurface(struct weston_animation *animation,
158 struct weston_output *output, uint32_t msecs);
159 /* check timer of mapped surface */
160 static int win_mgr_timer_mapsurface(void *data);
161 /* check and change mapped surface */
162 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event,
164 /* map surface to system application */
165 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
166 uint32_t surfaceid, int32_t framerate, const char *filepath);
168 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
171 static void bind_ico_win_mgr(struct wl_client *client,
172 void *data, uint32_t version, uint32_t id);
174 static void unbind_ico_win_mgr(struct wl_resource *resource);
175 /* convert animation name to Id value */
176 static int ico_get_animation_name(const char *animation);
177 /* touch/click select surface */
178 static void win_mgr_select_surface(struct weston_seat *seat,
179 struct weston_surface *focus, int target);
180 static void win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
181 uint32_t button, void *data);
182 static void win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time,
184 /* hook for create surface of ivi-shell */
185 static void ico_ivi_surfaceCreateNotification(struct weston_layout_surface *ivisurf,
187 /* hook for remove surface of ivi-shell */
188 static void ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf,
190 /* hook for configure surface of ivi-shell*/
191 static void ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf,
193 /* hook for property change of ivi-shell*/
194 static void ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf,
195 struct weston_layout_SurfaceProperties *prop,
196 enum weston_layout_notification_mask mask,
198 /* hook for animation */
199 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
200 /* hook for input region */
201 static void (*win_mgr_hook_change)(struct uifw_win_surface *usurf) = NULL;
202 static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL;
203 static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf,
204 int32_t x, int32_t y, int32_t width,
205 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
206 int32_t cursor_x, int32_t cursor_y,
207 int32_t cursor_width, int32_t cursor_height,
208 uint32_t attr) = NULL;
211 /* Multi Window Manager interface */
212 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
219 /* plugin common value(without ico_plugin_loader) */
220 static int _ico_ivi_option_flag = 0; /* option flags */
221 static int _ico_ivi_debug_level = 3; /* debug Level */
222 static char *_ico_ivi_animation_name = NULL; /* default animation name */
223 static int _ico_ivi_animation_time = 500; /* default animation time */
224 static int _ico_ivi_animation_fps = 30; /* animation frame rate */
226 /* static management table */
227 static struct ico_win_mgr *_ico_win_mgr = NULL;
228 static int _ico_num_nodes = 0;
229 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
230 static struct weston_seat *touch_check_seat = NULL;
233 /*--------------------------------------------------------------------------*/
235 * @brief ico_ivi_optionflag: get option flags
238 * @return option flags
240 /*--------------------------------------------------------------------------*/
242 ico_ivi_optionflag(void)
244 return _ico_ivi_option_flag;
247 /*--------------------------------------------------------------------------*/
249 * @brief ico_ivi_debuglevel: answer debug output level.
252 * @return debug output level
253 * @retval 0 No debug output
254 * @retval 1 Only error output
255 * @retval 2 Error and Warning output
256 * @retval 3 Error, Warning and information output
257 * @retval 4 Error, Warning, information and Debug Trace output
258 * @retval 5 All output with debug write
260 /*--------------------------------------------------------------------------*/
262 ico_ivi_debuglevel(void)
264 return (_ico_ivi_debug_level & 0x0ffff);
267 /*--------------------------------------------------------------------------*/
269 * @brief ico_ivi_debugflag: get debug flags
272 * @return debug flags
274 /*--------------------------------------------------------------------------*/
276 ico_ivi_debugflag(void)
278 return ((_ico_ivi_debug_level >> 16) & 0x0ffff);
281 /*--------------------------------------------------------------------------*/
283 * @brief ico_ivi_default_animation_name: get default animation name
286 * @return Default animation name
288 /*--------------------------------------------------------------------------*/
289 WL_EXPORT const char *
290 ico_ivi_default_animation_name(void)
292 return _ico_ivi_animation_name;
295 /*--------------------------------------------------------------------------*/
297 * @brief ico_ivi_default_animation_time: get default animation time
300 * @return Default animation time(miri sec)
302 /*--------------------------------------------------------------------------*/
304 ico_ivi_default_animation_time(void)
306 return _ico_ivi_animation_time;
309 /*--------------------------------------------------------------------------*/
311 * @brief ico_ivi_default_animation_fps: get default animation frame rate
314 * @return Default animation frame rate(frames/sec)
316 /*--------------------------------------------------------------------------*/
318 ico_ivi_default_animation_fps(void)
320 return _ico_ivi_animation_fps;
323 /*--------------------------------------------------------------------------*/
325 * @brief ico_ivi_get_mynode: Get my NodeId
328 * @return NodeId of my node
330 /*--------------------------------------------------------------------------*/
332 ico_ivi_get_mynode(void)
334 /* Reference Platform 0.90 only support 1 ECU */
338 /*--------------------------------------------------------------------------*/
340 * @brief ico_ivi_surface_buffer_width: get surface buffer width
342 * @param[in] es weston surface
343 * @return buffer width(if surface has no buffer, return 0)
345 /*--------------------------------------------------------------------------*/
347 ico_ivi_surface_buffer_width(struct weston_surface *es)
351 if (! es->buffer_ref.buffer) {
354 if (es->buffer_viewport.viewport_set) {
355 return es->buffer_viewport.dst_width;
357 switch (es->buffer_viewport.transform) {
358 case WL_OUTPUT_TRANSFORM_90:
359 case WL_OUTPUT_TRANSFORM_270:
360 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
361 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
362 v = es->buffer_ref.buffer->height;
365 v = es->buffer_ref.buffer->width;
368 return (v / es->buffer_viewport.scale);
371 /*--------------------------------------------------------------------------*/
373 * @brief ico_ivi_surface_buffer_height: get surface buffer height
375 * @param[in] es weston surface
376 * @return buffer height(if surface has no buffer, return 0)
378 /*--------------------------------------------------------------------------*/
380 ico_ivi_surface_buffer_height(struct weston_surface *es)
384 if (! es->buffer_ref.buffer) {
387 if (es->buffer_viewport.viewport_set) {
388 return es->buffer_viewport.dst_height;
390 switch (es->buffer_viewport.transform) {
391 case WL_OUTPUT_TRANSFORM_90:
392 case WL_OUTPUT_TRANSFORM_270:
393 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
394 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
395 v = es->buffer_ref.buffer->width;
398 v = es->buffer_ref.buffer->height;
401 return (v / es->buffer_viewport.scale);
404 /*--------------------------------------------------------------------------*/
406 * @brief ico_ivi_surface_buffer_size: get surface buffer size
408 * @param[in] es weston surface
409 * @param[out] width buffer width
410 * @param[out] height buffer height
413 /*--------------------------------------------------------------------------*/
415 ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height)
417 if (! es->buffer_ref.buffer) {
421 else if (es->buffer_viewport.viewport_set) {
422 *width = es->buffer_viewport.dst_width;
423 *height = es->buffer_viewport.dst_height;
426 switch (es->buffer_viewport.transform) {
427 case WL_OUTPUT_TRANSFORM_90:
428 case WL_OUTPUT_TRANSFORM_270:
429 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
430 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
431 *width = es->buffer_ref.buffer->height;
432 *height = es->buffer_ref.buffer->width;
435 *width = es->buffer_ref.buffer->width;
436 *height = es->buffer_ref.buffer->height;
439 *width = *width / es->buffer_viewport.scale;
440 *height = *height / es->buffer_viewport.scale;
444 /*--------------------------------------------------------------------------*/
446 * @brief ico_ivi_surface_buffer_size: get surface buffer size
448 * @param[in] es weston surface
449 * @param[out] width buffer width
450 * @param[out] height buffer height
453 /*--------------------------------------------------------------------------*/
454 WL_EXPORT struct weston_view *
455 ico_ivi_get_primary_view(struct uifw_win_surface *usurf)
457 struct weston_view *ev = NULL;
458 struct shell_surface *shsurf;
460 if (_ico_win_mgr->compositor->shell_interface.get_primary_view) {
461 shsurf = usurf->surface->configure_private;
463 ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view)(NULL, shsurf);
467 ev = weston_layout_get_weston_view(usurf->ivisurf);
470 uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view",
471 (int)usurf, usurf->surfaceid, (int)usurf->surface);
474 uifw_debug("ico_ivi_get_primary_view: %08x view=%08x view->surf=%08x",
475 usurf->surfaceid, (int)ev, (int)ev->surface);
480 /*--------------------------------------------------------------------------*/
482 * @brief ico_window_mgr_set_weston_surface: set weston surface
484 * @param[in] usurf UIFW surface
485 * @param[in] x X coordinate on screen
486 * @param[in] y Y coordinate on screen
487 * @param[in] width width
488 * @param[in] height height
491 /*--------------------------------------------------------------------------*/
493 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
494 int x, int y, int width, int height)
496 struct weston_surface *es = usurf->surface;
497 struct weston_view *ev;
498 int buf_width, buf_height;
500 if ((es == NULL) || (usurf->ivisurf == NULL)) {
501 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
506 if (es->buffer_ref.buffer != NULL) {
507 ico_ivi_surface_buffer_size(es, &buf_width, &buf_height);
508 if ((width <= 0) || (height <= 0)) {
510 usurf->width = buf_width;
512 usurf->height = buf_height;
514 if ((usurf->width > buf_width) && (usurf->scalex <= 1.0f)) {
516 x += (usurf->width - buf_width)/2;
518 if ((usurf->height > buf_height) && (usurf->scaley <= 1.0f)) {
520 y += (usurf->height - buf_height)/2;
522 if (usurf->visible) {
523 x += usurf->node_tbl->disp_x;
524 y += usurf->node_tbl->disp_y;
527 x = ICO_IVI_MAX_COORDINATE+1;
528 y = ICO_IVI_MAX_COORDINATE+1;
530 ev = ico_ivi_get_primary_view(usurf);
532 (((int)ev->geometry.x != x) || ((int)ev->geometry.y != y) ||
533 (es->width != width) || (es->height != height))) {
534 weston_view_damage_below(ev);
535 win_mgr_surface_configure(usurf, x, y, width, height);
537 weston_surface_damage(es);
541 /*--------------------------------------------------------------------------*/
543 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
545 * @param[in] surfaceid UIFW surface id
546 * @return UIFW surface table address
547 * @retval !=NULL success(surface table address)
548 * @retval NULL error(surface id dose not exist)
550 /*--------------------------------------------------------------------------*/
551 WL_EXPORT struct uifw_win_surface *
552 ico_window_mgr_get_usurf(const uint32_t surfaceid)
554 struct uifw_win_surface *usurf;
556 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
559 if (usurf->surfaceid == surfaceid) {
562 usurf = usurf->next_idhash;
564 uifw_trace("ico_window_mgr_get_usurf: NULL");
568 /*--------------------------------------------------------------------------*/
570 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
572 * @param[in] surfaceid UIFW surface id
573 * @param[in] client Wayland client
574 * @return UIFW surface table address
575 * @retval !=NULL success(surface table address)
576 * @retval NULL error(surface id or client dose not exist)
578 /*--------------------------------------------------------------------------*/
579 WL_EXPORT struct uifw_win_surface *
580 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
582 struct uifw_win_surface *usurf;
584 usurf = ico_window_mgr_get_usurf(surfaceid);
588 /*--------------------------------------------------------------------------*/
590 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
592 * @param[in] wsurf Weston surface
593 * @return UIFW surface table address
594 * @retval !=NULL success(surface table address)
595 * @retval NULL error(surface dose not exist)
597 /*--------------------------------------------------------------------------*/
598 static struct uifw_win_surface *
599 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
601 struct uifw_win_surface *usurf;
603 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
606 if (usurf->surface == wsurf) {
609 usurf = usurf->next_wshash;
611 uifw_trace("find_uifw_win_surface_by_ws: NULL");
615 /*--------------------------------------------------------------------------*/
617 * @brief ico_window_mgr_find_uclient: find UIFW client by wayland client
619 * @param[in] client Wayland client
620 * @return UIFW client table address
621 * @retval !=NULL success(client table address)
622 * @retval NULL error(client dose not exist)
624 /*--------------------------------------------------------------------------*/
625 WL_EXPORT struct uifw_client*
626 ico_window_mgr_find_uclient(struct wl_client *client)
628 struct uifw_client *uclient;
630 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
631 if (uclient->client == client) {
635 uifw_trace("ico_window_mgr_find_uclient: client.%08x is NULL", (int)client);
639 /*--------------------------------------------------------------------------*/
641 * @brief ico_window_mgr_get_appid: find application id by wayland client
643 * @param[in] client Wayland client
644 * @return application id
645 * @retval !=NULL success(application id)
646 * @retval NULL error(client dose not exist)
648 /*--------------------------------------------------------------------------*/
650 ico_window_mgr_get_appid(struct wl_client* client)
652 struct uifw_client *uclient;
654 uclient = ico_window_mgr_find_uclient(client);
659 return uclient->appid;
662 /*--------------------------------------------------------------------------*/
664 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
666 * @param[in] displayno display number
667 * @param[out] x relative X coordinate
668 * @param[out] y relative Y coordinate
671 /*--------------------------------------------------------------------------*/
673 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
675 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
678 *x = _ico_node_table[displayno].disp_x;
679 *y = _ico_node_table[displayno].disp_y;
682 /*--------------------------------------------------------------------------*/
684 * @brief win_mgr_bind_client: desktop_shell from client
686 * @param[in] client Wayland client
687 * @param[in] shell shell table address
690 /*--------------------------------------------------------------------------*/
692 win_mgr_bind_client(struct wl_client *client, void *shell)
694 struct uifw_client *uclient;
700 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
701 (int)client, (int)shell);
703 /* save shell table address */
705 _ico_win_mgr->shell = shell;
709 uclient = ico_window_mgr_find_uclient(client);
711 /* client not exist, create client management table */
712 uifw_trace("win_mgr_bind_client: Create Client");
713 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
715 uifw_error("win_mgr_bind_client: Error, No Memory");
718 memset(uclient, 0, sizeof(struct uifw_client));
719 uclient->client = client;
720 wl_list_init(&uclient->surface_link);
722 uclient->destroy_listener.notify = win_mgr_destroy_client;
723 wl_client_add_destroy_listener(client, &uclient->destroy_listener);
728 wl_client_get_credentials(client, &pid, &uid, &gid);
729 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
730 (int)client, (int)pid, (int)uid, (int)gid);
732 uclient->pid = (int)pid;
733 /* get applicationId from AppCore(AUL) */
734 win_mgr_get_client_appid(uclient);
737 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
741 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
743 uifw_trace("win_mgr_bind_client: Leave");
746 /*--------------------------------------------------------------------------*/
748 * @brief win_mgr_destroy_client: destroy client
750 * @param[in] listener listener
751 * @param[in] data listener
754 /*--------------------------------------------------------------------------*/
756 win_mgr_destroy_client(struct wl_listener *listener, void *data)
758 struct uifw_client *uclient;
760 uclient = container_of(listener, struct uifw_client, destroy_listener);
762 uifw_trace("win_mgr_destroy_client: Enter(uclient=%08x)", (int)uclient);
765 /* Client exist, Destory client management table */
766 wl_list_remove(&uclient->link);
769 uifw_trace("win_mgr_destroy_client: Leave");
772 #if 0 /* work around: Walk through child processes until app ID is found */
773 /*--------------------------------------------------------------------------*/
775 * @brief win_mgr_get_ppid: Get parent process ID.
777 * Similar to getppid(), except that this implementation accepts an
778 * arbitrary process ID.
780 * @param[in] pid Process ID of child process
781 * @return parent process ID on success, -1 on failure
783 /*--------------------------------------------------------------------------*/
785 win_mgr_get_ppid(pid_t pid)
788 char procpath[PATH_MAX] = { 0 };
790 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid);
792 /* We better have read permissions! */
793 int const fd = open(procpath, O_RDONLY);
798 char buffer[1024] = { 0 };
800 ssize_t const size = read(fd, buffer, sizeof(buffer));
806 /* Find line containing the parent process ID. */
807 char const * const ppid_line = strstr(buffer, "PPid");
809 if (ppid_line != NULL)
810 sscanf(ppid_line, "PPid: %d", &ppid);
814 #endif /* work around: Walk through child processes until app ID is found */
816 /*--------------------------------------------------------------------------*/
818 * @brief win_mgr_get_client_appid: get applicationId from pid
820 * @param[in] uclient UIFW client management table
823 /*--------------------------------------------------------------------------*/
825 win_mgr_get_client_appid(struct uifw_client *uclient)
827 int status = AUL_R_ERROR;
829 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
831 #if 0 /* work around: Walk through child processes until app ID is found */
833 * Walk the parent process chain until we find a parent process
838 for (pid = uclient->pid;
839 pid > 1 && status != AUL_R_OK;
840 pid = win_mgr_get_ppid(pid)) {
842 status = aul_app_get_appid_bypid(pid,
844 ICO_IVI_APPID_LENGTH);
846 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
847 "pid=%d appid=<%s>", status, pid, uclient->appid);
850 * Walk the child process chain as well since app ID was not yet found
852 if (status != AUL_R_OK) {
861 dr = opendir("/proc/");
864 wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
866 while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
868 char fullpath[PATH_MAX] = { 0 };
872 snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
874 if (stat(fullpath, &ps) == -1) {
878 /* find pid dirs for this user (uid) only */
879 if (ps.st_uid != uid)
882 pid = atoi(de->d_name);
884 /* check if it's a valid child */
885 if (pid < uclient->pid)
888 /* scan up to pid to find if a chain exists */
889 for (tmppid = pid; tmppid > uclient->pid;) {
890 tmppid = win_mgr_get_ppid(tmppid);
891 if (tmppid == uclient->pid)
896 status = aul_app_get_appid_bypid(pid, uclient->appid,
897 ICO_IVI_APPID_LENGTH);
899 uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid "
900 "ret=%d pid=%d appid=<%s>", status, pid,
905 #else /* work around: Walk through child processes until app ID is found */
906 status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
907 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
908 "pid=%d appid=<%s>", status, uclient->pid, uclient->appid);
909 #endif /* work around: Walk through child processes until app ID is found */
911 if (uclient->appid[0] != 0) {
912 /* OK, end of get appid */
913 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
916 /* client does not exist in AppCore, search Linux process table */
924 uclient->fixed_appid ++;
925 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
926 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
927 fd = open(procpath, O_RDONLY);
929 size = read(fd, procpath, sizeof(procpath));
930 for (; size > 0; size--) {
931 if (procpath[size-1]) break;
934 /* get program base name */
936 for (j = 0; j < size; j++) {
937 if (procpath[j] == 0) break;
938 if (procpath[j] == '/') i = j + 1;
941 for (; i < size; i++) {
942 uclient->appid[j] = procpath[i];
943 if ((uclient->appid[j] == 0) ||
944 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
947 /* search application number in apprication start option */
948 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
949 for (; i < size; i++) {
950 if ((procpath[i] == 0) &&
951 (procpath[i+1] == '@')) {
952 strncpy(&uclient->appid[j], &procpath[i+1],
953 ICO_IVI_APPID_LENGTH - j - 2);
960 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
961 if (uclient->appid[i] != ' ') break;
963 uclient->appid[i+1] = 0;
964 if (uclient->appid[0]) {
965 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
967 uclient->pid, uclient->appid, uclient->fixed_appid );
970 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
972 sprintf(uclient->appid, "?%d?", uclient->pid);
977 /*--------------------------------------------------------------------------*/
979 * @brief ico_get_animation_name: convert animation name to Id value
981 * @param[in] animation animation name
982 * @return animation Id value
984 /*--------------------------------------------------------------------------*/
986 ico_get_animation_name(const char *animation)
988 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
990 if (strcasecmp(animation, "none") == 0) {
991 return ICO_WINDOW_MGR_ANIMATION_NONE;
994 if (win_mgr_hook_animation) {
995 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
998 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1003 /*--------------------------------------------------------------------------*/
1005 * @brief win_mgr_select_surface: select surface by mouse click
1007 * @param[in] seat weston seat
1008 * @param[in] focus selected surface
1009 * @param[in] select selected device
1012 /*--------------------------------------------------------------------------*/
1014 win_mgr_select_surface(struct weston_seat *seat, struct weston_surface *focus, int select)
1016 struct weston_surface *surface;
1017 struct uifw_win_surface *usurf;
1018 struct uifw_manager *mgr;
1020 surface = weston_surface_get_main_surface(focus);
1022 uifw_trace("win_mgr_select_surface: Enter(%08x,%d)", (int)surface, select);
1025 uifw_trace("win_mgr_select_surface: Leave(no surface)");
1029 usurf = find_uifw_win_surface_by_ws(surface);
1031 uifw_trace("win_mgr_select_surface: Leave(usurf not exist)");
1034 /* surface active */
1035 weston_surface_activate(surface, seat);
1037 /* send active event to manager */
1038 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1039 uifw_trace("win_mgr_select_surface: Send Manager ACTIVE(surf=%08x)",
1041 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
1044 uifw_trace("win_mgr_select_surface: Leave");
1047 /*--------------------------------------------------------------------------*/
1049 * @brief win_mgr_click_to_activate: select surface by mouse click
1051 * @param[in] seat weston seat
1052 * @param[in] time click time(current time)
1053 * @param[in] button click button
1054 * @param[in] data user data(unused)
1057 /*--------------------------------------------------------------------------*/
1059 win_mgr_click_to_activate(struct weston_seat *seat, uint32_t time,
1060 uint32_t button, void *data)
1062 if (seat->pointer->grab != &seat->pointer->default_grab)
1064 if (seat->pointer->focus == NULL)
1067 win_mgr_select_surface(seat, seat->pointer->focus->surface,
1068 ICO_WINDOW_MGR_SELECT_POINTER);
1071 /*--------------------------------------------------------------------------*/
1073 * @brief win_mgr_touch_to_activate: select surface by touch touch-panel
1075 * @param[in] seat weston seat
1076 * @param[in] time click time(current time)
1077 * @param[in] data user data(unused)
1080 /*--------------------------------------------------------------------------*/
1082 win_mgr_touch_to_activate(struct weston_seat *seat, uint32_t time, void *data)
1084 if (seat->touch->grab != &seat->touch->default_grab)
1086 if (seat->touch->focus == NULL)
1089 win_mgr_select_surface(seat, seat->touch->focus->surface, ICO_WINDOW_MGR_SELECT_TOUCH);
1092 /*--------------------------------------------------------------------------*/
1094 * @brief ico_ivi_surfaceCreateNotification: create ivi-surface
1096 * @param[in] ivisurf ivi surface
1097 * @param[in] userdata User Data(Unused)
1100 /*--------------------------------------------------------------------------*/
1102 ico_ivi_surfaceCreateNotification(struct weston_layout_surface *ivisurf, void *userdata)
1104 uint32_t id_surface;
1105 struct weston_view *ev;
1106 struct weston_surface *es;
1107 struct wl_client *client;
1109 id_surface = weston_layout_getIdOfSurface(ivisurf);
1110 uifw_trace("ico_ivi_surfaceCreateNotification: Create %x", id_surface);
1112 /* set property notification */
1113 if (weston_layout_surfaceAddNotification(ivisurf, ico_ivi_surfacePropertyNotification, NULL) != 0) {
1114 uifw_error("ico_ivi_surfaceCreateNotification: weston_layout_surfaceAddNotification Error");
1116 ev = weston_layout_get_weston_view(ivisurf);
1118 uifw_error("ico_ivi_surfaceCreateNotification: weston_layout_get_weston_view Error");
1123 uifw_error("ico_ivi_surfaceCreateNotification: no weston_surface");
1126 client = wl_resource_get_client(es->resource);
1128 uifw_error("ico_ivi_surfaceCreateNotification: no wl_client");
1131 win_mgr_register_surface(id_surface, es, client, ivisurf);
1137 /*--------------------------------------------------------------------------*/
1139 * @brief ico_ivi_surfaceRemoveNotification: remove ivi-surface
1141 * @param[in] ivisurf ivi surface
1142 * @param[in] userdata User Data(Unused)
1145 /*--------------------------------------------------------------------------*/
1147 ico_ivi_surfaceRemoveNotification(struct weston_layout_surface *ivisurf, void *userdata)
1149 uint32_t id_surface;
1150 struct weston_view *ev;
1151 struct weston_surface *es;
1153 id_surface = weston_layout_getIdOfSurface(ivisurf);
1154 uifw_trace("ico_ivi_surfaceRemoveNotification: Remove %x", id_surface);
1156 ev = weston_layout_get_weston_view(ivisurf);
1158 uifw_error("ico_ivi_surfaceRemoveNotification: weston_layout_get_weston_view Error");
1163 uifw_error("ico_ivi_surfaceRemoveNotification: no weston_surface");
1166 win_mgr_destroy_surface(es);
1171 /*--------------------------------------------------------------------------*/
1173 * @brief ico_ivi_surfaceConfigureNotification: configure ivi-surface
1175 * @param[in] ivisurf ivi surface
1176 * @param[in] userdata User Data(Unused)
1179 /*--------------------------------------------------------------------------*/
1181 ico_ivi_surfaceConfigureNotification(struct weston_layout_surface *ivisurf, void *userdata)
1183 struct weston_view *view;
1184 struct weston_surface *surface;
1185 uint32_t id_surface;
1186 #if 1 /* for check genivi */
1187 struct weston_layout_SurfaceProperties prop;
1190 id_surface = weston_layout_getIdOfSurface(ivisurf);
1191 view = weston_layout_get_weston_view(ivisurf);
1193 uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no view",
1197 surface = view->surface;
1199 uifw_trace("ico_ivi_surfaceConfigureNotification: %08x has no surface",
1203 #if 1 /* for check genivi */
1204 if (weston_layout_getPropertiesOfSurface(ivisurf, &prop) != 0) {
1205 uifw_trace("ico_ivi_surfaceConfigureNotification: Properties get Error");
1206 uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x "
1207 "x/y=%d/%d w/h=%d/%d",
1208 id_surface, (int)view->geometry.x, (int)view->geometry.y,
1209 surface->width, surface->height);
1212 uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x "
1213 "x/y=%d/%d->%d/%d w/h=%d/%d(%d/%d)->%d/%d",
1214 id_surface, prop.destX, prop.destY,
1215 (int)view->geometry.x, (int)view->geometry.y,
1216 prop.sourceWidth, prop.sourceHeight,
1217 prop.origSourceWidth, prop.origSourceHeight,
1218 surface->width, surface->height);
1221 uifw_trace("ico_ivi_surfaceConfigureNotification: Configure %08x "
1222 "x/y=%d/%d w/h=%d/%d",
1223 id_surface, (int)view->geometry.x, (int)view->geometry.y,
1224 surface->width, surface->height);
1226 weston_layout_surfaceSetSourceRectangle(ivisurf,
1227 0, 0, surface->width, surface->height);
1228 weston_layout_surfaceSetDestinationRectangle(ivisurf,
1229 (uint32_t)view->geometry.x, (uint32_t)view->geometry.y,
1230 surface->width, surface->height);
1231 weston_layout_commitChanges();
1236 /*--------------------------------------------------------------------------*/
1238 * @brief ico_ivi_surfacePropertyNotification: property change ivi-surface
1240 * @param[in] ivisurf ivi surface
1241 * @param[in] userdata User Data(Unused)
1244 /*--------------------------------------------------------------------------*/
1246 ico_ivi_surfacePropertyNotification(struct weston_layout_surface *ivisurf,
1247 struct weston_layout_SurfaceProperties *prop,
1248 enum weston_layout_notification_mask mask,
1251 uint32_t id_surface;
1253 struct uifw_win_surface *usurf;
1255 id_surface = weston_layout_getIdOfSurface(ivisurf);
1257 usurf = ico_window_mgr_get_usurf(id_surface);
1258 uifw_trace("ico_ivi_surfacePropertyNotification: Property %x(%08x) usurf=%08x",
1259 id_surface, mask, (int)usurf);
1260 if ((mask & IVI_NOTIFICATION_VISIBILITY) && (usurf != NULL)) {
1261 if ((usurf->visible == 0) && (prop->visibility)) {
1262 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 0=>1",
1265 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1266 (win_mgr_hook_animation != NULL)) {
1267 /* show with animation */
1268 usurf->animation.pos_x = usurf->x;
1269 usurf->animation.pos_y = usurf->y;
1270 usurf->animation.pos_width = usurf->width;
1271 usurf->animation.pos_height = usurf->height;
1273 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1275 uifw_trace("ico_ivi_surfacePropertyNotification: ret call anima = %d",
1279 else if ((usurf->visible != 0) && (! prop->visibility)) {
1280 uifw_trace("ico_ivi_surfacePropertyNotification: %08x Visible 1=>0",
1282 if ((usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1283 (win_mgr_hook_animation != NULL)) {
1284 /* hide with animation */
1285 usurf->animation.pos_x = usurf->x;
1286 usurf->animation.pos_y = usurf->y;
1287 usurf->animation.pos_width = usurf->width;
1288 usurf->animation.pos_height = usurf->height;
1290 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1294 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1296 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1298 uifw_trace("ico_ivi_surfacePropertyNotification: Change to UnVisible");
1302 uifw_trace("ico_ivi_surfacePropertyNotification: Change to Visible");
1303 weston_layout_surfaceSetVisibility(ivisurf, 1);
1304 weston_layout_commitChanges();
1308 uifw_trace("ico_ivi_surfacePropertyNotification: visible no change");
1314 /*--------------------------------------------------------------------------*/
1316 * @brief win_mgr_register_surface: create UIFW surface
1318 * @param[in] id_surface surface id (by ivi-shell)
1319 * @param[in] surface Weston surface
1320 * @param[in] client Wayland client
1321 * @param[in] ivisurf weston layout surface
1324 /*--------------------------------------------------------------------------*/
1326 win_mgr_register_surface(uint32_t id_surface, struct weston_surface *surface,
1327 struct wl_client *client, struct weston_layout_surface *ivisurf)
1329 struct uifw_win_surface *usurf;
1330 struct uifw_win_surface *phash;
1331 struct uifw_win_surface *bhash;
1334 uifw_trace("win_mgr_register_surface: Enter(surf=%x[%08x],client=%08x,ivisurf=%08x)",
1335 id_surface, (int)surface, (int)client, (int)ivisurf);
1337 /* check new surface */
1338 if (find_uifw_win_surface_by_ws(surface)) {
1339 /* surface exist, NOP */
1340 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
1344 /* set default color and shader */
1345 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
1346 /* create UIFW surface management table */
1347 usurf = malloc(sizeof(struct uifw_win_surface));
1349 uifw_error("win_mgr_register_surface: No Memory");
1353 memset(usurf, 0, sizeof(struct uifw_win_surface));
1355 usurf->surfaceid = id_surface;
1356 usurf->surface = surface;
1357 usurf->ivisurf = ivisurf;
1358 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
1359 wl_list_init(&usurf->client_link);
1360 wl_list_init(&usurf->animation.animation.link);
1361 wl_list_init(&usurf->surf_map);
1362 wl_list_init(&usurf->input_region);
1363 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
1364 usurf->animation.hide_time = ico_ivi_default_animation_time();
1365 usurf->animation.show_anima = usurf->animation.hide_anima;
1366 usurf->animation.show_time = usurf->animation.hide_time;
1367 usurf->animation.move_anima = usurf->animation.hide_anima;
1368 usurf->animation.move_time = usurf->animation.hide_time;
1369 usurf->animation.resize_anima = usurf->animation.hide_anima;
1370 usurf->animation.resize_time = usurf->animation.hide_time;
1374 usurf->uclient = ico_window_mgr_find_uclient(client);
1375 if (! usurf->uclient) {
1376 /* client not exist, create client management table */
1377 uifw_trace("win_mgr_register_surface: Create Client");
1378 win_mgr_bind_client(client, NULL);
1379 usurf->uclient = ico_window_mgr_find_uclient(client);
1380 if (! usurf->uclient) {
1381 uifw_error("win_mgr_register_surface: No Memory");
1385 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1387 /* make surface id hash table */
1388 hash = MAKE_IDHASH(usurf->surfaceid);
1389 phash = _ico_win_mgr->idhash[hash];
1393 phash = phash->next_idhash;
1396 bhash->next_idhash = usurf;
1399 _ico_win_mgr->idhash[hash] = usurf;
1402 /* make weston surface hash table */
1403 hash = MAKE_WSHASH(usurf->surface);
1404 phash = _ico_win_mgr->wshash[hash];
1408 phash = phash->next_wshash;
1411 bhash->next_wshash = usurf;
1414 _ico_win_mgr->wshash[hash] = usurf;
1416 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1419 /*--------------------------------------------------------------------------*/
1421 * @brief uifw_set_animation: set animation of surface visible/unvisible
1423 * @param[in] client Weyland client
1424 * @param[in] resource resource of request
1425 * @param[in] surfaceid UIFW surface id
1426 * @param[in] type how to change surface
1427 * @param[in] anmation animation name
1428 * @param[in] time animation time(ms), if 0, default time
1431 /*--------------------------------------------------------------------------*/
1433 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1434 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1437 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1439 uifw_trace("uifw_set_transition: surf=%08x,type=%x,anim=%s,time=%d",
1440 surfaceid, type, animation, time);
1443 if ((*animation != 0) && (*animation != ' ')) {
1444 animaid = ico_get_animation_name(animation);
1445 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1446 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1447 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1448 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1449 usurf->animation.next_anima = animaid;
1452 usurf->animation.hide_anima = animaid;
1455 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1456 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1457 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1458 usurf->animation.next_anima = animaid;
1461 usurf->animation.show_anima = animaid;
1464 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1465 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
1466 usurf->animation.next_anima = animaid;
1469 usurf->animation.move_anima = animaid;
1472 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1473 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
1474 usurf->animation.next_anima = animaid;
1477 usurf->animation.resize_anima = animaid;
1481 if ((time > 0) && (time < 10000)) {
1482 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1483 usurf->animation.hide_time = time;
1485 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1486 usurf->animation.show_time = time;
1488 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1489 usurf->animation.move_time = time;
1491 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1492 usurf->animation.resize_time = time;
1497 uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid);
1501 /*--------------------------------------------------------------------------*/
1503 * @brief win_mgr_check_mapsurface: check and change all surface
1505 * @param[in] animation weston animation table(unused)
1506 * @param[in] outout weston output table(unused)
1507 * @param[in] mseces current time(unused)
1510 /*--------------------------------------------------------------------------*/
1512 win_mgr_check_mapsurface(struct weston_animation *animation,
1513 struct weston_output *output, uint32_t msecs)
1515 struct uifw_surface_map *sm, *sm_tmp;
1517 int wait = 99999999;
1519 /* check touch down counter */
1520 if ((touch_check_seat) &&
1521 (touch_check_seat->touch)) {
1522 if (touch_check_seat->touch->num_tp > 10) {
1523 uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset",
1524 (int)touch_check_seat->touch->num_tp);
1525 touch_check_seat->touch->num_tp = 0;
1529 /* check all mapped surfaces */
1530 curtime = weston_compositor_get_time();
1531 wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) {
1532 uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x",
1533 (int)sm, sm->usurf->surfaceid);
1534 win_mgr_change_mapsurface(sm, 0, curtime);
1536 if (sm->interval < wait) {
1537 wait = sm->interval;
1542 /* check frame interval */
1549 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait);
1552 /*--------------------------------------------------------------------------*/
1554 * @brief win_mgr_timer_mapsurface: mapped surface check timer
1556 * @param[in] data user data(unused)
1559 /*--------------------------------------------------------------------------*/
1561 win_mgr_timer_mapsurface(void *data)
1563 win_mgr_check_mapsurface(NULL, NULL, 0);
1567 /*--------------------------------------------------------------------------*/
1569 * @brief win_mgr_change_mapsurface: check and change mapped surface
1571 * @param[in] sm map surface table
1572 * @param[in] event send event (if 0, send if changed)
1573 * @param[in] curtime current time(ms)
1576 /*--------------------------------------------------------------------------*/
1578 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime)
1580 struct weston_surface *es;
1581 struct wl_shm_buffer *shm_buffer;
1587 uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event);
1589 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
1592 /* check if buffered */
1593 es = sm->usurf->surface;
1595 ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) &&
1596 ((es->buffer_ref.buffer == NULL) ||
1597 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) {
1598 /* surface has no buffer */
1599 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x",
1600 sm->usurf->surfaceid, (int)es,
1601 es ? (int)es->buffer_ref.buffer : 0);
1603 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1609 else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1610 if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) {
1611 if ((void *)wl_resource_get_user_data(
1612 (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer)
1614 /* surface has no buffer */
1615 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer",
1616 sm->usurf->surfaceid);
1618 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1627 if (es->buffer_ref.buffer != NULL) {
1628 shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource);
1630 format = wl_shm_buffer_get_format(shm_buffer);
1631 if (format != WL_SHM_FORMAT_ARGB8888) {
1632 uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x",
1633 sm->usurf->surfaceid, format);
1634 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
1640 if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) {
1642 if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1643 format = EGL_TEXTURE_RGBA; /* currently only support RGBA */
1644 width = es->buffer_ref.buffer->width;
1645 height = es->buffer_ref.buffer->height;
1646 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1648 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1650 else if ((width <= 0) || (height <= 0)) {
1653 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1654 if ((sm->width != width) || (sm->height != height) ||
1655 (format != sm->format)) {
1656 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1659 if (es->buffer_ref.buffer->legacy_buffer != sm->curbuf) {
1660 #if PERFORMANCE_EVALUATIONS > 0
1661 uifw_perf("SWAP_BUFFER appid=%s surface=%08x",
1662 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1663 #endif /*PERFORMANCE_EVALUATIONS*/
1664 dtime = curtime - sm->lasttime;
1665 if ((sm->interval > 0) && (dtime < sm->interval)) {
1670 else if (sm->eventque) {
1671 dtime = curtime - sm->lasttime;
1672 if ((sm->interval > 0) && (dtime < sm->interval)) {
1682 sm->height = height;
1683 sm->stride = width * 4;
1684 sm->format = format;
1685 sm->curbuf = es->buffer_ref.buffer->legacy_buffer;
1688 if ((sm->eventque != 0) ||
1689 (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) {
1690 sm->curbuf = es->buffer_ref.buffer;
1691 if (es->buffer_ref.buffer != NULL) {
1692 width = es->buffer_ref.buffer->width;
1693 height = es->buffer_ref.buffer->height;
1697 height = es->height;
1699 if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
1701 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
1702 uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x",
1703 sm->usurf->surfaceid);
1706 if ((width <= 0) || (height <= 0)) {
1709 uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0",
1710 sm->usurf->surfaceid);
1712 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
1713 #if PERFORMANCE_EVALUATIONS > 0
1714 if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) {
1715 uifw_perf("SWAP_BUFFER appid=%s surface=%08x",
1716 sm->usurf->uclient->appid, sm->usurf->surfaceid);
1718 #endif /*PERFORMANCE_EVALUATIONS*/
1719 if ((sm->width != width) || (sm->height != height)) {
1720 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
1723 dtime = curtime - sm->lasttime;
1724 if ((sm->interval > 0) && (dtime < sm->interval)) {
1727 uifw_detail("win_mgr_change_mapsurface: PIX %08x new queue",
1728 sm->usurf->surfaceid);
1730 else if (sm->eventque) {
1731 dtime = curtime - sm->lasttime;
1732 if ((sm->interval > 0) && (dtime < sm->interval)) {
1734 uifw_detail("win_mgr_change_mapsurface: PIX %08x queued",
1735 sm->usurf->surfaceid);
1742 sm->height = height;
1743 sm->stride = width * 4;
1744 sm->format = EGL_TEXTURE_RGBA;
1753 uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d "
1754 "w/h/s=%d/%d/%d format=%x",
1755 event, sm->usurf->surfaceid, sm->type,
1756 sm->width, sm->height, sm->stride, sm->format);
1757 sm->lasttime = curtime;
1759 if ((event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) &&
1760 (sm->filepath != NULL)) {
1761 if (weston_layout_takeSurfaceScreenshot(sm->filepath,
1762 sm->usurf->ivisurf) != 0) {
1763 uifw_warn("win_mgr_change_mapsurface: surface.%08x image read(%s) Error",
1764 sm->usurf->surfaceid, sm->filepath);
1765 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
1768 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
1769 sm->usurf->surfaceid, sm->type,
1770 sm->width, sm->height, sm->stride, sm->format);
1771 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
1772 /* free map table if error */
1773 wl_list_remove(&sm->surf_link);
1774 wl_list_remove(&sm->map_link);
1775 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
1776 _ico_win_mgr->free_maptable = sm;
1781 /*--------------------------------------------------------------------------*/
1783 * @brief uifw_map_surface: mapped surface buffer to system application
1785 * @param[in] client Weyland client
1786 * @param[in] resource resource of request
1787 * @param[in] surfaceid surface id
1788 * @param[in] framerate frame rate of surface update(frame/sec)
1789 * @param[in] filepath surface image file path(if NULL, not create file)
1792 /*--------------------------------------------------------------------------*/
1794 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
1795 uint32_t surfaceid, int32_t framerate, const char *filepath)
1797 struct uifw_win_surface *usurf;
1798 struct weston_surface *es;
1799 struct uifw_surface_map *sm;
1800 struct weston_buffer *buffer;
1801 struct wl_shm_buffer *shm_buffer;
1802 struct uifw_client *uclient;
1803 struct uifw_gl_surface_state *gl_state;
1807 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d,file=%s)",
1808 surfaceid, framerate, filepath ? filepath : "(null)");
1810 uclient = ico_window_mgr_find_uclient(client);
1811 usurf = ico_window_mgr_get_usurf(surfaceid);
1813 /* surface dose not exist, error */
1814 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
1815 surfaceid, 1, 0, 0, 0, 0);
1816 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
1820 /* check if buffered */
1821 es = usurf->surface;
1823 /* surface has no buffer, error */
1824 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
1825 surfaceid, 2, 0, 0, 0, 0);
1826 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid);
1829 buffer = es->buffer_ref.buffer;
1831 /* check buffer type */
1832 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
1833 if (gl_state == NULL) {
1834 ico_window_mgr_send_map_surface(resource,
1835 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
1836 surfaceid, 3, 0, 0, 0, 0);
1837 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no gl_state)", surfaceid);
1840 else if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
1843 if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) {
1844 if (buffer != NULL) {
1845 shm_buffer = wl_shm_buffer_get(buffer->resource);
1847 format = wl_shm_buffer_get_format(shm_buffer);
1848 uifw_detail("uifw_map_surface: %08x shm_buffer type %x",
1850 if (format == WL_SHM_FORMAT_ARGB8888) {
1851 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
1856 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
1860 ico_window_mgr_send_map_surface(resource,
1861 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
1862 surfaceid, 4, 0, 0, 0, 0);
1863 uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))",
1869 maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL;
1872 /* maximum framerate */
1873 if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1874 if ((framerate <= 0) || (framerate > 15))
1878 if ((framerate <= 0) || (framerate > 5))
1882 /* check same surface */
1883 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
1884 if ((sm->usurf == usurf) && (sm->uclient == uclient)) {
1889 if (&sm->surf_link == &usurf->surf_map) {
1890 /* create map table */
1891 sm = _ico_win_mgr->free_maptable;
1893 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
1896 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
1898 ico_window_mgr_send_map_surface(resource,
1899 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
1900 surfaceid, 5, 0, 0, 0, 0);
1901 uifw_trace("uifw_map_surface: Leave(malloc error)");
1905 memset(sm, 0, sizeof(struct uifw_surface_map));
1907 wl_list_init(&sm->map_link);
1908 wl_list_init(&sm->surf_link);
1910 sm->uclient = uclient;
1912 sm->framerate = framerate;
1913 sm->interval = (1000 / sm->framerate) - 1;
1914 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
1915 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
1918 /* change frame rate */
1919 uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d",
1920 sm->framerate, framerate);
1921 if (sm->framerate != framerate) {
1922 sm->framerate = framerate;
1923 sm->interval = (1000 / sm->framerate) - 1;
1924 win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time());
1929 memset(sm->filepath, 0, ICO_IVI_FILEPATH_LENGTH);
1930 if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) {
1931 strncpy(sm->filepath, filepath, ICO_IVI_FILEPATH_LENGTH-1);
1934 if (buffer != NULL) {
1935 sm->width = buffer->width;
1936 sm->height = buffer->height;
1937 if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1938 sm->stride = sm->width * 4;
1939 sm->format = EGL_TEXTURE_RGBA;
1940 if ((sm->width > 0) && (sm->height > 0)) {
1943 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
1944 maptype, surfaceid, framerate, buffer->width, buffer->height);
1947 if (wl_resource_get_user_data((struct wl_resource *)buffer->legacy_buffer)
1949 sm->format = EGL_TEXTURE_RGBA;
1950 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
1951 (gl_state != NULL)) {
1954 uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d",
1955 surfaceid, framerate, buffer->width, buffer->height);
1958 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
1959 surfaceid, framerate);
1963 else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
1964 sm->width = es->width;
1965 sm->height = es->height;
1966 sm->stride = sm->width * 4;
1967 sm->format = EGL_TEXTURE_RGBA;
1968 if ((sm->width > 0) && (sm->height > 0)) {
1971 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
1972 maptype, surfaceid, framerate, sm->width, sm->height);
1975 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
1976 surfaceid, framerate);
1979 /* send map event */
1981 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP,
1982 weston_compositor_get_time());
1984 uifw_trace("uifw_map_surface: Leave");
1987 /*--------------------------------------------------------------------------*/
1989 * @brief uifw_unmap_surface: unmap surface buffer
1991 * @param[in] client Weyland client
1992 * @param[in] resource resource of request
1993 * @param[in] surfaceid surface id
1996 /*--------------------------------------------------------------------------*/
1998 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2001 struct uifw_win_surface *usurf;
2002 struct uifw_surface_map *sm, *sm_tmp;
2003 struct uifw_client *uclient;
2005 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2007 usurf = ico_window_mgr_get_usurf(surfaceid);
2009 /* surface dose not exist, error */
2010 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2014 uclient = ico_window_mgr_find_uclient(client);
2015 if ((! uclient) || (! uclient->mgr)) {
2016 /* client dose not exist, error */
2017 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2023 wl_list_for_each (sm, &usurf->surf_map, surf_link) {
2024 if (sm->uclient->mgr != NULL) {
2025 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x "
2026 "w/h/s=%d/%d/%d format=%x",
2027 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2028 sm->width, sm->height, sm->stride, sm->format);
2029 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2030 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2031 surfaceid, sm->type, sm->width,
2032 sm->height, sm->stride, sm->format);
2036 wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) {
2037 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2038 wl_list_remove(&sm->surf_link);
2039 wl_list_remove(&sm->map_link);
2040 if (sm->filepath[0]) {
2041 unlink(sm->filepath);
2043 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2044 _ico_win_mgr->free_maptable = sm;
2046 uifw_trace("uifw_unmap_surface: Leave");
2049 /*--------------------------------------------------------------------------*/
2051 * @brief win_mgr_surface_configure: UIFW surface configure
2053 * @param[in] usurf UIFW surface
2054 * @param[in] x X coordinate on screen
2055 * @param[in] y Y coordinate on screen
2056 * @param[in] width surface width
2057 * @param[in] height surface height
2060 /*--------------------------------------------------------------------------*/
2062 win_mgr_surface_configure(struct uifw_win_surface *usurf,
2063 int x, int y, int width, int height)
2065 struct weston_surface *es;
2066 struct weston_view *ev;
2068 es = usurf->surface;
2069 if ((es != NULL) && (es->buffer_ref.buffer)) {
2070 if (usurf->client_width == 0) {
2071 usurf->client_width = es->width;
2072 if (usurf->client_width == 0)
2073 usurf->client_width = ico_ivi_surface_buffer_width(es);
2075 if (usurf->client_height == 0) {
2076 usurf->client_height = es->height;
2077 if (usurf->client_height == 0)
2078 usurf->client_height = ico_ivi_surface_buffer_height(es);
2081 /* not set geometry width/height */
2082 ev = ico_ivi_get_primary_view(usurf);
2083 weston_view_set_position(ev, x + usurf->xadd, y + usurf->yadd);
2087 /*--------------------------------------------------------------------------*/
2089 * @brief win_mgr_destroy_surface: surface destroy
2091 * @param[in] surface Weston surface
2094 /*--------------------------------------------------------------------------*/
2096 win_mgr_destroy_surface(struct weston_surface *surface)
2098 struct uifw_win_surface *usurf;
2099 struct uifw_win_surface *phash;
2100 struct uifw_win_surface *bhash;
2103 usurf = find_uifw_win_surface_by_ws(surface);
2105 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
2108 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
2110 /* destory input region */
2111 if (win_mgr_hook_destory) {
2112 (*win_mgr_hook_destory)(usurf);
2116 if (&usurf->surf_map != usurf->surf_map.next) {
2117 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
2120 /* destroy animation extenson */
2121 if (win_mgr_hook_animation) {
2122 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
2125 /* delete from cleint list */
2126 wl_list_remove(&usurf->client_link);
2128 /* delete from hash table */
2129 hash = MAKE_IDHASH(usurf->surfaceid);
2130 phash = _ico_win_mgr->idhash[hash];
2132 while ((phash) && (phash != usurf)) {
2134 phash = phash->next_idhash;
2137 bhash->next_idhash = usurf->next_idhash;
2140 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
2143 hash = MAKE_WSHASH(usurf->surface);
2144 phash = _ico_win_mgr->wshash[hash];
2146 while ((phash) && (phash != usurf)) {
2148 phash = phash->next_wshash;
2151 bhash->next_wshash = usurf->next_wshash;
2154 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
2158 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
2161 /*--------------------------------------------------------------------------*/
2163 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
2165 * @param[in] client client
2166 * @param[in] data user data(unused)
2167 * @param[in] version protocol version(unused)
2168 * @param[in] id client object id
2171 /*--------------------------------------------------------------------------*/
2173 bind_ico_win_mgr(struct wl_client *client,
2174 void *data, uint32_t version, uint32_t id)
2176 struct wl_resource *add_resource;
2177 struct uifw_manager *mgr;
2178 struct uifw_client *uclient;
2180 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
2182 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
2184 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
2185 _ico_win_mgr, unbind_ico_win_mgr);
2188 /* Create client management tabel */
2189 uclient = ico_window_mgr_find_uclient(client);
2191 win_mgr_bind_client(client, NULL);
2192 uclient = ico_window_mgr_find_uclient(client);
2196 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
2198 uifw_error("bind_ico_win_mgr: Error, No Memory");
2201 memset(mgr, 0, sizeof(struct uifw_manager));
2202 mgr->resource = add_resource;
2206 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
2208 uifw_trace("bind_ico_win_mgr: Leave");
2211 /*--------------------------------------------------------------------------*/
2213 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
2215 * @param[in] resource client resource
2218 /*--------------------------------------------------------------------------*/
2220 unbind_ico_win_mgr(struct wl_resource *resource)
2222 struct uifw_manager *mgr, *itmp;
2224 uifw_trace("unbind_ico_win_mgr: Enter");
2226 /* Remove manager from manager list */
2227 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
2228 if (mgr->resource == resource) {
2229 wl_list_remove(&mgr->link);
2233 uifw_trace("unbind_ico_win_mgr: Leave");
2236 /*--------------------------------------------------------------------------*/
2238 * @brief ico_window_mgr_get_uclient: get UIFW client table
2240 * @param[in] appid application Id
2241 * @return UIFW client table
2242 * @retval !=NULL success(UIFW client table address)
2243 * @retval = NULL error(appid not exist)
2245 /*--------------------------------------------------------------------------*/
2246 WL_EXPORT struct uifw_client *
2247 ico_window_mgr_get_uclient(const char *appid)
2249 struct uifw_client *uclient;
2251 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2252 if (strcmp(uclient->appid, appid) == 0) {
2259 /*--------------------------------------------------------------------------*/
2261 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
2263 * @param[in] target surface window name and application Id(winname@appid)
2264 * @return UIFW surface table
2265 * @retval !=NULL success(UIFW surface table address)
2266 * @retval = NULL error(appid or winname not exist)
2268 /*--------------------------------------------------------------------------*/
2269 WL_EXPORT struct uifw_win_surface *
2270 ico_window_mgr_get_client_usurf(const char *target)
2272 struct uifw_client *uclient;
2273 struct uifw_win_surface *usurf;
2275 char winname[ICO_IVI_WINNAME_LENGTH];
2276 char appid[ICO_IVI_APPID_LENGTH];
2278 /* get window name and application id */
2280 for (i = 0; target[i]; i++) {
2281 if (target[i] == '@') {
2282 if (target[i+1] != '@') break;
2285 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
2286 winname[j++] = target[i];
2290 if (target[i] == '@') {
2298 for ( ; target[i]; i++) {
2299 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
2300 if (j < (ICO_IVI_APPID_LENGTH-1)) {
2301 appid[j++] = target[i];
2305 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
2306 target, appid, winname);
2308 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2309 if (strcmp(uclient->appid, appid) == 0) {
2310 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
2311 if ((winname[0] == 0) ||
2312 (strcmp(winname, usurf->winname) == 0)) {
2321 /*--------------------------------------------------------------------------*/
2323 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
2325 * @param[in] hook_animation hook routine
2328 /*--------------------------------------------------------------------------*/
2330 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
2332 win_mgr_hook_animation = hook_animation;
2335 /*--------------------------------------------------------------------------*/
2337 * @brief ico_window_mgr_set_hook_change: set input region hook routine
2339 * @param[in] hook_change hook routine
2342 /*--------------------------------------------------------------------------*/
2344 ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf))
2346 win_mgr_hook_change = hook_change;
2349 /*--------------------------------------------------------------------------*/
2351 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
2353 * @param[in] hook_destroy hook routine
2356 /*--------------------------------------------------------------------------*/
2358 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
2360 win_mgr_hook_destory = hook_destroy;
2363 /*--------------------------------------------------------------------------*/
2365 * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine
2367 * @param[in] hook_inputregion hook routine
2370 /*--------------------------------------------------------------------------*/
2372 ico_window_mgr_set_hook_inputregion(
2373 void (*hook_inputregion)(int set, struct uifw_win_surface *usurf,
2374 int32_t x, int32_t y, int32_t width,
2375 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
2376 int32_t cursor_x, int32_t cursor_y, int32_t cursor_width,
2377 int32_t cursor_height, uint32_t attr))
2379 win_mgr_hook_inputregion = hook_inputregion;
2382 /*--------------------------------------------------------------------------*/
2384 * @brief module_init: initialize ico_window_mgr
2385 * this function called from ico_pluign_loader
2387 * @param[in] es weston compositor
2388 * @param[in] argc number of arguments(unused)
2389 * @param[in] argv argument list(unused)
2394 /*--------------------------------------------------------------------------*/
2396 module_init(struct weston_compositor *ec, int *argc, char *argv[])
2401 struct weston_output *output;
2402 struct weston_config_section *section;
2403 char *displayno = NULL;
2405 struct wl_event_loop *loop;
2407 uifw_info("ico_window_mgr: Enter(module_init)");
2409 /* get ivi debug level */
2410 section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL);
2412 weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0);
2413 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
2416 /* get display number */
2417 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
2419 weston_config_section_get_string(section, "displayno", &displayno, NULL);
2422 /* get animation default */
2423 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
2425 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
2426 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500);
2427 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30);
2429 if (_ico_ivi_animation_name == NULL)
2430 _ico_ivi_animation_name = (char *)"fade";
2431 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500;
2432 if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30;
2434 /* create ico_window_mgr management table */
2435 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
2436 if (_ico_win_mgr == NULL) {
2437 uifw_error("ico_window_mgr: malloc failed");
2441 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
2443 _ico_win_mgr->compositor = ec;
2445 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
2446 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
2447 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
2448 uifw_error("ico_window_mgr: Error(wl_global_create)");
2452 wl_list_init(&_ico_win_mgr->client_list);
2453 wl_list_init(&_ico_win_mgr->manager_list);
2454 wl_list_init(&_ico_win_mgr->map_list);
2455 _ico_win_mgr->free_maptable = NULL;
2457 /* create display list */
2458 if (displayno != NULL) {
2465 wl_list_for_each (output, &ec->output_list, link) {
2466 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
2467 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurface;
2468 wl_list_insert(output->animation_list.prev,
2469 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
2471 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
2473 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
2475 wl_list_for_each (output, &ec->output_list, link) {
2478 idx = strtol(p, (char **)0, 0);
2479 uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx);
2481 if ((idx < 0) || (idx >= _ico_num_nodes)) {
2488 if (_ico_node_table[idx].node) {
2489 for (idx = 0; idx < _ico_num_nodes; idx++) {
2490 if (_ico_node_table[idx].node == 0) break;
2492 if (idx >= _ico_num_nodes) {
2493 uifw_error("ico_window_mgr: number of display overflow");
2497 _ico_node_table[idx].node = idx + 0x100;
2498 _ico_node_table[idx].displayno = i;
2499 _ico_node_table[idx].output = output;
2500 _ico_node_table[idx].disp_x = output->x;
2501 _ico_node_table[idx].disp_y = output->y;
2502 _ico_node_table[idx].disp_width = output->width;
2503 _ico_node_table[idx].disp_height = output->height;
2505 if (i >= _ico_num_nodes) break;
2508 for (i = 0; i < _ico_num_nodes; i++) {
2509 _ico_node_table[i].node &= 0x0ff;
2510 uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
2511 i, _ico_node_table[i].displayno,
2512 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
2513 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
2515 if (displayno) free(displayno);
2517 /* my node Id ... this version fixed 0 */
2518 nodeId = ico_ivi_get_mynode();
2520 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
2521 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
2522 nodeId, _ico_win_mgr->surface_head);
2524 /* get seat for touch down counter check */
2525 touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link);
2526 loop = wl_display_get_event_loop(ec->wl_display);
2527 _ico_win_mgr->wait_mapevent =
2528 wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL);
2529 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000);
2531 uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d",
2532 _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps);
2533 uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x",
2534 _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff,
2535 (_ico_ivi_debug_level >> 16) & 0x0ffff);
2537 /* touch/click binding for select surface */
2538 weston_compositor_add_button_binding(ec, BTN_LEFT, 0, win_mgr_click_to_activate, NULL);
2539 weston_compositor_add_touch_binding(ec, 0, win_mgr_touch_to_activate, NULL);
2541 /* set Notification function for GENIVI ivi-shell */
2542 if (weston_layout_setNotificationCreateSurface(ico_ivi_surfaceCreateNotification, NULL) != 0) {
2543 uifw_error("ico_window_mgr: weston_layout_setNotificationCreateSurface Error");
2545 if (weston_layout_setNotificationRemoveSurface(ico_ivi_surfaceRemoveNotification, NULL) != 0) {
2546 uifw_error("ico_window_mgr: weston_layout_setNotificationRemoveSurface Error");
2548 if (weston_layout_setNotificationConfigureSurface(ico_ivi_surfaceConfigureNotification, NULL) != 0) {
2549 uifw_error("ico_window_mgr: weston_layout_setNotificationConfigureSurface Error");
2551 uifw_info("ico_window_mgr: Leave(module_init)");