2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 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>
42 #include <sys/types.h>
46 #include <wayland-server.h>
52 #include <EGL/eglext.h>
53 #include <GLES2/gl2.h>
54 #include <GLES2/gl2ext.h>
55 #include <GL/internal/dri_interface.h>
57 /* inport Mesa version */
58 #if EGL_EGLEXT_VERSION >= 16
59 #define MESA_VERSION 921
61 #define MESA_VERSION 913
64 #include <weston/compositor.h>
65 #if MESA_VERSION >= 921
66 #include <libdrm/intel_bufmgr.h>
68 #include "ico_ivi_common.h"
69 #include "ico_ivi_shell.h"
70 #include "ico_window_mgr.h"
71 #include "desktop-shell-server-protocol.h"
72 #include "ico_window_mgr-server-protocol.h"
76 #define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */
77 #define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */
78 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId bit mask pattern */
79 #define UIFW_HASH 64 /* Hash value (2's compliment) */
81 /* Internal fixed value */
82 #define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */
83 /* show/hide animation with position */
84 #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000
86 /* wl_buffer (inport from wayland-1.2.0/src/wayland-server.h) */
87 struct uifw_wl_buffer { /* struct wl_buffer */
88 struct wl_resource resource;
89 int32_t width, height;
93 /* wl_drm_buffer (inport from mesa-9.1.3 & mesa-9.2.1/ */
94 /* src/egl/wayland/wayland-drm/wayland-drm.h) */
95 struct uifw_drm_buffer {
96 struct uifw_wl_buffer buffer;
97 void *drm; /* struct wl_drm */
99 const void *driver_format;
105 /* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h */
106 /* mesa-9.2.1/src/mesa/drivers/dri/i915/intel_regions.h */
107 /* mesa-9.2.1/src/mesa/drivers/dri/i965/intel_regions.h) */
108 #if MESA_VERSION >= 920
109 struct uifw_intel_region { /* struct intel_region for mesa 9.2.1 */
110 void *bo; /**< buffer manager's buffer */
111 uint32_t refcount; /**< Reference count for region */
112 uint32_t cpp; /**< bytes per pixel */
113 uint32_t width; /**< in pixels */
114 uint32_t height; /**< in pixels */
115 uint32_t pitch; /**< in bytes */
116 uint32_t tiling; /**< Which tiling mode the region is in */
117 uint32_t name; /**< Global name for the bo */
119 #else /*MESA_VERSION < 920*/
120 struct uifw_intel_region { /* struct intel_region */
121 void *bo; /**< buffer manager's buffer */
122 uint32_t refcount; /**< Reference count for region */
123 uint32_t cpp; /**< bytes per pixel */
124 uint32_t width; /**< in pixels */
125 uint32_t height; /**< in pixels */
126 uint32_t pitch; /**< in bytes */
127 char *map; /**< only non-NULL when region is actually mapped */
128 uint32_t map_refcount; /**< Reference count for mapping */
129 uint32_t tiling; /**< Which tiling mode the region is in */
130 uint32_t name; /**< Global name for the bo */
131 void *screen; /* screen */
133 #endif /*MESA_VERSION*/
135 struct uifw_dri_image { /* struct __DRIimageRec */
136 struct uifw_intel_region *region;
143 void *planar_format; /* intel_image_format */
144 #if MESA_VERSION >= 920
149 bool has_depthstencil; /* i965 only */
150 #endif /*MESA_VERSION*/
154 /* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c) */
160 struct uifw_gl_surface_state { /* struct gl_surface_state */
162 struct gl_shader *shader;
166 int needs_full_upload;
167 pixman_region32_t texture_damage;
169 void *images[3]; /* EGLImageKHR */
173 struct weston_buffer_reference buffer_ref;
174 enum buffer_type buffer_type;
175 int pitch; /* in pixels */
176 int height; /* in pixels */
179 /* Multi Windiw Manager */
181 struct weston_compositor *compositor; /* Weston compositor */
182 void *shell; /* shell(ico_ivi_shell) table address */
183 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
185 struct wl_list client_list; /* Clients */
186 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
187 int num_manager; /* Number of managers */
189 struct wl_list ivi_layer_list; /* Layer management table list */
190 struct uifw_win_layer *touch_layer; /* layer table for touch panel layer */
191 struct uifw_win_layer *cursor_layer; /* layer table for cursor layer */
193 struct wl_list map_list; /* surface map list */
194 struct uifw_surface_map *free_maptable; /* free maped surface table list */
195 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
196 /* animation for map check */
197 struct wl_event_source *wait_mapevent; /* map event send wait timer */
198 int waittime; /* minimaum send wait time(ms) */
200 struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */
201 struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */
203 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
204 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
206 uint32_t surfaceid_count; /* Number of surface id */
207 uint32_t surfaceid_max; /* Maximum number of surface id */
208 uint16_t *surfaceid_map; /* SurfaceId assign bit map */
210 char shell_init; /* shell initialize flag */
211 char res[3]; /* (unused) */
214 /* Internal macros */
216 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
218 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
220 /* function prototype */
221 /* get surface table from weston surface*/
222 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
223 struct weston_surface *wsurf);
224 /* get client table from weston client */
225 static struct uifw_client* find_client_from_client(struct wl_client *client);
226 /* assign new surface id */
227 static uint32_t generate_id(void);
228 /* bind shell client */
229 static void win_mgr_bind_client(struct wl_client *client, void *shell);
230 /* unind shell client */
231 static void win_mgr_unbind_client(struct wl_client *client);
232 #if 0 /* work around: Walk through child processes until app ID is found */
234 static pid_t win_mgr_get_ppid(pid_t pid);
235 #endif /* work around: Walk through child processes until app ID is found */
236 /* get appid from pid */
237 static void win_mgr_get_client_appid(struct uifw_client *uclient);
238 /* create new surface */
239 static void win_mgr_register_surface(
240 int layertype, struct wl_client *client, struct wl_resource *resource,
241 struct weston_surface *surface, struct shell_surface *shsurf);
242 /* surface destroy */
243 static void win_mgr_destroy_surface(struct weston_surface *surface);
244 /* map new surface */
245 static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width,
246 int32_t *height, int32_t *sx, int32_t *sy);
247 /* send surface change event to manager */
248 static void win_mgr_change_surface(struct weston_surface *surface,
249 const int to, const int manager);
250 /* window manager surface configure */
251 static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
252 int x, int y, int width, int height);
253 /* shell surface configure */
254 static void win_mgr_shell_configure(struct weston_surface *surface);
256 static void win_mgr_select_surface(struct weston_surface *surface);
257 /* surface set title */
258 static void win_mgr_set_title(struct weston_surface *surface, const char *title);
259 /* surface move request from shell */
260 static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy);
261 /* shell layer visible control */
262 static void win_mgr_show_layer(int layertype, int show, void *data);
263 /* shell full screen surface control */
264 static int win_mgr_fullscreen(int event, struct weston_surface *surface);
266 static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise);
267 /* surface change from manager */
268 static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x,
269 const int y, const int width, const int height);
270 /* reset surface focus */
271 static void win_mgr_reset_focus(struct uifw_win_surface *usurf);
272 /* create new layer */
273 static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf,
274 const uint32_t layer, const int layertype);
275 /* set surface layer */
276 static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer);
277 /* set active surface */
278 static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target);
280 /* declare manager */
281 static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource,
283 /* set window layer */
284 static void uifw_set_window_layer(struct wl_client *client,
285 struct wl_resource *resource,
286 uint32_t surfaceid, uint32_t layer);
287 /* set surface size and position */
288 static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
289 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
290 int32_t width, int32_t height, int32_t flags);
291 /* show/hide and raise/lower surface */
292 static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
293 uint32_t surfaceid, int32_t visible, int32_t raise,
295 /* set surface animation */
296 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
297 uint32_t surfaceid, int32_t type,
298 const char *animation, int32_t time);
299 /* set surface attributes */
300 static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
301 uint32_t surfaceid, uint32_t attributes);
302 /* surface visibility control with animation*/
303 static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
304 uint32_t surfaceid, int32_t visible,
305 int32_t x, int32_t y, int32_t width, int32_t height);
306 /* set active surface (form HomeScreen) */
307 static void uifw_set_active(struct wl_client *client, struct wl_resource *resource,
308 uint32_t surfaceid, int32_t active);
309 /* layer visibility control */
310 static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
311 uint32_t layer, int32_t visible);
312 /* get application surfaces */
313 static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
314 const char *appid, int32_t pid);
315 /* check and change all mapped surface */
316 static void win_mgr_check_mapsurrace(struct weston_animation *animation,
317 struct weston_output *output, uint32_t msecs);
318 /* check timer of mapped surface */
319 static int win_mgr_timer_mapsurrace(void *data);
320 /* check and change mapped surface */
321 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event,
323 /* map surface to system application */
324 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
325 uint32_t surfaceid, int32_t framerate);
327 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
330 static void bind_ico_win_mgr(struct wl_client *client,
331 void *data, uint32_t version, uint32_t id);
333 static void unbind_ico_win_mgr(struct wl_resource *resource);
334 /* send event to manager */
335 static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
336 const int param1, const int param2, const int param3,
337 const int param4, const int param5);
338 /* set surface transform */
339 static int win_mgr_set_scale(struct uifw_win_surface *usurf);
340 /* convert animation name to Id value */
341 static int ico_get_animation_name(const char *animation);
342 /* hook for animation */
343 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
344 /* hook for input region */
345 static void (*win_mgr_hook_visible)(struct uifw_win_surface *usurf) = NULL;
346 static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL;
349 /* Multi Window Manager interface */
350 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
351 uifw_declare_manager,
352 uifw_set_window_layer,
353 uifw_set_positionsize,
357 uifw_visible_animation,
359 uifw_set_layer_visible,
365 /* plugin common value(without ico_plugin_loader) */
366 static int _ico_ivi_debug_flag = 0; /* debug flags */
367 static int _ico_ivi_debug_level = 3; /* debug Level */
368 static char *_ico_ivi_animation_name = NULL; /* default animation name */
369 static int _ico_ivi_animation_time = 500; /* default animation time */
370 static int _ico_ivi_animation_fps = 30; /* animation frame rate */
371 static char *_ico_ivi_inputpanel_animation = NULL; /* default animation name for input panel*/
372 static int _ico_ivi_inputpanel_anima_time = 0; /* default animation time for input panel*/
374 static int _ico_ivi_inputpanel_display = 0; /* input panel display number */
375 static int _ico_ivi_inputdeco_mag = 100; /* input panel magnification rate(%)*/
376 static int _ico_ivi_inputdeco_diff = 0; /* input panel difference from the bottom*/
378 static int _ico_ivi_background_layer = 0; /* background layer */
379 static int _ico_ivi_default_layer = 1; /* deafult layer id at surface create*/
380 static int _ico_ivi_touch_layer = 101; /* touch panel layer id */
381 static int _ico_ivi_cursor_layer = 102; /* cursor layer id */
382 static int _ico_ivi_startup_layer = 109; /* deafult layer id at system startup*/
384 /* static management table */
385 static struct ico_win_mgr *_ico_win_mgr = NULL;
386 static int _ico_num_nodes = 0;
387 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
388 static struct weston_seat *touch_check_seat = NULL;
391 /*--------------------------------------------------------------------------*/
393 * @brief ico_ivi_debugflag: get debug flags
396 * @return debug flags
398 /*--------------------------------------------------------------------------*/
400 ico_ivi_debugflag(void)
402 return _ico_ivi_debug_flag;
405 /*--------------------------------------------------------------------------*/
407 * @brief ico_ivi_debuglevel: answer debug output level.
410 * @return debug output level
411 * @retval 0 No debug output
412 * @retval 1 Only error output
413 * @retval 2 Error and Warning output
414 * @retval 3 Error, Warning and information output
415 * @retval 4 All output with debug write
417 /*--------------------------------------------------------------------------*/
419 ico_ivi_debuglevel(void)
421 return _ico_ivi_debug_level;
424 /*--------------------------------------------------------------------------*/
426 * @brief ico_ivi_default_animation_name: get default animation name
429 * @return Default animation name
431 /*--------------------------------------------------------------------------*/
432 WL_EXPORT const char *
433 ico_ivi_default_animation_name(void)
435 return _ico_ivi_animation_name;
438 /*--------------------------------------------------------------------------*/
440 * @brief ico_ivi_default_animation_time: get default animation time
443 * @return Default animation time(miri sec)
445 /*--------------------------------------------------------------------------*/
447 ico_ivi_default_animation_time(void)
449 return _ico_ivi_animation_time;
452 /*--------------------------------------------------------------------------*/
454 * @brief ico_ivi_default_animation_fps: get default animation frame rate
457 * @return Default animation frame rate(frames/sec)
459 /*--------------------------------------------------------------------------*/
461 ico_ivi_default_animation_fps(void)
463 return _ico_ivi_animation_fps;
466 /*--------------------------------------------------------------------------*/
468 * @brief ico_ivi_get_mynode: Get my NodeId
471 * @return NodeId of my node
473 /*--------------------------------------------------------------------------*/
475 ico_ivi_get_mynode(void)
477 /* Reference Platform 0.90 only support 1 ECU */
481 /*--------------------------------------------------------------------------*/
483 * @brief ico_window_mgr_set_weston_surface: set weston surface
485 * @param[in] usurf UIFW surface
486 * @param[in] x X coordinate on screen
487 * @param[in] y Y coordinate on screen
488 * @param[in] width width
489 * @param[in] height height
492 /*--------------------------------------------------------------------------*/
494 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
495 int x, int y, int width, int height)
497 struct weston_surface *es = usurf->surface;
498 int buf_width, buf_height;
501 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
506 if (es->buffer_ref.buffer != NULL) {
507 buf_width = weston_surface_buffer_width(es);
508 buf_height = weston_surface_buffer_height(es);
509 if ((width <= 0) || (height <= 0)) {
511 usurf->width = buf_width;
513 usurf->height = buf_height;
515 if ((usurf->width > buf_width) && (usurf->scalex <= 1.0f)) {
517 x += (usurf->width - buf_width)/2;
519 if ((usurf->height > buf_height) && (usurf->scaley <= 1.0f)) {
521 y += (usurf->height - buf_height)/2;
523 if (usurf->visible) {
524 x += usurf->node_tbl->disp_x;
525 y += usurf->node_tbl->disp_y;
528 x = ICO_IVI_MAX_COORDINATE+1;
529 y = ICO_IVI_MAX_COORDINATE+1;
531 if ((es->geometry.x != x) || (es->geometry.y != y) ||
532 (es->geometry.width != width) || (es->geometry.height != height)) {
533 weston_surface_damage_below(es);
534 win_mgr_surface_configure(usurf, x, y, width, height);
536 weston_surface_damage(es);
537 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
541 /*--------------------------------------------------------------------------*/
543 * @brief ico_window_mgr_set_weston_surface: set weston surface
545 * @param[in] usurf UIFW surface
546 * @param[in] x X coordinate on screen
547 * @param[in] y Y coordinate on screen
548 * @param[in] width width
549 * @param[in] height height
552 /*--------------------------------------------------------------------------*/
554 ico_window_mgr_change_surface(struct uifw_win_surface *usurf,
555 const int to, const int manager)
557 uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)",
558 usurf->surfaceid, to, manager);
559 win_mgr_change_surface(usurf->surface, to, manager);
560 uifw_trace("ico_window_mgr_change_surface: Leave");
563 /*--------------------------------------------------------------------------*/
565 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
567 * @param[in] surfaceid UIFW surface id
568 * @return UIFW surface table address
569 * @retval !=NULL success(surface table address)
570 * @retval NULL error(surface id dose not exist)
572 /*--------------------------------------------------------------------------*/
573 WL_EXPORT struct uifw_win_surface *
574 ico_window_mgr_get_usurf(const uint32_t surfaceid)
576 struct uifw_win_surface *usurf;
578 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
581 if (usurf->surfaceid == surfaceid) {
584 usurf = usurf->next_idhash;
586 uifw_trace("ico_window_mgr_get_usurf: NULL");
590 /*--------------------------------------------------------------------------*/
592 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
594 * @param[in] surfaceid UIFW surface id
595 * @param[in] client Wayland client
596 * @return UIFW surface table address
597 * @retval !=NULL success(surface table address)
598 * @retval NULL error(surface id or client dose not exist)
600 /*--------------------------------------------------------------------------*/
601 WL_EXPORT struct uifw_win_surface *
602 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
604 struct uifw_win_surface *usurf;
605 struct uifw_client *uclient;
607 if (surfaceid == ICO_WINDOW_MGR_V_MAINSURFACE) {
608 uclient = find_client_from_client(client);
610 if (&uclient->surface_link != uclient->surface_link.next) {
611 usurf = container_of (uclient->surface_link.next,
612 struct uifw_win_surface, client_link);
623 usurf = ico_window_mgr_get_usurf(surfaceid);
628 /*--------------------------------------------------------------------------*/
630 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
632 * @param[in] wsurf Weston surface
633 * @return UIFW surface table address
634 * @retval !=NULL success(surface table address)
635 * @retval NULL error(surface dose not exist)
637 /*--------------------------------------------------------------------------*/
638 static struct uifw_win_surface *
639 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
641 struct uifw_win_surface *usurf;
643 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
646 if (usurf->surface == wsurf) {
649 usurf = usurf->next_wshash;
651 uifw_trace("find_uifw_win_surface_by_ws: NULL");
655 /*--------------------------------------------------------------------------*/
657 * @brief find_client_from_client: find UIFW client by wayland client
659 * @param[in] client Wayland client
660 * @return UIFW client table address
661 * @retval !=NULL success(client table address)
662 * @retval NULL error(client dose not exist)
664 /*--------------------------------------------------------------------------*/
665 static struct uifw_client*
666 find_client_from_client(struct wl_client *client)
668 struct uifw_client *uclient;
670 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
671 if (uclient->client == client) {
675 uifw_trace("find_client_from_client: client.%08x is NULL", (int)client);
679 /*--------------------------------------------------------------------------*/
681 * @brief ico_window_mgr_get_appid: find application id by wayland client
683 * @param[in] client Wayland client
684 * @return application id
685 * @retval !=NULL success(application id)
686 * @retval NULL error(client dose not exist)
688 /*--------------------------------------------------------------------------*/
690 ico_window_mgr_get_appid(struct wl_client* client)
692 struct uifw_client *uclient;
694 uclient = find_client_from_client(client);
699 return uclient->appid;
702 /*--------------------------------------------------------------------------*/
704 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
706 * @param[in] displayno display number
707 * @param[out] x relative X coordinate
708 * @param[out] y relative Y coordinate
711 /*--------------------------------------------------------------------------*/
713 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
715 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
718 *x = _ico_node_table[displayno].disp_x;
719 *y = _ico_node_table[displayno].disp_y;
722 /*--------------------------------------------------------------------------*/
724 * @brief generate_id: generate uniq id for UIFW surface id
727 * @return uniq id for UIFW surface id
729 /*--------------------------------------------------------------------------*/
740 _ico_win_mgr->surfaceid_count ++;
742 /* serach free id from bitmap */
743 for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) {
744 if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) {
745 _ico_win_mgr->surfaceid_count = 0;
747 if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) {
748 /* find free id from bitmap */
749 map = 1 << (_ico_win_mgr->surfaceid_count % 16);
750 for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) {
751 if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map)
753 _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map;
754 _ico_win_mgr->surfaceid_count
755 = (_ico_win_mgr->surfaceid_count/16)*16 + i;
757 surfaceId = (_ico_win_mgr->surfaceid_count + 1)
758 | _ico_win_mgr->surface_head;
759 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
765 _ico_win_mgr->surfaceid_count += 16;
768 /* no free id in bitmap, extend bitmap */
769 if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) {
770 /* too many surfaces, system error */
771 uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort",
772 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
773 fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n",
774 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
778 new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8);
779 memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8);
780 memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8);
781 _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max;
782 new_map[_ico_win_mgr->surfaceid_count/16] |= 1;
783 _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS;
784 free(_ico_win_mgr->surfaceid_map);
785 _ico_win_mgr->surfaceid_map = new_map;
787 uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)",
788 _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max);
789 surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head;
791 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
795 /*--------------------------------------------------------------------------*/
797 * @brief win_mgr_bind_client: desktop_shell from client
799 * @param[in] client Wayland client
800 * @param[in] shell shell(ico_ivi_shell) table address
803 /*--------------------------------------------------------------------------*/
805 win_mgr_bind_client(struct wl_client *client, void *shell)
807 struct uifw_client *uclient;
813 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
814 (int)client, (int)shell);
816 /* save shell table address */
818 _ico_win_mgr->shell = shell;
822 uclient = find_client_from_client(client);
824 /* client not exist, create client management table */
825 uifw_trace("win_mgr_bind_client: Create Client");
826 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
828 uifw_error("win_mgr_bind_client: Error, No Memory");
831 memset(uclient, 0, sizeof(struct uifw_client));
832 uclient->client = client;
833 wl_list_init(&uclient->surface_link);
839 wl_client_get_credentials(client, &pid, &uid, &gid);
840 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
841 (int)client, (int)pid, (int)uid, (int)gid);
843 uclient->pid = (int)pid;
844 /* get applicationId from AppCore(AUL) */
845 win_mgr_get_client_appid(uclient);
848 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
852 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
854 uifw_trace("win_mgr_bind_client: Leave");
857 /*--------------------------------------------------------------------------*/
859 * @brief win_mgr_unbind_client: unbind desktop_shell from client
861 * @param[in] client Wayland client
864 /*--------------------------------------------------------------------------*/
866 win_mgr_unbind_client(struct wl_client *client)
868 struct uifw_client *uclient;
870 uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client);
872 uclient = find_client_from_client(client);
874 /* Client exist, Destory client management table */
875 wl_list_remove(&uclient->link);
878 uifw_trace("win_mgr_unbind_client: Leave");
881 #if 0 /* work around: Walk through child processes until app ID is found */
882 /*--------------------------------------------------------------------------*/
884 * @brief win_mgr_get_ppid: Get parent process ID.
886 * Similar to getppid(), except that this implementation accepts an
887 * arbitrary process ID.
889 * @param[in] pid Process ID of child process
890 * @return parent process ID on success, -1 on failure
892 /*--------------------------------------------------------------------------*/
894 win_mgr_get_ppid(pid_t pid)
897 char procpath[PATH_MAX] = { 0 };
899 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid);
901 /* We better have read permissions! */
902 int const fd = open(procpath, O_RDONLY);
907 char buffer[1024] = { 0 };
909 ssize_t const size = read(fd, buffer, sizeof(buffer));
915 /* Find line containing the parent process ID. */
916 char const * const ppid_line = strstr(buffer, "PPid");
918 if (ppid_line != NULL)
919 sscanf(ppid_line, "PPid: %d", &ppid);
923 #endif /* work around: Walk through child processes until app ID is found */
925 /*--------------------------------------------------------------------------*/
927 * @brief win_mgr_get_client_appid: get applicationId from pid
929 * @param[in] uclient UIFW client management table
932 /*--------------------------------------------------------------------------*/
934 win_mgr_get_client_appid(struct uifw_client *uclient)
936 int status = AUL_R_ERROR;
938 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
940 #if 0 /* work around: Walk through child processes until app ID is found */
942 * Walk the parent process chain until we find a parent process
947 for (pid = uclient->pid;
948 pid > 1 && status != AUL_R_OK;
949 pid = win_mgr_get_ppid(pid)) {
951 status = aul_app_get_appid_bypid(pid,
953 ICO_IVI_APPID_LENGTH);
955 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
956 "pid=%d appid=<%s>", status, pid, uclient->appid);
959 * Walk the child process chain as well since app ID was not yet found
961 if (status != AUL_R_OK) {
970 dr = opendir("/proc/");
973 wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
975 while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
977 char fullpath[PATH_MAX] = { 0 };
981 snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
983 if (stat(fullpath, &ps) == -1) {
987 /* find pid dirs for this user (uid) only */
988 if (ps.st_uid != uid)
991 pid = atoi(de->d_name);
993 /* check if it's a valid child */
994 if (pid < uclient->pid)
997 /* scan up to pid to find if a chain exists */
998 for (tmppid = pid; tmppid > uclient->pid;) {
999 tmppid = win_mgr_get_ppid(tmppid);
1000 if (tmppid == uclient->pid)
1005 status = aul_app_get_appid_bypid(pid, uclient->appid,
1006 ICO_IVI_APPID_LENGTH);
1008 uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid "
1009 "ret=%d pid=%d appid=<%s>", status, pid,
1014 #else /* work around: Walk through child processes until app ID is found */
1015 status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
1016 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
1017 "pid=%d appid=<%s>", status, uclient->pid, uclient->appid);
1018 #endif /* work around: Walk through child processes until app ID is found */
1020 if (uclient->appid[0] != 0) {
1021 /* OK, end of get appid */
1022 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
1025 /* client does not exist in AppCore, search Linux process table */
1033 uclient->fixed_appid ++;
1034 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
1035 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
1036 fd = open(procpath, O_RDONLY);
1038 size = read(fd, procpath, sizeof(procpath));
1039 for (; size > 0; size--) {
1040 if (procpath[size-1]) break;
1043 /* get program base name */
1045 for (j = 0; j < size; j++) {
1046 if (procpath[j] == 0) break;
1047 if (procpath[j] == '/') i = j + 1;
1050 for (; i < size; i++) {
1051 uclient->appid[j] = procpath[i];
1052 if ((uclient->appid[j] == 0) ||
1053 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
1056 /* search application number in apprication start option */
1057 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
1058 for (; i < size; i++) {
1059 if ((procpath[i] == 0) &&
1060 (procpath[i+1] == '@')) {
1061 strncpy(&uclient->appid[j], &procpath[i+1],
1062 ICO_IVI_APPID_LENGTH - j - 2);
1069 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
1070 if (uclient->appid[i] != ' ') break;
1072 uclient->appid[i+1] = 0;
1073 if (uclient->appid[0]) {
1074 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
1075 "Process table(%d)",
1076 uclient->pid, uclient->appid, uclient->fixed_appid );
1079 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
1081 sprintf(uclient->appid, "?%d?", uclient->pid);
1086 /*--------------------------------------------------------------------------*/
1088 * @brief ico_get_animation_name: convert animation name to Id value
1090 * @param[in] animation animation name
1091 * @return animation Id value
1093 /*--------------------------------------------------------------------------*/
1095 ico_get_animation_name(const char *animation)
1097 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1099 if (strcasecmp(animation, "none") == 0) {
1100 return ICO_WINDOW_MGR_ANIMATION_NONE;
1103 if (win_mgr_hook_animation) {
1104 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
1107 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1112 /*--------------------------------------------------------------------------*/
1114 * @brief win_mgr_register_surface: create UIFW surface
1116 * @param[in] layertype surface layer type
1117 * @param[in] client Wayland client
1118 * @param[in] resource client resource
1119 * @param[in] surface Weston surface
1120 * @param[in] shsurf shell surface
1123 /*--------------------------------------------------------------------------*/
1125 win_mgr_register_surface(int layertype, struct wl_client *client,
1126 struct wl_resource *resource, struct weston_surface *surface,
1127 struct shell_surface *shsurf)
1129 struct uifw_win_surface *usurf;
1130 struct uifw_win_surface *phash;
1131 struct uifw_win_surface *bhash;
1135 uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x,layer=%x)",
1136 (int)surface, (int)client, (int)resource, layertype);
1138 /* check new surface */
1139 if (find_uifw_win_surface_by_ws(surface)) {
1140 /* surface exist, NOP */
1141 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
1145 /* set default color and shader */
1146 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
1148 /* create UIFW surface management table */
1149 usurf = malloc(sizeof(struct uifw_win_surface));
1151 uifw_error("win_mgr_register_surface: No Memory");
1155 memset(usurf, 0, sizeof(struct uifw_win_surface));
1157 usurf->surfaceid = generate_id();
1158 usurf->surface = surface;
1159 usurf->shsurf = shsurf;
1160 usurf->layertype = layertype;
1161 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
1162 wl_list_init(&usurf->ivi_layer);
1163 wl_list_init(&usurf->client_link);
1164 wl_list_init(&usurf->animation.animation.link);
1165 wl_list_init(&usurf->surf_map);
1166 wl_list_init(&usurf->input_region);
1167 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
1168 usurf->animation.hide_time = ico_ivi_default_animation_time();;
1169 usurf->animation.show_anima = usurf->animation.hide_anima;
1170 usurf->animation.show_time = usurf->animation.hide_time;
1171 usurf->animation.move_anima = usurf->animation.hide_anima;
1172 usurf->animation.move_time = usurf->animation.hide_time;
1173 usurf->animation.resize_anima = usurf->animation.hide_anima;
1174 usurf->animation.resize_time = usurf->animation.hide_time;
1175 if (layertype == LAYER_TYPE_INPUTPANEL) {
1176 usurf->attributes = ICO_WINDOW_MGR_ATTR_FIXED_ASPECT;
1177 usurf->animation.hide_anima = ico_get_animation_name(_ico_ivi_inputpanel_animation);
1178 usurf->animation.hide_time = _ico_ivi_inputpanel_anima_time;
1179 usurf->animation.show_anima = usurf->animation.hide_anima;
1180 usurf->animation.show_time = usurf->animation.hide_time;
1182 if ((layertype != LAYER_TYPE_INPUTPANEL) &&
1183 ((_ico_win_mgr->num_manager <= 0) ||
1184 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE))) {
1185 uifw_trace("win_mgr_register_surface: No Manager, Force visible");
1189 uifw_trace("win_mgr_register_surface: Manager exist, Not visible");
1194 usurf->uclient = find_client_from_client(client);
1195 if (! usurf->uclient) {
1196 /* client not exist, create client management table */
1197 uifw_trace("win_mgr_register_surface: Create Client");
1198 win_mgr_bind_client(client, NULL);
1199 usurf->uclient = find_client_from_client(client);
1200 if (! usurf->uclient) {
1201 uifw_error("win_mgr_register_surface: No Memory");
1205 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1207 /* make surface id hash table */
1208 hash = MAKE_IDHASH(usurf->surfaceid);
1209 phash = _ico_win_mgr->idhash[hash];
1213 phash = phash->next_idhash;
1216 bhash->next_idhash = usurf;
1219 _ico_win_mgr->idhash[hash] = usurf;
1222 /* make weston surface hash table */
1223 hash = MAKE_WSHASH(usurf->surface);
1224 phash = _ico_win_mgr->wshash[hash];
1228 phash = phash->next_wshash;
1231 bhash->next_wshash = usurf;
1234 _ico_win_mgr->wshash[hash] = usurf;
1236 /* set default layer id */
1237 switch (layertype) {
1238 case LAYER_TYPE_BACKGROUND:
1239 layer = _ico_ivi_background_layer;
1241 case LAYER_TYPE_TOUCH:
1242 layer = _ico_ivi_touch_layer;
1244 case LAYER_TYPE_CURSOR:
1245 layer = _ico_ivi_cursor_layer;
1248 if (_ico_win_mgr->num_manager > 0) {
1249 layer = _ico_ivi_default_layer;
1252 layer = _ico_ivi_startup_layer;
1256 win_mgr_set_layer(usurf, layer);
1258 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1261 /*--------------------------------------------------------------------------*/
1263 * @brief win_mgr_map_surface: map surface
1265 * @param[in] surface Weston surface
1266 * @param[in] width surface width
1267 * @param[in] height surface height
1268 * @param[in] sx X coordinate on screen
1269 * @param[in] sy Y coordinate on screen
1272 /*--------------------------------------------------------------------------*/
1274 win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height,
1275 int32_t *sx, int32_t *sy)
1277 struct uifw_win_surface *usurf;
1279 uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)",
1280 (int)surface, *sx, *sy, *width, *height);
1282 usurf = find_uifw_win_surface_by_ws(surface);
1285 uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d",
1286 usurf->surfaceid, usurf->width, usurf->height, usurf->visible);
1287 if ((usurf->width > 0) && (usurf->height > 0)) {
1288 uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize"
1289 "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d",
1290 usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height,
1292 *width = usurf->width;
1293 *height = usurf->height;
1294 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1295 usurf->node_tbl->disp_y + usurf->y,
1296 usurf->width, usurf->height);
1299 uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, "
1300 "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)",
1301 usurf->surfaceid, *sx, *sy, *width, *height);
1302 usurf->width = *width;
1303 usurf->height = *height;
1306 if (usurf->x < 0) usurf->x = 0;
1307 if (usurf->y < 0) usurf->y = 0;
1308 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
1310 usurf->node_tbl = &_ico_node_table[_ico_ivi_inputpanel_display];
1312 usurf->width = (float)usurf->surface->geometry.width
1313 * (float)_ico_ivi_inputdeco_mag / 100.0f;
1314 usurf->height = (float)usurf->surface->geometry.height
1315 * (float)_ico_ivi_inputdeco_mag / 100.0f;
1317 if ((usurf->width > (usurf->node_tbl->disp_width - 16)) ||
1318 (usurf->height > (usurf->node_tbl->disp_height - 16))) {
1319 usurf->x = (usurf->node_tbl->disp_width
1320 - usurf->surface->geometry.width) / 2;
1321 usurf->y = usurf->node_tbl->disp_height
1322 - usurf->surface->geometry.height - 16
1323 - _ico_ivi_inputdeco_diff;
1324 if (usurf->x < 0) usurf->x = 0;
1325 if (usurf->y < 0) usurf->y = 0;
1328 win_mgr_set_scale(usurf);
1330 usurf->x = (usurf->node_tbl->disp_width
1331 - usurf->width) / 2;
1332 usurf->y = usurf->node_tbl->disp_height
1333 - usurf->height - 16 - _ico_ivi_inputdeco_diff;
1334 if (usurf->x < 0) usurf->x = 0;
1335 if (usurf->y < 0) usurf->y = 0;
1337 uifw_trace("win_mgr_map_surface: set position %08x %d.%d/%d",
1338 usurf->surfaceid, usurf->node_tbl->node, usurf->x, usurf->y);
1340 if (((ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE) == 0) &&
1341 (_ico_win_mgr->num_manager > 0)) {
1342 /* HomeScreen exist, coodinate set by HomeScreen */
1343 if (usurf->visible) {
1344 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1345 usurf->node_tbl->disp_y + usurf->y,
1346 usurf->width, usurf->height);
1349 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1350 ICO_IVI_MAX_COORDINATE+1,
1351 usurf->width, usurf->height);
1353 uifw_trace("win_mgr_map_surface: Change size/position x/y=%d/%d w/h=%d/%d",
1354 (int)surface->geometry.x, (int)surface->geometry.y,
1355 surface->geometry.width, surface->geometry.height);
1357 else if (usurf->layertype != LAYER_TYPE_INPUTPANEL) {
1358 uifw_trace("win_mgr_map_surface: No HomeScreen, chaneg to Visible");
1359 ico_window_mgr_set_visible(usurf, 1);
1362 if (usurf->visible) {
1363 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1364 usurf->node_tbl->disp_y + usurf->y,
1365 usurf->width, usurf->height);
1368 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1369 ICO_IVI_MAX_COORDINATE+1,
1370 usurf->width, usurf->height);
1375 if (usurf->visible) {
1376 ico_window_mgr_restack_layer(NULL);
1378 uifw_trace("win_mgr_map_surface: Leave");
1381 uifw_trace("win_mgr_map_surface: Leave(No UIFW Surface)");
1385 /*--------------------------------------------------------------------------*/
1387 * @brief ico_window_mgr_restack_layer: restack surface list
1389 * @param[in] usurf UIFW surface (if NULL, no surface)
1392 /*--------------------------------------------------------------------------*/
1394 ico_window_mgr_restack_layer(struct uifw_win_surface *usurf)
1396 struct uifw_win_surface *eu;
1397 struct uifw_win_layer *el;
1398 int32_t buf_width, buf_height;
1400 struct weston_layer *wlayer;
1401 struct weston_surface *surface, *surfacetmp;
1402 int num_visible = 0;
1406 /* save current visible */
1408 old_visible = ico_window_mgr_is_visible(usurf);
1411 /* make compositor surface list */
1412 wlayer = ico_ivi_shell_weston_layer();
1414 uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x) layer=%08x",
1415 (int)usurf, (int)wlayer);
1417 /* remove all surfaces in panel_layer */
1418 wl_list_for_each_safe (surface, surfacetmp, &wlayer->surface_list, layer_link) {
1419 wl_list_remove(&surface->layer_link);
1420 wl_list_init(&surface->layer_link);
1422 wl_list_init(&wlayer->surface_list);
1424 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1425 if (el->layertype == LAYER_TYPE_CURSOR) continue;
1426 wl_list_for_each (eu, &el->surface_list, ivi_layer) {
1427 if (eu->surface == NULL) continue;
1429 /* target only panel or unknown layer */
1430 layertype = ico_ivi_shell_layertype(eu->surface);
1431 if ((layertype != LAYER_TYPE_PANEL) && (layertype != LAYER_TYPE_INPUTPANEL) &&
1432 (layertype != LAYER_TYPE_FULLSCREEN) && (layertype != LAYER_TYPE_UNKNOWN)) {
1435 wl_list_remove(&eu->surface->layer_link);
1436 wl_list_init(&eu->surface->layer_link);
1438 if (eu->mapped != 0) {
1439 if ((el->visible == FALSE) || (eu->visible == FALSE)) {
1440 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1441 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1443 else if (eu->surface->buffer_ref.buffer) {
1444 buf_width = weston_surface_buffer_width(eu->surface);
1445 buf_height = weston_surface_buffer_height(eu->surface);
1446 if ((eu->width > buf_width) && (eu->scalex <= 1.0f)) {
1447 new_x = (float)(eu->x +
1448 (eu->width - eu->surface->geometry.width)/2);
1451 new_x = (float)eu->x;
1453 if ((eu->height > buf_height) && (eu->scaley <= 1.0f)) {
1454 new_y = (float) (eu->y +
1455 (eu->height - eu->surface->geometry.height)/2);
1458 new_y = (float)eu->y;
1460 new_x += eu->node_tbl->disp_x + eu->xadd;
1461 new_y += eu->node_tbl->disp_y + eu->yadd;
1465 new_x = (float)(eu->x + eu->node_tbl->disp_x + eu->xadd);
1466 new_y = (float)(eu->y + eu->node_tbl->disp_y + eu->yadd);
1468 wl_list_insert(wlayer->surface_list.prev, &eu->surface->layer_link);
1469 if ((eu->restrain_configure == 0) &&
1470 ((new_x != eu->surface->geometry.x) ||
1471 (new_y != eu->surface->geometry.y))) {
1472 weston_surface_damage_below(eu->surface);
1473 weston_surface_set_position(eu->surface, (float)new_x, (float)new_y);
1474 weston_surface_damage(eu->surface);
1476 uifw_debug("ico_window_mgr_restack_layer:%3d(%d).%08x(%08x:%d) "
1477 "x/y=%d/%d w/h=%d/%d %x",
1478 el->layer, el->visible, eu->surfaceid, (int)eu->surface,
1479 eu->visible, (int)eu->surface->geometry.x,
1480 (int)eu->surface->geometry.y, eu->surface->geometry.width,
1481 eu->surface->geometry.height, eu->layertype);
1486 /* damage(redraw) target surfacem if target exist */
1488 weston_surface_damage(usurf->surface);
1491 /* composit and draw screen(plane) */
1492 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
1494 if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) &&
1495 (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) {
1496 /* start shell fade */
1497 _ico_win_mgr->shell_init = 1;
1498 ico_ivi_shell_startup(_ico_win_mgr->shell);
1501 /* if visible change, call hook for input region */
1502 if ((usurf != NULL) && (win_mgr_hook_visible != NULL)) {
1503 if (old_visible != ico_window_mgr_is_visible(usurf)) {
1504 (*win_mgr_hook_visible)(usurf);
1507 uifw_trace("ico_window_mgr_restack_layer: Leave");
1510 /*--------------------------------------------------------------------------*/
1512 * @brief ico_window_mgr_touch_layer: touch panel layer control
1514 * @param[in] omit omit touch layer flag (TRUE=omit/FALSE=not omit)
1517 /*--------------------------------------------------------------------------*/
1519 ico_window_mgr_touch_layer(int omit)
1521 struct uifw_win_surface *eu;
1523 /* check current touch layer mode */
1524 if ((_ico_win_mgr->touch_layer == NULL) ||
1525 ((omit != FALSE) && (_ico_win_mgr->touch_layer->visible == FALSE))) {
1526 uifw_trace("ico_window_mgr_touch_layer: touch layer not exist or hide");
1530 wl_list_for_each (eu, &_ico_win_mgr->touch_layer->surface_list, ivi_layer) {
1531 if ((eu->surface == NULL) || (eu->mapped == 0)) continue;
1532 if (omit != FALSE) {
1533 eu->animation.pos_x = (int)eu->surface->geometry.x;
1534 eu->animation.pos_y = (int)eu->surface->geometry.y;
1535 eu->surface->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1);
1536 eu->surface->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1);
1539 eu->surface->geometry.x = (float)eu->animation.pos_x;
1540 eu->surface->geometry.y = (float)eu->animation.pos_y;
1545 /*--------------------------------------------------------------------------*/
1547 * @brief win_mgr_create_layer: create new layer
1549 * @param[in] usurf UIFW surface, (if need)
1550 * @param[in] layer layer id
1551 * @param[in] layertype layer type if need
1553 * @retval != NULL success(layer management table)
1554 * @retval == NULL error(No Memory)
1556 /*--------------------------------------------------------------------------*/
1557 static struct uifw_win_layer *
1558 win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer,
1559 const int layertype)
1561 struct uifw_win_layer *el;
1562 struct uifw_win_layer *new_el;
1564 new_el = malloc(sizeof(struct uifw_win_layer));
1566 uifw_trace("win_mgr_create_layer: Leave(No Memory)");
1570 memset(new_el, 0, sizeof(struct uifw_win_layer));
1571 new_el->layer = layer;
1572 if ((int)layer == _ico_ivi_background_layer ) {
1573 new_el->layertype = LAYER_TYPE_BACKGROUND;
1575 else if ((int)layer == _ico_ivi_touch_layer ) {
1576 new_el->layertype = LAYER_TYPE_TOUCH;
1577 _ico_win_mgr->touch_layer = new_el;
1579 else if ((int)layer == _ico_ivi_cursor_layer ) {
1580 new_el->layertype = LAYER_TYPE_CURSOR;
1581 _ico_win_mgr->cursor_layer = new_el;
1583 else if(layertype != 0) {
1584 new_el->layertype = layertype;
1587 new_el->layertype = LAYER_TYPE_PANEL;
1589 new_el->visible = TRUE;
1590 wl_list_init(&new_el->surface_list);
1591 wl_list_init(&new_el->link);
1593 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1594 if (layer >= el->layer) break;
1596 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1597 wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link);
1600 wl_list_insert(el->link.prev, &new_el->link);
1604 wl_list_remove(&usurf->ivi_layer);
1605 wl_list_insert(&new_el->surface_list, &usurf->ivi_layer);
1606 usurf->win_layer = new_el;
1611 /*--------------------------------------------------------------------------*/
1613 * @brief win_mgr_set_layer: set(or change) surface layer
1615 * @param[in] usurf UIFW surface
1616 * @param[in] layer layer id
1619 /*--------------------------------------------------------------------------*/
1621 win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1623 struct uifw_win_layer *el;
1624 struct uifw_win_layer *new_el;
1626 uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)",
1627 usurf->surfaceid, (int)usurf->surface, layer);
1629 /* check if same layer */
1630 if ((usurf->win_layer != NULL) && (usurf->win_layer->layer == layer)) {
1631 uifw_trace("win_mgr_set_layer: Leave(Same Layer)");
1635 /* search existing layer */
1636 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1637 if (el->layer == layer) break;
1640 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1641 /* layer not exist, create new layer */
1642 uifw_trace("win_mgr_set_layer: New Layer %d(%d)", layer, usurf->layertype);
1643 new_el = win_mgr_create_layer(usurf, layer, usurf->layertype);
1645 uifw_trace("win_mgr_set_layer: Leave(No Memory)");
1650 uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer);
1651 usurf->win_layer = el;
1652 win_mgr_set_raise(usurf, 3);
1654 /* rebild compositor surface list */
1655 if (usurf->visible) {
1656 ico_window_mgr_restack_layer(usurf);
1658 uifw_trace("win_mgr_set_layer: Leave");
1661 /*--------------------------------------------------------------------------*/
1663 * @brief win_mgr_set_active: set(or change) active surface
1665 * @param[in] usurf UIFW surface
1666 * @param[in] target target device
1669 /*--------------------------------------------------------------------------*/
1671 win_mgr_set_active(struct uifw_win_surface *usurf, const int target)
1673 struct weston_seat *seat;
1674 struct weston_surface *surface;
1675 int object = target;
1676 #if 0 /* pointer grab can not release */
1678 #endif /* pointer grab can not release */
1680 uifw_trace("win_mgr_set_active: Enter(%08x,%x)", (int)usurf, target);
1682 if ((usurf) && (usurf->shsurf) && (usurf->surface)) {
1683 surface = usurf->surface;
1684 if ((object & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) {
1686 if (_ico_win_mgr->active_pointer_usurf == usurf) {
1687 object |= ICO_WINDOW_MGR_ACTIVE_POINTER;
1689 if (_ico_win_mgr->active_keyboard_usurf == usurf) {
1690 object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1694 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1695 _ico_win_mgr->active_pointer_usurf = usurf;
1697 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1698 _ico_win_mgr->active_keyboard_usurf = usurf;
1705 object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1707 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1708 _ico_win_mgr->active_pointer_usurf = NULL;
1710 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1711 _ico_win_mgr->active_keyboard_usurf = NULL;
1715 wl_list_for_each (seat, &_ico_win_mgr->compositor->seat_list, link) {
1716 #if 0 /* pointer grab can not release */
1717 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1719 if ((seat->pointer != NULL) && (seat->pointer->focus != surface)) {
1720 uifw_trace("win_mgr_set_active: pointer reset focus(%08x)",
1721 (int)seat->pointer->focus);
1722 if (seat->pointer->button_count > 0) {
1723 /* emulate button release */
1724 notify_button(seat, weston_compositor_get_time(),
1725 seat->pointer->grab_button,
1726 WL_POINTER_BUTTON_STATE_RELEASED);
1727 /* count up button, because real mouse botan release */
1728 seat->pointer->button_count ++;
1730 weston_pointer_set_focus(seat->pointer, NULL,
1731 wl_fixed_from_int(0), wl_fixed_from_int(0));
1734 uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)",
1737 if ((seat->touch != NULL) && (seat->touch->focus != surface)) {
1738 uifw_trace("win_mgr_set_active: touch reset surface(%08x)",
1739 (int)seat->touch->focus);
1740 if (seat->num_tp > 10) {
1741 seat->num_tp = 0; /* safty gard */
1743 else if (seat->num_tp > 0) {
1744 /* emulate touch up */
1745 savetp = seat->num_tp;
1746 for (i = 0; i < savetp; i++) {
1747 notify_touch(seat, weston_compositor_get_time(), i+1,
1748 seat->touch->grab_x, seat->touch->grab_y,
1751 /* touch count up, becase real touch release */
1752 seat->num_tp = savetp;
1754 weston_touch_set_focus(seat, NULL);
1757 uifw_trace("win_mgr_set_active: touch nochange surface(%08x)",
1762 uifw_trace("win_mgr_set_active: pointer reset surface(%08x)",
1763 (int)seat->pointer->focus);
1764 if ((seat->pointer != NULL) && (seat->pointer->focus != NULL)) {
1765 if (seat->pointer->button_count > 0) {
1766 /* emulate button release */
1767 notify_button(seat, weston_compositor_get_time(),
1768 seat->pointer->grab_button,
1769 WL_POINTER_BUTTON_STATE_RELEASED);
1770 seat->pointer->button_count ++;
1772 weston_pointer_set_focus(seat->pointer, NULL,
1773 wl_fixed_from_int(0), wl_fixed_from_int(0));
1775 if ((seat->touch != NULL) && (seat->touch->focus != NULL)) {
1776 if (seat->num_tp > 10) {
1777 seat->num_tp = 0; /* safty gard */
1779 else if (seat->num_tp > 0) {
1780 /* emulate touch up */
1781 savetp = seat->num_tp;
1782 for (i = 0; i < savetp; i++) {
1783 notify_touch(seat, weston_compositor_get_time(), i+1,
1784 seat->touch->grab_x, seat->touch->grab_y,
1787 /* touch count up, becase real touch release */
1788 seat->num_tp = savetp;
1790 weston_touch_set_focus(seat, NULL);
1794 #endif /* pointer grab can not release */
1795 if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) {
1797 if (seat->keyboard->focus != surface) {
1798 weston_keyboard_set_focus(seat->keyboard, surface);
1799 uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)",
1800 (int)seat->keyboard->focus, (int)surface);
1803 uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)",
1808 uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)",
1809 (int)seat->keyboard);
1810 weston_keyboard_set_focus(seat->keyboard, NULL);
1814 uifw_trace("win_mgr_set_active: Leave(%08x)", (int)usurf);
1817 /*--------------------------------------------------------------------------*/
1819 * @brief ico_window_mgr_ismykeyboard: check active keyboard
1821 * @param[in] usurf UIFW surface
1822 * @return check result
1823 * @retval =1 usurf is active keyboard surface
1824 * @retval =0 usurf is not active
1826 /*--------------------------------------------------------------------------*/
1828 ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf)
1830 return (_ico_win_mgr->active_keyboard_usurf == usurf) ? 1 : 0;
1833 /*--------------------------------------------------------------------------*/
1835 * @brief uifw_declare_manager: declare manager(ex.SystemController) client
1837 * @param[in] client Weyland client
1838 * @param[in] resource resource of request
1839 * @param[in] manager manager(1=manager, 0=not manager)
1842 /*--------------------------------------------------------------------------*/
1844 uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager)
1846 struct uifw_manager* mgr;
1847 struct uifw_win_surface *usurf;
1848 struct uifw_client *uclient;
1849 struct uifw_win_layer *el;
1851 uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d",
1852 (int)client, manager);
1854 uclient = find_client_from_client(client);
1856 uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client);
1860 uclient->manager = manager;
1862 /* client set to manager */
1863 _ico_win_mgr->num_manager = 0;
1864 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1865 if (mgr->resource == resource) {
1866 if (mgr->manager != manager) {
1867 uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d",
1868 (int)client, mgr->manager, manager);
1869 mgr->manager = manager;
1872 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1873 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
1874 /* send window create event to manager */
1875 if (usurf->created != 0) {
1876 uifw_trace("uifw_declare_manager: Send manager(%08x) "
1877 "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)",
1878 (int)resource, usurf->surfaceid,
1879 usurf->uclient->pid, usurf->uclient->appid);
1880 ico_window_mgr_send_window_created(resource,
1883 usurf->uclient->pid,
1884 usurf->uclient->appid,
1885 usurf->layertype << 12);
1893 _ico_win_mgr->num_manager++;
1896 uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager);
1899 /*--------------------------------------------------------------------------*/
1901 * @brief uifw_set_window_layer: set layer id to surface
1903 * @param[in] client Weyland client
1904 * @param[in] resource resource of request
1905 * @param[in] surfaceid UIFW surface id
1906 * @param[in] layer layer id
1909 /*--------------------------------------------------------------------------*/
1911 uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource,
1912 uint32_t surfaceid, uint32_t layer)
1914 if (layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) {
1915 layer = _ico_ivi_background_layer;
1917 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) {
1918 layer = _ico_ivi_touch_layer;
1920 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) {
1921 layer = _ico_ivi_cursor_layer;
1923 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) {
1924 layer = _ico_ivi_startup_layer;
1927 uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d",
1928 (int)resource, surfaceid, layer);
1930 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1933 uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid);
1937 if (usurf->win_layer->layer != layer) {
1938 win_mgr_set_layer(usurf, layer);
1939 win_mgr_change_surface(usurf->surface, -1, 1);
1941 uifw_trace("uifw_set_window_layer: Leave");
1944 /*--------------------------------------------------------------------------*/
1946 * @brief uifw_set_positionsize: set surface position and size
1948 * @param[in] client Weyland client
1949 * @param[in] resource resource of request
1950 * @param[in] surfaceid UIFW surface id
1951 * @param[in] node surface node id
1952 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
1953 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
1954 * @param[in] width surface width(if bigger than 16383, no change)
1955 * @param[in] height surface height(if bigger than 16383, no change)
1956 * @param[in] flags with/without animation and client configure flag
1959 /*--------------------------------------------------------------------------*/
1961 uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
1962 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
1963 int32_t width, int32_t height, int32_t flags)
1965 struct uifw_client *uclient;
1966 struct uifw_win_surface *usurf;
1967 struct weston_surface *es;
1971 uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x",
1972 surfaceid, node, x, y, width, height, flags);
1974 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1976 uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid);
1980 uclient = find_client_from_client(client);
1983 if (((int)node) >= _ico_num_nodes) {
1984 uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)",
1985 node, _ico_num_nodes);
1986 if ((ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_NODISP) == 0) {
1987 if (usurf->visible) {
1988 /* no display, change to hide */
1989 uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE,
1990 ICO_WINDOW_MGR_V_NOCHANGE, 0);
1996 usurf->node_tbl = &_ico_node_table[node];
1998 es = usurf->surface;
2000 /* weston surface exist */
2001 es = usurf->surface;
2002 retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
2004 /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */
2005 if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x;
2006 if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y;
2007 if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width;
2008 if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height;
2010 /* check animation */
2011 if ((usurf->animation.restrain_configure != 0) &&
2012 (x == usurf->x) && (y == usurf->y) &&
2013 (width == usurf->width) && (height == usurf->height)) {
2014 uifw_trace("uifw_set_positionsize: Leave(same position size at animation)");
2019 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
2020 (uclient->manager == 0)) uclient = NULL;
2023 if ((usurf->width > 0) && (usurf->height > 0)) {
2024 win_mgr_surface_change_mgr(es, x, y, width, height);
2025 uifw_trace("uifw_set_positionsize: Leave(Request from App)");
2029 uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d",
2031 /* Initiale position is (0,0) */
2032 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x),
2033 (float)(usurf->node_tbl->disp_y));
2036 uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d",
2037 (int)es->geometry.x, (int)es->geometry.y,
2038 (int)es->geometry.width, (int)es->geometry.height);
2040 usurf->animation.pos_x = usurf->x;
2041 usurf->animation.pos_y = usurf->y;
2042 usurf->animation.pos_width = usurf->width;
2043 usurf->animation.pos_height = usurf->height;
2044 usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0;
2047 usurf->width = width;
2048 usurf->height = height;
2049 if (_ico_win_mgr->num_manager <= 0) {
2050 /* no manager(HomeScreen), set geometory */
2051 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x + x),
2052 (float)(usurf->node_tbl->disp_y + y));
2054 if ((es->output) && (es->buffer_ref.buffer) &&
2055 (es->geometry.width > 0) && (es->geometry.height > 0)) {
2056 uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)",
2058 if (usurf->visible) {
2059 if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) &&
2060 (win_mgr_hook_animation != NULL)) {
2061 /* with animation */
2062 if ((x != (usurf->surface->geometry.x - usurf->node_tbl->disp_x)) ||
2063 (y != (usurf->surface->geometry.y - usurf->node_tbl->disp_y))) {
2064 op = ICO_WINDOW_MGR_ANIMATION_OPMOVE;
2066 else if ((width != usurf->surface->geometry.width) ||
2067 (height != usurf->surface->geometry.height)) {
2068 op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE;
2071 op = ICO_WINDOW_MGR_ANIMATION_OPNONE;
2073 if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) &&
2074 (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) ||
2075 ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) &&
2076 (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) {
2077 retanima = (*win_mgr_hook_animation)(op, (void *)usurf);
2078 uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima);
2081 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
2082 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
2083 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2084 usurf->width, usurf->height);
2088 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
2089 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
2090 win_mgr_change_surface(es,
2091 (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1);
2093 uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output);
2098 usurf->width = width;
2099 usurf->height = height;
2100 uifw_trace("uifw_set_positionsize: Leave(OK,but no buffer)");
2104 /*--------------------------------------------------------------------------*/
2106 * @brief uifw_set_visible: surface visible/raise control
2108 * @param[in] client Weyland client
2109 * @param[in] resource resource of request
2110 * @param[in] surfaceid UIFW surface id
2111 * @param[in] visible visible(1=show/0=hide/other=no change)
2112 * @param[in] raise raise(1=raise/0=lower/other=no change)
2113 * @param[in] flags with/without animation
2116 /*--------------------------------------------------------------------------*/
2118 uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
2119 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags)
2121 struct uifw_win_surface *usurf;
2122 struct uifw_client *uclient;
2126 uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)",
2127 surfaceid, visible, raise, flags);
2129 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2130 if ((! usurf) || (! usurf->surface)) {
2131 uifw_trace("uifw_set_visible: Leave(Surface Not Exist)");
2135 uclient = find_client_from_client(client);
2137 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
2138 (uclient->manager == 0)) {
2139 uifw_trace("uifw_set_visible: Request from App(%s), not Manager",
2144 uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid);
2148 uifw_trace("uifw_set_visible: Request from Unknown App, not Manager");
2153 if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) {
2155 if ((! usurf->visible) ||
2156 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
2158 uifw_trace("uifw_set_visible: Change to Visible");
2160 ico_ivi_shell_set_toplevel(usurf->shsurf);
2162 /* Weston surface configure */
2163 uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d",
2164 (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y,
2165 usurf->width, usurf->height);
2166 ico_ivi_shell_set_surface_type(usurf->shsurf);
2167 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2168 usurf->width, usurf->height);
2170 restack = 1; /* need damage */
2172 if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) &&
2173 (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
2174 (win_mgr_hook_animation != NULL)) {
2175 usurf->animation.pos_x = usurf->x;
2176 usurf->animation.pos_y = usurf->y;
2177 usurf->animation.pos_width = usurf->width;
2178 usurf->animation.pos_height = usurf->height;
2179 usurf->animation.no_configure = 0;
2180 retanima = (*win_mgr_hook_animation)(
2181 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
2182 ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS :
2183 ICO_WINDOW_MGR_ANIMATION_OPSHOW,
2185 uifw_trace("uifw_set_visible: ret call anima = %d", retanima);
2188 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
2189 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
2190 uifw_trace("uifw_set_visible: Leave(No Change)");
2194 else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) {
2196 if ((usurf->visible) ||
2197 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
2200 win_mgr_reset_focus(usurf);
2202 /* Weston surface configure */
2203 weston_surface_damage_below(usurf->surface);
2204 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2205 usurf->width, usurf->height);
2207 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
2208 if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) &&
2209 (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
2210 (win_mgr_hook_animation != NULL)) {
2211 usurf->animation.pos_x = usurf->x;
2212 usurf->animation.pos_y = usurf->y;
2213 usurf->animation.pos_width = usurf->width;
2214 usurf->animation.pos_height = usurf->height;
2215 usurf->animation.no_configure = 0;
2216 retanima = (*win_mgr_hook_animation)(
2217 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
2218 ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS :
2219 ICO_WINDOW_MGR_ANIMATION_OPHIDE,
2222 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
2224 uifw_trace("uifw_set_visible: Change to UnVisible");
2225 /* change visible to unvisible, restack surface list */
2227 /* Weston surface configure */
2228 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2229 usurf->width, usurf->height);
2232 uifw_trace("uifw_set_visible: UnVisible but animation");
2235 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
2236 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
2237 uifw_trace("uifw_set_visible: Leave(No Change)");
2241 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
2242 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
2243 uifw_trace("uifw_set_visible: Leave(No Change)");
2248 if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) {
2249 win_mgr_set_raise(usurf, raise);
2250 if (usurf->visible == 0) {
2255 raise = ICO_WINDOW_MGR_V_NOCHANGE;
2259 ico_window_mgr_restack_layer(usurf);
2262 /* send event(VISIBLE) to manager */
2264 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
2266 (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 :
2267 ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 :
2268 ICO_WINDOW_MGR_V_NOCHANGE),
2269 raise, uclient ? 0 : 1, 0,0);
2271 uifw_trace("uifw_set_visible: Leave(OK)");
2274 /*--------------------------------------------------------------------------*/
2276 * @brief uifw_set_animation: set animation of surface visible/unvisible
2278 * @param[in] client Weyland client
2279 * @param[in] resource resource of request
2280 * @param[in] surfaceid UIFW surface id
2281 * @param[in] type how to change surface
2282 * @param[in] anmation animation name
2283 * @param[in] time animation time(ms), if 0, default time
2286 /*--------------------------------------------------------------------------*/
2288 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
2289 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
2292 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2294 uifw_trace("uifw_set_transition: surf=%08x,type=%x,anim=%s,time=%d",
2295 surfaceid, type, animation, time);
2298 if ((*animation != 0) && (*animation != ' ')) {
2299 animaid = ico_get_animation_name(animation);
2300 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
2301 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
2302 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
2303 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
2304 usurf->animation.next_anima = animaid;
2307 usurf->animation.hide_anima = animaid;
2310 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
2311 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
2312 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
2313 usurf->animation.next_anima = animaid;
2316 usurf->animation.show_anima = animaid;
2319 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
2320 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
2321 usurf->animation.next_anima = animaid;
2324 usurf->animation.move_anima = animaid;
2327 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
2328 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
2329 usurf->animation.next_anima = animaid;
2332 usurf->animation.resize_anima = animaid;
2336 if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) {
2337 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
2338 usurf->animation.hide_time = time;
2340 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
2341 usurf->animation.show_time = time;
2343 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
2344 usurf->animation.move_time = time;
2346 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
2347 usurf->animation.resize_time = time;
2352 uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid);
2356 /*--------------------------------------------------------------------------*/
2358 * @brief uifw_set_attributes: set surface attributes
2360 * @param[in] client Weyland client
2361 * @param[in] resource resource of request
2362 * @param[in] surfaceid UIFW surface id
2363 * @param[in] attributes surface attributes
2366 /*--------------------------------------------------------------------------*/
2368 uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
2369 uint32_t surfaceid, uint32_t attributes)
2371 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2373 uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes);
2376 usurf->attributes = attributes;
2377 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) ==
2378 (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) {
2379 usurf->attributes &=
2380 ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT);
2382 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) ==
2383 (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) {
2384 usurf->attributes &=
2385 ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM);
2388 uifw_trace("uifw_set_attributes: Leave");
2391 /*--------------------------------------------------------------------------*/
2393 * @brief uifw_visible_animation: surface visibility control with animation
2395 * @param[in] client Weyland client
2396 * @param[in] resource resource of request
2397 * @param[in] surfaceid surface id
2398 * @param[in] visible visible(1=show/0=hide)
2399 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
2400 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
2401 * @param[in] width surface width(if bigger than 16383, no change)
2402 * @param[in] height surface height(if bigger than 16383, no change)
2405 /*--------------------------------------------------------------------------*/
2407 uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
2408 uint32_t surfaceid, int32_t visible,
2409 int32_t x, int32_t y, int32_t width, int32_t height)
2411 struct uifw_win_surface *usurf;
2413 uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)",
2414 surfaceid, visible, x, y, width, height);
2416 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2418 if ((! usurf) || (! usurf->surface)) {
2419 uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)");
2423 usurf->animation.pos_x = x;
2424 usurf->animation.pos_y = y;
2425 if (width > 0) usurf->animation.pos_width = width;
2426 else usurf->animation.pos_width = 1;
2427 if (height > 0) usurf->animation.pos_height = height;
2428 else usurf->animation.pos_height = 1;
2429 usurf->animation.no_configure = 0;
2431 uifw_set_visible(client, resource, surfaceid, visible,
2432 ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS);
2434 uifw_trace("uifw_visible_animation: Leave");
2437 /*--------------------------------------------------------------------------*/
2439 * @brief uifw_set_active: set active surface
2441 * @param[in] client Weyland client
2442 * @param[in] resource resource of request
2443 * @param[in] surfaceid UIFW surface id
2444 * @param[in] active target device
2447 /*--------------------------------------------------------------------------*/
2449 uifw_set_active(struct wl_client *client, struct wl_resource *resource,
2450 uint32_t surfaceid, int32_t active)
2452 struct uifw_win_surface *usurf;
2454 uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active);
2456 if ((surfaceid > 0) &&
2457 ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) {
2458 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2464 switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) {
2465 case ICO_WINDOW_MGR_ACTIVE_POINTER:
2466 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2467 uifw_trace("uifw_set_active: pointer active change %08x->%08x",
2468 _ico_win_mgr->active_pointer_usurf ?
2469 _ico_win_mgr->active_pointer_usurf->surfaceid : 0,
2470 usurf ? usurf->surfaceid : 0);
2471 if (_ico_win_mgr->active_pointer_usurf) {
2472 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2473 _ico_win_mgr->active_pointer_usurf,
2474 (_ico_win_mgr->active_keyboard_usurf ==
2475 _ico_win_mgr->active_pointer_usurf) ?
2476 ICO_WINDOW_MGR_ACTIVE_KEYBOARD :
2477 ICO_WINDOW_MGR_ACTIVE_NONE,
2480 _ico_win_mgr->active_pointer_usurf = usurf;
2481 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2483 ICO_WINDOW_MGR_ACTIVE_POINTER |
2484 (_ico_win_mgr->active_keyboard_usurf == usurf) ?
2485 ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0,
2487 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER);
2490 case ICO_WINDOW_MGR_ACTIVE_KEYBOARD:
2491 if (usurf != _ico_win_mgr->active_keyboard_usurf) {
2492 uifw_trace("uifw_set_active: keyboard active change %08x->%08x",
2493 _ico_win_mgr->active_keyboard_usurf ?
2494 _ico_win_mgr->active_keyboard_usurf->surfaceid : 0,
2495 usurf ? usurf->surfaceid : 0);
2496 if (_ico_win_mgr->active_keyboard_usurf) {
2497 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2498 _ico_win_mgr->active_keyboard_usurf,
2499 (_ico_win_mgr->active_keyboard_usurf ==
2500 _ico_win_mgr->active_pointer_usurf) ?
2501 ICO_WINDOW_MGR_ACTIVE_POINTER :
2502 ICO_WINDOW_MGR_ACTIVE_NONE,
2505 _ico_win_mgr->active_keyboard_usurf = usurf;
2506 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2508 ICO_WINDOW_MGR_ACTIVE_KEYBOARD |
2509 (_ico_win_mgr->active_pointer_usurf == usurf) ?
2510 ICO_WINDOW_MGR_ACTIVE_POINTER : 0,
2512 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2516 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
2517 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
2518 uifw_trace("uifw_set_active: active change %08x/%08x->%08x",
2519 _ico_win_mgr->active_pointer_usurf ?
2520 _ico_win_mgr->active_pointer_usurf->surfaceid : 0,
2521 _ico_win_mgr->active_keyboard_usurf ?
2522 _ico_win_mgr->active_keyboard_usurf->surfaceid : 0,
2523 usurf ? usurf->surfaceid : 0);
2524 if (_ico_win_mgr->active_pointer_usurf) {
2525 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2526 _ico_win_mgr->active_pointer_usurf,
2527 ICO_WINDOW_MGR_ACTIVE_NONE,
2529 if (_ico_win_mgr->active_keyboard_usurf ==
2530 _ico_win_mgr->active_pointer_usurf) {
2531 _ico_win_mgr->active_keyboard_usurf = NULL;
2534 if (_ico_win_mgr->active_keyboard_usurf) {
2535 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2536 _ico_win_mgr->active_keyboard_usurf,
2537 ICO_WINDOW_MGR_ACTIVE_NONE,
2540 _ico_win_mgr->active_pointer_usurf = usurf;
2541 _ico_win_mgr->active_keyboard_usurf = usurf;
2542 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2544 ICO_WINDOW_MGR_ACTIVE_POINTER |
2545 ICO_WINDOW_MGR_ACTIVE_KEYBOARD,
2547 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2548 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2552 uifw_trace("uifw_set_active: Leave(Change Active)");
2555 win_mgr_set_active(NULL, active);
2556 uifw_trace("uifw_set_active: Leave(Reset active surface)");
2560 /*--------------------------------------------------------------------------*/
2562 * @brief uifw_set_layer_visible: layer visible control
2564 * @param[in] client Weyland client
2565 * @param[in] resource resource of request
2566 * @param[in] layer layer id
2567 * @param[in] visible visible(1=show/0=hide)
2570 /*--------------------------------------------------------------------------*/
2572 uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
2573 uint32_t layer, int32_t visible)
2575 struct uifw_win_layer *el;
2576 struct uifw_win_layer *new_el;
2577 struct uifw_win_surface *usurf;
2580 if (layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) {
2581 layer = _ico_ivi_background_layer;
2582 layertype = LAYER_TYPE_BACKGROUND;
2584 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) {
2585 layer = _ico_ivi_touch_layer;
2586 layertype = LAYER_TYPE_TOUCH;
2588 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) {
2589 layer = _ico_ivi_cursor_layer;
2590 layertype = LAYER_TYPE_CURSOR;
2592 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) {
2593 layer = _ico_ivi_startup_layer;
2596 uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible);
2599 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2600 if (el->layer == layer) break;
2603 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
2604 /* layer not exist, create new layer */
2605 uifw_trace("uifw_set_layer_visible: New Layer %d", layer);
2606 new_el = win_mgr_create_layer(NULL, layer, layertype);
2608 uifw_trace("uifw_set_layer_visible: Leave(No Memory)");
2611 new_el->visible = (visible != 0) ? TRUE : FALSE;
2612 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2613 layer, new_el->visible, 0,0,0);
2614 uifw_trace("uifw_set_layer_visible: Leave(new layer)");
2618 /* control all surface in layer */
2619 if ((el->visible != FALSE) && (visible == 0)) {
2620 /* layer change to NOT visible */
2621 uifw_trace("uifw_set_layer_visible: change to not visible");
2622 el->visible = FALSE;
2624 else if ((el->visible == FALSE) && (visible != 0)) {
2625 /* layer change to visible */
2626 uifw_trace("uifw_set_layer_visible: change to visible");
2631 uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)",
2632 el->visible, visible);
2636 /* set damege area */
2637 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2638 if ((usurf->visible != FALSE) && (usurf->surface != NULL) &&
2639 (usurf->surface->output != NULL)) {
2640 /* Reset focus if hide */
2642 win_mgr_reset_focus(usurf);
2644 /* Damage(redraw) target surface */
2645 weston_surface_damage_below(usurf->surface);
2649 /* rebild compositor surface list */
2650 ico_window_mgr_restack_layer(NULL);
2652 /* send layer visible event to manager */
2653 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2654 layer, el->visible, 0,0,0);
2656 uifw_trace("uifw_set_layer_visible: Leave");
2659 /*--------------------------------------------------------------------------*/
2661 * @brief uifw_get_surfaces: get application surfaces
2663 * @param[in] client Weyland client
2664 * @param[in] resource resource of request
2665 * @param[in] appid application id
2666 * @param[in] pid process id
2669 /*--------------------------------------------------------------------------*/
2671 uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
2672 const char *appid, int32_t pid)
2674 struct uifw_client *uclient;
2675 struct uifw_win_layer *el;
2676 struct uifw_win_surface *usurf;
2677 struct wl_array reply;
2680 uifw_trace("uifw_get_surfaces: Enter(appid=%s, pid=%d)", appid ? appid : " ", pid);
2682 wl_array_init(&reply);
2684 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2685 if ((appid != NULL) && (*appid != ' ')) {
2686 if (strcmp(uclient->appid, appid) == 0) break;
2689 if (uclient->pid == pid) break;
2692 if (&uclient->link == &_ico_win_mgr->client_list) {
2693 uifw_trace("uifw_get_surfaces: appid=%s pid=%d dose not exist",
2694 appid ? appid : " ", pid);
2697 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2698 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2699 if (usurf->uclient == uclient) {
2700 uifw_trace("uifw_get_surfaces: %s(%d) surf=%08x",
2701 uclient->appid, uclient->pid, usurf->surfaceid);
2702 up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t));
2704 *up = usurf->surfaceid;
2710 ico_window_mgr_send_app_surfaces(resource, uclient->appid, uclient->pid, &reply);
2712 wl_array_release(&reply);
2713 uifw_trace("uifw_get_surfaces: Leave");
2716 /*--------------------------------------------------------------------------*/
2718 * @brief win_mgr_check_mapsurrace: check and change all surface
2720 * @param[in] animation weston animation table(unused)
2721 * @param[in] outout weston output table(unused)
2722 * @param[in] mseces current time(unused)
2725 /*--------------------------------------------------------------------------*/
2727 win_mgr_check_mapsurrace(struct weston_animation *animation,
2728 struct weston_output *output, uint32_t msecs)
2730 struct uifw_surface_map *sm;
2732 int wait = 99999999;
2734 /* check touch down counter */
2735 if (touch_check_seat) {
2736 if (touch_check_seat->num_tp > 10) {
2737 uifw_trace("win_mgr_change_mapsurface: illegal touch counter(num=%d), reset",
2738 (int)touch_check_seat->num_tp);
2739 touch_check_seat->num_tp = 0;
2743 /* check all mapped surfaces */
2744 curtime = weston_compositor_get_time();
2745 wl_list_for_each (sm, &_ico_win_mgr->map_list, map_link) {
2746 win_mgr_change_mapsurface(sm, 0, curtime);
2748 if (sm->interval < wait) {
2749 wait = sm->interval;
2754 /* check frame interval */
2755 if (wait < 99999999) {
2761 if (wait != _ico_win_mgr->waittime) {
2762 _ico_win_mgr->waittime = wait;
2763 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent,
2764 _ico_win_mgr->waittime);
2768 /*--------------------------------------------------------------------------*/
2770 * @brief win_mgr_timer_mapsurrace: mapped surface check timer
2772 * @param[in] data user data(unused)
2775 /*--------------------------------------------------------------------------*/
2777 win_mgr_timer_mapsurrace(void *data)
2779 win_mgr_check_mapsurrace(NULL, NULL, 0);
2783 /*--------------------------------------------------------------------------*/
2785 * @brief win_mgr_change_mapsurface: check and change mapped surface
2787 * @param[in] sm map surface table
2788 * @param[in] event send event (if 0, send if changed)
2789 * @param[in] curtime current time(ms)
2792 /*--------------------------------------------------------------------------*/
2794 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime)
2796 struct uifw_drm_buffer *drm_buffer;
2797 struct uifw_dri_image *dri_image;
2798 struct uifw_intel_region *dri_region;
2799 struct uifw_gl_surface_state *gl_state;
2800 struct weston_surface *es;
2808 /* check if buffered */
2809 es = sm->usurf->surface;
2810 if ((es == NULL) || (es->buffer_ref.buffer == NULL) ||
2811 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0) ||
2812 (es->buffer_ref.buffer->legacy_buffer == NULL) || (es->renderer_state == NULL) ||
2813 (((struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer)->driver_buffer
2815 /* surface has no buffer, error */
2816 uifw_trace("win_mgr_change_mapsurface: surface(%08x) has no buffer",
2817 sm->usurf->surfaceid);
2819 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
2826 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2827 if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2828 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
2830 else if (gl_state->buffer_type != BUFFER_TYPE_EGL) {
2834 drm_buffer = (struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer;
2835 dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer;
2836 dri_region = dri_image->region;
2837 width = es->buffer_ref.buffer->width;
2838 height = es->buffer_ref.buffer->height;
2839 stride = drm_buffer->stride[0];
2840 if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) {
2841 format = EGL_TEXTURE_RGB;
2843 else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) {
2844 format = EGL_TEXTURE_RGBA;
2847 /* unknown format, error */
2848 format = EGL_NO_TEXTURE;
2850 eglname = dri_region->name;
2851 #if MESA_VERSION >= 921
2853 if (drm_intel_bo_flink((drm_intel_bo *)dri_region->bo, &eglname)) {
2854 uifw_warn("win_mgr_change_mapsurface: drm_intel_bo_flink() Error");
2859 if ((sm->initflag == 0) && (eglname != 0) &&
2860 (width > 0) && (height > 0) && (stride > 0)) {
2862 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
2865 if ((eglname == 0) || (width <= 0) || (height <= 0) || (stride <= 0)) {
2868 else if (event == 0) {
2869 if ((sm->width != width) || (sm->height != height) ||
2870 (sm->stride != stride) || (format != sm->format)) {
2871 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
2873 else if (eglname != sm->eglname) {
2874 #if 1 /* log for speed test */
2875 uifw_debug("win_mgr_change_mapsurface: SWAPBUFFER(surf=%08x name=%d)",
2876 sm->usurf->surfaceid, sm->eglname);
2878 dtime = curtime - sm->lasttime;
2879 if ((sm->interval > 0) && (dtime < sm->interval)) {
2884 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
2887 else if (sm->eventque) {
2888 dtime = curtime - sm->lasttime;
2889 if ((sm->interval == 0) || (dtime >= sm->interval)) {
2890 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
2896 sm->height = height;
2897 sm->stride = stride;
2898 sm->eglname = eglname;
2899 sm->format = format;
2904 #if 0 /* too many logs */
2905 uifw_debug("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x name=%d "
2906 "w/h/s=%d/%d/%d format=%x",
2907 event, sm->usurf->surfaceid, sm->eglname,
2908 sm->width, sm->height, sm->stride, sm->format);
2910 sm->lasttime = curtime;
2912 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
2913 sm->usurf->surfaceid, sm->type, sm->eglname,
2914 sm->width, sm->height, sm->stride, sm->format);
2915 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
2916 /* free map table if error */
2917 wl_list_remove(&sm->surf_link);
2918 wl_list_remove(&sm->map_link);
2919 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2920 _ico_win_mgr->free_maptable = sm;
2925 /*--------------------------------------------------------------------------*/
2927 * @brief uifw_map_surface: mapped surface buffer to system application
2929 * @param[in] client Weyland client
2930 * @param[in] resource resource of request
2931 * @param[in] surfaceid surface id
2932 * @param[in] framerate frame rate of surface update(frame/sec)
2935 /*--------------------------------------------------------------------------*/
2937 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
2938 uint32_t surfaceid, int32_t framerate)
2940 struct uifw_win_surface *usurf;
2941 struct weston_surface *es;
2942 struct uifw_surface_map *sm;
2943 struct weston_buffer *buffer;
2944 struct uifw_client *uclient;
2945 struct uifw_drm_buffer *drm_buffer;
2946 struct uifw_gl_surface_state *gl_state;
2948 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate);
2950 usurf = ico_window_mgr_get_usurf(surfaceid);
2952 /* surface dose not exist, error */
2953 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2954 surfaceid, 1, 0, 0, 0, 0, 0);
2955 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
2958 uclient = find_client_from_client(client);
2959 if ((! uclient) || (! uclient->mgr)) {
2960 /* client dose not exist, error */
2961 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2962 surfaceid, 2, 0, 0, 0, 0, 0);
2963 uifw_trace("uifw_map_surface: Leave(client=%08x dose not exist)", (int)client);
2967 /* check if buffered */
2968 es = usurf->surface;
2970 /* surface has no buffer, error */
2971 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2972 surfaceid, 3, 0, 0, 0, 0, 0);
2973 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid);
2977 /* check buffer type */
2978 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2979 if ((gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) {
2980 /* wl_shm_buffer not support */
2981 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2982 surfaceid, 4, 0, 0, 0, 0, 0);
2983 uifw_trace("uifw_map_surface: Leave(surface(%08x) is wl_shm_buffer, "
2984 "not support)", surfaceid);
2988 /* check same surface */
2989 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2990 if ((sm->usurf == usurf) && (sm->uclient == uclient)) {
2995 if (&sm->surf_link == &usurf->surf_map) {
2996 /* create map table */
2997 sm = _ico_win_mgr->free_maptable;
2999 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
3002 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
3004 ico_window_mgr_send_map_surface(resource,
3005 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
3006 surfaceid, 5, 0, 0, 0, 0, 0);
3007 uifw_trace("uifw_map_surface: Leave(malloc error)");
3011 memset(sm, 0, sizeof(struct uifw_surface_map));
3013 wl_list_init(&sm->map_link);
3014 wl_list_init(&sm->surf_link);
3016 sm->uclient = uclient;
3017 sm->type = ICO_WINDOW_MGR_MAP_TYPE_EGL;
3018 sm->framerate = framerate;
3019 if (sm->framerate > 60) sm->framerate = 60;
3020 if (sm->framerate > 0) {
3021 sm->interval = (1000 / sm->framerate) - 1;
3023 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
3024 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
3027 /* change frame rate */
3028 uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d",
3029 sm->framerate, framerate);
3030 if (sm->framerate != framerate) {
3031 sm->framerate = framerate;
3032 if (sm->framerate > 60) sm->framerate = 60;
3033 if (sm->framerate > 0) {
3034 sm->interval = (1000 / sm->framerate) - 1;
3036 win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time());
3041 buffer = es->buffer_ref.buffer;
3042 if ((buffer != NULL) && (gl_state->buffer_type == BUFFER_TYPE_EGL)) {
3043 sm->width = buffer->width;
3044 sm->height = buffer->height;
3045 drm_buffer = (struct uifw_drm_buffer *)buffer->legacy_buffer;
3046 if (drm_buffer != NULL) {
3047 sm->stride = drm_buffer->stride[0];
3048 if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) {
3049 sm->format = EGL_TEXTURE_RGB;
3051 else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) {
3052 sm->format = EGL_TEXTURE_RGBA;
3055 /* unknown format, error */
3056 sm->format = EGL_NO_TEXTURE;
3058 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
3059 (gl_state != NULL)) {
3065 /* send map event */
3067 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP,
3068 weston_compositor_get_time());
3070 uifw_trace("uifw_map_surface: Leave");
3073 /*--------------------------------------------------------------------------*/
3075 * @brief uifw_unmap_surface: unmap surface buffer
3077 * @param[in] client Weyland client
3078 * @param[in] resource resource of request
3079 * @param[in] surfaceid surface id
3082 /*--------------------------------------------------------------------------*/
3084 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
3087 struct uifw_win_surface *usurf;
3088 struct uifw_surface_map *sm, *sm_tmp;
3089 struct uifw_client *uclient;
3091 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
3093 usurf = ico_window_mgr_get_usurf(surfaceid);
3095 /* surface dose not exist, error */
3096 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
3100 uclient = find_client_from_client(client);
3101 if ((! uclient) || (! uclient->mgr)) {
3102 /* client dose not exist, error */
3103 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
3109 wl_list_for_each (sm, &usurf->surf_map, surf_link) {
3110 if (sm->uclient->mgr != NULL) {
3111 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x "
3112 "w/h/s=%d/%d/%d format=%x",
3113 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
3114 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
3115 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
3116 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
3117 surfaceid, sm->type, sm->eglname, sm->width,
3118 sm->height, sm->stride, sm->format);
3123 wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) {
3124 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
3125 /* send unmap event */
3126 if ((uclient != NULL) && (uclient->mgr != NULL)) {
3127 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x "
3128 "w/h/s=%d/%d/%d format=%x",
3129 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
3130 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
3131 ico_window_mgr_send_map_surface(uclient->mgr->resource,
3132 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
3133 surfaceid, sm->type, sm->eglname, sm->width,
3134 sm->height, sm->stride, sm->format);
3136 wl_list_remove(&sm->surf_link);
3137 wl_list_remove(&sm->map_link);
3138 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
3139 _ico_win_mgr->free_maptable = sm;
3141 uifw_trace("uifw_unmap_surface: Leave");
3144 /*--------------------------------------------------------------------------*/
3146 * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen)
3148 * @param[in] surface Weston surface
3149 * @param[in] x X coordinate on screen
3150 * @param[in] y Y coordinate on screen
3151 * @param[in] width surface width
3152 * @param[in] height surface height
3153 * @return number of managers
3154 * @retval > 0 number of managers
3155 * @retval 0 manager not exist
3157 /*--------------------------------------------------------------------------*/
3159 win_mgr_surface_change_mgr(struct weston_surface *surface,
3160 const int x, const int y, const int width, const int height)
3163 struct uifw_win_surface *usurf;
3165 uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)",
3166 (int)surface, x, y, width, height);
3168 usurf = find_uifw_win_surface_by_ws(surface);
3170 uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)");
3174 num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
3175 usurf, x, y, width, height, 1);
3177 uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr);
3181 /*--------------------------------------------------------------------------*/
3183 * @brief win_mgr_change_surface: surface change
3185 * @param[in] surface Weston surface
3186 * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager)
3187 * @param[in] manager request from manager(0=Client,1=Manager)
3190 /*--------------------------------------------------------------------------*/
3192 win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager)
3194 struct uifw_win_surface *usurf;
3195 struct weston_surface *es;
3200 uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager);
3203 usurf = find_uifw_win_surface_by_ws(surface);
3205 uifw_trace("win_mgr_change_surface: Leave(Not Exist)");
3208 es = usurf->surface;
3210 uifw_trace("win_mgr_change_surface: Leave(No weston surface)");
3214 /* set surface size */
3215 uifw_debug("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d",
3216 (int)es->geometry.x, (int)es->geometry.y, usurf->x, usurf->y,
3217 usurf->width, usurf->height, es->geometry.width, es->geometry.height);
3218 if ((usurf->width <= 0) || (usurf->height <= 0)) {
3219 usurf->width = es->geometry.width;
3220 usurf->height = es->geometry.height;
3222 win_mgr_set_scale(usurf);
3223 if (usurf->visible) {
3224 weston_surface_set_position(usurf->surface,
3225 (float)(usurf->node_tbl->disp_x +
3226 usurf->x + usurf->xadd),
3227 (float)(usurf->node_tbl->disp_y +
3228 usurf->y + usurf->yadd));
3229 ico_window_mgr_restack_layer(usurf);
3232 weston_surface_set_position(usurf->surface, (float)(ICO_IVI_MAX_COORDINATE+1),
3233 (float)(ICO_IVI_MAX_COORDINATE+1));
3236 /* send wayland event to client */
3237 if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) &&
3238 (usurf->width > 0) && (usurf->height > 0)) {
3239 if ((usurf->width != usurf->conf_width) ||
3240 (usurf->height != usurf->conf_height)) {
3241 usurf->conf_width = usurf->width;
3242 usurf->conf_height = usurf->height;
3243 uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ",
3244 usurf->surfaceid, (int)es, usurf->width, usurf->height);
3245 ico_ivi_shell_send_configure(es,
3246 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
3247 usurf->width, usurf->height);
3251 if (usurf->visible) {
3252 x = usurf->node_tbl->disp_x + usurf->x;
3253 y = usurf->node_tbl->disp_y + usurf->y;
3256 x = ICO_IVI_MAX_COORDINATE+1;
3257 y = ICO_IVI_MAX_COORDINATE+1;
3259 /* change geometry if request from manager */
3261 if ((usurf->width != es->geometry.width) ||
3262 (usurf->height != es->geometry.height) ||
3263 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
3264 win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height);
3269 /* send manager event to HomeScreen */
3272 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
3273 usurf, usurf->x, usurf->y,
3274 usurf->width, usurf->height, 0);
3277 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
3278 usurf, (int)es->geometry.x, (int)es->geometry.y,
3279 es->geometry.width, es->geometry.height, 1);
3283 /* change geometry if request from client */
3285 if ((usurf->width != es->geometry.width) || (usurf->height != es->geometry.height) ||
3286 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
3287 win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height);
3293 uifw_trace("win_mgr_change_surface: repaint");
3294 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
3296 uifw_trace("win_mgr_change_surface: Leave(OK)");
3299 /*--------------------------------------------------------------------------*/
3301 * @brief win_mgr_surface_configure: UIFW surface configure
3303 * @param[in] usurf UIFW surface
3304 * @param[in] x X coordinate on screen
3305 * @param[in] y Y coordinate on screen
3306 * @param[in] width surface width
3307 * @param[in] height surface height
3310 /*--------------------------------------------------------------------------*/
3312 win_mgr_surface_configure(struct uifw_win_surface *usurf,
3313 int x, int y, int width, int height)
3315 struct weston_surface *es;
3317 es = usurf->surface;
3318 if ((es != NULL) && (es->buffer_ref.buffer)) {
3319 if (usurf->client_width == 0) {
3320 usurf->client_width = es->geometry.width;
3321 if (usurf->client_width == 0)
3322 usurf->client_width = weston_surface_buffer_width(es);
3324 if (usurf->client_height == 0) {
3325 usurf->client_height = es->geometry.height;
3326 if (usurf->client_height == 0)
3327 usurf->client_height = weston_surface_buffer_height(es);
3330 /* not set geometry width/height */
3331 win_mgr_set_scale(usurf);
3332 weston_surface_set_position(es, x + usurf->xadd, y + usurf->yadd);
3336 /*--------------------------------------------------------------------------*/
3338 * @brief win_mgr_shell_configure: shell surface configure
3340 * @param[in] surface Weston surface
3343 /*--------------------------------------------------------------------------*/
3345 win_mgr_shell_configure(struct weston_surface *surface)
3347 struct uifw_win_surface *usurf;
3351 uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface);
3353 /* Find UIFW surface */
3354 usurf = find_uifw_win_surface_by_ws(surface);
3356 uifw_trace("win_mgr_shell_configure: Leave(Not Exist)");
3360 usurf->client_width = surface->geometry.width;
3361 usurf->client_height = surface->geometry.height;
3362 buf_width = weston_surface_buffer_width(surface);
3363 buf_height = weston_surface_buffer_height(surface);
3364 uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d",
3366 usurf->client_width, usurf->client_height, buf_width, buf_height);
3367 if (usurf->client_width > buf_width) usurf->client_width = buf_width;
3368 if (usurf->client_height > buf_height) usurf->client_height = buf_height;
3370 /* send event to manager */
3371 win_mgr_change_surface(surface, -1, 0);
3373 uifw_trace("win_mgr_shell_configure: Leave");
3376 /*--------------------------------------------------------------------------*/
3378 * @brief win_mgr_select_surface: select surface by Bottun/Touch
3380 * @param[in] surface Weston surface
3383 /*--------------------------------------------------------------------------*/
3385 win_mgr_select_surface(struct weston_surface *surface)
3387 struct uifw_win_surface *usurf;
3389 uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface);
3392 usurf = find_uifw_win_surface_by_ws(surface);
3394 uifw_trace("win_mgr_select_surface: Leave(Not Exist)");
3397 if (usurf != _ico_win_mgr->active_pointer_usurf) {
3399 /* send active event to manager */
3400 if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
3401 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) {
3402 uifw_trace("win_mgr_select_surface: not found manager, set active");
3403 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
3404 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
3407 uifw_trace("win_mgr_select_surface: Leave(OK)");
3410 /*--------------------------------------------------------------------------*/
3412 * @brief win_mgr_set_title: set tile name to surface
3414 * @param[in] surface weston surface
3415 * @param[in] title title name
3418 /*--------------------------------------------------------------------------*/
3420 win_mgr_set_title(struct weston_surface *surface, const char *title)
3422 struct uifw_win_surface *usurf;
3424 uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title);
3426 usurf = find_uifw_win_surface_by_ws(surface);
3428 uifw_trace("win_mgr_set_title: Leave(Not Exist)");
3431 if (((usurf->width > 0) && (usurf->height > 0)) &&
3432 ((usurf->created == 0) ||
3433 (strncmp(title, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) {
3434 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
3435 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
3436 if (usurf->created == 0) {
3437 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0);
3441 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0);
3445 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
3446 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
3448 uifw_trace("win_mgr_set_title: Leave");
3451 /*--------------------------------------------------------------------------*/
3453 * @brief win_mgr_surface_move: set tile name to surface
3455 * @param[in] surface weston surface
3456 * @param[in] title title name
3459 /*--------------------------------------------------------------------------*/
3461 win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy)
3463 struct uifw_win_surface *usurf;
3465 uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy);
3467 usurf = find_uifw_win_surface_by_ws(surface);
3469 uifw_trace("win_mgr_surface_move: Leave(Not Exist)");
3472 if (usurf->visible) {
3473 *dx = usurf->node_tbl->disp_x + usurf->x;
3474 *dy = usurf->node_tbl->disp_y + usurf->y;
3477 *dx = ICO_IVI_MAX_COORDINATE+1;
3478 *dy = ICO_IVI_MAX_COORDINATE+1;
3480 uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy);
3483 /*--------------------------------------------------------------------------*/
3485 * @brief win_mgr_show_layer: shell layer visible control
3487 * @param[in] layertype shell layer type
3488 * @param[in] show show(1)/hide(0)
3489 * @param[in] data requested weston surface in show
3492 /*--------------------------------------------------------------------------*/
3494 win_mgr_show_layer(int layertype, int show, void *data)
3496 struct uifw_win_layer *el;
3497 struct uifw_win_surface *usurf;
3498 struct uifw_win_surface *inusurf = NULL;
3500 uifw_trace("win_mgr_show_layer: Enter(type=%d, show=%d, data=%08x)",
3501 layertype, show, (int)data);
3503 if (layertype != LAYER_TYPE_INPUTPANEL) {
3504 uifw_trace("win_mgr_show_layer: Leave(layertype npt InputPanel)");
3509 uifw_trace("win_mgr_show_layer: Leave(show but input surface not exist)");
3512 inusurf = find_uifw_win_surface_by_ws((struct weston_surface *)data);
3514 uifw_trace("win_mgr_show_layer: Leave(show but unknown input surface)");
3519 /* all input panel surface show/hide */
3520 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
3521 if ((el->layertype == LAYER_TYPE_CURSOR) ||
3522 (el->layertype == LAYER_TYPE_TOUCH)) continue;
3523 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
3524 if ((usurf->layertype == LAYER_TYPE_INPUTPANEL) &&
3525 (usurf->surface != NULL) && (usurf->mapped != 0) &&
3526 (usurf->surface->buffer_ref.buffer != NULL)) {
3528 if ((inusurf != NULL) && (usurf->win_layer != inusurf->win_layer)) {
3529 win_mgr_set_layer(usurf, usurf->win_layer->layer);
3531 win_mgr_change_surface(usurf->surface, -1, 1);
3533 if ((show == 0) || (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_INPUTLAYER)) {
3534 /* show input panel automatically */
3535 ico_window_mgr_set_visible(usurf, show | 2);
3538 /* send hint event to HomeScreen */
3539 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3540 usurf, show, ICO_WINDOW_MGR_RAISE_RAISE, 1, 0,0);
3545 uifw_trace("win_mgr_show_layer: Leave");
3548 /*--------------------------------------------------------------------------*/
3550 * @brief win_mgr_fullscreen: shell full screen surface control
3552 * @param[in] event control event
3553 * @param[in] surface target weston surface
3556 /*--------------------------------------------------------------------------*/
3558 win_mgr_fullscreen(int event, struct weston_surface *surface)
3560 struct uifw_win_surface *usurf;
3561 struct uifw_win_surface *tmpusurf;
3562 struct uifw_win_layer *ulayer;
3566 uifw_trace("win_mgr_fullscreen: Enter(event=%d, surface=%08x)", event, (int)surface);
3568 if (event == SHELL_FULLSCREEN_HIDEALL) {
3569 /* hide all fullscreen srface */
3570 uifw_trace("win_mgr_fullscreen: SHELL_FULLSCREEN_HIDEALL");
3572 wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) {
3573 if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue;
3574 wl_list_for_each_safe (usurf, tmpusurf, &ulayer->surface_list, ivi_layer) {
3575 if (usurf->layertype == LAYER_TYPE_FULLSCREEN) {
3576 ico_window_mgr_set_visible(usurf, 2);
3577 usurf->layertype = usurf->old_layertype;
3578 win_mgr_set_layer(usurf, usurf->old_layer->layer);
3579 win_mgr_change_surface(usurf->surface, -1, 1);
3580 /* send event to HomeScreen */
3581 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
3582 usurf, usurf->x, usurf->y,
3583 usurf->width, usurf->height, 0);
3587 uifw_trace("win_mgr_fullscreen: Leave");
3591 usurf = find_uifw_win_surface_by_ws(surface);
3593 uifw_trace("win_mgr_fullscreen: Leave(surface dose not exist)");
3598 case SHELL_FULLSCREEN_ISTOP: /* check if top surrace */
3599 if (usurf->layertype == LAYER_TYPE_FULLSCREEN) {
3600 wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) {
3601 if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue;
3602 wl_list_for_each(tmpusurf, &ulayer->surface_list, ivi_layer) {
3603 if (usurf == tmpusurf) {
3604 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP"
3605 "(fullscreen surface)", usurf->surfaceid);
3608 if (tmpusurf->layertype == LAYER_TYPE_FULLSCREEN) {
3609 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP"
3610 "(fullscreen surface but not top)", usurf->surfaceid);
3616 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP"
3617 "(not fullscreen surface)", usurf->surfaceid);
3619 case SHELL_FULLSCREEN_SET: /* change surface to full screen */
3620 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_SET", usurf->surfaceid);
3621 if (usurf->layertype != LAYER_TYPE_FULLSCREEN) {
3622 usurf->old_layertype = usurf->layertype;
3623 usurf->layertype = LAYER_TYPE_FULLSCREEN;
3624 usurf->old_layer = usurf->win_layer;
3625 /* send hint event to HomeScreen */
3626 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
3627 usurf, usurf->x, usurf->y,
3628 usurf->width, usurf->height, 1);
3631 case SHELL_FULLSCREEN_STACK: /* change surface to top of layer */
3632 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_STACK", usurf->surfaceid);
3633 if (usurf->mapped == 0) {
3634 uifw_trace("win_mgr_fullscreen: not map, change to map");
3635 width = usurf->node_tbl->disp_width;
3636 height = usurf->node_tbl->disp_height;
3639 win_mgr_map_surface(usurf->surface, &width, &height, &sx, &sy);
3641 if ((usurf->surface != NULL) && (usurf->mapped != 0) &&
3642 (usurf->surface->buffer_ref.buffer != NULL)) {
3643 /* fullscreen surface raise */
3644 win_mgr_set_raise(usurf, 1);
3647 case SHELL_FULLSCREEN_CONF: /* configure full screen surface */
3648 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_CONF", usurf->surfaceid);
3649 if (usurf->mapped == 0) {
3650 width = usurf->node_tbl->disp_width;
3651 height = usurf->node_tbl->disp_height;
3654 win_mgr_map_surface(usurf->surface, &width, &height, &sx, &sy);
3658 uifw_trace("win_mgr_fullscreen: Leave(unknown event %d)", event);
3661 uifw_trace("win_mgr_fullscreen: Leave");
3665 /*--------------------------------------------------------------------------*/
3667 * @brief win_mgr_reset_focus: reset surface focus
3669 * @param[in] usurf UIFW surface
3672 /*--------------------------------------------------------------------------*/
3674 win_mgr_reset_focus(struct uifw_win_surface *usurf)
3676 struct weston_seat *seat;
3677 struct weston_surface *surface;
3679 uifw_trace("win_mgr_reset_focus: Enter(%08x)", usurf->surfaceid);
3681 seat = container_of (_ico_win_mgr->compositor->seat_list.next, struct weston_seat, link);
3682 surface = usurf->surface;
3683 if ((seat != NULL) && (surface != NULL)) {
3684 /* reset pointer focus */
3685 if ((seat->pointer != NULL) && (seat->pointer->focus == surface)) {
3686 weston_pointer_set_focus(seat->pointer, NULL,
3687 wl_fixed_from_int(0), wl_fixed_from_int(0));
3689 /* reset touch focus */
3690 if ((seat->touch != NULL) && (seat->touch->focus == surface)) {
3691 weston_touch_set_focus(seat, NULL);
3693 /* reset keyboard focus */
3694 if ((seat->keyboard != NULL) && (seat->keyboard->focus == surface)) {
3695 weston_keyboard_set_focus(seat->keyboard, NULL);
3698 uifw_trace("win_mgr_reset_focus: Leave");
3701 /*--------------------------------------------------------------------------*/
3703 * @brief ico_window_mgr_set_visible: change surface visibility
3705 * @param[in] usurf UIFW surface
3706 * @param[in] visible bit 0: visible(=1)/unvisible(=0)
3707 * bit 1: widht anima(=1)/without anima(=0)
3710 /*--------------------------------------------------------------------------*/
3712 ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible)
3717 if ((usurf->visible == 0) ||
3718 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
3719 uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x) x/y=%d/%d",
3720 usurf->surfaceid, usurf->x, usurf->y);
3722 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
3723 usurf->width, usurf->height);
3724 if ((visible & 2) && (win_mgr_hook_animation != NULL)) {
3725 usurf->animation.pos_x = usurf->x;
3726 usurf->animation.pos_y = usurf->y;
3727 usurf->animation.pos_width = usurf->width;
3728 usurf->animation.pos_height = usurf->height;
3729 usurf->animation.no_configure = 0;
3730 retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
3732 uifw_trace("ico_window_mgr_set_visible: show animation = %d", retanima);
3734 /* change unvisible to visible, restack surface list */
3735 ico_window_mgr_restack_layer(usurf);
3739 if ((usurf->visible != 0) ||
3740 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
3742 uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)",
3746 win_mgr_reset_focus(usurf);
3748 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
3749 if ((visible & 2) && (win_mgr_hook_animation != NULL)) {
3750 usurf->animation.pos_x = usurf->x;
3751 usurf->animation.pos_y = usurf->y;
3752 usurf->animation.pos_width = usurf->width;
3753 usurf->animation.pos_height = usurf->height;
3754 usurf->animation.no_configure = 0;
3755 retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
3757 uifw_trace("ico_window_mgr_set_visible: hide animation = %d", retanima);
3758 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
3760 /* Weston surface configure */
3761 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
3762 usurf->width, usurf->height);
3767 /* Weston surface configure */
3768 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
3769 usurf->width, usurf->height);
3771 ico_window_mgr_restack_layer(usurf);
3774 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3775 usurf, usurf->visible, usurf->raise, 0, 0, 0);
3778 /*--------------------------------------------------------------------------*/
3780 * @brief win_mgr_set_raise: change surface raise/lower
3782 * @param[in] usurf UIFW surface
3783 * @param[in] raise raise(=1)/lower(0)
3786 /*--------------------------------------------------------------------------*/
3788 win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise)
3790 struct uifw_win_surface *eu;
3792 uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%x type=%d",
3793 (int)usurf, raise, (int)usurf->win_layer->layer, usurf->layertype);
3795 wl_list_remove(&usurf->ivi_layer);
3797 /* raise ... surface stack to top of layer */
3798 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
3799 /* if input panel, top of surface list */
3800 uifw_trace("win_mgr_set_raise: Raise Link to Top(InputPanel)");
3801 wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer);
3804 /* if not input panel, search not input panel */
3805 wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) {
3806 if (eu->layertype != LAYER_TYPE_INPUTPANEL) break;
3808 uifw_trace("win_mgr_set_raise: Raise Link to Top(Normal)");
3809 wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer);
3814 /* Lower ... surface stack to bottom of layer */
3815 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
3816 /* if input panel, search not input panel */
3817 uifw_trace("win_mgr_set_raise: Lower Link to Bottom(InputPanel)");
3818 wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) {
3819 if (eu->layertype != LAYER_TYPE_INPUTPANEL) break;
3821 wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer);
3824 /* if not input panel, bottom of surface list */
3825 uifw_trace("win_mgr_set_raise: Lower Link to Bottom(Normal)");
3826 wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer);
3831 /* rebild compositor surface list */
3832 if ((raise & 2) == 0) {
3833 if (usurf->visible) {
3834 ico_window_mgr_restack_layer(usurf);
3836 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3837 usurf, usurf->visible, usurf->raise, 0, 0,0);
3839 uifw_trace("win_mgr_set_raise: Leave");
3842 /*--------------------------------------------------------------------------*/
3844 * @brief win_mgr_destroy_surface: surface destroy
3846 * @param[in] surface Weston surface
3849 /*--------------------------------------------------------------------------*/
3851 win_mgr_destroy_surface(struct weston_surface *surface)
3853 struct uifw_win_surface *usurf;
3854 struct uifw_win_surface *phash;
3855 struct uifw_win_surface *bhash;
3858 usurf = find_uifw_win_surface_by_ws(surface);
3860 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
3863 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
3866 win_mgr_reset_focus(usurf);
3868 /* destory input region */
3869 if (win_mgr_hook_destory) {
3870 (*win_mgr_hook_destory)(usurf);
3874 if (&usurf->surf_map != usurf->surf_map.next) {
3875 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
3878 /* destroy active surface */
3879 if (usurf == _ico_win_mgr->active_pointer_usurf) {
3880 _ico_win_mgr->active_pointer_usurf = NULL;
3882 if (usurf == _ico_win_mgr->active_keyboard_usurf) {
3883 _ico_win_mgr->active_keyboard_usurf = NULL;
3886 /* destroy animation extenson */
3887 if (win_mgr_hook_animation) {
3888 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
3891 /* delete from layer list */
3892 wl_list_remove(&usurf->ivi_layer);
3893 ico_window_mgr_restack_layer(NULL);
3895 /* delete from cleint list */
3896 wl_list_remove(&usurf->client_link);
3898 /* delete from hash table */
3899 hash = MAKE_IDHASH(usurf->surfaceid);
3900 phash = _ico_win_mgr->idhash[hash];
3902 while ((phash) && (phash != usurf)) {
3904 phash = phash->next_idhash;
3907 bhash->next_idhash = usurf->next_idhash;
3910 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
3913 hash = MAKE_WSHASH(usurf->surface);
3914 phash = _ico_win_mgr->wshash[hash];
3916 while ((phash) && (phash != usurf)) {
3918 phash = phash->next_wshash;
3921 bhash->next_wshash = usurf->next_wshash;
3924 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
3927 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED,
3930 hash = usurf->surfaceid & SURCAFE_ID_MASK;
3931 _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16));
3934 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
3937 /*--------------------------------------------------------------------------*/
3939 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
3941 * @param[in] client client
3942 * @param[in] data user data(unused)
3943 * @param[in] version protocol version(unused)
3944 * @param[in] id client object id
3947 /*--------------------------------------------------------------------------*/
3949 bind_ico_win_mgr(struct wl_client *client,
3950 void *data, uint32_t version, uint32_t id)
3952 struct wl_resource *add_resource;
3953 struct uifw_manager *mgr;
3954 struct uifw_client *uclient;
3956 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
3958 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
3960 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
3961 _ico_win_mgr, unbind_ico_win_mgr);
3964 /* Create client management tabel */
3965 uclient = find_client_from_client(client);
3967 win_mgr_bind_client(client, NULL);
3968 uclient = find_client_from_client(client);
3972 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
3974 uifw_error("bind_ico_win_mgr: Error, No Memory");
3977 memset(mgr, 0, sizeof(struct uifw_manager));
3978 mgr->resource = add_resource;
3982 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
3984 uifw_trace("bind_ico_win_mgr: Leave");
3987 /*--------------------------------------------------------------------------*/
3989 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
3991 * @param[in] resource client resource
3994 /*--------------------------------------------------------------------------*/
3996 unbind_ico_win_mgr(struct wl_resource *resource)
3998 struct uifw_manager *mgr, *itmp;
4000 uifw_trace("unbind_ico_win_mgr: Enter");
4002 /* Remove manager from manager list */
4003 _ico_win_mgr->num_manager = 0;
4004 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
4005 if (mgr->resource == resource) {
4006 wl_list_remove(&mgr->link);
4011 _ico_win_mgr->num_manager++;
4015 uifw_trace("unbind_ico_win_mgr: Leave");
4018 /*--------------------------------------------------------------------------*/
4020 * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen)
4022 * @param[in] event event code(if -1, not send event)
4023 * @param[in] usurf UIFW surface table
4024 * @param[in] param1 parameter 1
4026 * @param[in] param5 parameter 5
4027 * @return number of managers
4028 * @retval > 0 number of managers
4029 * @retval 0 manager not exist
4031 /*--------------------------------------------------------------------------*/
4033 ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
4034 const int param1, const int param2, const int param3,
4035 const int param4, const int param5)
4038 struct uifw_manager* mgr;
4040 /* if appid not fix, check and fix appid */
4041 if ((usurf != NULL) &&
4042 (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) {
4043 win_mgr_get_client_appid(usurf->uclient);
4046 /* send created if not send created event */
4047 if ((usurf != NULL) && (usurf->created == 0) &&
4048 (((usurf->width > 0) && (usurf->height > 0)) ||
4049 ((event != ICO_WINDOW_MGR_WINDOW_CREATED) &&
4050 (event != ICO_WINDOW_MGR_WINDOW_NAME)))) {
4051 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
4053 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED"
4054 "(surf=%08x,name=%s,pid=%d,appid=%s,type=%x)", (int)mgr->resource,
4055 usurf->surfaceid, usurf->winname, usurf->uclient->pid,
4056 usurf->uclient->appid, usurf->layertype);
4057 ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid,
4058 usurf->winname, usurf->uclient->pid,
4059 usurf->uclient->appid,
4060 usurf->layertype << 12);
4066 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
4071 case ICO_WINDOW_MGR_WINDOW_CREATED:
4072 /* Do nothing anymore because sended window create event */
4075 case ICO_WINDOW_MGR_WINDOW_NAME:
4076 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME"
4077 "(surf=%08x,name=%s)", (int)mgr->resource,
4078 usurf->surfaceid, usurf->winname);
4079 ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid,
4083 case ICO_WINDOW_MGR_WINDOW_DESTROYED:
4084 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED"
4085 "(surf=%08x)", (int)mgr->resource, usurf->surfaceid);
4086 ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid);
4089 case ICO_WINDOW_MGR_WINDOW_VISIBLE:
4090 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE"
4091 "(surf=%08x,vis=%d,raise=%d,hint=%d)",
4092 (int)mgr->resource, usurf->surfaceid, param1, param2, param3);
4093 ico_window_mgr_send_window_visible(mgr->resource,
4094 usurf->surfaceid, param1, param2, param3);
4097 case ICO_WINDOW_MGR_WINDOW_CONFIGURE:
4098 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE"
4099 "(surf=%08x,app=%s,node=%x,type=%x,layer=%x,"
4100 "x/y=%d/%d,w/h=%d/%d,hint=%d)",
4101 (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid,
4102 usurf->node_tbl->node, usurf->layertype,
4103 usurf->win_layer->layer, param1, param2, param3, param4, param5);
4104 ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid,
4105 usurf->node_tbl->node,
4106 usurf->layertype << 12,
4107 usurf->win_layer->layer,
4108 param1, param2, param3, param4, param5);
4111 case ICO_WINDOW_MGR_WINDOW_ACTIVE:
4112 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE"
4113 "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid,
4115 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
4119 case ICO_WINDOW_MGR_LAYER_VISIBLE:
4120 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE"
4121 "(layer=%x,visivle=%d)", (int)mgr->resource, param1, param2);
4122 ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2);
4126 uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event);
4134 /*--------------------------------------------------------------------------*/
4136 * @brief win_mgr_set_scale: set surface transform scale
4138 * @param[in] usurf UIFW surface
4139 * @return chagne display
4140 * @retval =1 change display
4141 * @retval =0 no change
4143 /*--------------------------------------------------------------------------*/
4145 win_mgr_set_scale(struct uifw_win_surface *usurf)
4147 struct weston_surface *es;
4152 es = usurf->surface;
4153 if ((es != NULL) && (es->buffer_ref.buffer)) {
4154 if (usurf->client_width == 0) usurf->client_width = es->geometry.width;
4155 if (usurf->client_height == 0) usurf->client_height = es->geometry.height;
4156 if ((usurf->client_width > 0) && (usurf->client_height > 0)) {
4157 scalex = (float)usurf->width / (float)usurf->client_width;
4158 scaley = (float)usurf->height / (float)usurf->client_height;
4164 uifw_debug("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)",
4165 usurf->surfaceid, scalex, usurf->width, usurf->client_width,
4166 scaley, usurf->height, usurf->client_height);
4169 if ((ico_ivi_debugflag() & ICO_IVI_DEBUG_FIXED_ASPECT) ||
4170 (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT)) {
4171 if (scalex > scaley) {
4173 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) {
4174 usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex);
4175 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) {
4180 else if (scalex < scaley) {
4182 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) {
4183 usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley);
4184 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) {
4189 uifw_trace("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d",
4190 usurf->surfaceid, usurf->xadd, usurf->yadd);
4192 if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) {
4193 usurf->scalex = scalex;
4194 usurf->scaley = scaley;
4195 if ((scalex != 1.0f) || (scaley != 1.0f)) {
4196 weston_matrix_init(&usurf->transform.matrix);
4197 weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f);
4198 uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform);
4199 if (usurf->set_transform == 0) {
4200 usurf->set_transform = 1;
4201 wl_list_init(&usurf->transform.link);
4202 wl_list_insert(&es->geometry.transformation_list, &usurf->transform.link);
4205 else if (usurf->set_transform != 0) {
4206 uifw_trace("win_mgr_set_scale: reset transform");
4207 usurf->set_transform = 0;
4208 wl_list_remove(&usurf->transform.link);
4210 weston_surface_geometry_dirty(es);
4211 weston_surface_update_transform(es);
4212 weston_surface_damage_below(es);
4213 weston_surface_damage(es);
4220 /*--------------------------------------------------------------------------*/
4222 * @brief ico_window_mgr_get_uclient: get UIFW client table
4224 * @param[in] appid application Id
4225 * @return UIFW client table
4226 * @retval !=NULL success(UIFW client table address)
4227 * @retval = NULL error(appid not exist)
4229 /*--------------------------------------------------------------------------*/
4230 WL_EXPORT struct uifw_client *
4231 ico_window_mgr_get_uclient(const char *appid)
4233 struct uifw_client *uclient;
4235 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
4236 if (strcmp(uclient->appid, appid) == 0) {
4243 /*--------------------------------------------------------------------------*/
4245 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
4247 * @param[in] target surface window name and application Id(winname@appid)
4248 * @return UIFW surface table
4249 * @retval !=NULL success(UIFW surface table address)
4250 * @retval = NULL error(appid or winname not exist)
4252 /*--------------------------------------------------------------------------*/
4253 WL_EXPORT struct uifw_win_surface *
4254 ico_window_mgr_get_client_usurf(const char *target)
4256 struct uifw_client *uclient;
4257 struct uifw_win_surface *usurf;
4259 char winname[ICO_IVI_WINNAME_LENGTH];
4260 char appid[ICO_IVI_APPID_LENGTH];
4262 /* get window name and application id */
4264 for (i = 0; target[i]; i++) {
4265 if (target[i] == '@') {
4266 if (target[i+1] != '@') break;
4269 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
4270 winname[j++] = target[i];
4274 if (target[i] == '@') {
4282 for ( ; target[i]; i++) {
4283 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
4284 if (j < (ICO_IVI_APPID_LENGTH-1)) {
4285 appid[j++] = target[i];
4289 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
4290 target, appid, winname);
4292 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
4293 if (strcmp(uclient->appid, appid) == 0) {
4294 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
4295 if ((winname[0] == 0) ||
4296 (strcmp(winname, usurf->winname) == 0)) {
4305 /*--------------------------------------------------------------------------*/
4307 * @brief ico_window_mgr_is_visible: check surface visible
4309 * @param[in] usurf UIFW surface
4310 * @return visibility
4311 * @retval =1 visible
4312 * @retval =0 not visible
4313 * @retval =-1 surface visible but layer not vlsible
4314 * @retval =-2 surface visible but lower
4316 /*--------------------------------------------------------------------------*/
4318 ico_window_mgr_is_visible(struct uifw_win_surface *usurf)
4320 if ((usurf->visible == 0) || (usurf->surface == NULL) ||
4321 (usurf->mapped == 0) || (usurf->surface->buffer_ref.buffer == NULL)) {
4324 if (usurf->win_layer->visible == 0) {
4330 /*--------------------------------------------------------------------------*/
4332 * @brief ico_window_mgr_active_surface: set active surface
4334 * @param[in] surface Weston surface
4337 /*--------------------------------------------------------------------------*/
4339 ico_window_mgr_active_surface(struct weston_surface *surface)
4341 struct uifw_win_surface *usurf;
4344 usurf = find_uifw_win_surface_by_ws(surface);
4346 uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", (int)surface);
4347 uifw_trace("ico_window_mgr_active_surface: Leave(Not Exist)");
4350 uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", usurf->surfaceid);
4352 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
4353 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
4355 /* set weston active surface */
4356 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
4357 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
4358 /* send active event to manager */
4359 (void) ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
4360 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0);
4362 uifw_trace("ico_window_mgr_active_surface: Leave(OK)");
4365 /*--------------------------------------------------------------------------*/
4367 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
4369 * @param[in] hook_animation hook routine
4372 /*--------------------------------------------------------------------------*/
4374 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
4376 win_mgr_hook_animation = hook_animation;
4379 /*--------------------------------------------------------------------------*/
4381 * @brief ico_window_mgr_set_hook_visible: set input region hook routine
4383 * @param[in] hook_visible hook routine
4386 /*--------------------------------------------------------------------------*/
4388 ico_window_mgr_set_hook_visible(void (*hook_visible)(struct uifw_win_surface *usurf))
4390 win_mgr_hook_visible = hook_visible;
4393 /*--------------------------------------------------------------------------*/
4395 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
4397 * @param[in] hook_destroy hook routine
4400 /*--------------------------------------------------------------------------*/
4402 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
4404 win_mgr_hook_destory = hook_destroy;
4407 /*--------------------------------------------------------------------------*/
4409 * @brief module_init: initialize ico_window_mgr
4410 * this function called from ico_pluign_loader
4412 * @param[in] es weston compositor
4413 * @param[in] argc number of arguments(unused)
4414 * @param[in] argv argument list(unused)
4419 /*--------------------------------------------------------------------------*/
4421 module_init(struct weston_compositor *ec, int *argc, char *argv[])
4426 struct weston_output *output;
4427 struct weston_config_section *section;
4428 char *displayno = NULL;
4431 struct wl_event_loop *loop;
4433 uifw_info("ico_window_mgr: Enter(module_init)");
4435 /* get ivi debug level */
4436 section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL);
4438 weston_config_section_get_int(section, "flag", &_ico_ivi_debug_flag, 0);
4439 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
4442 /* get display number */
4443 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
4445 weston_config_section_get_string(section, "displayno", &displayno, NULL);
4446 weston_config_section_get_int(section, "inputpanel",
4447 &_ico_ivi_inputpanel_display, 0);
4451 section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL);
4453 weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1);
4454 weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0);
4455 weston_config_section_get_int(section, "touch", &_ico_ivi_touch_layer, 101);
4456 weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102);
4457 weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 103);
4458 weston_config_section_get_string(section, "inputpaneldeco", &wrkstrp, NULL);
4460 p = strtok(wrkstrp, ";,");
4462 _ico_ivi_inputdeco_mag = strtol(p, (char **)0, 0);
4463 p = strtok(NULL, ";,");
4465 _ico_ivi_inputdeco_diff = strtol(p, (char **)0, 0);
4471 if (_ico_ivi_inputdeco_mag < 20) _ico_ivi_inputdeco_mag = 100;
4473 /* get animation default */
4474 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
4476 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
4477 weston_config_section_get_string(section, "inputpanel",
4478 &_ico_ivi_inputpanel_animation, NULL);
4479 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500);
4480 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30);
4481 if (_ico_ivi_animation_name) {
4482 p = strtok(_ico_ivi_animation_name, ";,");
4484 p = strtok(NULL, ";.");
4486 _ico_ivi_animation_time = strtol(p, (char **)0, 0);
4487 p = strtok(NULL, ";.");
4489 _ico_ivi_animation_fps = strtol(p, (char **)0, 0);
4494 if (_ico_ivi_inputpanel_animation) {
4495 p = strtok(_ico_ivi_inputpanel_animation, ";,");
4497 p = strtok(NULL, ",;");
4499 _ico_ivi_inputpanel_anima_time = strtol(p, (char **)0, 0);
4504 if (_ico_ivi_animation_name == NULL)
4505 _ico_ivi_animation_name = (char *)"fade";
4506 if (_ico_ivi_inputpanel_animation == NULL)
4507 _ico_ivi_inputpanel_animation = (char *)"fade";
4508 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500;
4509 if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30;
4510 if (_ico_ivi_inputpanel_anima_time < 100)
4511 _ico_ivi_inputpanel_anima_time = _ico_ivi_animation_time;
4513 /* create ico_window_mgr management table */
4514 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
4515 if (_ico_win_mgr == NULL) {
4516 uifw_error("ico_window_mgr: malloc failed");
4520 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
4521 _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8);
4522 if (! _ico_win_mgr->surfaceid_map) {
4523 uifw_error("ico_window_mgr: malloc failed");
4526 memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8);
4528 _ico_win_mgr->compositor = ec;
4530 _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS;
4531 _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS;
4533 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
4534 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
4535 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
4536 uifw_error("ico_window_mgr: Error(wl_global_create)");
4540 wl_list_init(&_ico_win_mgr->client_list);
4541 wl_list_init(&_ico_win_mgr->manager_list);
4542 wl_list_init(&_ico_win_mgr->ivi_layer_list);
4543 wl_list_init(&_ico_win_mgr->map_list);
4545 _ico_win_mgr->free_maptable = NULL;
4547 /* create display list */
4548 if (displayno != NULL) {
4555 wl_list_for_each (output, &ec->output_list, link) {
4556 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
4557 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurrace;
4558 wl_list_insert(output->animation_list.prev,
4559 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
4561 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
4563 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
4565 wl_list_for_each (output, &ec->output_list, link) {
4568 idx = strtol(p, (char **)0, 0);
4569 uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx);
4571 if ((idx < 0) || (idx >= _ico_num_nodes)) {
4578 if (_ico_node_table[idx].node) {
4579 for (idx = 0; idx < _ico_num_nodes; idx++) {
4580 if (_ico_node_table[idx].node == 0) break;
4582 if (idx >= _ico_num_nodes) {
4583 uifw_error("ico_window_mgr: number of display overflow");
4587 _ico_node_table[idx].node = idx + 0x100;
4588 _ico_node_table[idx].displayno = i;
4589 _ico_node_table[idx].output = output;
4590 _ico_node_table[idx].disp_x = output->x;
4591 _ico_node_table[idx].disp_y = output->y;
4592 _ico_node_table[idx].disp_width = output->width;
4593 _ico_node_table[idx].disp_height = output->height;
4595 if (i >= _ico_num_nodes) break;
4598 for (i = 0; i < _ico_num_nodes; i++) {
4599 _ico_node_table[i].node &= 0x0ff;
4600 uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
4601 i, _ico_node_table[i].displayno,
4602 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
4603 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
4605 if (displayno) free(displayno);
4607 if (_ico_ivi_inputpanel_display >= _ico_num_nodes) {
4608 _ico_ivi_inputpanel_display = 0;
4610 uifw_info("ico_window_mgr: inputpanel_display=%d", _ico_ivi_inputpanel_display);
4612 /* set default display to ico_ivi_shell */
4613 ivi_shell_set_default_display(_ico_node_table[_ico_ivi_inputpanel_display].output);
4615 /* my node Id ... this version fixed 0 */
4616 nodeId = ico_ivi_get_mynode();
4618 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
4619 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
4620 nodeId, _ico_win_mgr->surface_head);
4622 /* get seat for touch down counter check */
4623 touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link);
4624 _ico_win_mgr->waittime = 1000;
4625 loop = wl_display_get_event_loop(ec->wl_display);
4626 _ico_win_mgr->wait_mapevent =
4627 wl_event_loop_add_timer(loop, win_mgr_timer_mapsurrace, NULL);
4628 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000);
4630 /* Hook to IVI-Shell */
4631 ico_ivi_shell_hook_bind(win_mgr_bind_client);
4632 ico_ivi_shell_hook_unbind(win_mgr_unbind_client);
4633 ico_ivi_shell_hook_create(win_mgr_register_surface);
4634 ico_ivi_shell_hook_destroy(win_mgr_destroy_surface);
4635 ico_ivi_shell_hook_map(win_mgr_map_surface);
4636 ico_ivi_shell_hook_configure(win_mgr_shell_configure);
4637 ico_ivi_shell_hook_select(win_mgr_select_surface);
4638 ico_ivi_shell_hook_title(win_mgr_set_title);
4639 ico_ivi_shell_hook_move(win_mgr_surface_move);
4640 ico_ivi_shell_hook_show_layer(win_mgr_show_layer);
4641 ico_ivi_shell_hook_fullscreen(win_mgr_fullscreen);
4643 uifw_info("ico_window_mgr: animation name=%s/%s time=%d/%d fps=%d",
4644 _ico_ivi_animation_name, _ico_ivi_inputpanel_animation,
4645 _ico_ivi_animation_time, _ico_ivi_inputpanel_anima_time,
4646 _ico_ivi_animation_fps);
4647 uifw_info("ico_window_mgr: input panel mag=%d%% diff=%d",
4648 _ico_ivi_inputdeco_mag,_ico_ivi_inputdeco_diff);
4649 uifw_info("ico_window_mgr: layer default=%d background=%d",
4650 _ico_ivi_default_layer, _ico_ivi_background_layer);
4651 uifw_info("ico_window_mgr: layer touch=%d cursor=%d startup=%d",
4652 _ico_ivi_touch_layer, _ico_ivi_cursor_layer, _ico_ivi_startup_layer);
4653 uifw_info("ico_window_mgr: option flag=0x%04x log level=%d",
4654 _ico_ivi_debug_flag, _ico_ivi_debug_level);
4656 uifw_info("ico_window_mgr: Leave(module_init)");