2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Multi Window Manager (Weston(Wayland) PlugIn)
37 #include <linux/input.h>
43 #include <sys/types.h>
48 #include <wayland-server.h>
54 #include <GLES2/gl2.h>
55 #include <GLES2/gl2ext.h>
56 #include <GL/internal/dri_interface.h>
58 #include <weston/compositor.h>
59 #include <libdrm/intel_bufmgr.h>
61 /* detail debug log */
62 #define UIFW_DETAIL_OUT 0 /* 1=detail debug log/0=no detail log */
64 #include "ico_ivi_common_private.h"
65 #include "ico_ivi_shell_private.h"
66 #include "ico_window_mgr_private.h"
67 #include "ico_window_mgr.h"
68 #include "desktop-shell-server-protocol.h"
69 #include "ico_window_mgr-server-protocol.h"
72 #define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */
73 #define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */
74 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId bit mask pattern */
75 #define UIFW_HASH 64 /* Hash value (2's compliment) */
77 /* Internal fixed value */
78 #define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */
79 /* show/hide animation with position */
80 #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000
83 #define ICO_GPUTYPE_NOACCELERATION 0 /* Do not use GPU-dependent acceleration*/
84 #define ICO_GPUTYPE_INTEL_SANDYBRIDGE 1 /* Intel Sandybridge Mobile */
86 /* Code for Intel Sandybridge Mobile GPU dependent acceleration */
88 /* wl_drm_buffer (inport from mesa-9.1.3 & mesa-9.2.1/ */
89 /* src/egl/wayland/wayland-drm/wayland-drm.h) */
90 struct uifw_drm_buffer {
91 struct wl_resource *resource;
92 void *drm; /* struct wl_drm */
93 int32_t width, height;
95 const void *driver_format;
101 /* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h */
102 /* mesa-9.2.1/src/mesa/drivers/dri/i915/intel_regions.h */
103 /* mesa-9.2.1/src/mesa/drivers/dri/i965/intel_regions.h) */
104 struct uifw_intel_region { /* struct intel_region for mesa 9.2.1 */
105 void *bo; /**< buffer manager's buffer */
106 uint32_t refcount; /**< Reference count for region */
107 uint32_t cpp; /**< bytes per pixel */
108 uint32_t width; /**< in pixels */
109 uint32_t height; /**< in pixels */
110 uint32_t pitch; /**< in bytes */
111 uint32_t tiling; /**< Which tiling mode the region is in */
112 uint32_t name; /**< Global name for the bo */
115 struct uifw_dri_image { /* struct __DRIimageRec */
116 struct uifw_intel_region *region;
123 void *planar_format; /* intel_image_format */
128 bool has_depthstencil; /* i965 only */
132 /* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c, */
133 /* weston-1.3.1/src/gl-renderer.c */
139 struct uifw_gl_surface_state { /* struct gl_surface_state */
141 struct gl_shader *shader;
145 int needs_full_upload;
146 pixman_region32_t texture_damage;
148 void *images[3]; /* EGLImageKHR */
152 struct weston_buffer_reference buffer_ref;
153 enum buffer_type buffer_type;
154 int pitch; /* in pixels */
155 int height; /* in pixels */
156 int y_inverted; /* add weston 1.3.x */
159 /* API access control configuration */
160 struct ico_api_permit {
161 struct ico_api_permit *next; /* access control configuration list */
162 struct ico_uifw_api_permit permit; /* permission */
165 /* Multi Windiw Manager */
167 struct weston_compositor *compositor; /* Weston compositor */
168 void *shell; /* shell(ico_ivi_shell) table address */
169 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
171 struct wl_list client_list; /* Clients */
172 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
173 int num_manager; /* Number of managers */
175 struct wl_list ivi_layer_list; /* Layer management table list */
176 struct uifw_win_layer *touch_layer; /* layer table for touch panel layer */
178 struct wl_list map_list; /* surface map list */
179 struct uifw_surface_map *free_maptable; /* free maped surface table list */
180 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
181 /* animation for map check */
182 struct wl_event_source *wait_mapevent; /* map event send wait timer */
184 struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */
185 struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */
187 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
188 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
190 uint32_t surfaceid_count; /* Number of surface id */
191 uint32_t surfaceid_max; /* Maximum number of surface id */
192 uint16_t *surfaceid_map; /* SurfaceId assign bit map */
194 struct ico_api_permit *access_config; /* access control configuration list */
195 uint32_t default_access; /* default permit APIs */
197 char shell_init; /* shell initialize flag */
198 char res[3]; /* (unused) */
201 /* access control api table */
202 static const struct {
203 char name[24]; /* API name */
204 uint32_t api; /* API flag */
205 } access_api_table[] = {
206 { "declare_manager", ICO_UIFW_WINDOW_MGR_DECLARE_MANAGER },
207 { "set_window_layer", ICO_UIFW_WINDOW_MGR_SET_WINDOW_LAYER },
208 { "set_positionsize", ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE },
209 { "set_visible", ICO_UIFW_WINDOW_MGR_SET_VISIBLE },
210 { "set_animation", ICO_UIFW_WINDOW_MGR_SET_ANIMATION },
211 { "set_attributes", ICO_UIFW_WINDOW_MGR_SET_ATTRIBUTES },
212 { "visible_animation", ICO_UIFW_WINDOW_MGR_VISIBLE_ANIMATION },
213 { "set_active", ICO_UIFW_WINDOW_MGR_SET_ACTIVE },
214 { "set_layer_visible", ICO_UIFW_WINDOW_MGR_SET_LAYER_VISIBLE },
215 { "get_surfaces", ICO_UIFW_WINDOW_MGR_GET_SURFACES },
216 { "set_map_buffer", ICO_UIFW_WINDOW_MGR_SET_MAP_BUFFER },
217 { "map_surface", ICO_UIFW_WINDOW_MGR_MAP_SURFACE },
218 { "unmap_surface", ICO_UIFW_WINDOW_MGR_UNMAP_SURFACE },
220 { "add_input_app", ICO_UIFW_INPUT_MGR_CONTROL_ADD_INPUT_APP },
221 { "del_input_app", ICO_UIFW_INPUT_MGR_CONTROL_DEL_INPUT_APP },
222 { "send_input_event", ICO_UIFW_INPUT_MGR_CONTROL_SEND_INPUT_EVENT },
223 { "set_input_region", ICO_UIFW_EXINPUT_SET_INPUT_REGION },
224 { "unset_input_region", ICO_UIFW_EXINPUT_UNSET_INPUT_REGION },
225 { "confiure_input", ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_INPUT },
226 { "confiure_code", ICO_UIFW_INPUT_MGR_DEVICE_CONFIGURE_CODE },
227 { "input_event", ICO_UIFW_INPUT_MGR_DEVICE_INPUT_EVENT },
232 /* Internal macros */
234 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
236 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
238 /* function prototype */
239 /* get surface table from weston surface*/
240 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
241 struct weston_surface *wsurf);
242 /* assign new surface id */
243 static uint32_t generate_id(void);
244 /* bind shell client */
245 static void win_mgr_bind_client(struct wl_client *client, void *shell);
246 /* unind shell client */
247 static void win_mgr_unbind_client(struct wl_client *client);
248 #if 0 /* work around: Walk through child processes until app ID is found */
250 static pid_t win_mgr_get_ppid(pid_t pid);
251 #endif /* work around: Walk through child processes until app ID is found */
252 /* get appid from pid */
253 static void win_mgr_get_client_appid(struct uifw_client *uclient);
254 /* create new surface */
255 static void win_mgr_register_surface(int layertype, struct weston_surface *surface,
256 struct wl_client *client,
257 struct shell_surface *shsurf);
258 /* surface destroy */
259 static void win_mgr_destroy_surface(struct weston_surface *surface);
260 /* map new surface */
261 static void win_mgr_surface_map(struct weston_surface *surface, int32_t *width,
262 int32_t *height, int32_t *sx, int32_t *sy);
263 /* send surface change event to manager */
264 static void win_mgr_change_surface(struct weston_surface *surface,
265 const int to, const int manager);
266 /* window manager surface configure */
267 static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
268 int x, int y, int width, int height);
269 /* shell surface configure */
270 static void win_mgr_shell_configure(struct weston_surface *surface);
272 static void win_mgr_select_surface(struct weston_surface *surface);
273 /* surface set title */
274 static char *win_mgr_set_title(struct weston_surface *surface, const char *title);
275 /* surface move request from shell */
276 static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy);
277 /* shell layer visible control */
278 static void win_mgr_show_layer(int layertype, int show, void *data);
279 /* shell full screen surface control */
280 static int win_mgr_fullscreen(int event, struct weston_surface *surface);
282 static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise);
283 /* surface change from manager */
284 static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x,
285 const int y, const int width, const int height);
286 /* reset surface focus */
287 static void win_mgr_reset_focus(struct uifw_win_surface *usurf);
288 /* create new layer */
289 static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf,
290 const uint32_t layer, const int layertype);
291 /* set surface layer */
292 static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer);
293 /* set active surface */
294 static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target);
296 /* declare manager */
297 static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource,
299 /* set window layer */
300 static void uifw_set_window_layer(struct wl_client *client,
301 struct wl_resource *resource,
302 uint32_t surfaceid, uint32_t layer);
303 /* set surface size and position */
304 static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
305 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
306 int32_t width, int32_t height, int32_t flags);
307 /* show/hide and raise/lower surface */
308 static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
309 uint32_t surfaceid, int32_t visible, int32_t raise,
311 /* set surface animation */
312 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
313 uint32_t surfaceid, int32_t type,
314 const char *animation, int32_t time);
315 /* set surface attributes */
316 static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
317 uint32_t surfaceid, uint32_t attributes);
318 /* surface visibility control with animation*/
319 static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
320 uint32_t surfaceid, int32_t visible,
321 int32_t x, int32_t y, int32_t width, int32_t height);
322 /* set active surface (form HomeScreen) */
323 static void uifw_set_active(struct wl_client *client, struct wl_resource *resource,
324 uint32_t surfaceid, int32_t active);
325 /* layer visibility control */
326 static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
327 uint32_t layer, int32_t visible);
328 /* get application surfaces */
329 static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
330 const char *appid, int32_t pid);
331 /* check and change all mapped surface */
332 static void win_mgr_check_mapsurface(struct weston_animation *animation,
333 struct weston_output *output, uint32_t msecs);
334 /* check timer of mapped surface */
335 static int win_mgr_timer_mapsurface(void *data);
336 /* check and change mapped surface */
337 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event,
340 static void uifw_set_map_buffer(struct wl_client *client, struct wl_resource *resource,
341 const char *shmname, uint32_t bufsize, uint32_t bufnum);
342 /* map surface to system application */
343 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
344 uint32_t surfaceid, int32_t framerate);
346 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
349 static void bind_ico_win_mgr(struct wl_client *client,
350 void *data, uint32_t version, uint32_t id);
352 static void unbind_ico_win_mgr(struct wl_resource *resource);
353 /* send event to manager */
354 static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
355 const int param1, const int param2, const int param3,
356 const int param4, const int param5);
357 /* set surface transform */
358 static int win_mgr_set_scale(struct uifw_win_surface *usurf);
359 /* convert animation name to Id value */
360 static int ico_get_animation_name(const char *animation);
361 /* read surface pixels */
362 static int ico_read_surface_pixels(struct weston_surface *es, pixman_format_code_t format,
363 void *pixels, int x, int y, int width, int height);
364 /* hook for animation */
365 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
366 /* hook for input region */
367 static void (*win_mgr_hook_change)(struct uifw_win_surface *usurf) = NULL;
368 static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL;
369 static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf,
370 int32_t x, int32_t y, int32_t width,
371 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
372 int32_t cursor_x, int32_t cursor_y,
373 int32_t cursor_width, int32_t cursor_height,
374 uint32_t attr) = NULL;
377 /* Multi Window Manager interface */
378 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
379 uifw_declare_manager,
380 uifw_set_window_layer,
381 uifw_set_positionsize,
385 uifw_visible_animation,
387 uifw_set_layer_visible,
395 /* GPU driver name */
396 static const struct _ico_gputype_table {
397 int gpu_type; /* GPU type code */
398 char *gpu_name; /* GPU driver name */
399 } ico_window_mgr_gpu_type[] = {
400 { ICO_GPUTYPE_INTEL_SANDYBRIDGE, "Mesa DRI Intel(R) Sandybridge Mobile" },
404 /* plugin common value(without ico_plugin_loader) */
405 static int _ico_ivi_option_flag = 0; /* option flags */
406 static int _ico_ivi_debug_level = 3; /* debug Level */
407 static char *_ico_ivi_animation_name = NULL; /* default animation name */
408 static int _ico_ivi_animation_time = 500; /* default animation time */
409 static int _ico_ivi_animation_fps = 30; /* animation frame rate */
410 static char *_ico_ivi_inputpanel_animation = NULL; /* default animation name for input panel*/
411 static int _ico_ivi_inputpanel_anima_time = 0; /* default animation time for input panel*/
413 static int _ico_ivi_inputpanel_display = 0; /* input panel display number */
414 static int _ico_ivi_inputdeco_mag = 100; /* input panel magnification rate(%)*/
415 static int _ico_ivi_inputdeco_diff = 0; /* input panel difference from the bottom*/
417 static int _ico_ivi_background_layer = 0; /* background layer */
418 static int _ico_ivi_default_layer = 1; /* deafult layer id at surface create*/
419 static int _ico_ivi_touch_layer = 101; /* touch panel layer id */
420 static int _ico_ivi_cursor_layer = 102; /* cursor layer id */
421 static int _ico_ivi_startup_layer = 109; /* deafult layer id at system startup*/
423 static int _ico_ivi_gpu_type = 0; /* GPU type for get EGL buffer */
424 static int _ico_ivi_map_framerate_gpu = 30; /* framerate of map surface for GPU*/
425 static int _ico_ivi_map_framerate_shm = 2; /* framerate of map surface for shm buffer*/
426 static int _ico_ivi_map_framerate_pixel = 5; /* framerate of map surface for ReadPixels*/
428 /* static management table */
429 static struct ico_win_mgr *_ico_win_mgr = NULL;
430 static int _ico_num_nodes = 0;
431 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
432 static struct weston_seat *touch_check_seat = NULL;
435 /*--------------------------------------------------------------------------*/
437 * @brief ico_ivi_optionflag: get option flags
440 * @return option flags
442 /*--------------------------------------------------------------------------*/
444 ico_ivi_optionflag(void)
446 return _ico_ivi_option_flag;
449 /*--------------------------------------------------------------------------*/
451 * @brief ico_ivi_debuglevel: answer debug output level.
454 * @return debug output level
455 * @retval 0 No debug output
456 * @retval 1 Only error output
457 * @retval 2 Error and Warning output
458 * @retval 3 Error, Warning and information output
459 * @retval 4 Error, Warning, information and Debug Trace output
460 * @retval 5 All output with debug write
462 /*--------------------------------------------------------------------------*/
464 ico_ivi_debuglevel(void)
466 return (_ico_ivi_debug_level & 0x0ffff);
469 /*--------------------------------------------------------------------------*/
471 * @brief ico_ivi_debugflag: get debug flags
474 * @return debug flags
476 /*--------------------------------------------------------------------------*/
478 ico_ivi_debugflag(void)
480 return ((_ico_ivi_debug_level >> 16) & 0x0ffff);
483 /*--------------------------------------------------------------------------*/
485 * @brief ico_ivi_default_animation_name: get default animation name
488 * @return Default animation name
490 /*--------------------------------------------------------------------------*/
491 WL_EXPORT const char *
492 ico_ivi_default_animation_name(void)
494 return _ico_ivi_animation_name;
497 /*--------------------------------------------------------------------------*/
499 * @brief ico_ivi_default_animation_time: get default animation time
502 * @return Default animation time(miri sec)
504 /*--------------------------------------------------------------------------*/
506 ico_ivi_default_animation_time(void)
508 return _ico_ivi_animation_time;
511 /*--------------------------------------------------------------------------*/
513 * @brief ico_ivi_default_animation_fps: get default animation frame rate
516 * @return Default animation frame rate(frames/sec)
518 /*--------------------------------------------------------------------------*/
520 ico_ivi_default_animation_fps(void)
522 return _ico_ivi_animation_fps;
525 /*--------------------------------------------------------------------------*/
527 * @brief ico_ivi_get_mynode: Get my NodeId
530 * @return NodeId of my node
532 /*--------------------------------------------------------------------------*/
534 ico_ivi_get_mynode(void)
536 /* Reference Platform 0.90 only support 1 ECU */
540 /*--------------------------------------------------------------------------*/
542 * @brief ico_ivi_surface_buffer_width: get surface buffer width
544 * @param[in] es weston surface
545 * @return buffer width(if surface has no buffer, return 0)
547 /*--------------------------------------------------------------------------*/
549 ico_ivi_surface_buffer_width(struct weston_surface *es)
553 if (! es->buffer_ref.buffer) {
556 if (es->buffer_viewport.viewport_set) {
557 return es->buffer_viewport.dst_width;
559 switch (es->buffer_viewport.transform) {
560 case WL_OUTPUT_TRANSFORM_90:
561 case WL_OUTPUT_TRANSFORM_270:
562 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
563 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
564 v = es->buffer_ref.buffer->height;
567 v = es->buffer_ref.buffer->width;
570 return (v / es->buffer_viewport.scale);
573 /*--------------------------------------------------------------------------*/
575 * @brief ico_ivi_surface_buffer_height: get surface buffer height
577 * @param[in] es weston surface
578 * @return buffer height(if surface has no buffer, return 0)
580 /*--------------------------------------------------------------------------*/
582 ico_ivi_surface_buffer_height(struct weston_surface *es)
586 if (! es->buffer_ref.buffer) {
589 if (es->buffer_viewport.viewport_set) {
590 return es->buffer_viewport.dst_height;
592 switch (es->buffer_viewport.transform) {
593 case WL_OUTPUT_TRANSFORM_90:
594 case WL_OUTPUT_TRANSFORM_270:
595 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
596 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
597 v = es->buffer_ref.buffer->width;
600 v = es->buffer_ref.buffer->height;
603 return (v / es->buffer_viewport.scale);
606 /*--------------------------------------------------------------------------*/
608 * @brief ico_ivi_surface_buffer_size: get surface buffer size
610 * @param[in] es weston surface
611 * @param[out] width buffer width
612 * @param[out] height buffer height
615 /*--------------------------------------------------------------------------*/
617 ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height)
619 if (! es->buffer_ref.buffer) {
623 else if (es->buffer_viewport.viewport_set) {
624 *width = es->buffer_viewport.dst_width;
625 *height = es->buffer_viewport.dst_height;
628 switch (es->buffer_viewport.transform) {
629 case WL_OUTPUT_TRANSFORM_90:
630 case WL_OUTPUT_TRANSFORM_270:
631 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
632 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
633 *width = es->buffer_ref.buffer->height;
634 *height = es->buffer_ref.buffer->width;
637 *width = es->buffer_ref.buffer->width;
638 *height = es->buffer_ref.buffer->height;
641 *width = *width / es->buffer_viewport.scale;
642 *height = *height / es->buffer_viewport.scale;
646 /*--------------------------------------------------------------------------*/
648 * @brief ico_ivi_surface_buffer_size: get surface buffer size
650 * @param[in] es weston surface
651 * @param[out] width buffer width
652 * @param[out] height buffer height
655 /*--------------------------------------------------------------------------*/
656 WL_EXPORT struct weston_view *
657 ico_ivi_get_primary_view(struct uifw_win_surface *usurf)
659 struct weston_view *ev;
661 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
662 ev = ico_input_panel_get_view((void *)(usurf->shsurf));
665 ev = (*_ico_win_mgr->compositor->shell_interface.get_primary_view)
666 (NULL, usurf->shsurf);
669 uifw_error("ico_ivi_get_primary_view: usurf=%08x(%x) surface=%08x has no view",
670 (int)usurf, usurf->surfaceid, (int)usurf->surface);
673 uifw_debug("ico_ivi_get_primary_view: %08x[%d] view=%08x view->surf=%08x",
674 usurf->surfaceid, usurf->layertype, (int)ev, (int)ev->surface);
679 /*--------------------------------------------------------------------------*/
681 * @brief ico_window_mgr_set_weston_surface: set weston surface
683 * @param[in] usurf UIFW surface
684 * @param[in] x X coordinate on screen
685 * @param[in] y Y coordinate on screen
686 * @param[in] width width
687 * @param[in] height height
690 /*--------------------------------------------------------------------------*/
692 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
693 int x, int y, int width, int height)
695 struct weston_surface *es = usurf->surface;
696 struct weston_view *ev;
697 int buf_width, buf_height;
699 if ((es == NULL) || (usurf->shsurf == NULL)) {
700 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
705 if (es->buffer_ref.buffer != NULL) {
706 ico_ivi_surface_buffer_size(es, &buf_width, &buf_height);
707 if ((width <= 0) || (height <= 0)) {
709 usurf->width = buf_width;
711 usurf->height = buf_height;
713 if ((usurf->width > buf_width) && (usurf->scalex <= 1.0f)) {
715 x += (usurf->width - buf_width)/2;
717 if ((usurf->height > buf_height) && (usurf->scaley <= 1.0f)) {
719 y += (usurf->height - buf_height)/2;
721 if (usurf->visible) {
722 x += usurf->node_tbl->disp_x;
723 y += usurf->node_tbl->disp_y;
726 x = ICO_IVI_MAX_COORDINATE+1;
727 y = ICO_IVI_MAX_COORDINATE+1;
729 ev = ico_ivi_get_primary_view(usurf);
731 (((int)ev->geometry.x != x) || ((int)ev->geometry.y != y) ||
732 (es->width != width) || (es->height != height))) {
733 weston_view_damage_below(ev);
734 win_mgr_surface_configure(usurf, x, y, width, height);
736 weston_surface_damage(es);
737 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
741 /*--------------------------------------------------------------------------*/
743 * @brief ico_window_mgr_set_weston_surface: set weston surface
745 * @param[in] usurf UIFW surface
746 * @param[in] x X coordinate on screen
747 * @param[in] y Y coordinate on screen
748 * @param[in] width width
749 * @param[in] height height
752 /*--------------------------------------------------------------------------*/
754 ico_window_mgr_change_surface(struct uifw_win_surface *usurf,
755 const int to, const int manager)
757 uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)",
758 usurf->surfaceid, to, manager);
759 win_mgr_change_surface(usurf->surface, to, manager);
760 uifw_trace("ico_window_mgr_change_surface: Leave");
763 /*--------------------------------------------------------------------------*/
765 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
767 * @param[in] surfaceid UIFW surface id
768 * @return UIFW surface table address
769 * @retval !=NULL success(surface table address)
770 * @retval NULL error(surface id dose not exist)
772 /*--------------------------------------------------------------------------*/
773 WL_EXPORT struct uifw_win_surface *
774 ico_window_mgr_get_usurf(const uint32_t surfaceid)
776 struct uifw_win_surface *usurf;
778 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
781 if (usurf->surfaceid == surfaceid) {
784 usurf = usurf->next_idhash;
786 uifw_trace("ico_window_mgr_get_usurf: NULL");
790 /*--------------------------------------------------------------------------*/
792 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
794 * @param[in] surfaceid UIFW surface id
795 * @param[in] client Wayland client
796 * @return UIFW surface table address
797 * @retval !=NULL success(surface table address)
798 * @retval NULL error(surface id or client dose not exist)
800 /*--------------------------------------------------------------------------*/
801 WL_EXPORT struct uifw_win_surface *
802 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
804 struct uifw_win_surface *usurf;
805 struct uifw_client *uclient;
807 if (surfaceid == ICO_WINDOW_MGR_V_MAINSURFACE) {
808 uclient = ico_window_mgr_find_uclient(client);
810 if (&uclient->surface_link != uclient->surface_link.next) {
811 usurf = container_of (uclient->surface_link.next,
812 struct uifw_win_surface, client_link);
823 usurf = ico_window_mgr_get_usurf(surfaceid);
828 /*--------------------------------------------------------------------------*/
830 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
832 * @param[in] wsurf Weston surface
833 * @return UIFW surface table address
834 * @retval !=NULL success(surface table address)
835 * @retval NULL error(surface dose not exist)
837 /*--------------------------------------------------------------------------*/
838 static struct uifw_win_surface *
839 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
841 struct uifw_win_surface *usurf;
843 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
846 if (usurf->surface == wsurf) {
849 usurf = usurf->next_wshash;
851 uifw_trace("find_uifw_win_surface_by_ws: NULL");
855 /*--------------------------------------------------------------------------*/
857 * @brief ico_window_mgr_find_uclient: find UIFW client by wayland client
859 * @param[in] client Wayland client
860 * @return UIFW client table address
861 * @retval !=NULL success(client table address)
862 * @retval NULL error(client dose not exist)
864 /*--------------------------------------------------------------------------*/
865 WL_EXPORT struct uifw_client*
866 ico_window_mgr_find_uclient(struct wl_client *client)
868 struct uifw_client *uclient;
870 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
871 if (uclient->client == client) {
875 uifw_trace("ico_window_mgr_find_uclient: client.%08x is NULL", (int)client);
879 /*--------------------------------------------------------------------------*/
881 * @brief ico_window_mgr_get_appid: find application id by wayland client
883 * @param[in] client Wayland client
884 * @return application id
885 * @retval !=NULL success(application id)
886 * @retval NULL error(client dose not exist)
888 /*--------------------------------------------------------------------------*/
890 ico_window_mgr_get_appid(struct wl_client* client)
892 struct uifw_client *uclient;
894 uclient = ico_window_mgr_find_uclient(client);
899 return uclient->appid;
902 /*--------------------------------------------------------------------------*/
904 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
906 * @param[in] displayno display number
907 * @param[out] x relative X coordinate
908 * @param[out] y relative Y coordinate
911 /*--------------------------------------------------------------------------*/
913 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
915 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
918 *x = _ico_node_table[displayno].disp_x;
919 *y = _ico_node_table[displayno].disp_y;
922 /*--------------------------------------------------------------------------*/
924 * @brief generate_id: generate uniq id for UIFW surface id
927 * @return uniq id for UIFW surface id
929 /*--------------------------------------------------------------------------*/
940 _ico_win_mgr->surfaceid_count ++;
942 /* serach free id from bitmap */
943 for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) {
944 if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) {
945 _ico_win_mgr->surfaceid_count = 0;
947 if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) {
948 /* find free id from bitmap */
949 map = 1 << (_ico_win_mgr->surfaceid_count % 16);
950 for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) {
951 if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map)
953 _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map;
954 _ico_win_mgr->surfaceid_count
955 = (_ico_win_mgr->surfaceid_count/16)*16 + i;
957 surfaceId = (_ico_win_mgr->surfaceid_count + 1)
958 | _ico_win_mgr->surface_head;
959 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
965 _ico_win_mgr->surfaceid_count += 16;
968 /* no free id in bitmap, extend bitmap */
969 if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) {
970 /* too many surfaces, system error */
971 uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort",
972 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
973 fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n",
974 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
978 new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8);
979 memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8);
980 memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8);
981 _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max;
982 new_map[_ico_win_mgr->surfaceid_count/16] |= 1;
983 _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS;
984 free(_ico_win_mgr->surfaceid_map);
985 _ico_win_mgr->surfaceid_map = new_map;
987 uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)",
988 _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max);
989 surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head;
991 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
995 /*--------------------------------------------------------------------------*/
997 * @brief win_mgr_bind_client: desktop_shell from client
999 * @param[in] client Wayland client
1000 * @param[in] shell shell(ico_ivi_shell) table address
1003 /*--------------------------------------------------------------------------*/
1005 win_mgr_bind_client(struct wl_client *client, void *shell)
1007 struct uifw_client *uclient;
1012 struct ico_api_permit *accp;
1013 char subject[ICO_UIFW_MAX_SUBJECT_NAME];
1017 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
1018 (int)client, (int)shell);
1020 /* save shell table address */
1022 _ico_win_mgr->shell = shell;
1026 uclient = ico_window_mgr_find_uclient(client);
1028 /* client not exist, create client management table */
1029 uifw_trace("win_mgr_bind_client: Create Client");
1030 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
1032 uifw_error("win_mgr_bind_client: Error, No Memory");
1035 memset(uclient, 0, sizeof(struct uifw_client));
1036 uclient->client = client;
1037 uclient->api_access_control = _ico_win_mgr->default_access;
1038 wl_list_init(&uclient->surface_link);
1044 wl_client_get_credentials(client, &pid, &uid, &gid);
1045 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
1046 (int)client, (int)pid, (int)uid, (int)gid);
1048 uclient->pid = (int)pid;
1049 /* get applicationId from AppCore(AUL) */
1050 win_mgr_get_client_appid(uclient);
1052 /* get SMACK subject label */
1053 if (! _ico_win_mgr->access_config) {
1054 /* no access control, permit all APIs */
1055 uclient->api_access_control = 0xffffffff;
1058 sprintf(subject, "/proc/%d/attr/current", (int)pid);
1059 fd = open(subject, O_RDONLY);
1061 uifw_warn("win_mgr_bind_client: pid=%d(%s) not exist current",
1062 pid, uclient->appid);
1065 i = read(fd, subject, sizeof(subject)-1);
1068 accp = _ico_win_mgr->access_config;
1070 if (strcmp(subject, accp->permit.subject) == 0) {
1071 uclient->api_access_control |= accp->permit.api_permit;
1079 uifw_trace("win_mgr_bind_client: pid=%d(%s) current read error<%d>",
1080 pid, uclient->appid, i);
1082 /* SMACK not active */
1083 uclient->api_access_control = 0xffffffff;
1089 uifw_trace("win_mgr_bind_client: pid=%d(%s) access_control=%08x",
1090 pid, uclient->appid, uclient->api_access_control);
1092 if (newclient > 0) {
1093 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
1097 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
1099 uifw_trace("win_mgr_bind_client: Leave");
1102 /*--------------------------------------------------------------------------*/
1104 * @brief win_mgr_unbind_client: unbind desktop_shell from client
1106 * @param[in] client Wayland client
1109 /*--------------------------------------------------------------------------*/
1111 win_mgr_unbind_client(struct wl_client *client)
1113 struct uifw_client *uclient;
1115 uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client);
1117 uclient = ico_window_mgr_find_uclient(client);
1119 /* Client exist, Destory client management table */
1120 wl_list_remove(&uclient->link);
1123 uifw_trace("win_mgr_unbind_client: Leave");
1126 #if 0 /* work around: Walk through child processes until app ID is found */
1127 /*--------------------------------------------------------------------------*/
1129 * @brief win_mgr_get_ppid: Get parent process ID.
1131 * Similar to getppid(), except that this implementation accepts an
1132 * arbitrary process ID.
1134 * @param[in] pid Process ID of child process
1135 * @return parent process ID on success, -1 on failure
1137 /*--------------------------------------------------------------------------*/
1139 win_mgr_get_ppid(pid_t pid)
1142 char procpath[PATH_MAX] = { 0 };
1144 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid);
1146 /* We better have read permissions! */
1147 int const fd = open(procpath, O_RDONLY);
1152 char buffer[1024] = { 0 };
1154 ssize_t const size = read(fd, buffer, sizeof(buffer));
1160 /* Find line containing the parent process ID. */
1161 char const * const ppid_line = strstr(buffer, "PPid");
1163 if (ppid_line != NULL)
1164 sscanf(ppid_line, "PPid: %d", &ppid);
1168 #endif /* work around: Walk through child processes until app ID is found */
1170 /*--------------------------------------------------------------------------*/
1172 * @brief win_mgr_get_client_appid: get applicationId from pid
1174 * @param[in] uclient UIFW client management table
1177 /*--------------------------------------------------------------------------*/
1179 win_mgr_get_client_appid(struct uifw_client *uclient)
1181 int status = AUL_R_ERROR;
1183 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
1185 #if 0 /* work around: Walk through child processes until app ID is found */
1187 * Walk the parent process chain until we find a parent process
1192 for (pid = uclient->pid;
1193 pid > 1 && status != AUL_R_OK;
1194 pid = win_mgr_get_ppid(pid)) {
1196 status = aul_app_get_appid_bypid(pid,
1198 ICO_IVI_APPID_LENGTH);
1200 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
1201 "pid=%d appid=<%s>", status, pid, uclient->appid);
1204 * Walk the child process chain as well since app ID was not yet found
1206 if (status != AUL_R_OK) {
1215 dr = opendir("/proc/");
1218 wl_client_get_credentials(uclient->client, &tpid, &uid, &gid);
1220 while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) {
1222 char fullpath[PATH_MAX] = { 0 };
1226 snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name);
1228 if (stat(fullpath, &ps) == -1) {
1232 /* find pid dirs for this user (uid) only */
1233 if (ps.st_uid != uid)
1236 pid = atoi(de->d_name);
1238 /* check if it's a valid child */
1239 if (pid < uclient->pid)
1242 /* scan up to pid to find if a chain exists */
1243 for (tmppid = pid; tmppid > uclient->pid;) {
1244 tmppid = win_mgr_get_ppid(tmppid);
1245 if (tmppid == uclient->pid)
1250 status = aul_app_get_appid_bypid(pid, uclient->appid,
1251 ICO_IVI_APPID_LENGTH);
1253 uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid "
1254 "ret=%d pid=%d appid=<%s>", status, pid,
1259 #else /* work around: Walk through child processes until app ID is found */
1260 status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
1261 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
1262 "pid=%d appid=<%s>", status, uclient->pid, uclient->appid);
1263 #endif /* work around: Walk through child processes until app ID is found */
1265 if (uclient->appid[0] != 0) {
1266 /* OK, end of get appid */
1267 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
1270 /* client does not exist in AppCore, search Linux process table */
1278 uclient->fixed_appid ++;
1279 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
1280 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
1281 fd = open(procpath, O_RDONLY);
1283 size = read(fd, procpath, sizeof(procpath));
1284 for (; size > 0; size--) {
1285 if (procpath[size-1]) break;
1288 /* get program base name */
1290 for (j = 0; j < size; j++) {
1291 if (procpath[j] == 0) break;
1292 if (procpath[j] == '/') i = j + 1;
1295 for (; i < size; i++) {
1296 uclient->appid[j] = procpath[i];
1297 if ((uclient->appid[j] == 0) ||
1298 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
1301 /* search application number in apprication start option */
1302 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
1303 for (; i < size; i++) {
1304 if ((procpath[i] == 0) &&
1305 (procpath[i+1] == '@')) {
1306 strncpy(&uclient->appid[j], &procpath[i+1],
1307 ICO_IVI_APPID_LENGTH - j - 2);
1314 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
1315 if (uclient->appid[i] != ' ') break;
1317 uclient->appid[i+1] = 0;
1318 if (uclient->appid[0]) {
1319 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
1320 "Process table(%d)",
1321 uclient->pid, uclient->appid, uclient->fixed_appid );
1324 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
1326 sprintf(uclient->appid, "?%d?", uclient->pid);
1331 /*--------------------------------------------------------------------------*/
1333 * @brief ico_get_animation_name: convert animation name to Id value
1335 * @param[in] animation animation name
1336 * @return animation Id value
1338 /*--------------------------------------------------------------------------*/
1340 ico_get_animation_name(const char *animation)
1342 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1344 if (strcasecmp(animation, "none") == 0) {
1345 return ICO_WINDOW_MGR_ANIMATION_NONE;
1348 if (win_mgr_hook_animation) {
1349 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
1352 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
1357 /*--------------------------------------------------------------------------*/
1359 * @brief ico_read_surface_pixels: read surface pixel image
1360 * this function inport from weston 1.3.1(by Tizen)
1362 * @param[in] es weston surface
1363 * @param[in] format pixel format
1364 * @param[out] pixels pixel read buffer
1365 * @param[in] x X coordinate
1366 * @param[in] y Y coordinate
1367 * @param[in] width width
1368 * @param[in] height height
1369 * @return success(=0) or error(-1)
1371 /*--------------------------------------------------------------------------*/
1373 ico_read_surface_pixels(struct weston_surface *es, pixman_format_code_t format,
1374 void *pixels, int x, int y, int width, int height)
1376 struct weston_buffer *buffer = es->buffer_ref.buffer;
1377 struct uifw_gl_surface_state *gs = es->renderer_state;
1380 struct wl_shm_buffer *shm_buffer = NULL;
1384 case PIXMAN_a8r8g8b8:
1385 gl_format = GL_BGRA_EXT;
1387 case PIXMAN_a8b8g8r8:
1388 gl_format = GL_RGBA;
1395 shm_buffer = wl_shm_buffer_get(buffer->resource);
1398 size = buffer->width * 4 * buffer->height;
1399 memcpy(pixels, wl_shm_buffer_get_data(shm_buffer), size);
1400 } else if (gs != NULL) {
1401 glGenFramebuffers(1, &fbo);
1402 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1403 glFramebufferTexture2D(GL_FRAMEBUFFER,
1404 GL_COLOR_ATTACHMENT0,
1406 gs->textures[0], 0);
1408 glReadPixels(x, y, width, height,
1409 gl_format, GL_UNSIGNED_BYTE, pixels);
1411 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1412 glDeleteFramebuffers(1, &fbo);
1420 /*--------------------------------------------------------------------------*/
1422 * @brief win_mgr_register_surface: create UIFW surface
1424 * @param[in] layertype surface layer type
1425 * @param[in] surface Weston surface
1426 * @param[in] client Wayland client
1427 * @param[in] shsurf shell surface
1430 /*--------------------------------------------------------------------------*/
1432 win_mgr_register_surface(int layertype, struct weston_surface *surface,
1433 struct wl_client *client, struct shell_surface *shsurf)
1435 struct uifw_win_surface *usurf;
1436 struct uifw_win_surface *phash;
1437 struct uifw_win_surface *bhash;
1441 uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,type=%x,shsurf=%08x)",
1442 (int)surface, (int)client, layertype, (int)shsurf);
1444 /* check new surface */
1445 if (find_uifw_win_surface_by_ws(surface)) {
1446 /* surface exist, NOP */
1447 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
1451 /* set default color and shader */
1452 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
1454 /* create UIFW surface management table */
1455 usurf = malloc(sizeof(struct uifw_win_surface));
1457 uifw_error("win_mgr_register_surface: No Memory");
1461 memset(usurf, 0, sizeof(struct uifw_win_surface));
1463 usurf->surfaceid = generate_id();
1464 usurf->surface = surface;
1465 usurf->shsurf = shsurf;
1466 usurf->layertype = layertype;
1467 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
1468 wl_list_init(&usurf->ivi_layer);
1469 wl_list_init(&usurf->client_link);
1470 wl_list_init(&usurf->animation.animation.link);
1471 wl_list_init(&usurf->surf_map);
1472 wl_list_init(&usurf->input_region);
1473 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
1474 usurf->animation.hide_time = ico_ivi_default_animation_time();
1475 usurf->animation.show_anima = usurf->animation.hide_anima;
1476 usurf->animation.show_time = usurf->animation.hide_time;
1477 usurf->animation.move_anima = usurf->animation.hide_anima;
1478 usurf->animation.move_time = usurf->animation.hide_time;
1479 usurf->animation.resize_anima = usurf->animation.hide_anima;
1480 usurf->animation.resize_time = usurf->animation.hide_time;
1481 if (layertype == LAYER_TYPE_INPUTPANEL) {
1482 usurf->attributes = ICO_WINDOW_MGR_ATTR_FIXED_ASPECT;
1483 usurf->animation.hide_anima = ico_get_animation_name(_ico_ivi_inputpanel_animation);
1484 usurf->animation.hide_time = _ico_ivi_inputpanel_anima_time;
1485 usurf->animation.show_anima = usurf->animation.hide_anima;
1486 usurf->animation.show_time = usurf->animation.hide_time;
1488 if ((layertype != LAYER_TYPE_INPUTPANEL) &&
1489 ((_ico_win_mgr->num_manager <= 0) ||
1490 (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE))) {
1491 uifw_trace("win_mgr_register_surface: No Manager, Force visible");
1495 uifw_trace("win_mgr_register_surface: Manager exist, Not visible");
1500 usurf->uclient = ico_window_mgr_find_uclient(client);
1501 if (! usurf->uclient) {
1502 /* client not exist, create client management table */
1503 uifw_trace("win_mgr_register_surface: Create Client");
1504 win_mgr_bind_client(client, NULL);
1505 usurf->uclient = ico_window_mgr_find_uclient(client);
1506 if (! usurf->uclient) {
1507 uifw_error("win_mgr_register_surface: No Memory");
1511 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1513 /* make surface id hash table */
1514 hash = MAKE_IDHASH(usurf->surfaceid);
1515 phash = _ico_win_mgr->idhash[hash];
1519 phash = phash->next_idhash;
1522 bhash->next_idhash = usurf;
1525 _ico_win_mgr->idhash[hash] = usurf;
1528 /* make weston surface hash table */
1529 hash = MAKE_WSHASH(usurf->surface);
1530 phash = _ico_win_mgr->wshash[hash];
1534 phash = phash->next_wshash;
1537 bhash->next_wshash = usurf;
1540 _ico_win_mgr->wshash[hash] = usurf;
1543 /* set default layer id */
1544 switch (layertype) {
1545 case LAYER_TYPE_BACKGROUND:
1546 layer = _ico_ivi_background_layer;
1548 case LAYER_TYPE_TOUCH:
1549 layer = _ico_ivi_touch_layer;
1551 case LAYER_TYPE_CURSOR:
1552 layer = _ico_ivi_cursor_layer;
1555 if ((_ico_win_mgr->num_manager > 0) ||
1556 (layertype == LAYER_TYPE_INPUTPANEL)) {
1557 layer = _ico_ivi_default_layer;
1560 layer = _ico_ivi_startup_layer;
1564 win_mgr_set_layer(usurf, layer);
1566 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1569 /*--------------------------------------------------------------------------*/
1571 * @brief win_mgr_surface_map: map surface to display
1573 * @param[in] surface Weston surface
1574 * @param[in] width surface width
1575 * @param[in] height surface height
1576 * @param[in] sx X coordinate on screen
1577 * @param[in] sy Y coordinate on screen
1580 /*--------------------------------------------------------------------------*/
1582 win_mgr_surface_map(struct weston_surface *surface, int32_t *width, int32_t *height,
1583 int32_t *sx, int32_t *sy)
1585 struct uifw_win_surface *usurf;
1587 uifw_trace("win_mgr_surface_map: Enter(%08x, x/y=%d/%d w/h=%d/%d)",
1588 (int)surface, *sx, *sy, *width, *height);
1590 usurf = find_uifw_win_surface_by_ws(surface);
1592 if ((usurf != NULL) && (usurf->mapped == 0)) {
1593 uifw_trace("win_mgr_surface_map: surf=%08x w/h=%d/%d vis=%d",
1594 usurf->surfaceid, usurf->width, usurf->height, usurf->visible);
1595 if ((usurf->width > 0) && (usurf->height > 0)) {
1596 uifw_trace("win_mgr_surface_map: HomeScreen registed, PositionSize"
1597 "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d",
1598 usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height,
1600 *width = usurf->width;
1601 *height = usurf->height;
1602 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1603 usurf->node_tbl->disp_y + usurf->y,
1604 usurf->width, usurf->height);
1607 uifw_trace("win_mgr_surface_map: HomeScreen not regist Surface, "
1608 "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)",
1609 usurf->surfaceid, *sx, *sy, *width, *height);
1610 usurf->width = *width;
1611 usurf->height = *height;
1614 if (usurf->x < 0) usurf->x = 0;
1615 if (usurf->y < 0) usurf->y = 0;
1616 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
1618 usurf->node_tbl = &_ico_node_table[_ico_ivi_inputpanel_display];
1620 usurf->width = (float)usurf->surface->width
1621 * (float)_ico_ivi_inputdeco_mag / 100.0f;
1622 usurf->height = (float)usurf->surface->height
1623 * (float)_ico_ivi_inputdeco_mag / 100.0f;
1625 if ((usurf->width > (usurf->node_tbl->disp_width - 16)) ||
1626 (usurf->height > (usurf->node_tbl->disp_height - 16))) {
1627 usurf->x = (usurf->node_tbl->disp_width
1628 - usurf->surface->width) / 2;
1629 usurf->y = usurf->node_tbl->disp_height
1630 - usurf->surface->height - 16
1631 - _ico_ivi_inputdeco_diff;
1632 if (usurf->x < 0) usurf->x = 0;
1633 if (usurf->y < 0) usurf->y = 0;
1636 win_mgr_set_scale(usurf);
1638 usurf->x = (usurf->node_tbl->disp_width
1639 - usurf->width) / 2;
1640 usurf->y = usurf->node_tbl->disp_height
1641 - usurf->height - 16 - _ico_ivi_inputdeco_diff;
1642 if (usurf->x < 0) usurf->x = 0;
1643 if (usurf->y < 0) usurf->y = 0;
1645 uifw_trace("win_mgr_surface_map: set position %08x %d.%d/%d",
1646 usurf->surfaceid, usurf->node_tbl->node, usurf->x, usurf->y);
1648 if (((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE) == 0) &&
1649 (_ico_win_mgr->num_manager > 0)) {
1650 /* HomeScreen exist, coodinate set by HomeScreen */
1651 if (usurf->visible) {
1652 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1653 usurf->node_tbl->disp_y + usurf->y,
1654 usurf->width, usurf->height);
1657 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1658 ICO_IVI_MAX_COORDINATE+1,
1659 usurf->width, usurf->height);
1661 uifw_trace("win_mgr_surface_map: Change size/position x/y=%d/%d w/h=%d/%d",
1662 usurf->x, usurf->y, surface->width, surface->height);
1664 else if (usurf->layertype != LAYER_TYPE_INPUTPANEL) {
1665 uifw_trace("win_mgr_surface_map: No HomeScreen, chaneg to Visible");
1666 ico_window_mgr_set_visible(usurf, 1);
1669 if (usurf->visible) {
1670 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1671 usurf->node_tbl->disp_y + usurf->y,
1672 usurf->width, usurf->height);
1675 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1676 ICO_IVI_MAX_COORDINATE+1,
1677 usurf->width, usurf->height);
1682 if (usurf->visible) {
1683 ico_window_mgr_restack_layer(NULL);
1685 uifw_trace("win_mgr_surface_map: Leave");
1688 uifw_trace("win_mgr_surface_map: Leave(No UIFW Surface or mapped)");
1692 /*--------------------------------------------------------------------------*/
1694 * @brief ico_window_mgr_restack_layer: restack surface list
1696 * @param[in] usurf UIFW surface (if NULL, no surface)
1699 /*--------------------------------------------------------------------------*/
1701 ico_window_mgr_restack_layer(struct uifw_win_surface *usurf)
1703 struct uifw_win_surface *eu;
1704 struct uifw_win_layer *el;
1705 int32_t buf_width, buf_height;
1707 struct weston_layer *wlayer;
1708 struct weston_view *view, *viewtmp;
1709 int num_visible = 0;
1712 /* make compositor surface list */
1713 wlayer = ico_ivi_shell_weston_layer();
1715 uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x) layer=%08x",
1716 (int)usurf, (int)wlayer);
1718 /* remove all surfaces in panel_layer */
1719 wl_list_for_each_safe (view, viewtmp, &wlayer->view_list, layer_link) {
1720 wl_list_remove(&view->layer_link);
1721 wl_list_init(&view->layer_link);
1723 wl_list_init(&wlayer->view_list);
1725 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1726 wl_list_for_each (eu, &el->surface_list, ivi_layer) {
1727 if (eu->surface == NULL) continue;
1729 /* target only panel or unknown layer */
1730 layertype = ico_ivi_shell_layertype(eu->surface);
1731 if ((layertype != LAYER_TYPE_PANEL) && (layertype != LAYER_TYPE_INPUTPANEL) &&
1732 (layertype != LAYER_TYPE_FULLSCREEN) && (layertype != LAYER_TYPE_CURSOR) &&
1733 (layertype != LAYER_TYPE_UNKNOWN)) {
1737 if (eu->mapped != 0) {
1738 if ((el->visible == FALSE) || (eu->visible == FALSE)) {
1739 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1740 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1742 else if (eu->surface->buffer_ref.buffer) {
1743 ico_ivi_surface_buffer_size(eu->surface, &buf_width, &buf_height);
1744 if ((eu->width > buf_width) && (eu->scalex <= 1.0f)) {
1745 new_x = (float)(eu->x +
1746 (eu->width - eu->surface->width)/2);
1749 new_x = (float)eu->x;
1751 if ((eu->height > buf_height) && (eu->scaley <= 1.0f)) {
1752 new_y = (float) (eu->y +
1753 (eu->height - eu->surface->height)/2);
1756 new_y = (float)eu->y;
1758 new_x += eu->node_tbl->disp_x + eu->xadd;
1759 new_y += eu->node_tbl->disp_y + eu->yadd;
1763 new_x = (float)(eu->x + eu->node_tbl->disp_x + eu->xadd);
1764 new_y = (float)(eu->y + eu->node_tbl->disp_y + eu->yadd);
1766 wl_list_for_each (view, &eu->surface->views, surface_link) {
1767 wl_list_remove(&view->layer_link);
1768 wl_list_init(&view->layer_link);
1769 wl_list_insert(wlayer->view_list.prev, &view->layer_link);
1770 if ((eu->restrain_configure == 0) &&
1771 ((new_x != view->geometry.x) ||
1772 (new_y != view->geometry.y))) {
1773 weston_view_damage_below(view);
1774 weston_view_set_position(view, (float)new_x, (float)new_y);
1775 weston_surface_damage(eu->surface);
1777 uifw_debug("ico_window_mgr_restack_layer:%3d(%d).%08x(%08x:%d) "
1778 "x/y=%d/%d w/h=%d/%d[%x]",
1779 el->layer, el->visible, eu->surfaceid, (int)eu->surface,
1780 eu->visible, (int)view->geometry.x,
1781 (int)view->geometry.y, eu->surface->width,
1782 eu->surface->height, eu->layertype);
1788 /* damage(redraw) target surfacem if target exist */
1790 weston_surface_damage(usurf->surface);
1793 /* composit and draw screen(plane) */
1794 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
1796 if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) &&
1797 (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) {
1798 /* start shell fade */
1799 _ico_win_mgr->shell_init = 1;
1800 ico_ivi_shell_startup(_ico_win_mgr->shell);
1802 uifw_trace("ico_window_mgr_restack_layer: Leave");
1805 /*--------------------------------------------------------------------------*/
1807 * @brief ico_window_mgr_touch_layer: touch panel layer control
1809 * @param[in] omit omit touch layer flag (TRUE=omit/FALSE=not omit)
1812 /*--------------------------------------------------------------------------*/
1814 ico_window_mgr_touch_layer(int omit)
1816 struct uifw_win_surface *eu;
1817 struct weston_view *ev;
1819 /* check current touch layer mode */
1820 if ((_ico_win_mgr->touch_layer == NULL) ||
1821 ((omit != FALSE) && (_ico_win_mgr->touch_layer->visible == FALSE))) {
1822 uifw_trace("ico_window_mgr_touch_layer: touch layer not exist or hide");
1826 wl_list_for_each (eu, &_ico_win_mgr->touch_layer->surface_list, ivi_layer) {
1827 if ((eu->surface == NULL) || (eu->mapped == 0)) continue;
1828 ev = ico_ivi_get_primary_view(eu);
1829 if (omit != FALSE) {
1830 eu->animation.pos_x = (int)ev->geometry.x;
1831 eu->animation.pos_y = (int)ev->geometry.y;
1832 ev->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1);
1833 ev->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1);
1836 ev->geometry.x = (float)eu->animation.pos_x;
1837 ev->geometry.y = (float)eu->animation.pos_y;
1842 /*--------------------------------------------------------------------------*/
1844 * @brief win_mgr_create_layer: create new layer
1846 * @param[in] usurf UIFW surface, (if need)
1847 * @param[in] layer layer id
1848 * @param[in] layertype layer type if need
1850 * @retval != NULL success(layer management table)
1851 * @retval == NULL error(No Memory)
1853 /*--------------------------------------------------------------------------*/
1854 static struct uifw_win_layer *
1855 win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer,
1856 const int layertype)
1858 struct uifw_win_layer *el;
1859 struct uifw_win_layer *new_el;
1861 new_el = malloc(sizeof(struct uifw_win_layer));
1863 uifw_trace("win_mgr_create_layer: Leave(No Memory)");
1867 memset(new_el, 0, sizeof(struct uifw_win_layer));
1868 new_el->layer = layer;
1869 if ((int)layer == _ico_ivi_background_layer ) {
1870 new_el->layertype = LAYER_TYPE_BACKGROUND;
1872 else if ((int)layer == _ico_ivi_touch_layer ) {
1873 new_el->layertype = LAYER_TYPE_TOUCH;
1874 _ico_win_mgr->touch_layer = new_el;
1876 else if ((int)layer == _ico_ivi_cursor_layer ) {
1877 new_el->layertype = LAYER_TYPE_CURSOR;
1880 new_el->layertype = LAYER_TYPE_PANEL;
1882 new_el->visible = TRUE;
1883 wl_list_init(&new_el->surface_list);
1884 wl_list_init(&new_el->link);
1886 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1887 if (layer >= el->layer) break;
1889 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1890 wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link);
1893 wl_list_insert(el->link.prev, &new_el->link);
1897 wl_list_remove(&usurf->ivi_layer);
1898 wl_list_insert(&new_el->surface_list, &usurf->ivi_layer);
1899 usurf->win_layer = new_el;
1900 if (new_el->layertype == LAYER_TYPE_CURSOR) {
1901 usurf->layertype = LAYER_TYPE_CURSOR;
1907 /*--------------------------------------------------------------------------*/
1909 * @brief win_mgr_set_layer: set(or change) surface layer
1911 * @param[in] usurf UIFW surface
1912 * @param[in] layer layer id
1915 /*--------------------------------------------------------------------------*/
1917 win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1919 struct uifw_win_layer *el;
1920 struct uifw_win_layer *new_el;
1923 uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)",
1924 usurf->surfaceid, (int)usurf->surface, layer);
1926 /* check if same layer */
1927 if (usurf->win_layer != NULL) {
1928 oldlayer = usurf->win_layer->layer ;
1929 if (oldlayer == layer) {
1930 uifw_trace("win_mgr_set_layer: Leave(Same Layer)");
1938 /* search existing layer */
1939 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1940 if (el->layer == layer) break;
1943 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1944 /* layer not exist, create new layer */
1945 uifw_trace("win_mgr_set_layer: New Layer %d(%d)", layer, usurf->layertype);
1946 new_el = win_mgr_create_layer(usurf, layer, usurf->layertype);
1948 uifw_trace("win_mgr_set_layer: Leave(No Memory)");
1953 uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer);
1954 usurf->win_layer = el;
1955 win_mgr_set_raise(usurf, 3);
1958 /* set input region */
1959 if (layer == (uint32_t)_ico_ivi_cursor_layer) {
1960 uifw_trace("win_mgr_set_layer: %08x cursor Change to cursor layer (%d,%d)-(%d,%d)",
1962 usurf->surface->input.extents.x1, usurf->surface->input.extents.y1,
1963 usurf->surface->input.extents.x2, usurf->surface->input.extents.y2);
1964 pixman_region32_fini(&usurf->surface->pending.input);
1965 pixman_region32_init_rect(&usurf->surface->pending.input,
1966 ICO_IVI_MAX_COORDINATE + 1, ICO_IVI_MAX_COORDINATE + 1,
1969 else if (oldlayer == (uint32_t)_ico_ivi_cursor_layer) {
1970 uifw_trace("win_mgr_set_layer: %08x cursor Change to normal layer (%d,%d)-(%d,%d)",
1972 usurf->surface->input.extents.x1, usurf->surface->input.extents.y1,
1973 usurf->surface->input.extents.x2, usurf->surface->input.extents.y2);
1974 pixman_region32_fini(&usurf->surface->pending.input);
1975 pixman_region32_init_rect(&usurf->surface->pending.input,
1976 INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
1979 /* rebild compositor surface list */
1980 if (usurf->visible) {
1981 ico_window_mgr_restack_layer(usurf);
1983 uifw_trace("win_mgr_set_layer: Leave");
1986 /*--------------------------------------------------------------------------*/
1988 * @brief win_mgr_set_active: set(or change) active surface
1990 * @param[in] usurf UIFW surface (if NULL, change to inactive)
1991 * @param[in] target target device
1994 /*--------------------------------------------------------------------------*/
1996 win_mgr_set_active(struct uifw_win_surface *usurf, const int target)
1998 struct weston_seat *seat;
1999 struct weston_surface *surface;
2000 int object = target;
2001 #if 0 /* pointer grab can not release */
2003 #endif /* pointer grab can not release */
2005 uifw_trace("win_mgr_set_active: Enter(%08x,%x)", usurf ? usurf->surfaceid : 0, target);
2007 if ((usurf) && (usurf->shsurf) && (usurf->surface)) {
2008 surface = usurf->surface;
2009 if ((object & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) {
2011 if (_ico_win_mgr->active_pointer_usurf == usurf) {
2012 object |= ICO_WINDOW_MGR_ACTIVE_POINTER;
2014 if (_ico_win_mgr->active_keyboard_usurf == usurf) {
2015 object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
2019 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
2020 _ico_win_mgr->active_pointer_usurf = usurf;
2022 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
2023 _ico_win_mgr->active_keyboard_usurf = usurf;
2030 object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
2032 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
2033 _ico_win_mgr->active_pointer_usurf = NULL;
2035 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
2036 _ico_win_mgr->active_keyboard_usurf = NULL;
2040 wl_list_for_each (seat, &_ico_win_mgr->compositor->seat_list, link) {
2041 #if 0 /* pointer grab can not release */
2042 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
2044 if ((seat->pointer != NULL) && (seat->pointer->focus != surface)) {
2045 uifw_trace("win_mgr_set_active: pointer reset focus(%08x)",
2046 (int)seat->pointer->focus);
2047 if (seat->pointer->button_count > 0) {
2048 /* emulate button release */
2049 notify_button(seat, weston_compositor_get_time(),
2050 seat->pointer->grab_button,
2051 WL_POINTER_BUTTON_STATE_RELEASED);
2052 /* count up button, because real mouse botan release */
2053 seat->pointer->button_count ++;
2055 weston_pointer_set_focus(seat->pointer, NULL,
2056 wl_fixed_from_int(0), wl_fixed_from_int(0));
2059 uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)",
2062 if ((seat->touch != NULL) && (seat->touch->focus != surface)) {
2063 uifw_trace("win_mgr_set_active: touch reset surface(%08x)",
2064 (int)seat->touch->focus);
2065 if (seat->num_tp > 10) {
2066 seat->num_tp = 0; /* safty gard */
2068 else if (seat->num_tp > 0) {
2069 /* emulate touch up */
2070 savetp = seat->num_tp;
2071 for (i = 0; i < savetp; i++) {
2072 notify_touch(seat, weston_compositor_get_time(), i+1,
2073 seat->touch->grab_x, seat->touch->grab_y,
2076 /* touch count up, becase real touch release */
2077 seat->num_tp = savetp;
2079 weston_touch_set_focus(seat, NULL);
2082 uifw_trace("win_mgr_set_active: touch nochange surface(%08x)",
2087 uifw_trace("win_mgr_set_active: pointer reset surface(%08x)",
2088 (int)seat->pointer->focus);
2089 if ((seat->pointer != NULL) && (seat->pointer->focus != NULL)) {
2090 if (seat->pointer->button_count > 0) {
2091 /* emulate button release */
2092 notify_button(seat, weston_compositor_get_time(),
2093 seat->pointer->grab_button,
2094 WL_POINTER_BUTTON_STATE_RELEASED);
2095 seat->pointer->button_count ++;
2097 weston_pointer_set_focus(seat->pointer, NULL,
2098 wl_fixed_from_int(0), wl_fixed_from_int(0));
2100 if ((seat->touch != NULL) && (seat->touch->focus != NULL)) {
2101 if (seat->num_tp > 10) {
2102 seat->num_tp = 0; /* safty gard */
2104 else if (seat->num_tp > 0) {
2105 /* emulate touch up */
2106 savetp = seat->num_tp;
2107 for (i = 0; i < savetp; i++) {
2108 notify_touch(seat, weston_compositor_get_time(), i+1,
2109 seat->touch->grab_x, seat->touch->grab_y,
2112 /* touch count up, becase real touch release */
2113 seat->num_tp = savetp;
2115 weston_touch_set_focus(seat, NULL);
2119 #endif /* pointer grab can not release */
2120 if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) {
2122 #if 0 /* pointer grab can not release */
2123 if (seat->keyboard->focus != surface) {
2124 #endif /* pointer grab can not release */
2125 weston_keyboard_set_focus(seat->keyboard, surface);
2126 uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)",
2127 (int)seat->keyboard->focus, (int)surface);
2128 #if 0 /* pointer grab can not release */
2131 uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)",
2134 #endif /* pointer grab can not release */
2137 uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)",
2138 (int)seat->keyboard);
2139 weston_keyboard_set_focus(seat->keyboard, NULL);
2143 uifw_trace("win_mgr_set_active: Leave");
2146 /*--------------------------------------------------------------------------*/
2148 * @brief ico_window_mgr_ismykeyboard: check active keyboard
2150 * @param[in] usurf UIFW surface
2151 * @return check result
2152 * @retval =1 usurf is active keyboard surface
2153 * @retval =0 usurf is not active
2155 /*--------------------------------------------------------------------------*/
2157 ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf)
2159 return (_ico_win_mgr->active_keyboard_usurf == usurf) ? 1 : 0;
2162 /*--------------------------------------------------------------------------*/
2164 * @brief uifw_declare_manager: declare manager(ex.SystemController) client
2166 * @param[in] client Weyland client
2167 * @param[in] resource resource of request
2168 * @param[in] manager manager(1=manager, 0=not manager)
2171 /*--------------------------------------------------------------------------*/
2173 uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager)
2175 struct uifw_manager* mgr;
2176 struct uifw_win_surface *usurf;
2177 struct uifw_client *uclient;
2178 struct uifw_win_layer *el;
2180 uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d",
2181 (int)client, manager);
2183 /* check for access control */
2184 uclient = ico_window_mgr_find_uclient(client);
2186 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2187 "ico_window_mgr_declare_manager: unknown client");
2188 uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client);
2191 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_DECLARE_MANAGER) == 0) {
2192 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2193 "ico_window_mgr_declare_manager: not permitted");
2194 uifw_trace("uifw_declare_manager: Leave(%s not permitted)", uclient->appid);
2198 uclient->manager = manager;
2200 /* client set to manager */
2201 _ico_win_mgr->num_manager = 0;
2202 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
2203 if (mgr->resource == resource) {
2204 if (mgr->manager != manager) {
2205 uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d",
2206 (int)client, mgr->manager, manager);
2207 mgr->manager = manager;
2210 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2211 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2212 /* send window create event to manager */
2213 if (usurf->created != 0) {
2214 uifw_trace("uifw_declare_manager: Send manager(%08x) "
2215 "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)",
2216 (int)resource, usurf->surfaceid,
2217 usurf->uclient->pid, usurf->uclient->appid);
2218 ico_window_mgr_send_window_created(resource,
2221 usurf->uclient->pid,
2222 usurf->uclient->appid,
2223 usurf->layertype << 12);
2231 _ico_win_mgr->num_manager++;
2234 uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager);
2237 /*--------------------------------------------------------------------------*/
2239 * @brief uifw_set_window_layer: set layer id to surface
2241 * @param[in] client Weyland client
2242 * @param[in] resource resource of request
2243 * @param[in] surfaceid UIFW surface id
2244 * @param[in] layer layer id
2247 /*--------------------------------------------------------------------------*/
2249 uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource,
2250 uint32_t surfaceid, uint32_t layer)
2252 struct uifw_client *uclient;
2253 struct uifw_win_surface *usurf;
2255 if (layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) {
2256 layer = _ico_ivi_background_layer;
2258 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) {
2259 layer = _ico_ivi_touch_layer;
2261 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) {
2262 layer = _ico_ivi_cursor_layer;
2264 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) {
2265 layer = _ico_ivi_startup_layer;
2268 uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d",
2269 (int)resource, surfaceid, layer);
2271 /* check for access control */
2272 if (resource != NULL) {
2273 /* resource is NULL, internal use */
2274 uclient = ico_window_mgr_find_uclient(client);
2276 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2277 "ico_window_mgr_set_window_layer: unknown client");
2278 uifw_trace("uifw_set_window_layer: Leave(unknown client=%08x)", (int)client);
2281 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_WINDOW_LAYER) == 0) {
2282 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2283 "ico_window_mgr_set_window_layer: not permitted");
2284 uifw_trace("uifw_set_window_layer: Leave(%s not permitted)", uclient->appid);
2288 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2291 uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid);
2295 if (usurf->win_layer->layer != layer) {
2296 win_mgr_set_layer(usurf, layer);
2297 win_mgr_change_surface(usurf->surface, -1, 1);
2299 uifw_trace("uifw_set_window_layer: Leave");
2302 /*--------------------------------------------------------------------------*/
2304 * @brief uifw_set_positionsize: set surface position and size
2306 * @param[in] client Weyland client
2307 * @param[in] resource resource of request
2308 * @param[in] surfaceid UIFW surface id
2309 * @param[in] node surface node id
2310 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
2311 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
2312 * @param[in] width surface width(if bigger than 16383, no change)
2313 * @param[in] height surface height(if bigger than 16383, no change)
2314 * @param[in] flags with/without animation and client configure flag
2317 /*--------------------------------------------------------------------------*/
2319 uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
2320 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
2321 int32_t width, int32_t height, int32_t flags)
2323 struct uifw_client *uclient;
2324 struct uifw_win_surface *usurf;
2325 struct weston_surface *es;
2326 struct weston_view *ev;
2330 struct uifw_node_table *oldnode;
2332 uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x",
2333 surfaceid, node, x, y, width, height, flags);
2335 /* check for access control */
2336 uclient = ico_window_mgr_find_uclient(client);
2337 if (resource != NULL) {
2338 /* resource is NULL, internal use */
2340 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2341 "ico_window_mgr_set_positionsize: unknown client");
2342 uifw_trace("uifw_set_positionsize: Leave(unknown client=%08x)", (int)client);
2345 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE) == 0) {
2346 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2347 "ico_window_mgr_set_positionsize: not permitted");
2348 uifw_trace("uifw_set_positionsize: Leave(%s not permitted)", uclient->appid);
2352 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2354 uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid);
2359 oldnode = usurf->node_tbl;
2362 if (((int)node) >= _ico_num_nodes) {
2363 uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)",
2364 node, _ico_num_nodes);
2365 if ((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_NODISP) == 0) {
2366 if (usurf->visible) {
2367 /* no display, change to hide */
2368 uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE,
2369 ICO_WINDOW_MGR_V_NOCHANGE, 0);
2375 usurf->node_tbl = &_ico_node_table[node];
2377 es = usurf->surface;
2379 /* weston surface exist */
2380 es = usurf->surface;
2381 retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
2383 /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */
2384 if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x;
2385 if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y;
2386 if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width;
2387 if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height;
2389 /* check animation */
2390 if ((usurf->animation.restrain_configure != 0) &&
2391 (x == usurf->x) && (y == usurf->y) &&
2392 (width == usurf->width) && (height == usurf->height)) {
2393 uifw_trace("uifw_set_positionsize: Leave(same position size at animation)");
2398 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
2399 (uclient->manager == 0) && (uclient->privilege == 0)) uclient = NULL;
2401 ev = ico_ivi_get_primary_view(usurf);
2403 if ((usurf->width > 0) && (usurf->height > 0)) {
2404 win_mgr_surface_change_mgr(es, x, y, width, height);
2405 uifw_trace("uifw_set_positionsize: Leave(Request from App)");
2409 uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d",
2411 /* Initiale position is (0,0) */
2412 weston_view_set_position(ev, (float)(usurf->node_tbl->disp_x),
2413 (float)(usurf->node_tbl->disp_y));
2416 uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d",
2417 (int)ev->geometry.x, (int)ev->geometry.y,
2418 (int)es->width, (int)es->height);
2420 usurf->animation.pos_x = usurf->x;
2421 usurf->animation.pos_y = usurf->y;
2422 usurf->animation.pos_width = usurf->width;
2423 usurf->animation.pos_height = usurf->height;
2424 usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0;
2428 usurf->width = width;
2429 usurf->height = height;
2430 if (_ico_win_mgr->num_manager <= 0) {
2431 /* no manager(HomeScreen), set geometory */
2432 weston_view_set_position(ev, (float)(usurf->node_tbl->disp_x + x),
2433 (float)(usurf->node_tbl->disp_y + y));
2435 if ((es->output) && (es->buffer_ref.buffer) &&
2436 (es->width > 0) && (es->height > 0)) {
2437 uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)",
2439 if (usurf->visible) {
2440 if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) &&
2441 (win_mgr_hook_animation != NULL)) {
2442 /* with animation */
2443 if ((x != (ev->geometry.x - usurf->node_tbl->disp_x)) ||
2444 (y != (ev->geometry.y - usurf->node_tbl->disp_y))) {
2445 op = ICO_WINDOW_MGR_ANIMATION_OPMOVE;
2447 else if ((width != usurf->surface->width) ||
2448 (height != usurf->surface->height)) {
2449 op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE;
2452 op = ICO_WINDOW_MGR_ANIMATION_OPNONE;
2454 if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) &&
2455 (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) ||
2456 ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) &&
2457 (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) {
2458 retanima = (*win_mgr_hook_animation)(op, (void *)usurf);
2459 uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima);
2462 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
2463 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
2464 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2465 usurf->width, usurf->height);
2469 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
2470 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
2471 win_mgr_change_surface(es,
2472 (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1);
2474 uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output);
2479 usurf->width = width;
2480 usurf->height = height;
2481 uifw_trace("uifw_set_positionsize: Leave(OK, but no buffer)");
2484 /* if position change, call hook for input region */
2485 if (win_mgr_hook_change != NULL) {
2486 if ((oldx != usurf->x) || (oldy != usurf->y) || (oldnode != usurf->node_tbl)) {
2487 (*win_mgr_hook_change)(usurf);
2492 /*--------------------------------------------------------------------------*/
2494 * @brief uifw_set_visible: surface visible/raise control
2496 * @param[in] client Weyland client
2497 * @param[in] resource resource of request
2498 * @param[in] surfaceid UIFW surface id
2499 * @param[in] visible visible(1=show/0=hide/other=no change)
2500 * @param[in] raise raise(1=raise/0=lower/other=no change)
2501 * @param[in] flags with/without animation
2504 /*--------------------------------------------------------------------------*/
2506 uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
2507 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags)
2509 struct uifw_win_surface *usurf;
2510 struct uifw_client *uclient;
2511 struct weston_view *ev;
2516 uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)",
2517 surfaceid, visible, raise, flags);
2519 /* check for access control */
2520 uclient = ico_window_mgr_find_uclient(client);
2521 if (resource != NULL) {
2522 /* resource is NULL, internal use */
2524 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2525 "ico_window_mgr_set_visible: unknown client");
2526 uifw_trace("uifw_set_visible: Leave(unknown client=%08x)", (int)client);
2529 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_POSITIONSIZE) == 0) {
2530 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2531 "ico_window_mgr_set_visible: not permitted");
2532 uifw_trace("uifw_set_visible: Leave(%s not permitted)", uclient->appid);
2536 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2537 if ((! usurf) || (! usurf->surface)) {
2538 uifw_trace("uifw_set_visible: Leave(Surface Not Exist)");
2541 oldvisible = ico_window_mgr_is_visible(usurf);
2543 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
2544 (uclient->manager == 0) && (uclient->privilege == 0)) {
2545 uifw_trace("uifw_set_visible: Request from App(%s), not Manager",
2546 uclient ? uclient->appid : "");
2550 uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid);
2555 if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) {
2557 #if PERFORMANCE_EVALUATIONS > 0
2558 if (! usurf->visible) {
2559 uifw_perf("SWAP_BUFFER Show appid=%s surface=%08x",
2560 usurf->uclient->appid, usurf->surfaceid);
2562 #endif /*PERFORMANCE_EVALUATIONS*/
2563 if ((! usurf->visible) ||
2564 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
2566 uifw_trace("uifw_set_visible: Change to Visible");
2568 if (usurf->layertype != LAYER_TYPE_INPUTPANEL) {
2569 ico_ivi_shell_set_toplevel(usurf->shsurf);
2572 /* Weston surface configure */
2573 uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d",
2574 (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y,
2575 usurf->width, usurf->height);
2576 ico_ivi_shell_set_surface_type(usurf->shsurf);
2577 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2578 usurf->width, usurf->height);
2580 restack = 1; /* need damage */
2582 if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) &&
2583 (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
2584 (win_mgr_hook_animation != NULL)) {
2585 usurf->animation.pos_x = usurf->x;
2586 usurf->animation.pos_y = usurf->y;
2587 usurf->animation.pos_width = usurf->width;
2588 usurf->animation.pos_height = usurf->height;
2589 usurf->animation.no_configure = 0;
2590 retanima = (*win_mgr_hook_animation)(
2591 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
2592 ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS :
2593 ICO_WINDOW_MGR_ANIMATION_OPSHOW,
2595 uifw_trace("uifw_set_visible: ret call anima = %d", retanima);
2598 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
2599 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
2600 uifw_trace("uifw_set_visible: Leave(No Change)");
2604 else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) {
2606 #if PERFORMANCE_EVALUATIONS > 0
2607 if (usurf->visible) {
2608 uifw_perf("SWAP_BUFFER Hide appid=%s surface=%08x",
2609 usurf->uclient->appid, usurf->surfaceid);
2611 #endif /*PERFORMANCE_EVALUATIONS*/
2612 if ((usurf->visible) ||
2613 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
2616 win_mgr_reset_focus(usurf);
2618 /* Weston surface configure */
2619 ev = ico_ivi_get_primary_view(usurf);
2620 weston_view_damage_below(ev);
2621 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2622 usurf->width, usurf->height);
2624 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
2625 if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) &&
2626 (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
2627 (win_mgr_hook_animation != NULL)) {
2628 usurf->animation.pos_x = usurf->x;
2629 usurf->animation.pos_y = usurf->y;
2630 usurf->animation.pos_width = usurf->width;
2631 usurf->animation.pos_height = usurf->height;
2632 usurf->animation.no_configure = 0;
2633 retanima = (*win_mgr_hook_animation)(
2634 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
2635 ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS :
2636 ICO_WINDOW_MGR_ANIMATION_OPHIDE,
2639 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
2641 uifw_trace("uifw_set_visible: Change to UnVisible");
2642 /* change visible to unvisible, restack surface list */
2644 /* Weston surface configure */
2645 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
2646 usurf->width, usurf->height);
2649 uifw_trace("uifw_set_visible: UnVisible but animation");
2652 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
2653 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
2654 uifw_trace("uifw_set_visible: Leave(No Change)");
2658 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
2659 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
2660 uifw_trace("uifw_set_visible: Leave(No Change)");
2665 if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) {
2666 win_mgr_set_raise(usurf, raise);
2667 if (usurf->visible == 0) {
2672 raise = ICO_WINDOW_MGR_V_NOCHANGE;
2676 ico_window_mgr_restack_layer(usurf);
2679 /* send event(VISIBLE) to manager */
2681 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
2683 (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 :
2684 ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 :
2685 ICO_WINDOW_MGR_V_NOCHANGE),
2686 raise, uclient ? 0 : 1, 0,0);
2689 /* if visible change, call hook for input region */
2690 if (win_mgr_hook_change != NULL) {
2691 if (oldvisible != ico_window_mgr_is_visible(usurf)) {
2692 (*win_mgr_hook_change)(usurf);
2695 uifw_trace("uifw_set_visible: Leave(OK)");
2698 /*--------------------------------------------------------------------------*/
2700 * @brief uifw_set_animation: set animation of surface visible/unvisible
2702 * @param[in] client Weyland client
2703 * @param[in] resource resource of request
2704 * @param[in] surfaceid UIFW surface id
2705 * @param[in] type how to change surface
2706 * @param[in] anmation animation name
2707 * @param[in] time animation time(ms), if 0, default time
2710 /*--------------------------------------------------------------------------*/
2712 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
2713 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
2715 struct uifw_client *uclient;
2717 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2719 uifw_trace("uifw_set_transition: surf=%08x,type=%x,anim=%s,time=%d",
2720 surfaceid, type, animation, time);
2722 /* check for access control */
2723 if (resource != NULL) {
2724 /* resource is NULL, internal use */
2725 uclient = ico_window_mgr_find_uclient(client);
2727 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2728 "ico_window_mgr_set_animation: unknown client");
2729 uifw_trace("uifw_set_animation: Leave(unknown client=%08x)", (int)client);
2732 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_ANIMATION) == 0) {
2733 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2734 "ico_window_mgr_set_animation: not permitted");
2735 uifw_trace("uifw_set_animation: Leave(%s not permitted)", uclient->appid);
2740 if ((*animation != 0) && (*animation != ' ')) {
2741 animaid = ico_get_animation_name(animation);
2742 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
2743 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
2744 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
2745 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
2746 usurf->animation.next_anima = animaid;
2749 usurf->animation.hide_anima = animaid;
2752 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
2753 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
2754 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
2755 usurf->animation.next_anima = animaid;
2758 usurf->animation.show_anima = animaid;
2761 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
2762 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
2763 usurf->animation.next_anima = animaid;
2766 usurf->animation.move_anima = animaid;
2769 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
2770 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
2771 usurf->animation.next_anima = animaid;
2774 usurf->animation.resize_anima = animaid;
2778 if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) {
2779 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
2780 usurf->animation.hide_time = time;
2782 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
2783 usurf->animation.show_time = time;
2785 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
2786 usurf->animation.move_time = time;
2788 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
2789 usurf->animation.resize_time = time;
2794 uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid);
2798 /*--------------------------------------------------------------------------*/
2800 * @brief uifw_set_attributes: set surface attributes
2802 * @param[in] client Weyland client
2803 * @param[in] resource resource of request
2804 * @param[in] surfaceid UIFW surface id
2805 * @param[in] attributes surface attributes
2808 /*--------------------------------------------------------------------------*/
2810 uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
2811 uint32_t surfaceid, uint32_t attributes)
2813 struct uifw_client *uclient;
2814 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2816 uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes);
2818 /* check for access control */
2819 if (resource != NULL) {
2820 /* resource is NULL, internal use */
2821 uclient = ico_window_mgr_find_uclient(client);
2823 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2824 "ico_window_mgr_set_attributes: unknown client");
2825 uifw_trace("uifw_set_attributes: Leave(unknown client=%08x)", (int)client);
2828 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_ATTRIBUTES) == 0) {
2829 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2830 "ico_window_mgr_set_attributes: not permitted");
2831 uifw_trace("uifw_set_attributes: Leave(%s not permitted)", uclient->appid);
2836 usurf->attributes = attributes;
2837 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) ==
2838 (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) {
2839 usurf->attributes &=
2840 ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT);
2842 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) ==
2843 (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) {
2844 usurf->attributes &=
2845 ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM);
2848 uifw_trace("uifw_set_attributes: Leave");
2851 /*--------------------------------------------------------------------------*/
2853 * @brief uifw_visible_animation: surface visibility control with animation
2855 * @param[in] client Weyland client
2856 * @param[in] resource resource of request
2857 * @param[in] surfaceid surface id
2858 * @param[in] visible visible(1=show/0=hide)
2859 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
2860 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
2861 * @param[in] width surface width(if bigger than 16383, no change)
2862 * @param[in] height surface height(if bigger than 16383, no change)
2865 /*--------------------------------------------------------------------------*/
2867 uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
2868 uint32_t surfaceid, int32_t visible,
2869 int32_t x, int32_t y, int32_t width, int32_t height)
2871 struct uifw_client *uclient;
2872 struct uifw_win_surface *usurf;
2874 uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)",
2875 surfaceid, visible, x, y, width, height);
2877 /* check for access control */
2878 if (resource != NULL) {
2879 /* resource is NULL, internal use */
2880 uclient = ico_window_mgr_find_uclient(client);
2882 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2883 "ico_window_mgr_visible_animation: unknown client");
2884 uifw_trace("uifw_visible_animation: Leave(unknown client=%08x)", (int)client);
2887 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_VISIBLE_ANIMATION) == 0) {
2888 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2889 "ico_window_mgr_visible_animation: not permitted");
2890 uifw_trace("uifw_visible_animation: Leave(%s not permitted)", uclient->appid);
2894 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2896 if ((! usurf) || (! usurf->surface)) {
2897 uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)");
2901 usurf->animation.pos_x = x;
2902 usurf->animation.pos_y = y;
2903 if (width > 0) usurf->animation.pos_width = width;
2904 else usurf->animation.pos_width = 1;
2905 if (height > 0) usurf->animation.pos_height = height;
2906 else usurf->animation.pos_height = 1;
2907 usurf->animation.no_configure = 0;
2909 uifw_set_visible(client, resource, surfaceid, visible,
2910 ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS);
2912 uifw_trace("uifw_visible_animation: Leave");
2915 /*--------------------------------------------------------------------------*/
2917 * @brief uifw_set_active: set active surface
2919 * @param[in] client Weyland client
2920 * @param[in] resource resource of request
2921 * @param[in] surfaceid UIFW surface id
2922 * @param[in] active target device
2925 /*--------------------------------------------------------------------------*/
2927 uifw_set_active(struct wl_client *client, struct wl_resource *resource,
2928 uint32_t surfaceid, int32_t active)
2930 struct uifw_client *uclient;
2931 struct uifw_win_surface *usurf;
2933 uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active);
2935 /* check for access control */
2936 if (resource != NULL) {
2937 /* resource is NULL, internal use */
2938 uclient = ico_window_mgr_find_uclient(client);
2940 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2941 "ico_window_mgr_set_active: unknown client");
2942 uifw_trace("uifw_set_active: Leave(unknown client=%08x)", (int)client);
2945 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_ACTIVE) == 0) {
2946 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
2947 "ico_window_mgr_set_active: not permitted");
2948 uifw_trace("uifw_set_active: Leave(%s not permitted)", uclient->appid);
2952 if ((surfaceid > 0) &&
2953 ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) {
2954 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2960 switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) {
2961 case ICO_WINDOW_MGR_ACTIVE_POINTER:
2962 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2963 uifw_trace("uifw_set_active: pointer active change %08x->%08x",
2964 _ico_win_mgr->active_pointer_usurf ?
2965 _ico_win_mgr->active_pointer_usurf->surfaceid : 0,
2966 usurf ? usurf->surfaceid : 0);
2967 if (_ico_win_mgr->active_pointer_usurf) {
2968 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2969 _ico_win_mgr->active_pointer_usurf,
2970 (_ico_win_mgr->active_keyboard_usurf ==
2971 _ico_win_mgr->active_pointer_usurf) ?
2972 ICO_WINDOW_MGR_ACTIVE_KEYBOARD :
2973 ICO_WINDOW_MGR_ACTIVE_NONE,
2976 _ico_win_mgr->active_pointer_usurf = usurf;
2977 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2979 ICO_WINDOW_MGR_ACTIVE_POINTER |
2980 (_ico_win_mgr->active_keyboard_usurf == usurf) ?
2981 ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0,
2983 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER);
2986 case ICO_WINDOW_MGR_ACTIVE_KEYBOARD:
2987 if (usurf != _ico_win_mgr->active_keyboard_usurf) {
2988 uifw_trace("uifw_set_active: keyboard active change %08x->%08x",
2989 _ico_win_mgr->active_keyboard_usurf ?
2990 _ico_win_mgr->active_keyboard_usurf->surfaceid : 0,
2991 usurf ? usurf->surfaceid : 0);
2992 if (_ico_win_mgr->active_keyboard_usurf) {
2993 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2994 _ico_win_mgr->active_keyboard_usurf,
2995 (_ico_win_mgr->active_keyboard_usurf ==
2996 _ico_win_mgr->active_pointer_usurf) ?
2997 ICO_WINDOW_MGR_ACTIVE_POINTER :
2998 ICO_WINDOW_MGR_ACTIVE_NONE,
3001 _ico_win_mgr->active_keyboard_usurf = usurf;
3002 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
3004 ICO_WINDOW_MGR_ACTIVE_KEYBOARD |
3005 (_ico_win_mgr->active_pointer_usurf == usurf) ?
3006 ICO_WINDOW_MGR_ACTIVE_POINTER : 0,
3008 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
3012 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
3013 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
3014 uifw_trace("uifw_set_active: active change %08x/%08x->%08x",
3015 _ico_win_mgr->active_pointer_usurf ?
3016 _ico_win_mgr->active_pointer_usurf->surfaceid : 0,
3017 _ico_win_mgr->active_keyboard_usurf ?
3018 _ico_win_mgr->active_keyboard_usurf->surfaceid : 0,
3019 usurf ? usurf->surfaceid : 0);
3020 if (_ico_win_mgr->active_pointer_usurf) {
3021 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
3022 _ico_win_mgr->active_pointer_usurf,
3023 ICO_WINDOW_MGR_ACTIVE_NONE,
3025 if (_ico_win_mgr->active_keyboard_usurf ==
3026 _ico_win_mgr->active_pointer_usurf) {
3027 _ico_win_mgr->active_keyboard_usurf = NULL;
3030 if (_ico_win_mgr->active_keyboard_usurf) {
3031 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
3032 _ico_win_mgr->active_keyboard_usurf,
3033 ICO_WINDOW_MGR_ACTIVE_NONE,
3036 _ico_win_mgr->active_pointer_usurf = usurf;
3037 _ico_win_mgr->active_keyboard_usurf = usurf;
3038 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
3040 ICO_WINDOW_MGR_ACTIVE_POINTER |
3041 ICO_WINDOW_MGR_ACTIVE_KEYBOARD,
3043 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
3044 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
3048 uifw_trace("uifw_set_active: Leave(Change Active)");
3051 win_mgr_set_active(NULL, active);
3052 uifw_trace("uifw_set_active: Leave(Reset active surface)");
3056 /*--------------------------------------------------------------------------*/
3058 * @brief uifw_set_layer_visible: layer visible control
3060 * @param[in] client Weyland client
3061 * @param[in] resource resource of request
3062 * @param[in] layer layer id
3063 * @param[in] visible visible(1=show/0=hide)
3066 /*--------------------------------------------------------------------------*/
3068 uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
3069 uint32_t layer, int32_t visible)
3071 struct uifw_client *uclient;
3072 struct uifw_win_layer *el;
3073 struct uifw_win_layer *new_el;
3074 struct uifw_win_surface *usurf;
3075 struct weston_view *ev;
3078 if ((layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) ||
3079 (layer == (uint32_t)_ico_ivi_background_layer)) {
3080 layer = _ico_ivi_background_layer;
3081 layertype = LAYER_TYPE_BACKGROUND;
3083 else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) ||
3084 (layer == (uint32_t)_ico_ivi_touch_layer)) {
3085 layer = _ico_ivi_touch_layer;
3086 layertype = LAYER_TYPE_TOUCH;
3088 else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) ||
3089 (layer == (uint32_t)_ico_ivi_cursor_layer)) {
3090 layer = _ico_ivi_cursor_layer;
3091 layertype = LAYER_TYPE_CURSOR;
3093 else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) {
3094 layer = _ico_ivi_startup_layer;
3096 uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible);
3098 /* check for access control */
3099 if (resource != NULL) {
3100 /* resource is NULL, internal use */
3101 uclient = ico_window_mgr_find_uclient(client);
3103 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3104 "ico_window_mgr_set_layer_visible: unknown client");
3105 uifw_trace("uifw_set_layer_visible: Leave(unknown client=%08x)", (int)client);
3108 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_LAYER_VISIBLE) == 0) {
3109 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3110 "ico_window_mgr_set_layer_visible: not permitted");
3111 uifw_trace("uifw_set_layer_visible: Leave(%s not permitted)", uclient->appid);
3116 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
3117 if (el->layer == layer) break;
3120 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
3121 /* layer not exist, create new layer */
3122 uifw_trace("uifw_set_layer_visible: New Layer %d", layer);
3123 new_el = win_mgr_create_layer(NULL, layer, layertype);
3125 uifw_trace("uifw_set_layer_visible: Leave(No Memory)");
3128 new_el->visible = (visible != 0) ? TRUE : FALSE;
3129 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
3130 layer, new_el->visible, 0,0,0);
3131 uifw_trace("uifw_set_layer_visible: Leave(new layer)");
3135 /* control all surface in layer */
3136 if ((el->visible != FALSE) && (visible == 0)) {
3137 /* layer change to NOT visible */
3138 uifw_trace("uifw_set_layer_visible: change to not visible");
3139 el->visible = FALSE;
3141 else if ((el->visible == FALSE) && (visible != 0)) {
3142 /* layer change to visible */
3143 uifw_trace("uifw_set_layer_visible: change to visible");
3148 uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)",
3149 el->visible, visible);
3153 /* set damege area */
3154 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
3155 if ((usurf->visible != FALSE) && (usurf->surface != NULL) &&
3156 (usurf->surface->output != NULL)) {
3157 /* Reset focus if hide */
3159 win_mgr_reset_focus(usurf);
3161 /* Damage(redraw) target surface */
3162 ev = ico_ivi_get_primary_view(usurf);
3163 weston_view_damage_below(ev);
3167 /* rebild compositor surface list */
3168 ico_window_mgr_restack_layer(NULL);
3170 /* send layer visible event to manager */
3171 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
3172 layer, el->visible, 0,0,0);
3174 uifw_trace("uifw_set_layer_visible: Leave");
3177 /*--------------------------------------------------------------------------*/
3179 * @brief uifw_get_surfaces: get application surfaces
3181 * @param[in] client Weyland client
3182 * @param[in] resource resource of request
3183 * @param[in] appid application id
3184 * @param[in] pid process id
3187 /*--------------------------------------------------------------------------*/
3189 uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
3190 const char *appid, int32_t pid)
3192 struct uifw_client *uclient;
3193 struct uifw_win_layer *el;
3194 struct uifw_win_surface *usurf;
3195 struct wl_array reply;
3198 uifw_trace("uifw_get_surfaces: Enter(appid=%s, pid=%d)", appid ? appid : " ", pid);
3200 /* check for access control */
3201 uclient = ico_window_mgr_find_uclient(client);
3203 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3204 "ico_window_mgr_get_surfaces: unknown client");
3205 uifw_trace("uifw_get_surfaces: Leave(unknown client=%08x)", (int)client);
3208 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_GET_SURFACES) == 0) {
3209 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3210 "ico_window_mgr_get_surfaces: not permitted");
3211 uifw_trace("uifw_get_surfaces: Leave(%s not permitted)", uclient->appid);
3215 wl_array_init(&reply);
3217 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3218 if ((appid != NULL) && (*appid != ' ')) {
3219 if (strcmp(uclient->appid, appid) == 0) break;
3222 if (uclient->pid == pid) break;
3225 if (&uclient->link == &_ico_win_mgr->client_list) {
3226 uifw_trace("uifw_get_surfaces: appid=%s pid=%d dose not exist",
3227 appid ? appid : " ", pid);
3230 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
3231 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
3232 if (usurf->uclient == uclient) {
3233 uifw_trace("uifw_get_surfaces: %s(%d) surf=%08x",
3234 uclient->appid, uclient->pid, usurf->surfaceid);
3235 up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t));
3237 *up = usurf->surfaceid;
3243 ico_window_mgr_send_app_surfaces(resource, uclient->appid, uclient->pid, &reply);
3245 wl_array_release(&reply);
3246 uifw_trace("uifw_get_surfaces: Leave");
3249 /*--------------------------------------------------------------------------*/
3251 * @brief win_mgr_check_mapsurface: check and change all surface
3253 * @param[in] animation weston animation table(unused)
3254 * @param[in] outout weston output table(unused)
3255 * @param[in] mseces current time(unused)
3258 /*--------------------------------------------------------------------------*/
3260 win_mgr_check_mapsurface(struct weston_animation *animation,
3261 struct weston_output *output, uint32_t msecs)
3263 struct uifw_surface_map *sm, *sm_tmp;
3265 int wait = 99999999;
3267 /* check touch down counter */
3268 if ((touch_check_seat) &&
3269 (touch_check_seat->touch)) {
3270 if (touch_check_seat->touch->num_tp > 10) {
3271 uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset",
3272 (int)touch_check_seat->touch->num_tp);
3273 touch_check_seat->touch->num_tp = 0;
3277 /* check all mapped surfaces */
3278 curtime = weston_compositor_get_time();
3279 wl_list_for_each_safe (sm, sm_tmp, &_ico_win_mgr->map_list, map_link) {
3280 uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x",
3281 (int)sm, sm->usurf->surfaceid);
3282 win_mgr_change_mapsurface(sm, 0, curtime);
3284 if (sm->interval < wait) {
3285 wait = sm->interval;
3290 /* check frame interval */
3297 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait);
3300 /*--------------------------------------------------------------------------*/
3302 * @brief win_mgr_timer_mapsurface: mapped surface check timer
3304 * @param[in] data user data(unused)
3307 /*--------------------------------------------------------------------------*/
3309 win_mgr_timer_mapsurface(void *data)
3311 win_mgr_check_mapsurface(NULL, NULL, 0);
3315 /*--------------------------------------------------------------------------*/
3317 * @brief win_mgr_change_mapsurface: check and change mapped surface
3319 * @param[in] sm map surface table
3320 * @param[in] event send event (if 0, send if changed)
3321 * @param[in] curtime current time(ms)
3324 /*--------------------------------------------------------------------------*/
3326 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime)
3328 struct uifw_drm_buffer *drm_buffer;
3329 struct uifw_dri_image *dri_image;
3330 struct uifw_intel_region *dri_region;
3331 struct uifw_gl_surface_state *gl_state;
3332 struct weston_surface *es;
3333 struct weston_view *ev;
3334 struct wl_shm_buffer *shm_buffer;
3342 int delta, settime2;
3343 struct ico_uifw_image_buffer *p;
3345 uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event);
3347 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
3350 /* check if buffered */
3352 es = sm->usurf->surface;
3354 ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) &&
3355 ((es->buffer_ref.buffer == NULL) ||
3356 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) {
3357 /* surface has no buffer */
3358 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x",
3359 sm->usurf->surfaceid, (int)es,
3360 es ? (int)es->buffer_ref.buffer : 0);
3362 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
3368 else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
3369 if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) {
3370 drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data(
3371 (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer);
3372 if ((drm_buffer != NULL) && (drm_buffer->driver_buffer == NULL)) {
3376 if (drm_buffer == NULL) {
3377 /* surface has no buffer */
3378 uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer",
3379 sm->usurf->surfaceid);
3381 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
3388 else if (sm->uclient->shmbuf == NULL) {
3389 /* no GPU acceleration but no buffer */
3390 uifw_debug("win_mgr_change_mapsurface: client has no shared memory buffer");
3392 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
3398 else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_SHM) {
3399 if (es->buffer_ref.buffer != NULL) {
3400 shm_buffer = wl_shm_buffer_get(es->buffer_ref.buffer->resource);
3402 format = wl_shm_buffer_get_format(shm_buffer);
3403 if (format != WL_SHM_FORMAT_ARGB8888) {
3404 uifw_trace("win_mgr_change_mapsurface: %08x shm_buffer type %x",
3405 sm->usurf->surfaceid, format);
3406 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
3412 if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) {
3414 if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
3415 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
3416 if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
3417 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
3419 else if (gl_state->buffer_type != BUFFER_TYPE_EGL) {
3423 dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer;
3424 dri_region = dri_image->region;
3425 width = es->buffer_ref.buffer->width;
3426 height = es->buffer_ref.buffer->height;
3427 stride = drm_buffer->stride[0];
3428 if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) {
3429 format = EGL_TEXTURE_RGB;
3431 else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) {
3432 format = EGL_TEXTURE_RGBA;
3435 /* unknown format, error */
3436 format = EGL_NO_TEXTURE;
3438 eglname = dri_region->name;
3440 if (drm_intel_bo_flink((drm_intel_bo *)dri_region->bo, &eglname)) {
3441 uifw_warn("win_mgr_change_mapsurface: drm_intel_bo_flink() Error");
3445 if ((sm->initflag == 0) && (eglname != 0) &&
3446 (width > 0) && (height > 0) && (stride > 0)) {
3448 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
3451 if ((eglname == 0) || (width <= 0) || (height <= 0) || (stride <= 0)) {
3454 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
3455 if ((sm->width != width) || (sm->height != height) ||
3456 (sm->stride != stride) || (format != sm->format)) {
3457 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
3459 else if (eglname != sm->eglname) {
3460 #if PERFORMANCE_EVALUATIONS > 0
3461 uifw_perf("SWAP_BUFFER appid=%s surface=%08x name=%d",
3462 sm->usurf->uclient->appid, sm->usurf->surfaceid,
3464 #endif /*PERFORMANCE_EVALUATIONS*/
3465 dtime = curtime - sm->lasttime;
3466 if ((sm->interval > 0) && (dtime < sm->interval)) {
3471 else if (sm->eventque) {
3472 dtime = curtime - sm->lasttime;
3473 if ((sm->interval > 0) && (dtime < sm->interval)) {
3483 sm->height = height;
3484 sm->stride = stride;
3485 sm->eglname = eglname;
3486 sm->format = format;
3490 if ((sm->type != ICO_WINDOW_MGR_MAP_TYPE_PIXEL) || (sm->eventque != 0) ||
3491 (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) {
3492 sm->curbuf = es->buffer_ref.buffer;
3493 if (es->buffer_ref.buffer != NULL) {
3494 width = es->buffer_ref.buffer->width;
3495 height = es->buffer_ref.buffer->height;
3498 width = sm->usurf->client_width;
3499 height = sm->usurf->client_height;
3501 /* get shared memory buffer area */
3502 idx2 = sm->uclient->bufnum;
3503 settime2 = 0x7fffffff;
3504 for (idx = 0; idx < sm->uclient->bufnum; idx++) {
3505 p = (struct ico_uifw_image_buffer *)
3506 (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize);
3507 if (p->settime == p->reftime) break;
3508 delta = curtime - p->settime;
3510 delta = delta + 0x80000000;
3512 if ((delta > 3000) && (delta < settime2)) {
3514 settime2 = p->settime;
3517 uifw_detail("win_mgr_change_mapsurface: PIX %08x idx=%d idx2=%d w/h=%d/%d",
3518 sm->usurf->surfaceid, idx, idx2, width, height);
3519 if (idx >= sm->uclient->bufnum) {
3522 if (idx >= sm->uclient->bufnum) {
3523 uifw_debug("win_mgr_change_mapsurface: shared buffer full");
3528 else if ((sm->initflag == 0) && (width > 0) && (height > 0)) {
3530 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
3531 uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x",
3532 sm->usurf->surfaceid);
3535 if ((width <= 0) || (height <= 0)) {
3538 uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0",
3539 sm->usurf->surfaceid);
3541 else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) {
3542 #if PERFORMANCE_EVALUATIONS > 0
3543 if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) {
3544 uifw_perf("SWAP_BUFFER appid=%s surface=%08x",
3545 sm->usurf->uclient->appid, sm->usurf->surfaceid);
3547 #endif /*PERFORMANCE_EVALUATIONS*/
3548 if ((sm->width != width) || (sm->height != height)) {
3549 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
3552 dtime = curtime - sm->lasttime;
3553 if ((sm->interval > 0) && (dtime < sm->interval)) {
3556 uifw_detail("win_mgr_change_mapsurface: PIX %08x new queue",
3557 sm->usurf->surfaceid);
3559 else if (sm->eventque) {
3560 dtime = curtime - sm->lasttime;
3561 if ((sm->interval > 0) && (dtime < sm->interval)) {
3563 uifw_detail("win_mgr_change_mapsurface: PIX %08x queued",
3564 sm->usurf->surfaceid);
3571 sm->height = height;
3572 sm->stride = width * 4;
3573 sm->format = EGL_TEXTURE_RGBA;
3576 p = (struct ico_uifw_image_buffer *)
3577 (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize);
3578 height = (sm->uclient->bufsize - sizeof(struct ico_uifw_image_buffer))
3580 uifw_detail("win_mgr_change_mapsurface: PIX read buf=%08x height=%d(%d)",
3581 (int)p, height, sm->height);
3582 if ((height < sm->height) &&
3583 (sm->type == ICO_WINDOW_MGR_MAP_TYPE_SHM)) {
3584 uifw_warn("win_mgr_change_mapsurface: Buffer SHM, "
3585 "but buffer overflow(%d>%d)", sm->height, height);
3586 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
3590 ev = ico_ivi_get_primary_view(sm->usurf);
3591 if ((ev == NULL) || (ev->output == NULL)) {
3592 uifw_debug("win_mgr_change_mapsurface: surface %08x has no view",
3593 sm->usurf->surfaceid);
3594 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
3597 if (height > sm->height) {
3598 height = sm->height;
3600 if (ico_read_surface_pixels(es, PIXMAN_a8r8g8b8, p->image,
3601 0, 0, sm->width, height) != 0) {
3602 uifw_debug("win_mgr_change_mapsurface: Error read pixel %s.%08x",
3603 sm->usurf->uclient->appid, sm->usurf->surfaceid);
3604 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
3608 uifw_detail("win_mgr_change_mapsurface: PIX read pixels(%d)",
3610 p->surfaceid = sm->usurf->surfaceid;
3611 p->settime = curtime;
3612 p->width = sm->width;
3614 sm->eglname = idx + 1;
3627 uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d "
3628 "name=%d w/h/s=%d/%d/%d format=%x",
3629 event, sm->usurf->surfaceid, sm->type, sm->eglname,
3630 sm->width, sm->height, sm->stride, sm->format);
3631 sm->lasttime = curtime;
3633 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
3634 sm->usurf->surfaceid, sm->type, sm->eglname,
3635 sm->width, sm->height, sm->stride, sm->format);
3636 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
3637 /* free map table if error */
3638 wl_list_remove(&sm->surf_link);
3639 wl_list_remove(&sm->map_link);
3640 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
3641 _ico_win_mgr->free_maptable = sm;
3646 /*--------------------------------------------------------------------------*/
3648 * @brief uifw_set_map_buffer: set map surface image buffer
3650 * @param[in] client Weyland client
3651 * @param[in] resource resource of request
3652 * @param[in] shmname shared memory name(POSIX I/F)
3653 * @param[in] bufsize buffer size in byte
3654 * @param[in] bufnum number of buffers
3657 /*--------------------------------------------------------------------------*/
3659 uifw_set_map_buffer(struct wl_client *client, struct wl_resource *resource,
3660 const char *shmname, uint32_t bufsize, uint32_t bufnum)
3662 struct uifw_client *uclient;
3663 struct ico_uifw_image_buffer *p;
3668 uifw_trace("uifw_set_map_buffer: Enter(%s,%d,%d)",
3669 shmname ? shmname : "(null)", bufsize, bufnum);
3671 /* check for access control */
3672 uclient = ico_window_mgr_find_uclient(client);
3674 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3675 "ico_window_mgr_set_map_buffer: unknown client");
3676 uifw_trace("uifw_set_map_buffer: Leave(unknown client=%08x)", (int)client);
3679 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_SET_MAP_BUFFER) == 0) {
3680 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3681 "ico_window_mgr_set_map_buffer: not permitted");
3682 uifw_trace("uifw_set_map_buffer: Leave(%s not permitted)", uclient->appid);
3686 if ((shmname == NULL) || (*shmname == 0) || (*shmname == ' ') ||
3687 (bufsize == 0) || (bufnum == 0)) {
3688 /* delete shared memory buffer */
3689 if (uclient->shmbuf) {
3690 munmap(uclient->shmbuf, uclient->bufsize * uclient->bufnum);
3691 uclient->shmbuf = NULL;
3693 uifw_trace("uifw_set_map_buffer: Leave(delete shared memory buffer)");
3697 shmfd = shm_open(shmname, O_RDWR, 0600);
3699 /* shared memory dose not exist */
3700 uifw_trace("uifw_set_map_buffer: Leave(shared memory(%s) dose not exist)", shmname);
3704 shmbuf = (char *)mmap(NULL, bufsize * bufnum, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
3707 if (shmbuf == NULL) {
3708 /* can not map shared memory */
3709 uifw_trace("uifw_set_map_buffer: Leave(can not map shared memory(%s))", shmname);
3712 if (uclient->shmbuf) {
3713 munmap(uclient->shmbuf, uclient->bufsize * uclient->bufnum);
3716 uclient->shmbuf = shmbuf;
3717 uclient->bufsize = bufsize;
3718 uclient->bufnum = bufnum;
3719 for (i = 0; i < (int)bufnum; i++) {
3720 p = (struct ico_uifw_image_buffer *)(((char *)shmbuf) + bufsize * i);
3721 memset((char *)p, 0, sizeof(struct ico_uifw_image_buffer));
3722 memcpy((char *)&p->magich, ICO_UIFW_IMAGE_BUFFER_MAGICH, 4);
3723 memcpy((char *)&p->magict, ICO_UIFW_IMAGE_BUFFER_MAGICT, 4);
3725 uifw_trace("uifw_set_map_buffer: Leave(shm addr=%08x)", (int)uclient->shmbuf);
3728 /*--------------------------------------------------------------------------*/
3730 * @brief uifw_map_surface: mapped surface buffer to system application
3732 * @param[in] client Weyland client
3733 * @param[in] resource resource of request
3734 * @param[in] surfaceid surface id
3735 * @param[in] framerate frame rate of surface update(frame/sec)
3738 /*--------------------------------------------------------------------------*/
3740 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
3741 uint32_t surfaceid, int32_t framerate)
3743 struct uifw_win_surface *usurf;
3744 struct weston_surface *es;
3745 struct uifw_surface_map *sm;
3746 struct weston_buffer *buffer;
3747 struct wl_shm_buffer *shm_buffer;
3748 struct uifw_client *uclient;
3749 struct uifw_drm_buffer *drm_buffer;
3750 struct uifw_gl_surface_state *gl_state;
3754 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate);
3756 /* check for access control */
3757 uclient = ico_window_mgr_find_uclient(client);
3758 if (resource != NULL) {
3759 /* resource is NULL, internal use */
3761 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3762 "ico_window_mgr_map_surface: unknown client");
3763 uifw_trace("uifw_map_surface: Leave(unknown client=%08x)", (int)client);
3766 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_MAP_SURFACE) == 0) {
3767 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
3768 "ico_window_mgr_map_surface: not permitted");
3769 uifw_trace("uifw_map_surface: Leave(%s not permitted)", uclient->appid);
3774 uifw_trace("uifw_map_surface: Leave(unknown client=%08x)", (int)client);
3778 usurf = ico_window_mgr_get_usurf(surfaceid);
3780 /* surface dose not exist, error */
3781 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
3782 surfaceid, 1, 0, 0, 0, 0, 0);
3783 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
3786 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
3787 /* input panel surface dose not suport, error */
3788 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
3789 surfaceid, 1, 0, 0, 0, 0, 0);
3790 uifw_trace("uifw_map_surface: Leave(surface=%08x is input panel)", surfaceid);
3794 /* check if buffered */
3795 es = usurf->surface;
3797 /* surface has no buffer, error */
3798 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
3799 surfaceid, 3, 0, 0, 0, 0, 0);
3800 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid);
3803 buffer = es->buffer_ref.buffer;
3805 /* check buffer type */
3806 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
3807 if ((_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) ||
3808 (gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) {
3809 /* No Acceleration or wl_shm_buffer support ReadPixels */
3810 if ((gl_state != NULL) && (gl_state->buffer_type == BUFFER_TYPE_SHM)) {
3813 if (ico_ivi_optionflag() & ICO_IVI_OPTION_SUPPORT_SHM) {
3814 if (buffer != NULL) {
3815 shm_buffer = wl_shm_buffer_get(buffer->resource);
3817 format = wl_shm_buffer_get_format(shm_buffer);
3818 uifw_detail("uifw_map_surface: %08x shm_buffer type %x",
3820 if (format == WL_SHM_FORMAT_ARGB8888) {
3821 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
3826 maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM;
3830 ico_window_mgr_send_map_surface(resource,
3831 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
3832 surfaceid, 5, 0, 0, 0, 0, 0);
3833 uifw_trace("uifw_map_surface: Leave(surface(%08x) not support shm_buffer(%x))",
3839 maptype = ICO_WINDOW_MGR_MAP_TYPE_PIXEL;
3843 /* H/W(GPU) driver EGL buffer (Intel only) */
3844 maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL;
3847 /* maximum framerate */
3848 if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) {
3849 if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_gpu))
3850 framerate = _ico_ivi_map_framerate_gpu;
3852 else if (maptype == ICO_WINDOW_MGR_MAP_TYPE_SHM) {
3853 if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_shm))
3854 framerate = _ico_ivi_map_framerate_shm;
3857 if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_pixel))
3858 framerate = _ico_ivi_map_framerate_pixel;
3861 /* check same surface */
3862 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
3863 if ((sm->usurf == usurf) && (sm->uclient == uclient)) {
3868 if (&sm->surf_link == &usurf->surf_map) {
3869 /* create map table */
3870 sm = _ico_win_mgr->free_maptable;
3872 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
3875 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
3877 ico_window_mgr_send_map_surface(resource,
3878 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
3879 surfaceid, 6, 0, 0, 0, 0, 0);
3880 uifw_trace("uifw_map_surface: Leave(malloc error)");
3884 memset(sm, 0, sizeof(struct uifw_surface_map));
3886 wl_list_init(&sm->map_link);
3887 wl_list_init(&sm->surf_link);
3889 sm->uclient = uclient;
3891 sm->framerate = framerate;
3892 sm->interval = (1000 / sm->framerate) - 1;
3893 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
3894 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
3897 /* change frame rate */
3898 uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d",
3899 sm->framerate, framerate);
3900 if (sm->framerate != framerate) {
3901 sm->framerate = framerate;
3902 sm->interval = (1000 / sm->framerate) - 1;
3903 win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time());
3908 if (buffer != NULL) {
3909 sm->width = buffer->width;
3910 sm->height = buffer->height;
3911 if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
3912 sm->stride = sm->width * 4;
3913 sm->format = EGL_TEXTURE_RGBA;
3914 if ((sm->width > 0) && (sm->height > 0)) {
3917 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
3918 maptype, surfaceid, framerate, buffer->width, buffer->height);
3921 drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data(
3922 (struct wl_resource *)buffer->legacy_buffer);
3923 if (drm_buffer != NULL) {
3924 sm->stride = drm_buffer->stride[0];
3925 if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) {
3926 sm->format = EGL_TEXTURE_RGB;
3928 else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) {
3929 sm->format = EGL_TEXTURE_RGBA;
3932 /* unknown format, error */
3933 sm->format = EGL_NO_TEXTURE;
3935 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
3936 (gl_state != NULL)) {
3939 uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d",
3940 surfaceid, framerate, buffer->width, buffer->height);
3943 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
3944 surfaceid, framerate);
3948 else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) {
3949 sm->width = usurf->client_width;
3950 sm->height = usurf->client_height;
3951 sm->stride = sm->width * 4;
3952 sm->format = EGL_TEXTURE_RGBA;
3953 if ((sm->width > 0) && (sm->height > 0)) {
3956 uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d",
3957 maptype, surfaceid, framerate, sm->width, sm->height);
3960 uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d",
3961 surfaceid, framerate);
3964 /* send map event */
3966 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP,
3967 weston_compositor_get_time());
3969 uifw_trace("uifw_map_surface: Leave");
3972 /*--------------------------------------------------------------------------*/
3974 * @brief uifw_unmap_surface: unmap surface buffer
3976 * @param[in] client Weyland client
3977 * @param[in] resource resource of request
3978 * @param[in] surfaceid surface id
3981 /*--------------------------------------------------------------------------*/
3983 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
3986 struct uifw_win_surface *usurf;
3987 struct uifw_surface_map *sm, *sm_tmp;
3988 struct uifw_client *uclient;
3989 struct ico_uifw_image_buffer *p;
3992 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
3994 /* check for access control */
3995 if (resource != NULL) {
3996 /* resource is NULL, internal use */
3997 uclient = ico_window_mgr_find_uclient(client);
3999 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
4000 "ico_window_mgr_unmap_surface: unknown client");
4001 uifw_trace("uifw_unmap_surface: Leave(unknown client=%08x)", (int)client);
4004 if ((uclient->api_access_control & ICO_UIFW_WINDOW_MGR_UNMAP_SURFACE) == 0) {
4005 wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
4006 "ico_window_mgr_unmap_surface: not permitted");
4007 uifw_trace("uifw_unmap_surface: Leave(%s not permitted)", uclient->appid);
4011 usurf = ico_window_mgr_get_usurf(surfaceid);
4013 /* surface dose not exist, error */
4014 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
4018 uclient = ico_window_mgr_find_uclient(client);
4019 if ((! uclient) || (! uclient->mgr)) {
4020 /* client dose not exist, error */
4021 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
4027 wl_list_for_each (sm, &usurf->surf_map, surf_link) {
4028 if (sm->uclient->mgr != NULL) {
4029 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x "
4030 "w/h/s=%d/%d/%d format=%x",
4031 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
4032 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
4033 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
4034 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
4035 surfaceid, sm->type, sm->eglname, sm->width,
4036 sm->height, sm->stride, sm->format);
4041 wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) {
4042 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
4044 if ((sm->type != ICO_WINDOW_MGR_MAP_TYPE_EGL) &&
4045 (sm->uclient->shmbuf != NULL)) {
4046 /* reset shared memory buffer */
4047 for (idx = 0; idx < sm->uclient->bufnum; idx++) {
4048 p = (struct ico_uifw_image_buffer *)
4049 (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize);
4050 if (p->surfaceid == surfaceid) {
4057 wl_list_remove(&sm->surf_link);
4058 wl_list_remove(&sm->map_link);
4059 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
4060 _ico_win_mgr->free_maptable = sm;
4062 uifw_trace("uifw_unmap_surface: Leave");
4065 /*--------------------------------------------------------------------------*/
4067 * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen)
4069 * @param[in] surface Weston surface
4070 * @param[in] x X coordinate on screen
4071 * @param[in] y Y coordinate on screen
4072 * @param[in] width surface width
4073 * @param[in] height surface height
4074 * @return number of managers
4075 * @retval > 0 number of managers
4076 * @retval 0 manager not exist
4078 /*--------------------------------------------------------------------------*/
4080 win_mgr_surface_change_mgr(struct weston_surface *surface,
4081 const int x, const int y, const int width, const int height)
4084 struct uifw_win_surface *usurf;
4086 uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)",
4087 (int)surface, x, y, width, height);
4089 usurf = find_uifw_win_surface_by_ws(surface);
4091 uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)");
4095 num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
4096 usurf, x, y, width, height, 1);
4098 uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr);
4102 /*--------------------------------------------------------------------------*/
4104 * @brief win_mgr_change_surface: surface change
4106 * @param[in] surface Weston surface
4107 * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager)
4108 * @param[in] manager request from manager(0=Client,1=Manager)
4111 /*--------------------------------------------------------------------------*/
4113 win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager)
4115 struct uifw_win_surface *usurf;
4116 struct weston_surface *es;
4117 struct weston_view *ev;
4122 uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager);
4125 usurf = find_uifw_win_surface_by_ws(surface);
4127 uifw_trace("win_mgr_change_surface: Leave(Not Exist)");
4130 es = usurf->surface;
4132 uifw_trace("win_mgr_change_surface: Leave(No weston surface)");
4136 /* set surface size */
4137 ev = ico_ivi_get_primary_view(usurf);
4138 uifw_debug("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d",
4139 (int)ev->geometry.x, (int)ev->geometry.y, usurf->x, usurf->y,
4140 es->width, es->height, usurf->width, usurf->height);
4141 if ((usurf->width <= 0) || (usurf->height <= 0)) {
4142 usurf->width = es->width;
4143 usurf->height = es->height;
4145 win_mgr_set_scale(usurf);
4146 if (usurf->visible) {
4147 weston_view_set_position(ev, (float)(usurf->node_tbl->disp_x +
4148 usurf->x + usurf->xadd),
4149 (float)(usurf->node_tbl->disp_y +
4150 usurf->y + usurf->yadd));
4151 ico_window_mgr_restack_layer(usurf);
4154 weston_view_set_position(ev, (float)(ICO_IVI_MAX_COORDINATE+1),
4155 (float)(ICO_IVI_MAX_COORDINATE+1));
4158 /* send wayland event to client */
4159 if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) &&
4160 (usurf->width > 0) && (usurf->height > 0)) {
4161 if ((usurf->width != usurf->conf_width) ||
4162 (usurf->height != usurf->conf_height)) {
4163 usurf->conf_width = usurf->width;
4164 usurf->conf_height = usurf->height;
4165 uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ",
4166 usurf->surfaceid, (int)es, usurf->width, usurf->height);
4167 ico_ivi_shell_send_configure(es,
4168 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
4169 usurf->width, usurf->height);
4173 if (usurf->visible) {
4174 x = usurf->node_tbl->disp_x + usurf->x;
4175 y = usurf->node_tbl->disp_y + usurf->y;
4178 x = ICO_IVI_MAX_COORDINATE+1;
4179 y = ICO_IVI_MAX_COORDINATE+1;
4181 /* change geometry if request from manager */
4183 if ((usurf->width != es->width) ||
4184 (usurf->height != es->height) ||
4185 ((int)ev->geometry.x != x) || ((int)ev->geometry.y != y)) {
4186 win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height);
4191 /* send manager event to HomeScreen */
4194 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
4195 usurf, usurf->x, usurf->y,
4196 usurf->width, usurf->height, 0);
4199 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
4200 usurf, (int)ev->geometry.x, (int)ev->geometry.y,
4201 es->width, es->height, 1);
4205 /* change geometry if request from client */
4207 if ((usurf->width != es->width) || (usurf->height != es->height) ||
4208 ((int)ev->geometry.x != x) || ((int)ev->geometry.y != y)) {
4209 win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height);
4215 uifw_trace("win_mgr_change_surface: repaint");
4216 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
4218 uifw_trace("win_mgr_change_surface: Leave(OK)");
4221 /*--------------------------------------------------------------------------*/
4223 * @brief win_mgr_surface_configure: UIFW surface configure
4225 * @param[in] usurf UIFW surface
4226 * @param[in] x X coordinate on screen
4227 * @param[in] y Y coordinate on screen
4228 * @param[in] width surface width
4229 * @param[in] height surface height
4232 /*--------------------------------------------------------------------------*/
4234 win_mgr_surface_configure(struct uifw_win_surface *usurf,
4235 int x, int y, int width, int height)
4237 struct weston_surface *es;
4238 struct weston_view *ev;
4240 es = usurf->surface;
4241 if ((es != NULL) && (es->buffer_ref.buffer)) {
4242 if (usurf->client_width == 0) {
4243 usurf->client_width = es->width;
4244 if (usurf->client_width == 0)
4245 usurf->client_width = ico_ivi_surface_buffer_width(es);
4247 if (usurf->client_height == 0) {
4248 usurf->client_height = es->height;
4249 if (usurf->client_height == 0)
4250 usurf->client_height = ico_ivi_surface_buffer_height(es);
4253 /* not set geometry width/height */
4254 win_mgr_set_scale(usurf);
4255 ev = ico_ivi_get_primary_view(usurf);
4256 weston_view_set_position(ev, x + usurf->xadd, y + usurf->yadd);
4260 /*--------------------------------------------------------------------------*/
4262 * @brief win_mgr_shell_configure: shell surface configure
4264 * @param[in] surface Weston surface
4267 /*--------------------------------------------------------------------------*/
4269 win_mgr_shell_configure(struct weston_surface *surface)
4271 struct uifw_win_surface *usurf;
4275 uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface);
4277 /* Find UIFW surface */
4278 usurf = find_uifw_win_surface_by_ws(surface);
4280 uifw_trace("win_mgr_shell_configure: Leave(Not Exist)");
4284 usurf->client_width = surface->width;
4285 usurf->client_height = surface->height;
4286 ico_ivi_surface_buffer_size(surface, &buf_width, &buf_height);
4287 uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d",
4289 usurf->client_width, usurf->client_height, buf_width, buf_height);
4290 if (usurf->client_width > buf_width) usurf->client_width = buf_width;
4291 if (usurf->client_height > buf_height) usurf->client_height = buf_height;
4293 /* send event to manager */
4294 win_mgr_change_surface(surface, -1, 0);
4296 uifw_trace("win_mgr_shell_configure: Leave");
4299 /*--------------------------------------------------------------------------*/
4301 * @brief win_mgr_select_surface: select surface by Bottun/Touch
4303 * @param[in] surface Weston surface
4306 /*--------------------------------------------------------------------------*/
4308 win_mgr_select_surface(struct weston_surface *surface)
4310 struct uifw_win_surface *usurf;
4312 uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface);
4315 usurf = find_uifw_win_surface_by_ws(surface);
4317 uifw_trace("win_mgr_select_surface: Leave(Not Exist)");
4320 if (usurf != _ico_win_mgr->active_pointer_usurf) {
4322 /* send active event to manager */
4323 if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
4324 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) {
4325 uifw_trace("win_mgr_select_surface: not found manager, set active");
4326 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
4327 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
4330 uifw_trace("win_mgr_select_surface: Leave(OK)");
4333 /*--------------------------------------------------------------------------*/
4335 * @brief win_mgr_set_title: set tile name to surface
4337 * @param[in] surface weston surface
4338 * @param[in] title title name
4339 * @return title string
4340 * @retval != NULL title string
4341 * @retval NULL no title string
4343 /*--------------------------------------------------------------------------*/
4345 win_mgr_set_title(struct weston_surface *surface, const char *title)
4347 struct uifw_win_surface *usurf;
4348 char *optpoint, *ppoint, *bpoint, *cpoint;
4349 int layer, visible, raise, node, x, y, width, height, attribute;
4351 char wktitle[ICO_IVI_WINNAME_LENGTH + 256];
4353 uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title);
4355 usurf = find_uifw_win_surface_by_ws(surface);
4357 uifw_trace("win_mgr_set_title: Leave(Not Exist)");
4358 return (char *)title;
4371 strncpy(wktitle, title, ICO_IVI_WINNAME_LENGTH+256-1);
4372 wktitle[ICO_IVI_WINNAME_LENGTH+256-1] = 0;
4374 /* get option parameters */
4375 optpoint = strstr(wktitle, "@@");
4377 if (optpoint != NULL) {
4380 usurf->uclient->privilege = 1; /* privilege application */
4381 ppoint = optpoint + 2;
4383 bpoint = strtok(ppoint, "=;");
4385 if (! bpoint) break;
4386 if (strcasecmp(bpoint, "layer") == 0) {
4387 /* layer name or number */
4388 bpoint = strtok(ppoint, "=;");
4390 if (strcasecmp(bpoint, "background") == 0) {
4391 layer = _ico_ivi_background_layer;
4393 else if (strcasecmp(bpoint, "default") == 0) {
4394 layer = _ico_ivi_default_layer;
4396 else if (strcasecmp(bpoint, "touch") == 0) {
4397 layer = _ico_ivi_touch_layer;
4399 else if (strcasecmp(bpoint, "cursor") == 0) {
4400 layer = _ico_ivi_cursor_layer;
4402 else if (strcasecmp(bpoint, "startup") == 0) {
4403 layer = _ico_ivi_startup_layer;
4406 layer = strtol(bpoint, (char **)0, 0);
4410 else if (strcasecmp(bpoint, "show") == 0) {
4414 else if (strcasecmp(bpoint, "hide") == 0) {
4418 else if (strcasecmp(bpoint, "raise") == 0) {
4422 else if (strcasecmp(bpoint, "lower") == 0) {
4426 else if (strcasecmp(bpoint, "node") == 0) {
4428 bpoint = strtok(ppoint, ",");
4430 node = strtol(bpoint, (char **)0, 0);
4433 else if (strcasecmp(bpoint, "position") == 0) {
4435 bpoint = strtok(ppoint, ",");
4437 cpoint = strtok(ppoint, ";");
4439 x = strtol(bpoint, (char **)0, 0);
4440 y = strtol(cpoint, (char **)0, 0);
4444 else if (strcasecmp(bpoint, "size") == 0) {
4446 bpoint = strtok(ppoint, ",");
4448 cpoint = strtok(ppoint, ";");
4450 width = strtol(bpoint, (char **)0, 0);
4451 height = strtol(cpoint, (char **)0, 0);
4455 else if (strcasecmp(bpoint, "attribute") == 0) {
4456 /* attribute flags */
4457 bpoint = strtok(ppoint, ",");
4459 attribute = strtol(bpoint, (char **)0, 0);
4462 else if (strcasecmp(bpoint, "region") == 0) {
4463 /* set input region */
4464 bpoint = strtok(ppoint, ",");
4469 rx = strtol(bpoint, (char **)0, 0);
4470 bpoint = strtok(ppoint, ",");
4472 ry = strtol(bpoint, (char **)0, 0);
4474 bpoint = strtok(ppoint, ",");
4476 rw = strtol(bpoint, (char **)0, 0);
4478 bpoint = strtok(ppoint, ";");
4480 rh = strtol(bpoint, (char **)0, 0);
4482 if (win_mgr_hook_inputregion) {
4483 (*win_mgr_hook_inputregion)(1, usurf, rx, ry, rw, rh, 0, 0,
4488 else if (strcasecmp(bpoint, "unregion") == 0) {
4489 /* unset input region */
4490 bpoint = strtok(ppoint, ",");
4495 rx = strtol(bpoint, (char **)0, 0);
4496 bpoint = strtok(ppoint, ",");
4498 ry = strtol(bpoint, (char **)0, 0);
4500 bpoint = strtok(ppoint, ",");
4502 rw = strtol(bpoint, (char **)0, 0);
4504 bpoint = strtok(ppoint, ";");
4506 rh = strtol(bpoint, (char **)0, 0);
4508 if (win_mgr_hook_inputregion) {
4509 (*win_mgr_hook_inputregion)(0, usurf, rx, ry, rw, rh, 0, 0,
4517 if ((optpoint == NULL) || (wktitle[0] != 0)) {
4518 if (((usurf->width > 0) && (usurf->height > 0)) &&
4519 ((usurf->created == 0) ||
4520 (strncmp(wktitle, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) {
4521 strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1);
4522 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
4523 if (usurf->created == 0) {
4524 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0);
4528 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0);
4532 strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1);
4533 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
4539 uifw_set_window_layer(usurf->uclient->client, NULL, usurf->surfaceid, layer);
4541 if (attribute >= 0) {
4542 uifw_set_attributes(usurf->uclient->client, NULL, usurf->surfaceid, attribute);
4544 if ((node >= 0) || (x >=0) || (y >= 0) || (width >=0) || (height >= 0)) {
4545 if (node < 0) node = usurf->node_tbl->node;
4546 if (x < 0) x = ICO_IVI_MAX_COORDINATE + 1;
4547 if (y < 0) y = ICO_IVI_MAX_COORDINATE + 1;
4548 if (width < 0) width = ICO_IVI_MAX_COORDINATE + 1;
4549 if (height < 0) height = ICO_IVI_MAX_COORDINATE + 1;
4550 uifw_set_positionsize(usurf->uclient->client, NULL, usurf->surfaceid,
4551 node, x, y, width, height, 0);
4553 if ((visible >= 0) || (raise >= 0)) {
4554 if (visible < 0) visible = ICO_WINDOW_MGR_V_NOCHANGE;
4555 if (raise < 0) raise = ICO_WINDOW_MGR_V_NOCHANGE;
4556 uifw_set_visible(usurf->uclient->client, NULL, usurf->surfaceid,
4560 uifw_trace("win_mgr_set_title: Leave");
4562 return usurf->winname;
4565 /*--------------------------------------------------------------------------*/
4567 * @brief win_mgr_surface_move: set tile name to surface
4569 * @param[in] surface weston surface
4570 * @param[in] title title name
4573 /*--------------------------------------------------------------------------*/
4575 win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy)
4577 struct uifw_win_surface *usurf;
4579 uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy);
4581 usurf = find_uifw_win_surface_by_ws(surface);
4583 uifw_trace("win_mgr_surface_move: Leave(Not Exist)");
4586 if (usurf->visible) {
4587 *dx = usurf->node_tbl->disp_x + usurf->x;
4588 *dy = usurf->node_tbl->disp_y + usurf->y;
4591 *dx = ICO_IVI_MAX_COORDINATE+1;
4592 *dy = ICO_IVI_MAX_COORDINATE+1;
4594 uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy);
4597 /*--------------------------------------------------------------------------*/
4599 * @brief win_mgr_show_layer: shell layer visible control
4601 * @param[in] layertype shell layer type
4602 * @param[in] show show(1)/hide(0)
4603 * @param[in] data requested weston surface in show
4606 /*--------------------------------------------------------------------------*/
4608 win_mgr_show_layer(int layertype, int show, void *data)
4610 struct uifw_win_layer *el;
4611 struct uifw_win_surface *usurf;
4612 struct uifw_win_surface *inusurf = NULL;
4614 uifw_trace("win_mgr_show_layer: Enter(type=%d, show=%d, data=%08x)",
4615 layertype, show, (int)data);
4617 if (layertype != LAYER_TYPE_INPUTPANEL) {
4618 uifw_trace("win_mgr_show_layer: Leave(layertype npt InputPanel)");
4623 uifw_trace("win_mgr_show_layer: Leave(show but input surface not exist)");
4626 inusurf = find_uifw_win_surface_by_ws((struct weston_surface *)data);
4628 uifw_trace("win_mgr_show_layer: Leave(show but unknown input surface)");
4633 /* all input panel surface show/hide */
4634 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
4635 if ((el->layertype == LAYER_TYPE_CURSOR) ||
4636 (el->layertype == LAYER_TYPE_TOUCH)) continue;
4637 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
4638 if ((usurf->layertype == LAYER_TYPE_INPUTPANEL) &&
4639 (usurf->surface != NULL) && (usurf->mapped != 0) &&
4640 (usurf->surface->buffer_ref.buffer != NULL)) {
4642 if ((inusurf != NULL) && (usurf->win_layer != inusurf->win_layer)) {
4643 win_mgr_set_layer(usurf, usurf->win_layer->layer);
4645 win_mgr_change_surface(usurf->surface, -1, 1);
4647 if ((show == 0) || (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_INPUTLAYER)) {
4648 /* show input panel automatically */
4649 ico_window_mgr_set_visible(usurf, show | 2);
4652 /* send hint event to HomeScreen */
4653 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
4654 usurf, show, ICO_WINDOW_MGR_RAISE_RAISE, 1, 0,0);
4659 uifw_trace("win_mgr_show_layer: Leave");
4662 /*--------------------------------------------------------------------------*/
4664 * @brief win_mgr_fullscreen: shell full screen surface control
4666 * @param[in] event control event
4667 * @param[in] surface target weston surface
4670 /*--------------------------------------------------------------------------*/
4672 win_mgr_fullscreen(int event, struct weston_surface *surface)
4674 struct uifw_win_surface *usurf;
4675 struct uifw_win_surface *tmpusurf;
4676 struct uifw_win_layer *ulayer;
4680 uifw_trace("win_mgr_fullscreen: Enter(event=%d, surface=%08x)", event, (int)surface);
4682 if (event == SHELL_FULLSCREEN_HIDEALL) {
4683 /* hide all fullscreen srface */
4684 uifw_trace("win_mgr_fullscreen: SHELL_FULLSCREEN_HIDEALL");
4686 wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) {
4687 if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue;
4688 wl_list_for_each_safe (usurf, tmpusurf, &ulayer->surface_list, ivi_layer) {
4689 if (usurf->layertype == LAYER_TYPE_FULLSCREEN) {
4690 ico_window_mgr_set_visible(usurf, 2);
4691 usurf->layertype = usurf->old_layertype;
4692 win_mgr_set_layer(usurf, usurf->old_layer->layer);
4693 win_mgr_change_surface(usurf->surface, -1, 1);
4694 /* send event to HomeScreen */
4695 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
4696 usurf, usurf->x, usurf->y,
4697 usurf->width, usurf->height, 0);
4701 uifw_trace("win_mgr_fullscreen: Leave");
4705 usurf = find_uifw_win_surface_by_ws(surface);
4707 uifw_trace("win_mgr_fullscreen: Leave(surface dose not exist)");
4712 case SHELL_FULLSCREEN_ISTOP: /* check if top surface */
4713 if (usurf->layertype == LAYER_TYPE_FULLSCREEN) {
4714 wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) {
4715 if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue;
4716 wl_list_for_each(tmpusurf, &ulayer->surface_list, ivi_layer) {
4717 if (usurf == tmpusurf) {
4718 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP"
4719 "(fullscreen surface)", usurf->surfaceid);
4722 if (tmpusurf->layertype == LAYER_TYPE_FULLSCREEN) {
4723 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP"
4724 "(fullscreen surface but not top)", usurf->surfaceid);
4730 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP"
4731 "(not fullscreen surface)", usurf->surfaceid);
4733 case SHELL_FULLSCREEN_SET: /* change surface to full screen */
4734 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_SET", usurf->surfaceid);
4735 if (usurf->layertype != LAYER_TYPE_FULLSCREEN) {
4736 usurf->old_layertype = usurf->layertype;
4737 usurf->layertype = LAYER_TYPE_FULLSCREEN;
4738 usurf->old_layer = usurf->win_layer;
4739 /* send hint event to HomeScreen */
4740 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
4741 usurf, usurf->x, usurf->y,
4742 usurf->width, usurf->height, 1);
4745 case SHELL_FULLSCREEN_UNSET: /* change surface to normal screen */
4746 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_UNSET", usurf->surfaceid);
4747 if (usurf->layertype == LAYER_TYPE_FULLSCREEN) {
4748 ico_window_mgr_set_visible(usurf, 2);
4749 usurf->layertype = usurf->old_layertype;
4750 win_mgr_set_layer(usurf, usurf->old_layer->layer);
4751 win_mgr_change_surface(usurf->surface, -1, 1);
4752 /* send event to HomeScreen */
4753 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
4754 usurf, usurf->x, usurf->y,
4755 usurf->width, usurf->height, 0);
4758 case SHELL_FULLSCREEN_CONF: /* configure full screen surface */
4759 uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_CONF", usurf->surfaceid);
4760 if (usurf->mapped == 0) {
4761 width = usurf->node_tbl->disp_width;
4762 height = usurf->node_tbl->disp_height;
4765 win_mgr_surface_map(usurf->surface, &width, &height, &sx, &sy);
4769 uifw_trace("win_mgr_fullscreen: Leave(unknown event %d)", event);
4772 uifw_trace("win_mgr_fullscreen: Leave");
4776 /*--------------------------------------------------------------------------*/
4778 * @brief win_mgr_reset_focus: reset surface focus
4780 * @param[in] usurf UIFW surface
4783 /*--------------------------------------------------------------------------*/
4785 win_mgr_reset_focus(struct uifw_win_surface *usurf)
4787 struct weston_seat *seat;
4788 struct weston_surface *surface;
4790 uifw_trace("win_mgr_reset_focus: Enter(%08x)", usurf->surfaceid);
4792 seat = container_of (_ico_win_mgr->compositor->seat_list.next, struct weston_seat, link);
4793 surface = usurf->surface;
4794 if ((seat != NULL) && (surface != NULL)) {
4795 #if 0 /* pointer grab can not release */
4796 /* reset pointer focus */
4797 if ((seat->pointer != NULL) && (seat->pointer->focus == surface)) {
4798 weston_pointer_set_focus(seat->pointer, NULL,
4799 wl_fixed_from_int(0), wl_fixed_from_int(0));
4801 /* reset touch focus */
4802 if ((seat->touch != NULL) && (seat->touch->focus == surface)) {
4803 weston_touch_set_focus(seat, NULL);
4805 #endif /* pointer grab can not release */
4806 /* reset keyboard focus */
4807 if ((seat->keyboard != NULL) && (seat->keyboard->focus == surface)) {
4808 weston_keyboard_set_focus(seat->keyboard, NULL);
4811 uifw_trace("win_mgr_reset_focus: Leave");
4814 /*--------------------------------------------------------------------------*/
4816 * @brief ico_window_mgr_set_visible: change surface visibility
4818 * @param[in] usurf UIFW surface
4819 * @param[in] visible bit 0: visible(=1)/unvisible(=0)
4820 * bit 1: width anima(=1)/without anima(=0)
4823 /*--------------------------------------------------------------------------*/
4825 ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible)
4830 if ((usurf->visible == 0) ||
4831 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
4832 uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x) x/y=%d/%d",
4833 usurf->surfaceid, usurf->x, usurf->y);
4835 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
4836 usurf->width, usurf->height);
4837 if ((visible & 2) && (win_mgr_hook_animation != NULL)) {
4838 usurf->animation.pos_x = usurf->x;
4839 usurf->animation.pos_y = usurf->y;
4840 usurf->animation.pos_width = usurf->width;
4841 usurf->animation.pos_height = usurf->height;
4842 usurf->animation.no_configure = 0;
4843 retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW,
4845 uifw_trace("ico_window_mgr_set_visible: show animation = %d", retanima);
4847 /* change unvisible to visible, restack surface list */
4848 ico_window_mgr_restack_layer(usurf);
4852 if ((usurf->visible != 0) ||
4853 (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) {
4855 uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)",
4859 win_mgr_reset_focus(usurf);
4861 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
4862 if ((visible & 2) && (win_mgr_hook_animation != NULL)) {
4863 usurf->animation.pos_x = usurf->x;
4864 usurf->animation.pos_y = usurf->y;
4865 usurf->animation.pos_width = usurf->width;
4866 usurf->animation.pos_height = usurf->height;
4867 usurf->animation.no_configure = 0;
4868 retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE,
4870 uifw_trace("ico_window_mgr_set_visible: hide animation = %d", retanima);
4871 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
4873 /* Weston surface configure */
4874 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
4875 usurf->width, usurf->height);
4880 /* Weston surface configure */
4881 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
4882 usurf->width, usurf->height);
4884 ico_window_mgr_restack_layer(usurf);
4887 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
4888 usurf, usurf->visible, usurf->raise, 0, 0, 0);
4891 /*--------------------------------------------------------------------------*/
4893 * @brief win_mgr_set_raise: change surface raise/lower
4895 * @param[in] usurf UIFW surface
4896 * @param[in] raise raise(=1)/lower(0)
4899 /*--------------------------------------------------------------------------*/
4901 win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise)
4903 struct uifw_win_surface *eu;
4905 uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%d type=%x",
4906 (int)usurf, raise, (int)usurf->win_layer->layer, usurf->layertype);
4908 wl_list_remove(&usurf->ivi_layer);
4910 /* raise ... surface stack to top of layer */
4911 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
4912 /* if input panel, top of surface list */
4913 uifw_trace("win_mgr_set_raise: Raise Link to Top(InputPanel)");
4914 wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer);
4917 /* if not input panel, search not input panel */
4918 wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) {
4919 if (eu->layertype != LAYER_TYPE_INPUTPANEL) break;
4921 uifw_trace("win_mgr_set_raise: Raise Link to Top(Normal)");
4922 wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer);
4927 /* Lower ... surface stack to bottom of layer */
4928 if (usurf->layertype == LAYER_TYPE_INPUTPANEL) {
4929 /* if input panel, search not input panel */
4930 uifw_trace("win_mgr_set_raise: Lower Link to Bottom(InputPanel)");
4931 wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) {
4932 if (eu->layertype != LAYER_TYPE_INPUTPANEL) break;
4934 wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer);
4937 /* if not input panel, bottom of surface list */
4938 uifw_trace("win_mgr_set_raise: Lower Link to Bottom(Normal)");
4939 wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer);
4944 /* rebild compositor surface list */
4945 if ((raise & 2) == 0) {
4946 if (usurf->visible) {
4947 ico_window_mgr_restack_layer(usurf);
4949 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
4950 usurf, usurf->visible, usurf->raise, 0, 0,0);
4952 uifw_trace("win_mgr_set_raise: Leave");
4955 /*--------------------------------------------------------------------------*/
4957 * @brief win_mgr_destroy_surface: surface destroy
4959 * @param[in] surface Weston surface
4962 /*--------------------------------------------------------------------------*/
4964 win_mgr_destroy_surface(struct weston_surface *surface)
4966 struct uifw_win_surface *usurf;
4967 struct uifw_win_surface *phash;
4968 struct uifw_win_surface *bhash;
4971 usurf = find_uifw_win_surface_by_ws(surface);
4973 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
4976 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
4979 win_mgr_reset_focus(usurf);
4981 /* destory input region */
4982 if (win_mgr_hook_destory) {
4983 (*win_mgr_hook_destory)(usurf);
4987 if (&usurf->surf_map != usurf->surf_map.next) {
4988 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
4991 /* destroy active surface */
4992 if (usurf == _ico_win_mgr->active_pointer_usurf) {
4993 _ico_win_mgr->active_pointer_usurf = NULL;
4995 if (usurf == _ico_win_mgr->active_keyboard_usurf) {
4996 _ico_win_mgr->active_keyboard_usurf = NULL;
4999 /* destroy animation extenson */
5000 if (win_mgr_hook_animation) {
5001 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
5004 /* delete from layer list */
5005 wl_list_remove(&usurf->ivi_layer);
5006 ico_window_mgr_restack_layer(NULL);
5008 /* delete from cleint list */
5009 wl_list_remove(&usurf->client_link);
5011 /* delete from hash table */
5012 hash = MAKE_IDHASH(usurf->surfaceid);
5013 phash = _ico_win_mgr->idhash[hash];
5015 while ((phash) && (phash != usurf)) {
5017 phash = phash->next_idhash;
5020 bhash->next_idhash = usurf->next_idhash;
5023 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
5026 hash = MAKE_WSHASH(usurf->surface);
5027 phash = _ico_win_mgr->wshash[hash];
5029 while ((phash) && (phash != usurf)) {
5031 phash = phash->next_wshash;
5034 bhash->next_wshash = usurf->next_wshash;
5037 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
5040 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED,
5043 hash = usurf->surfaceid & SURCAFE_ID_MASK;
5044 _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16));
5047 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
5050 /*--------------------------------------------------------------------------*/
5052 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
5054 * @param[in] client client
5055 * @param[in] data user data(unused)
5056 * @param[in] version protocol version(unused)
5057 * @param[in] id client object id
5060 /*--------------------------------------------------------------------------*/
5062 bind_ico_win_mgr(struct wl_client *client,
5063 void *data, uint32_t version, uint32_t id)
5065 struct wl_resource *add_resource;
5066 struct uifw_manager *mgr;
5067 struct uifw_client *uclient;
5069 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
5071 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
5073 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
5074 _ico_win_mgr, unbind_ico_win_mgr);
5077 /* Create client management tabel */
5078 uclient = ico_window_mgr_find_uclient(client);
5080 win_mgr_bind_client(client, NULL);
5081 uclient = ico_window_mgr_find_uclient(client);
5085 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
5087 uifw_error("bind_ico_win_mgr: Error, No Memory");
5090 memset(mgr, 0, sizeof(struct uifw_manager));
5091 mgr->resource = add_resource;
5095 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
5097 uifw_trace("bind_ico_win_mgr: Leave");
5100 /*--------------------------------------------------------------------------*/
5102 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
5104 * @param[in] resource client resource
5107 /*--------------------------------------------------------------------------*/
5109 unbind_ico_win_mgr(struct wl_resource *resource)
5111 struct uifw_manager *mgr, *itmp;
5113 uifw_trace("unbind_ico_win_mgr: Enter");
5115 /* Remove manager from manager list */
5116 _ico_win_mgr->num_manager = 0;
5117 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
5118 if (mgr->resource == resource) {
5119 wl_list_remove(&mgr->link);
5124 _ico_win_mgr->num_manager++;
5128 uifw_trace("unbind_ico_win_mgr: Leave");
5131 /*--------------------------------------------------------------------------*/
5133 * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen)
5135 * @param[in] event event code(if -1, not send event)
5136 * @param[in] usurf UIFW surface table
5137 * @param[in] param1 parameter 1
5139 * @param[in] param5 parameter 5
5140 * @return number of managers
5141 * @retval > 0 number of managers
5142 * @retval 0 manager not exist
5144 /*--------------------------------------------------------------------------*/
5146 ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
5147 const int param1, const int param2, const int param3,
5148 const int param4, const int param5)
5151 struct uifw_manager* mgr;
5153 /* if DESTROY and no send CREATE, Nop */
5154 if ((event == ICO_WINDOW_MGR_WINDOW_DESTROYED) &&
5155 (usurf != NULL) && (usurf->created == 0)) {
5159 /* if appid not fix, check and fix appid */
5160 if ((usurf != NULL) &&
5161 (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) {
5162 win_mgr_get_client_appid(usurf->uclient);
5165 /* send created if not send created event */
5166 if ((usurf != NULL) && (usurf->created == 0) &&
5167 (((usurf->width > 0) && (usurf->height > 0)) ||
5168 ((event != ICO_WINDOW_MGR_WINDOW_CREATED) &&
5169 (event != ICO_WINDOW_MGR_WINDOW_NAME)))) {
5170 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
5172 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED"
5173 "(surf=%08x,name=%s,pid=%d,appid=%s,type=%x)", (int)mgr->resource,
5174 usurf->surfaceid, usurf->winname, usurf->uclient->pid,
5175 usurf->uclient->appid, usurf->layertype);
5176 ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid,
5177 usurf->winname, usurf->uclient->pid,
5178 usurf->uclient->appid,
5179 usurf->layertype << 12);
5185 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
5190 case ICO_WINDOW_MGR_WINDOW_CREATED:
5191 /* Do nothing anymore because sended window create event */
5194 case ICO_WINDOW_MGR_WINDOW_NAME:
5195 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME"
5196 "(surf=%08x,name=%s)", (int)mgr->resource,
5197 usurf->surfaceid, usurf->winname);
5198 ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid,
5202 case ICO_WINDOW_MGR_WINDOW_DESTROYED:
5203 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED"
5204 "(surf=%08x)", (int)mgr->resource, usurf->surfaceid);
5205 ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid);
5208 case ICO_WINDOW_MGR_WINDOW_VISIBLE:
5209 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE"
5210 "(surf=%08x,vis=%d,raise=%d,hint=%d)",
5211 (int)mgr->resource, usurf->surfaceid, param1, param2, param3);
5212 ico_window_mgr_send_window_visible(mgr->resource,
5213 usurf->surfaceid, param1, param2, param3);
5216 case ICO_WINDOW_MGR_WINDOW_CONFIGURE:
5217 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE"
5218 "(surf=%08x,app=%s,node=%x,type=%x,layer=%d,"
5219 "x/y=%d/%d,w/h=%d/%d,hint=%d)",
5220 (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid,
5221 usurf->node_tbl->node, usurf->layertype,
5222 usurf->win_layer->layer, param1, param2, param3, param4, param5);
5223 ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid,
5224 usurf->node_tbl->node,
5225 usurf->layertype << 12,
5226 usurf->win_layer->layer,
5227 param1, param2, param3, param4, param5);
5230 case ICO_WINDOW_MGR_WINDOW_ACTIVE:
5231 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE"
5232 "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid,
5234 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
5238 case ICO_WINDOW_MGR_LAYER_VISIBLE:
5239 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE"
5240 "(layer=%d,visivle=%d)", (int)mgr->resource, param1, param2);
5241 ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2);
5245 uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event);
5253 /*--------------------------------------------------------------------------*/
5255 * @brief win_mgr_set_scale: set surface transform scale
5257 * @param[in] usurf UIFW surface
5258 * @return chagne display
5259 * @retval =1 change display
5260 * @retval =0 no change
5262 /*--------------------------------------------------------------------------*/
5264 win_mgr_set_scale(struct uifw_win_surface *usurf)
5266 struct weston_surface *es;
5267 struct weston_view *ev;
5272 es = usurf->surface;
5273 if ((es != NULL) && (es->buffer_ref.buffer)) {
5274 if (usurf->client_width == 0) usurf->client_width = es->width;
5275 if (usurf->client_height == 0) usurf->client_height = es->height;
5276 if ((usurf->client_width > 0) && (usurf->client_height > 0)) {
5277 scalex = (float)usurf->width / (float)usurf->client_width;
5278 scaley = (float)usurf->height / (float)usurf->client_height;
5284 uifw_debug("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)",
5285 usurf->surfaceid, scalex, usurf->width, usurf->client_width,
5286 scaley, usurf->height, usurf->client_height);
5289 if ((ico_ivi_optionflag() & ICO_IVI_OPTION_FIXED_ASPECT) ||
5290 (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT)) {
5291 if (scalex > scaley) {
5293 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) {
5294 usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex);
5295 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) {
5300 else if (scalex < scaley) {
5302 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) {
5303 usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley);
5304 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) {
5309 uifw_debug("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d",
5310 usurf->surfaceid, usurf->xadd, usurf->yadd);
5312 if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) {
5313 usurf->scalex = scalex;
5314 usurf->scaley = scaley;
5315 ev = ico_ivi_get_primary_view(usurf);
5316 if ((scalex != 1.0f) || (scaley != 1.0f)) {
5317 weston_matrix_init(&usurf->transform.matrix);
5318 weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f);
5319 uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform);
5320 if (usurf->set_transform == 0) {
5321 usurf->set_transform = 1;
5322 wl_list_init(&usurf->transform.link);
5323 wl_list_insert(&ev->geometry.transformation_list, &usurf->transform.link);
5326 else if (usurf->set_transform != 0) {
5327 uifw_trace("win_mgr_set_scale: reset transform");
5328 usurf->set_transform = 0;
5329 wl_list_remove(&usurf->transform.link);
5331 weston_view_geometry_dirty(ev);
5332 weston_view_update_transform(ev);
5333 weston_view_damage_below(ev);
5334 weston_surface_damage(es);
5341 /*--------------------------------------------------------------------------*/
5343 * @brief ico_window_mgr_get_uclient: get UIFW client table
5345 * @param[in] appid application Id
5346 * @return UIFW client table
5347 * @retval !=NULL success(UIFW client table address)
5348 * @retval = NULL error(appid not exist)
5350 /*--------------------------------------------------------------------------*/
5351 WL_EXPORT struct uifw_client *
5352 ico_window_mgr_get_uclient(const char *appid)
5354 struct uifw_client *uclient;
5356 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
5357 if (strcmp(uclient->appid, appid) == 0) {
5364 /*--------------------------------------------------------------------------*/
5366 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
5368 * @param[in] target surface window name and application Id(winname@appid)
5369 * @return UIFW surface table
5370 * @retval !=NULL success(UIFW surface table address)
5371 * @retval = NULL error(appid or winname not exist)
5373 /*--------------------------------------------------------------------------*/
5374 WL_EXPORT struct uifw_win_surface *
5375 ico_window_mgr_get_client_usurf(const char *target)
5377 struct uifw_client *uclient;
5378 struct uifw_win_surface *usurf;
5380 char winname[ICO_IVI_WINNAME_LENGTH];
5381 char appid[ICO_IVI_APPID_LENGTH];
5383 /* get window name and application id */
5385 for (i = 0; target[i]; i++) {
5386 if (target[i] == '@') {
5387 if (target[i+1] != '@') break;
5390 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
5391 winname[j++] = target[i];
5395 if (target[i] == '@') {
5403 for ( ; target[i]; i++) {
5404 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
5405 if (j < (ICO_IVI_APPID_LENGTH-1)) {
5406 appid[j++] = target[i];
5410 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
5411 target, appid, winname);
5413 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
5414 if (strcmp(uclient->appid, appid) == 0) {
5415 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
5416 if ((winname[0] == 0) ||
5417 (strcmp(winname, usurf->winname) == 0)) {
5426 /*--------------------------------------------------------------------------*/
5428 * @brief ico_window_mgr_is_visible: check surface visible
5430 * @param[in] usurf UIFW surface
5431 * @return visibility
5432 * @retval =1 visible
5433 * @retval =0 not visible
5434 * @retval =-1 surface visible but layer not vlsible
5435 * @retval =-2 surface visible but lower(currently not support)
5437 /*--------------------------------------------------------------------------*/
5439 ico_window_mgr_is_visible(struct uifw_win_surface *usurf)
5441 if ((usurf->visible == 0) || (usurf->surface == NULL) || (usurf->mapped == 0)) {
5444 if (usurf->win_layer->visible == 0) {
5450 /*--------------------------------------------------------------------------*/
5452 * @brief ico_window_mgr_active_surface: set active surface
5454 * @param[in] surface Weston surface
5457 /*--------------------------------------------------------------------------*/
5459 ico_window_mgr_active_surface(struct weston_surface *surface)
5461 struct uifw_win_surface *usurf;
5464 usurf = find_uifw_win_surface_by_ws(surface);
5466 uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", (int)surface);
5467 uifw_trace("ico_window_mgr_active_surface: Leave(Not Exist)");
5470 uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", usurf->surfaceid);
5472 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
5473 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
5475 /* set weston active surface */
5476 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
5477 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
5478 /* send active event to manager */
5479 (void) ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
5480 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0);
5482 uifw_trace("ico_window_mgr_active_surface: Leave(OK)");
5485 /*--------------------------------------------------------------------------*/
5487 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
5489 * @param[in] hook_animation hook routine
5492 /*--------------------------------------------------------------------------*/
5494 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
5496 win_mgr_hook_animation = hook_animation;
5499 /*--------------------------------------------------------------------------*/
5501 * @brief ico_window_mgr_set_hook_change: set input region hook routine
5503 * @param[in] hook_change hook routine
5506 /*--------------------------------------------------------------------------*/
5508 ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf))
5510 win_mgr_hook_change = hook_change;
5513 /*--------------------------------------------------------------------------*/
5515 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
5517 * @param[in] hook_destroy hook routine
5520 /*--------------------------------------------------------------------------*/
5522 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
5524 win_mgr_hook_destory = hook_destroy;
5527 /*--------------------------------------------------------------------------*/
5529 * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine
5531 * @param[in] hook_inputregion hook routine
5534 /*--------------------------------------------------------------------------*/
5536 ico_window_mgr_set_hook_inputregion(
5537 void (*hook_inputregion)(int set, struct uifw_win_surface *usurf,
5538 int32_t x, int32_t y, int32_t width,
5539 int32_t height, int32_t hotspot_x, int32_t hotspot_y,
5540 int32_t cursor_x, int32_t cursor_y, int32_t cursor_width,
5541 int32_t cursor_height, uint32_t attr))
5543 win_mgr_hook_inputregion = hook_inputregion;
5546 /*--------------------------------------------------------------------------*/
5548 * @brief module_init: initialize ico_window_mgr
5549 * this function called from ico_pluign_loader
5551 * @param[in] es weston compositor
5552 * @param[in] argc number of arguments(unused)
5553 * @param[in] argv argument list(unused)
5558 /*--------------------------------------------------------------------------*/
5560 module_init(struct weston_compositor *ec, int *argc, char *argv[])
5565 struct weston_output *output;
5566 struct weston_config_section *section;
5567 char *displayno = NULL;
5570 char wkbuf[ICO_UIFW_MAX_SUBJECT_NAME];
5571 struct ico_api_permit *accp;
5572 struct ico_api_permit *accp_next;
5574 struct wl_event_loop *loop;
5576 uifw_info("ico_window_mgr: Enter(module_init)");
5578 /* get ivi debug level */
5579 section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL);
5581 weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0);
5582 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
5585 /* get display number */
5586 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
5588 weston_config_section_get_string(section, "displayno", &displayno, NULL);
5589 weston_config_section_get_int(section, "inputpanel",
5590 &_ico_ivi_inputpanel_display, 0);
5594 section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL);
5596 weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1);
5597 weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0);
5598 weston_config_section_get_int(section, "touch", &_ico_ivi_touch_layer, 101);
5599 weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102);
5600 weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 103);
5601 weston_config_section_get_string(section, "inputpaneldeco", &wrkstrp, NULL);
5603 p = strtok(wrkstrp, ";,");
5605 _ico_ivi_inputdeco_mag = strtol(p, (char **)0, 0);
5606 p = strtok(NULL, ";,");
5608 _ico_ivi_inputdeco_diff = strtol(p, (char **)0, 0);
5614 if (_ico_ivi_inputdeco_mag < 20) _ico_ivi_inputdeco_mag = 100;
5616 /* get animation default */
5617 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
5619 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
5620 weston_config_section_get_string(section, "inputpanel",
5621 &_ico_ivi_inputpanel_animation, NULL);
5622 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500);
5623 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30);
5624 if (_ico_ivi_animation_name) {
5625 p = strtok(_ico_ivi_animation_name, ";,");
5627 p = strtok(NULL, ";.");
5629 _ico_ivi_animation_time = strtol(p, (char **)0, 0);
5630 p = strtok(NULL, ";.");
5632 _ico_ivi_animation_fps = strtol(p, (char **)0, 0);
5637 if (_ico_ivi_inputpanel_animation) {
5638 p = strtok(_ico_ivi_inputpanel_animation, ";,");
5640 p = strtok(NULL, ",;");
5642 _ico_ivi_inputpanel_anima_time = strtol(p, (char **)0, 0);
5647 if (_ico_ivi_animation_name == NULL)
5648 _ico_ivi_animation_name = (char *)"fade";
5649 if (_ico_ivi_inputpanel_animation == NULL)
5650 _ico_ivi_inputpanel_animation = (char *)"fade";
5651 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500;
5652 if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30;
5653 if (_ico_ivi_inputpanel_anima_time < 100)
5654 _ico_ivi_inputpanel_anima_time = _ico_ivi_animation_time;
5656 /* get thumbnail maximum frame rate */
5657 section = weston_config_get_section(ec->config, "ivi-thumbnail", NULL, NULL);
5659 weston_config_section_get_int(section, "gpu_accel_fps",
5660 &_ico_ivi_map_framerate_gpu, 30);
5661 if ((_ico_ivi_map_framerate_gpu <= 0) || (_ico_ivi_map_framerate_gpu > 60)) {
5662 _ico_ivi_map_framerate_gpu = 30;
5664 weston_config_section_get_int(section, "shm_buffer_fps",
5665 &_ico_ivi_map_framerate_shm, 5);
5666 if ((_ico_ivi_map_framerate_shm <= 0) || (_ico_ivi_map_framerate_shm > 10)) {
5667 _ico_ivi_map_framerate_shm = 5;
5669 weston_config_section_get_int(section, "no_accel_fps",
5670 &_ico_ivi_map_framerate_pixel, 10);
5671 if ((_ico_ivi_map_framerate_pixel <= 0) || (_ico_ivi_map_framerate_pixel > 20)) {
5672 _ico_ivi_map_framerate_pixel = 10;
5676 /* create ico_window_mgr management table */
5677 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
5678 if (_ico_win_mgr == NULL) {
5679 uifw_error("ico_window_mgr: malloc failed");
5683 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
5685 /* get access control configuration */
5686 section = weston_config_get_section(ec->config, "ivi-access-control", NULL, NULL);
5689 for (idx = 0; ; idx++) {
5690 sprintf(wkbuf, "access_api.%d", idx);
5691 weston_config_section_get_string(section, wkbuf, &wrkstrp, NULL);
5692 if (wrkstrp == NULL) {
5693 if (idx <= 0) continue;
5697 for (i = 0; i < (ICO_UIFW_MAX_SUBJECT_NAME-1); i++, p++) {
5698 if ((*p == 0) || (*p == ';')) break;
5701 if ((i <= 0) || (*p == 0)) {
5702 uifw_error("ico_window_mgr: illegal config format[%s]", wrkstrp);
5707 accp = _ico_win_mgr->access_config;
5709 if (strcmp(wkbuf, accp->permit.subject) == 0) break;
5713 accp = (struct ico_api_permit *) malloc(sizeof(struct ico_api_permit));
5715 uifw_error("ico_window_mgr: malloc failed");
5719 memset(accp, 0, sizeof(struct ico_api_permit));
5720 strcpy(accp->permit.subject, wkbuf);
5728 for (p++; (*p != 0) && (*p != ','); p++) ;
5729 if ((strcasecmp(pp, "all") == 0) || (strcmp(pp, "*") == 0)) {
5730 accp->permit.api_permit = 0xffffffff;
5733 if (strncasecmp(pp, "ico_", 4) == 0) pp += 4;
5734 if (strncasecmp(pp, "window_mgr_", 11) == 0) pp += 11;
5735 if (strncasecmp(pp, "input_mgr_", 10) == 0) pp += 10;
5736 if (strncasecmp(pp, "exinput_", 8) == 0) pp += 8;
5737 for (i = 0; access_api_table[i].name[0]; i++) {
5738 if (strncasecmp(pp, access_api_table[i].name, p - pp) == 0) {
5739 accp->permit.api_permit |= access_api_table[i].api;
5746 if (same_accp == 0) {
5748 accp_next->next = accp;
5751 _ico_win_mgr->access_config = accp;
5755 if (strcmp(accp->permit.subject, "*") == 0) {
5756 _ico_win_mgr->default_access |= accp->permit.api_permit;
5759 accp = _ico_win_mgr->access_config;
5761 accp->permit.api_permit |= _ico_win_mgr->default_access;
5766 uifw_trace("ico_window_mgr: no access control in weston.ini");
5769 _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8);
5770 if (! _ico_win_mgr->surfaceid_map) {
5771 uifw_error("ico_window_mgr: malloc failed");
5774 memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8);
5776 _ico_win_mgr->compositor = ec;
5778 _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS;
5779 _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS;
5781 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
5782 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
5783 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
5784 uifw_error("ico_window_mgr: Error(wl_global_create)");
5788 wl_list_init(&_ico_win_mgr->client_list);
5789 wl_list_init(&_ico_win_mgr->manager_list);
5790 wl_list_init(&_ico_win_mgr->ivi_layer_list);
5791 wl_list_init(&_ico_win_mgr->map_list);
5793 _ico_win_mgr->free_maptable = NULL;
5795 /* create display list */
5796 if (displayno != NULL) {
5803 wl_list_for_each (output, &ec->output_list, link) {
5804 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
5805 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurface;
5806 wl_list_insert(output->animation_list.prev,
5807 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
5809 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
5811 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
5813 wl_list_for_each (output, &ec->output_list, link) {
5816 idx = strtol(p, (char **)0, 0);
5817 uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx);
5819 if ((idx < 0) || (idx >= _ico_num_nodes)) {
5826 if (_ico_node_table[idx].node) {
5827 for (idx = 0; idx < _ico_num_nodes; idx++) {
5828 if (_ico_node_table[idx].node == 0) break;
5830 if (idx >= _ico_num_nodes) {
5831 uifw_error("ico_window_mgr: number of display overflow");
5835 _ico_node_table[idx].node = idx + 0x100;
5836 _ico_node_table[idx].displayno = i;
5837 _ico_node_table[idx].output = output;
5838 _ico_node_table[idx].disp_x = output->x;
5839 _ico_node_table[idx].disp_y = output->y;
5840 _ico_node_table[idx].disp_width = output->width;
5841 _ico_node_table[idx].disp_height = output->height;
5843 if (i >= _ico_num_nodes) break;
5846 for (i = 0; i < _ico_num_nodes; i++) {
5847 _ico_node_table[i].node &= 0x0ff;
5848 uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
5849 i, _ico_node_table[i].displayno,
5850 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
5851 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
5853 if (displayno) free(displayno);
5855 if (_ico_ivi_inputpanel_display >= _ico_num_nodes) {
5856 _ico_ivi_inputpanel_display = 0;
5858 uifw_info("ico_window_mgr: inputpanel_display=%d", _ico_ivi_inputpanel_display);
5860 /* set default display to ico_ivi_shell */
5861 ivi_shell_set_default_display(_ico_node_table[_ico_ivi_inputpanel_display].output);
5863 /* my node Id ... this version fixed 0 */
5864 nodeId = ico_ivi_get_mynode();
5866 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
5867 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
5868 nodeId, _ico_win_mgr->surface_head);
5870 /* get seat for touch down counter check */
5871 touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link);
5872 loop = wl_display_get_event_loop(ec->wl_display);
5873 _ico_win_mgr->wait_mapevent =
5874 wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL);
5875 wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000);
5877 /* Hook to IVI-Shell */
5878 ico_ivi_shell_hook_bind(win_mgr_bind_client);
5879 ico_ivi_shell_hook_unbind(win_mgr_unbind_client);
5880 ico_ivi_shell_hook_create(win_mgr_register_surface);
5881 ico_ivi_shell_hook_destroy(win_mgr_destroy_surface);
5882 ico_ivi_shell_hook_map(win_mgr_surface_map);
5883 ico_ivi_shell_hook_configure(win_mgr_shell_configure);
5884 ico_ivi_shell_hook_select(win_mgr_select_surface);
5885 ico_ivi_shell_hook_title(win_mgr_set_title);
5886 ico_ivi_shell_hook_move(win_mgr_surface_move);
5887 ico_ivi_shell_hook_show_layer(win_mgr_show_layer);
5888 ico_ivi_shell_hook_fullscreen(win_mgr_fullscreen);
5890 uifw_info("ico_window_mgr: animation name=%s/%s time=%d/%d fps=%d",
5891 _ico_ivi_animation_name, _ico_ivi_inputpanel_animation,
5892 _ico_ivi_animation_time, _ico_ivi_inputpanel_anima_time,
5893 _ico_ivi_animation_fps);
5894 uifw_info("ico_window_mgr: input panel mag=%d%% diff=%d",
5895 _ico_ivi_inputdeco_mag,_ico_ivi_inputdeco_diff);
5896 uifw_info("ico_window_mgr: layer default=%d background=%d",
5897 _ico_ivi_default_layer, _ico_ivi_background_layer);
5898 uifw_info("ico_window_mgr: layer touch=%d cursor=%d startup=%d",
5899 _ico_ivi_touch_layer, _ico_ivi_cursor_layer, _ico_ivi_startup_layer);
5900 uifw_info("ico_window_mgr: thumbnail framerate gpu_accel=%d shm_buff=%d no_accel=%d",
5901 _ico_ivi_map_framerate_gpu, _ico_ivi_map_framerate_shm,
5902 _ico_ivi_map_framerate_pixel);
5903 uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x",
5904 _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff,
5905 (_ico_ivi_debug_level >> 16) & 0x0ffff);
5906 accp = _ico_win_mgr->access_config;
5908 uifw_info("ico_window_mgr: access_control %s=%08x",
5909 accp->permit.subject, accp->permit.api_permit);
5913 /* get GPU type for H/W support of the thumbnail acquisition */
5914 if ((ico_ivi_optionflag() & ICO_IVI_OPTION_GPU_DEPEND) == 0) {
5915 /* can not use GPU H/W dependent acceleration */
5916 _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION;
5917 uifw_info("ico_window_mgr: GPU type=No Acceleration by option flag");
5920 _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION;
5922 p = (char *)glGetString(GL_RENDERER);
5924 uifw_info("ico_window_mgr: Renderer=<%s>", p);
5925 for (i = 0; ico_window_mgr_gpu_type[i].gpu_type; i++) {
5926 if (strncmp(p, ico_window_mgr_gpu_type[i].gpu_name,
5927 strlen(ico_window_mgr_gpu_type[i].gpu_name)) == 0) {
5928 _ico_ivi_gpu_type = ico_window_mgr_gpu_type[i].gpu_type;
5929 uifw_info("ico_window_mgr: GPU type=Acceleration %d", _ico_ivi_gpu_type);
5934 if (_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) {
5935 uifw_info("ico_window_mgr: GPU type=No Acceleration(can not find GPU)");
5938 uifw_info("ico_window_mgr: Leave(module_init)");