2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Multi Window Manager (Weston(Wayland) PlugIn)
37 #include <linux/input.h>
42 #include <sys/types.h>
45 #include <wayland-server.h>
50 #include <GLES2/gl2.h>
51 #include <GLES2/gl2ext.h>
53 #include <weston/compositor.h>
54 #include "ico_ivi_common.h"
55 #include "ico_ivi_shell.h"
56 #include "ico_window_mgr.h"
57 #include "desktop-shell-server-protocol.h"
58 #include "ico_window_mgr-server-protocol.h"
61 #define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */
62 #define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */
63 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId bit mask pattern */
64 #define UIFW_HASH 64 /* Hash value (2's compliment) */
66 /* Internal fixed value */
67 #define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */
68 /* show/hide animation with position */
69 #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000
71 /* wl_drm_buffer (inport from mesa-9.1.3/src/egl/wayland/wayland-drm/wayland-drm.h) */
72 struct uifw_wl_buffer {
73 struct wl_resource resource;
74 int32_t width, height;
77 struct uifw_drm_buffer {
78 struct uifw_wl_buffer buffer;
79 void *drm; /* struct wl_drm */
81 const void *driver_format;
87 /* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h) */
88 struct uifw_dri_region {
89 void *bo; /**< buffer manager's buffer */
90 uint32_t refcount; /**< Reference count for region */
91 uint32_t cpp; /**< bytes per pixel */
92 uint32_t width; /**< in pixels */
93 uint32_t height; /**< in pixels */
94 uint32_t pitch; /**< in bytes */
95 char *map; /**< only non-NULL when region is actually mapped */
96 uint32_t map_refcount; /**< Reference count for mapping */
97 uint32_t tiling; /**< Which tiling mode the region is in */
98 uint32_t name; /**< Global name for the bo */
99 void *screen; /* screen */
101 struct uifw_dri_image {
102 struct uifw_dri_region *region;
109 void *planar_format; /* image_format */
113 /* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c) */
119 struct uifw_gl_surface_state {
121 struct gl_shader *shader;
125 int needs_full_upload;
126 pixman_region32_t texture_damage;
128 void *images[3]; /* EGLImageKHR */
132 struct weston_buffer_reference buffer_ref;
133 enum buffer_type buffer_type;
134 int pitch; /* in pixels */
135 int height; /* in pixels */
138 /* Multi Windiw Manager */
140 struct weston_compositor *compositor; /* Weston compositor */
141 void *shell; /* shell(ico_ivi_shell) table address */
142 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
144 struct wl_list client_list; /* Clients */
145 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
146 int num_manager; /* Number of managers */
147 struct wl_list ivi_layer_list; /* Layer management table list */
148 struct wl_list map_list; /* surface map list */
149 struct uifw_surface_map *free_maptable; /* free maped surface table list */
150 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
151 /* animation for map check */
152 struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */
153 struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */
155 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
156 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
158 uint32_t surfaceid_count; /* Number of surface id */
159 uint32_t surfaceid_max; /* Maximum number of surface id */
160 uint16_t *surfaceid_map; /* SurfaceId assign bit map */
162 char shell_init; /* shell initialize flag */
163 char res; /* (unused) */
166 /* Internal macros */
168 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
170 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
172 /* function prototype */
173 /* get surface table from weston surface*/
174 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
175 struct weston_surface *wsurf);
176 /* get client table from weston client */
177 static struct uifw_client* find_client_from_client(struct wl_client *client);
178 /* assign new surface id */
179 static uint32_t generate_id(void);
180 /* bind shell client */
181 static void win_mgr_bind_client(struct wl_client *client, void *shell);
182 /* unind shell client */
183 static void win_mgr_unbind_client(struct wl_client *client);
184 /* get appid from pid */
185 static void win_mgr_get_client_appid(struct uifw_client *uclient);
186 /* create new surface */
187 static void win_mgr_register_surface(
188 struct wl_client *client, struct wl_resource *resource,
189 struct weston_surface *surface, struct shell_surface *shsurf);
190 /* surface destroy */
191 static void win_mgr_destroy_surface(struct weston_surface *surface);
192 /* map new surface */
193 static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width,
194 int32_t *height, int32_t *sx, int32_t *sy);
195 /* send surface change event to manager */
196 static void win_mgr_change_surface(struct weston_surface *surface,
197 const int to, const int manager);
198 /* window manager surface configure */
199 static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
200 int x, int y, int width, int height);
201 /* shell surface configure */
202 static void win_mgr_shell_configure(struct weston_surface *surface);
204 static void win_mgr_select_surface(struct weston_surface *surface);
205 /* surface set title */
206 static void win_mgr_set_title(struct weston_surface *surface, const char *title);
207 /* surface move request from shell */
208 static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy);
210 static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise);
211 /* surface change from manager */
212 static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x,
213 const int y, const int width, const int height);
214 /* create new layer */
215 static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf,
216 const uint32_t layer);
217 /* set surface layer */
218 static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer);
219 /* set active surface */
220 static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target);
222 /* declare manager */
223 static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource,
225 /* set window layer */
226 static void uifw_set_window_layer(struct wl_client *client,
227 struct wl_resource *resource,
228 uint32_t surfaceid, uint32_t layer);
229 /* set surface size and position */
230 static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
231 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
232 int32_t width, int32_t height, int32_t flags);
233 /* show/hide and raise/lower surface */
234 static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
235 uint32_t surfaceid, int32_t visible, int32_t raise,
237 /* set surface animation */
238 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
239 uint32_t surfaceid, int32_t type,
240 const char *animation, int32_t time);
241 /* set surface attributes */
242 static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
243 uint32_t surfaceid, uint32_t attributes);
244 /* surface visibility control with animation*/
245 static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
246 uint32_t surfaceid, int32_t visible,
247 int32_t x, int32_t y, int32_t width, int32_t height);
248 /* set active surface (form HomeScreen) */
249 static void uifw_set_active(struct wl_client *client, struct wl_resource *resource,
250 uint32_t surfaceid, int32_t active);
251 /* layer visibility control */
252 static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
253 uint32_t layer, int32_t visible);
254 /* get application surfaces */
255 static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
257 /* check and change all mapped surface */
258 static void win_mgr_check_surfacemap(struct weston_animation *animation,
259 struct weston_output *output, uint32_t msecs);
260 /* check and change mapped surface */
261 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event);
262 /* map surface to system application */
263 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
264 uint32_t surfaceid, int32_t framerate);
266 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
269 static void bind_ico_win_mgr(struct wl_client *client,
270 void *data, uint32_t version, uint32_t id);
272 static void unbind_ico_win_mgr(struct wl_resource *resource);
273 /* send event to manager */
274 static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
275 const int param1, const int param2, const int param3,
276 const int param4, const int param5);
277 /* set surface transform */
278 static int win_mgr_set_scale(struct uifw_win_surface *usurf);
279 /* convert animation name to Id value */
280 static int ico_get_animation_name(const char *animation);
281 /* hook for animation */
282 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
285 /* Multi Window Manager interface */
286 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
287 uifw_declare_manager,
288 uifw_set_window_layer,
289 uifw_set_positionsize,
293 uifw_visible_animation,
295 uifw_set_layer_visible,
301 /* plugin common value(without ico_plugin_loader) */
302 static int _ico_ivi_debug_flag = 0; /* Debug flags */
303 static int _ico_ivi_debug_level = 3; /* Debug Level */
304 static char *_ico_ivi_animation_name = NULL; /* Default animation name */
305 static int _ico_ivi_animation_time = 500; /* Default animation time */
306 static int _ico_ivi_animation_fps = 15; /* Animation frame rate */
307 static int _ico_ivi_background_layer = 0; /* Background layer */
308 static int _ico_ivi_default_layer = 1; /* Deafult layer id at surface create*/
309 static int _ico_ivi_input_layer = 101; /* Input layer id */
310 static int _ico_ivi_cursor_layer = 102; /* Cursor layer id */
311 static int _ico_ivi_startup_layer = 109; /* Deafult layer id at system startup*/
313 /* static management table */
314 static struct ico_win_mgr *_ico_win_mgr = NULL;
315 static int _ico_num_nodes = 0;
316 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
319 /*--------------------------------------------------------------------------*/
321 * @brief ico_ivi_debugflag: get debug flags
324 * @return debug flags
326 /*--------------------------------------------------------------------------*/
328 ico_ivi_debugflag(void)
330 return _ico_ivi_debug_flag;
333 /*--------------------------------------------------------------------------*/
335 * @brief ico_ivi_debuglevel: answer debug output level.
338 * @return debug output level
339 * @retval 0 No debug output
340 * @retval 1 Only error output
341 * @retval 2 Error and Warning output
342 * @retval 3 Error, Warning and information output
343 * @retval 4 All output with debug write
345 /*--------------------------------------------------------------------------*/
347 ico_ivi_debuglevel(void)
349 return _ico_ivi_debug_level;
352 /*--------------------------------------------------------------------------*/
354 * @brief ico_ivi_default_animation_name: get default animation name
357 * @return Default animation name
359 /*--------------------------------------------------------------------------*/
360 WL_EXPORT const char *
361 ico_ivi_default_animation_name(void)
363 return _ico_ivi_animation_name;
366 /*--------------------------------------------------------------------------*/
368 * @brief ico_ivi_default_animation_time: get default animation time
371 * @return Default animation time(miri sec)
373 /*--------------------------------------------------------------------------*/
375 ico_ivi_default_animation_time(void)
377 return _ico_ivi_animation_time;
380 /*--------------------------------------------------------------------------*/
382 * @brief ico_ivi_default_animation_fps: get default animation frame rate
385 * @return Default animation frame rate(frames/sec)
387 /*--------------------------------------------------------------------------*/
389 ico_ivi_default_animation_fps(void)
391 return _ico_ivi_animation_fps;
394 /*--------------------------------------------------------------------------*/
396 * @brief ico_ivi_get_mynode: Get my NodeId
399 * @return NodeId of my node
401 /*--------------------------------------------------------------------------*/
403 ico_ivi_get_mynode(void)
405 /* Reference Platform 0.90 only support 1 ECU */
409 /*--------------------------------------------------------------------------*/
411 * @brief ico_window_mgr_set_weston_surface: set weston surface
413 * @param[in] usurf UIFW surface
414 * @param[in] x X coordinate on screen
415 * @param[in] y Y coordinate on screen
416 * @param[in] width width
417 * @param[in] height height
420 /*--------------------------------------------------------------------------*/
422 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
423 int x, int y, int width, int height)
425 struct weston_surface *es = usurf->surface;
426 int buf_width, buf_height;
429 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
434 if (es->buffer_ref.buffer != NULL) {
435 buf_width = weston_surface_buffer_width(es);
436 buf_height = weston_surface_buffer_height(es);
437 if ((width <= 0) || (height <= 0)) {
439 usurf->width = buf_width;
441 usurf->height = buf_height;
443 if (usurf->width > buf_width) {
445 x += (usurf->width - buf_width)/2;
447 if (usurf->height > buf_height) {
449 y += (usurf->height - buf_height)/2;
451 if (usurf->visible) {
452 x += usurf->node_tbl->disp_x;
453 y += usurf->node_tbl->disp_y;
456 x = ICO_IVI_MAX_COORDINATE+1;
457 y = ICO_IVI_MAX_COORDINATE+1;
459 if ((es->geometry.x != x) || (es->geometry.y != y) ||
460 (es->geometry.width != width) || (es->geometry.height != height)) {
461 weston_surface_damage_below(es);
462 win_mgr_surface_configure(usurf, x, y, width, height);
464 weston_surface_damage(es);
465 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
469 /*--------------------------------------------------------------------------*/
471 * @brief ico_window_mgr_set_weston_surface: set weston surface
473 * @param[in] usurf UIFW surface
474 * @param[in] x X coordinate on screen
475 * @param[in] y Y coordinate on screen
476 * @param[in] width width
477 * @param[in] height height
480 /*--------------------------------------------------------------------------*/
482 ico_window_mgr_change_surface(struct uifw_win_surface *usurf,
483 const int to, const int manager)
485 uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)",
486 usurf->surfaceid, to, manager);
487 win_mgr_change_surface(usurf->surface, to, manager);
488 uifw_trace("ico_window_mgr_change_surface: Leave");
491 /*--------------------------------------------------------------------------*/
493 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
495 * @param[in] surfaceid UIFW surface id
496 * @return UIFW surface table address
497 * @retval !=NULL success(surface table address)
498 * @retval NULL error(surface id dose not exist)
500 /*--------------------------------------------------------------------------*/
501 WL_EXPORT struct uifw_win_surface *
502 ico_window_mgr_get_usurf(const uint32_t surfaceid)
504 struct uifw_win_surface *usurf;
506 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
509 if (usurf->surfaceid == surfaceid) {
512 usurf = usurf->next_idhash;
514 uifw_trace("ico_window_mgr_get_usurf: NULL");
518 /*--------------------------------------------------------------------------*/
520 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
522 * @param[in] wsurf Weston surface
523 * @return UIFW surface table address
524 * @retval !=NULL success(surface table address)
525 * @retval NULL error(surface dose not exist)
527 /*--------------------------------------------------------------------------*/
528 static struct uifw_win_surface *
529 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
531 struct uifw_win_surface *usurf;
533 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
536 if (usurf->surface == wsurf) {
539 usurf = usurf->next_wshash;
541 uifw_trace("find_uifw_win_surface_by_ws: NULL");
545 /*--------------------------------------------------------------------------*/
547 * @brief find_client_from_client: find UIFW client by wayland client
549 * @param[in] client Wayland client
550 * @return UIFW client table address
551 * @retval !=NULL success(client table address)
552 * @retval NULL error(client dose not exist)
554 /*--------------------------------------------------------------------------*/
555 static struct uifw_client*
556 find_client_from_client(struct wl_client *client)
558 struct uifw_client *uclient;
560 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
561 if (uclient->client == client) {
565 uifw_trace("find_client_from_client: client.%08x is NULL", (int)client);
569 /*--------------------------------------------------------------------------*/
571 * @brief ico_window_mgr_get_appid: find application id by wayland client
573 * @param[in] client Wayland client
574 * @return application id
575 * @retval !=NULL success(application id)
576 * @retval NULL error(client dose not exist)
578 /*--------------------------------------------------------------------------*/
580 ico_window_mgr_get_appid(struct wl_client* client)
582 struct uifw_client *uclient;
584 uclient = find_client_from_client(client);
589 return uclient->appid;
592 /*--------------------------------------------------------------------------*/
594 * @brief generate_id: generate uniq id for UIFW surface id
597 * @return uniq id for UIFW surface id
599 /*--------------------------------------------------------------------------*/
610 _ico_win_mgr->surfaceid_count ++;
612 /* serach free id from bitmap */
613 for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) {
614 if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) {
615 _ico_win_mgr->surfaceid_count = 0;
617 if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) {
618 /* find free id from bitmap */
619 map = 1 << (_ico_win_mgr->surfaceid_count % 16);
620 for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) {
621 if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map)
623 _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map;
624 _ico_win_mgr->surfaceid_count
625 = (_ico_win_mgr->surfaceid_count/16)*16 + i;
627 surfaceId = (_ico_win_mgr->surfaceid_count + 1)
628 | _ico_win_mgr->surface_head;
629 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
635 _ico_win_mgr->surfaceid_count += 16;
638 /* no free id in bitmap, extend bitmap */
639 if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) {
640 /* too many surfaces, system error */
641 uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort",
642 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
643 fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n",
644 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
648 new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8);
649 memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8);
650 memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8);
651 _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max;
652 new_map[_ico_win_mgr->surfaceid_count/16] |= 1;
653 _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS;
654 free(_ico_win_mgr->surfaceid_map);
655 _ico_win_mgr->surfaceid_map = new_map;
657 uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)",
658 _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max);
659 surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head;
661 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
665 /*--------------------------------------------------------------------------*/
667 * @brief win_mgr_bind_client: desktop_shell from client
669 * @param[in] client Wayland client
670 * @param[in] shell shell(ico_ivi_shell) table address
673 /*--------------------------------------------------------------------------*/
675 win_mgr_bind_client(struct wl_client *client, void *shell)
677 struct uifw_client *uclient;
683 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
684 (int)client, (int)shell);
686 /* save shell table address */
688 _ico_win_mgr->shell = shell;
692 uclient = find_client_from_client(client);
694 /* client not exist, create client management table */
695 uifw_trace("win_mgr_bind_client: Create Client");
696 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
698 uifw_error("win_mgr_bind_client: Error, No Memory");
701 memset(uclient, 0, sizeof(struct uifw_client));
702 uclient->client = client;
703 wl_list_init(&uclient->surface_link);
709 wl_client_get_credentials(client, &pid, &uid, &gid);
710 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
711 (int)client, (int)pid, (int)uid, (int)gid);
713 uclient->pid = (int)pid;
714 /* get applicationId from AppCore(AUL) */
715 win_mgr_get_client_appid(uclient);
717 /* weston internal client, not manage */
718 if (strcmp(uclient->appid, "weston") == 0) {
720 uifw_trace("win_mgr_bind_client: client=%08x is internal, delete", (int)client);
722 else if (newclient > 0) {
723 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
727 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
729 uifw_trace("win_mgr_bind_client: Leave");
732 /*--------------------------------------------------------------------------*/
734 * @brief win_mgr_unbind_client: unbind desktop_shell from client
736 * @param[in] client Wayland client
739 /*--------------------------------------------------------------------------*/
741 win_mgr_unbind_client(struct wl_client *client)
743 struct uifw_client *uclient;
745 uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client);
747 uclient = find_client_from_client(client);
749 /* Client exist, Destory client management table */
750 wl_list_remove(&uclient->link);
753 uifw_trace("win_mgr_unbind_client: Leave");
756 /*--------------------------------------------------------------------------*/
758 * @brief win_mgr_get_client_appid: get applicationId from pid
760 * @param[in] uclient UIFW client management table
763 /*--------------------------------------------------------------------------*/
765 win_mgr_get_client_appid(struct uifw_client *uclient)
773 uifw_trace("win_mgr_get_client_appid: Enter(pid=%d)", uclient->pid);
775 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
776 i = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
777 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
778 "pid=%d appid=<%s>", i, uclient->pid, uclient->appid);
779 if (uclient->appid[0] != 0) {
780 /* OK, end of get appid */
781 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
784 uclient->fixed_appid ++;
785 /* client dose not exist in AppCore, search Linux process table */
786 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in AppCore(AUL)",
789 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
790 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
791 fd = open(procpath, O_RDONLY);
793 size = read(fd, procpath, sizeof(procpath));
794 for (; size > 0; size--) {
795 if (procpath[size-1]) break;
798 /* get program base name */
800 for (j = 0; j < size; j++) {
801 if (procpath[j] == 0) break;
802 if (procpath[j] == '/') i = j + 1;
805 for (; i < size; i++) {
806 uclient->appid[j] = procpath[i];
807 if ((uclient->appid[j] == 0) ||
808 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
811 /* search application number in apprication start option */
812 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
813 for (; i < size; i++) {
814 if ((procpath[i] == 0) &&
815 (procpath[i+1] == '@')) {
816 strncpy(&uclient->appid[j], &procpath[i+1],
817 ICO_IVI_APPID_LENGTH - j - 2);
824 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
825 if (uclient->appid[i] != ' ') break;
827 uclient->appid[i+1] = 0;
828 if (uclient->appid[0]) {
829 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
830 "Process table", uclient->pid, uclient->appid);
833 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
835 sprintf(uclient->appid, "?%d?", uclient->pid);
838 uifw_trace("win_mgr_get_client_appid: Leave(pid=%d,appid=%s)",
839 uclient->pid, uclient->appid);
842 /*--------------------------------------------------------------------------*/
844 * @brief ico_get_animation_name: convert animation name to Id value
846 * @param[in] animation animation name
847 * @return animation Id value
849 /*--------------------------------------------------------------------------*/
851 ico_get_animation_name(const char *animation)
853 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
855 if (strcasecmp(animation, "none") == 0) {
856 return ICO_WINDOW_MGR_ANIMATION_NONE;
859 if (win_mgr_hook_animation) {
860 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
863 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
868 /*--------------------------------------------------------------------------*/
870 * @brief win_mgr_register_surface: create UIFW surface
872 * @param[in] client Wayland client
873 * @param[in] resource client resource
874 * @param[in] surface Weston surface
875 * @param[in] shsurf shell surface
878 /*--------------------------------------------------------------------------*/
880 win_mgr_register_surface(struct wl_client *client, struct wl_resource *resource,
881 struct weston_surface *surface, struct shell_surface *shsurf)
883 struct uifw_win_surface *usurf;
884 struct uifw_win_surface *phash;
885 struct uifw_win_surface *bhash;
888 uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x)",
889 (int)surface, (int)client, (int)resource);
891 /* check new surface */
892 if (find_uifw_win_surface_by_ws(surface)) {
893 /* surface exist, NOP */
894 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
898 /* set default color and shader */
899 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
901 /* create UIFW surface management table */
902 usurf = malloc(sizeof(struct uifw_win_surface));
904 uifw_error("win_mgr_register_surface: No Memory");
908 memset(usurf, 0, sizeof(struct uifw_win_surface));
910 usurf->surfaceid = generate_id();
911 usurf->surface = surface;
912 usurf->shsurf = shsurf;
913 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
914 wl_list_init(&usurf->ivi_layer);
915 wl_list_init(&usurf->client_link);
916 wl_list_init(&usurf->animation.animation.link);
917 wl_list_init(&usurf->surf_map);
918 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
919 usurf->animation.hide_time = ico_ivi_default_animation_time();;
920 usurf->animation.show_anima = usurf->animation.hide_anima;
921 usurf->animation.show_time = usurf->animation.hide_time;
922 usurf->animation.move_anima = usurf->animation.hide_anima;
923 usurf->animation.move_time = usurf->animation.hide_time;
924 usurf->animation.resize_anima = usurf->animation.hide_anima;
925 usurf->animation.resize_time = usurf->animation.hide_time;
927 if ((_ico_win_mgr->num_manager <= 0) ||
928 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE)) {
929 uifw_trace("win_mgr_register_surface: No Manager, Force visible");
933 uifw_trace("win_mgr_register_surface: Manager exist, Not visible");
938 usurf->uclient = find_client_from_client(client);
939 if (! usurf->uclient) {
940 /* client not exist, create client management table */
941 uifw_trace("win_mgr_register_surface: Create Client");
942 win_mgr_bind_client(client, NULL);
943 usurf->uclient = find_client_from_client(client);
944 if (! usurf->uclient) {
945 uifw_error("win_mgr_register_surface: No Memory");
949 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
951 /* make surface id hash table */
952 hash = MAKE_IDHASH(usurf->surfaceid);
953 phash = _ico_win_mgr->idhash[hash];
957 phash = phash->next_idhash;
960 bhash->next_idhash = usurf;
963 _ico_win_mgr->idhash[hash] = usurf;
966 /* make weston surface hash table */
967 hash = MAKE_WSHASH(usurf->surface);
968 phash = _ico_win_mgr->wshash[hash];
972 phash = phash->next_wshash;
975 bhash->next_wshash = usurf;
978 _ico_win_mgr->wshash[hash] = usurf;
980 /* set default layer id */
981 win_mgr_set_layer(usurf, (_ico_win_mgr->num_manager > 0) ? _ico_ivi_default_layer :
982 _ico_ivi_startup_layer);
983 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
986 /*--------------------------------------------------------------------------*/
988 * @brief win_mgr_map_surface: map surface
990 * @param[in] surface Weston surface
991 * @param[in] width surface width
992 * @param[in] height surface height
993 * @param[in] sx X coordinate on screen
994 * @param[in] sy Y coordinate on screen
997 /*--------------------------------------------------------------------------*/
999 win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height,
1000 int32_t *sx, int32_t *sy)
1002 struct uifw_win_surface *usurf;
1004 uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)",
1005 (int)surface, *sx, *sy, *width, *height);
1007 usurf = find_uifw_win_surface_by_ws(surface);
1010 uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d",
1011 usurf->surfaceid, usurf->width, usurf->height, usurf->visible);
1012 if ((usurf->width > 0) && (usurf->height > 0)) {
1013 uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize"
1014 "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d",
1015 usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height,
1017 *width = usurf->width;
1018 *height = usurf->height;
1019 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1020 usurf->node_tbl->disp_y + usurf->y,
1021 usurf->width, usurf->height);
1024 uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, "
1025 "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)",
1026 usurf->surfaceid, *sx, *sy, *width, *height);
1027 usurf->width = *width;
1028 usurf->height = *height;
1031 if (usurf->x < 0) usurf->x = 0;
1032 if (usurf->y < 0) usurf->y = 0;
1034 if (_ico_win_mgr->num_manager > 0) {
1035 /* HomeScreen exist, coodinate set by HomeScreen */
1036 if (usurf->visible) {
1037 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1038 usurf->node_tbl->disp_y + usurf->y,
1039 usurf->width, usurf->height);
1042 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1043 ICO_IVI_MAX_COORDINATE+1,
1044 usurf->width, usurf->height);
1046 uifw_trace("win_mgr_map_surface: Change size/position x/y=%d/%d w/h=%d/%d",
1047 (int)surface->geometry.x, (int)surface->geometry.y,
1048 surface->geometry.width, surface->geometry.height);
1050 if ((_ico_win_mgr->num_manager <= 0) ||
1051 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE)) {
1052 uifw_trace("win_mgr_map_surface: Np HomeScreen, chaneg to Visible");
1053 ico_window_mgr_set_visible(usurf, 1);
1057 if (usurf->visible) {
1058 ico_window_mgr_restack_layer(NULL, FALSE);
1060 uifw_trace("win_mgr_map_surface: Leave");
1063 uifw_trace("win_mgr_map_surface: Leave(No UIFW Surface)");
1067 /*--------------------------------------------------------------------------*/
1069 * @brief ico_window_mgr_restack_layer: restack surface list
1071 * @param[in] usurf UIFW surface (if NULL, no surface)
1072 * @param[in] omit_touch omit touch layer flag (TRUE=omit/FALSE=not omit)
1075 /*--------------------------------------------------------------------------*/
1077 ico_window_mgr_restack_layer(struct uifw_win_surface *usurf, const int omit_touch)
1079 struct uifw_win_surface *es;
1080 struct uifw_win_layer *el;
1081 int32_t buf_width, buf_height;
1083 struct weston_layer *wlayer;
1084 int num_visible = 0;
1086 uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x,omit=%d)",
1087 (int)usurf, omit_touch);
1089 /* make compositor surface list */
1090 wlayer = ico_ivi_shell_current_layer();
1092 wl_list_init(&wlayer->surface_list);
1093 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1094 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1095 if ((es->mapped != 0) && (es->surface != NULL)) {
1096 if ((el->visible == FALSE) || (es->visible == FALSE) ||
1097 ((omit_touch != FALSE) &&
1098 ((el->layer_type == ICO_WINDOW_MGR_LAYER_TYPE_INPUT) ||
1099 (el->layer_type == ICO_WINDOW_MGR_LAYER_TYPE_CURSOR)))) {
1100 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1101 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1103 else if (es->surface->buffer_ref.buffer) {
1104 buf_width = weston_surface_buffer_width(es->surface);
1105 buf_height = weston_surface_buffer_height(es->surface);
1106 if (es->width > buf_width) {
1107 new_x = (float)(es->x +
1108 (es->width - es->surface->geometry.width)/2);
1111 new_x = (float)es->x;
1113 if (es->height > buf_height) {
1114 new_y = (float) (es->y +
1115 (es->height - es->surface->geometry.height)/2);
1118 new_y = (float)es->y;
1120 new_x += es->node_tbl->disp_x + es->xadd;
1121 new_y += es->node_tbl->disp_y + es->yadd;
1125 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1126 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1128 wl_list_insert(wlayer->surface_list.prev, &es->surface->layer_link);
1129 if ((new_x != es->surface->geometry.x) ||
1130 (new_y != es->surface->geometry.y)) {
1131 weston_surface_damage_below(es->surface);
1132 weston_surface_set_position(es->surface, (float)new_x, (float)new_y);
1133 weston_surface_damage(es->surface);
1135 #if 0 /* too many debug log */
1136 uifw_trace("ico_window_mgr_restack_layer: %08x x/y=%d/%d w/h=%d/%d",
1138 (int)es->surface->geometry.x, (int)es->surface->geometry.y,
1139 es->surface->geometry.width, es->surface->geometry.height);
1145 /* damage(redraw) target surfacem if target exist */
1147 weston_surface_damage(usurf->surface);
1150 /* composit and draw screen(plane) */
1151 if (omit_touch == FALSE) {
1152 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
1154 if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) &&
1155 (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) {
1156 /* start shell fade */
1157 _ico_win_mgr->shell_init = 1;
1158 ico_ivi_shell_startup(_ico_win_mgr->shell);
1161 uifw_trace("ico_window_mgr_restack_layer: Leave");
1164 /*--------------------------------------------------------------------------*/
1166 * @brief win_mgr_create_layer: create new layer
1168 * @param[in] usurf UIFW surface, (if need)
1169 * @param[in] layer layer id
1171 * @retval != NULL success(layer management table)
1172 * @retval == NULL error(No Memory)
1174 /*--------------------------------------------------------------------------*/
1175 static struct uifw_win_layer *
1176 win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1178 struct uifw_win_layer *el;
1179 struct uifw_win_layer *new_el;
1181 new_el = malloc(sizeof(struct uifw_win_layer));
1183 uifw_trace("win_mgr_create_layer: Leave(No Memory)");
1187 memset(new_el, 0, sizeof(struct uifw_win_layer));
1188 new_el->layer = layer;
1189 if ((int)layer == _ico_ivi_background_layer ) {
1190 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_BACKGROUND;
1192 else if ((int)layer == _ico_ivi_input_layer ) {
1193 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_INPUT;
1195 else if ((int)layer == _ico_ivi_cursor_layer ) {
1196 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_CURSOR;
1199 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_NORMAL;
1201 new_el->visible = TRUE;
1202 wl_list_init(&new_el->surface_list);
1203 wl_list_init(&new_el->link);
1205 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1206 if (layer >= el->layer) break;
1208 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1209 wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link);
1212 wl_list_insert(el->link.prev, &new_el->link);
1216 wl_list_remove(&usurf->ivi_layer);
1217 wl_list_insert(&new_el->surface_list, &usurf->ivi_layer);
1218 usurf->win_layer = new_el;
1223 /*--------------------------------------------------------------------------*/
1225 * @brief win_mgr_set_layer: set(or change) surface layer
1227 * @param[in] usurf UIFW surface
1228 * @param[in] layer layer id
1231 /*--------------------------------------------------------------------------*/
1233 win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1235 struct uifw_win_layer *el;
1236 struct uifw_win_layer *new_el;
1238 uifw_trace("win_mgr_set_layer: Enter([%08x],%08x,%x)",
1239 (int)usurf, (int)usurf->surface, layer);
1241 /* check if same layer */
1242 if ((usurf->win_layer != NULL) && (usurf->win_layer->layer == layer)) {
1243 uifw_trace("win_mgr_set_layer: Leave(Same Layer)");
1247 /* search existing layer */
1248 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1249 if (el->layer == layer) break;
1252 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1253 /* layer not exist, create new layer */
1254 uifw_trace("win_mgr_set_layer: New Layer %d", layer);
1255 new_el = win_mgr_create_layer(usurf, layer);
1257 uifw_trace("win_mgr_set_layer: Leave(No Memory)");
1262 uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer);
1263 wl_list_remove(&usurf->ivi_layer);
1264 wl_list_insert(&el->surface_list, &usurf->ivi_layer);
1265 usurf->win_layer = el;
1268 /* rebild compositor surface list */
1269 if (usurf->visible) {
1270 ico_window_mgr_restack_layer(usurf, 0);
1272 uifw_trace("win_mgr_set_layer: Leave");
1275 /*--------------------------------------------------------------------------*/
1277 * @brief win_mgr_set_active: set(or change) active surface
1279 * @param[in] usurf UIFW surface
1280 * @param[in] target target device
1283 /*--------------------------------------------------------------------------*/
1285 win_mgr_set_active(struct uifw_win_surface *usurf, const int target)
1287 struct weston_seat *seat;
1288 struct weston_surface *surface;
1289 int object = target;
1292 uifw_trace("win_mgr_set_active: Enter(%08x,%x)", (int)usurf, target);
1294 if ((usurf) && (usurf->shsurf) && (usurf->surface)) {
1295 surface = usurf->surface;
1296 if ((target & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) {
1298 if (_ico_win_mgr->active_pointer_usurf == usurf) {
1299 object |= ICO_WINDOW_MGR_ACTIVE_POINTER;
1301 if (_ico_win_mgr->active_keyboard_usurf == usurf) {
1302 object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1306 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1307 _ico_win_mgr->active_pointer_usurf = usurf;
1309 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1310 _ico_win_mgr->active_keyboard_usurf = usurf;
1317 object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1319 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1320 _ico_win_mgr->active_pointer_usurf = NULL;
1322 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1323 _ico_win_mgr->active_keyboard_usurf = NULL;
1327 wl_list_for_each(seat, &_ico_win_mgr->compositor->seat_list, link) {
1328 if ((object & ICO_WINDOW_MGR_ACTIVE_POINTER) && (seat->pointer)) {
1330 if (seat->pointer->focus != surface) {
1331 uifw_trace("win_mgr_set_active: pointer change surface(%08x=>%08x)",
1332 (int)seat->pointer->focus, (int)surface);
1333 weston_surface_from_global_fixed(surface,
1337 weston_pointer_set_focus(seat->pointer, surface, sx, sy);
1340 uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)",
1345 uifw_trace("win_mgr_set_active: pointer reset surface(%08x)",
1346 (int)seat->pointer->focus);
1347 weston_pointer_set_focus(seat->pointer, NULL,
1348 wl_fixed_from_int(0), wl_fixed_from_int(0));
1351 if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) {
1353 if (seat->keyboard->focus != surface) {
1354 weston_keyboard_set_focus(seat->keyboard, surface);
1355 uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)",
1356 (int)seat->keyboard->focus, (int)surface);
1359 uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)",
1364 uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)",
1365 (int)seat->keyboard);
1366 weston_keyboard_set_focus(seat->keyboard, NULL);
1370 uifw_trace("win_mgr_set_active: Leave(%08x)", (int)usurf);
1373 /*--------------------------------------------------------------------------*/
1375 * @brief uifw_declare_manager: declare manager(ex.SystemController) client
1377 * @param[in] client Weyland client
1378 * @param[in] resource resource of request
1379 * @param[in] manager manager(1=manager, 0=not manager)
1382 /*--------------------------------------------------------------------------*/
1384 uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager)
1386 struct uifw_manager* mgr;
1387 struct uifw_win_surface *usurf;
1388 struct uifw_client *uclient;
1389 struct uifw_win_layer *el;
1391 uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d",
1392 (int)client, manager);
1394 uclient = find_client_from_client(client);
1396 uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client);
1400 uclient->manager = manager;
1402 /* client set to manager */
1403 _ico_win_mgr->num_manager = 0;
1404 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1405 if (mgr->resource == resource) {
1406 if (mgr->manager != manager) {
1407 uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d",
1408 (int)client, mgr->manager, manager);
1409 mgr->manager = manager;
1412 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1413 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
1414 /* send window create event to manager */
1415 if (usurf->created != 0) {
1416 uifw_trace("uifw_declare_manager: Send manager(%08x) "
1417 "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)",
1418 (int)resource, usurf->surfaceid,
1419 usurf->uclient->pid, usurf->uclient->appid);
1420 ico_window_mgr_send_window_created(resource,
1423 usurf->uclient->pid,
1424 usurf->uclient->appid);
1432 _ico_win_mgr->num_manager++;
1435 uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager);
1438 /*--------------------------------------------------------------------------*/
1440 * @brief uifw_set_window_layer: set layer id to surface
1442 * @param[in] client Weyland client
1443 * @param[in] resource resource of request
1444 * @param[in] surfaceid UIFW surface id
1445 * @param[in] layer layer id
1448 /*--------------------------------------------------------------------------*/
1450 uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource,
1451 uint32_t surfaceid, uint32_t layer)
1453 uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d",
1454 (int)resource, surfaceid, layer);
1456 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf(surfaceid);
1459 uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid);
1462 if (usurf->win_layer->layer != layer) {
1463 win_mgr_set_layer(usurf, layer);
1465 win_mgr_change_surface(usurf->surface, -1, 1);
1467 uifw_trace("uifw_set_window_layer: Leave");
1470 /*--------------------------------------------------------------------------*/
1472 * @brief uifw_set_positionsize: set surface position and size
1474 * @param[in] client Weyland client
1475 * @param[in] resource resource of request
1476 * @param[in] surfaceid UIFW surface id
1477 * @param[in] node surface node id
1478 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
1479 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
1480 * @param[in] width surface width(if bigger than 16383, no change)
1481 * @param[in] height surface height(if bigger than 16383, no change)
1482 * @param[in] flags with/without animation and client configure flag
1485 /*--------------------------------------------------------------------------*/
1487 uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
1488 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
1489 int32_t width, int32_t height, int32_t flags)
1491 struct uifw_client *uclient;
1492 struct weston_surface *es;
1496 uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x",
1497 surfaceid, node, x, y, width, height, flags);
1499 if (((int)node) >= _ico_num_nodes) {
1500 uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)",
1501 node, _ico_num_nodes);
1504 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf(surfaceid);
1506 if (usurf && (usurf->surface)) {
1507 /* weston surface exist */
1508 usurf->node_tbl = &_ico_node_table[node];
1509 es = usurf->surface;
1510 retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
1512 /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */
1513 if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x;
1514 if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y;
1515 if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width;
1516 if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height;
1518 /* check animation */
1519 if ((usurf->animation.restrain_configure != 0) &&
1520 (x == usurf->x) && (y == usurf->y) &&
1521 (width == usurf->width) && (height == usurf->height)) {
1522 uifw_trace("uifw_set_positionsize: Leave(same position size at animation)");
1526 uclient = find_client_from_client(client);
1528 if (! uclient->manager) uclient = NULL;
1531 if ((usurf->width > 0) && (usurf->height > 0)) {
1532 win_mgr_surface_change_mgr(es, x, y, width, height);
1533 uifw_trace("uifw_set_positionsize: Leave(Request from App)");
1537 uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d",
1539 /* Initiale position is (0,0) */
1540 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x),
1541 (float)(usurf->node_tbl->disp_y));
1544 uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d",
1545 (int)es->geometry.x, (int)es->geometry.y,
1546 (int)es->geometry.width, (int)es->geometry.height);
1548 usurf->animation.pos_x = usurf->x;
1549 usurf->animation.pos_y = usurf->y;
1550 usurf->animation.pos_width = usurf->width;
1551 usurf->animation.pos_height = usurf->height;
1552 usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0;
1555 usurf->width = width;
1556 usurf->height = height;
1557 if (_ico_win_mgr->num_manager <= 0) {
1558 /* no manager(HomeScreen), set geometory */
1559 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x + x),
1560 (float)(usurf->node_tbl->disp_y + y));
1562 if ((es->output) && (es->buffer_ref.buffer) &&
1563 (es->geometry.width > 0) && (es->geometry.height > 0)) {
1564 uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)",
1566 if (usurf->visible) {
1567 if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) &&
1568 (win_mgr_hook_animation != NULL)) {
1569 /* with animation */
1570 if ((x != (usurf->surface->geometry.x - usurf->node_tbl->disp_x)) ||
1571 (y != (usurf->surface->geometry.y - usurf->node_tbl->disp_y))) {
1572 op = ICO_WINDOW_MGR_ANIMATION_OPMOVE;
1574 else if ((width != usurf->surface->geometry.width) ||
1575 (height != usurf->surface->geometry.height)) {
1576 op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE;
1579 op = ICO_WINDOW_MGR_ANIMATION_OPNONE;
1581 if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) &&
1582 (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) ||
1583 ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) &&
1584 (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) {
1585 retanima = (*win_mgr_hook_animation)(op, (void *)usurf);
1586 uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima);
1589 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
1590 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
1591 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1592 usurf->width, usurf->height);
1596 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
1597 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
1598 win_mgr_change_surface(es,
1599 (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1);
1601 uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output);
1604 uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid);
1608 /*--------------------------------------------------------------------------*/
1610 * @brief uifw_set_visible: surface visible/raise control
1612 * @param[in] client Weyland client
1613 * @param[in] resource resource of request
1614 * @param[in] surfaceid UIFW surface id
1615 * @param[in] visible visible(1=show/0=hide/other=no change)
1616 * @param[in] raise raise(1=raise/0=lower/other=no change)
1617 * @param[in] flags with/without animation
1620 /*--------------------------------------------------------------------------*/
1622 uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
1623 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags)
1625 struct uifw_win_surface *usurf;
1626 struct uifw_client *uclient;
1630 uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)",
1631 surfaceid, visible, raise, flags);
1633 uclient = find_client_from_client(client);
1635 if (! uclient->manager) {
1636 uifw_trace("uifw_set_visible: Request from App(%s), not Manager",
1641 uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid);
1645 uifw_trace("uifw_set_visible: Request from Unknown App, not Manager");
1648 usurf = ico_window_mgr_get_usurf(surfaceid);
1650 if ((! usurf) || (! usurf->surface)) {
1651 uifw_trace("uifw_set_visible: Leave(Surface Not Exist)");
1656 if (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) {
1658 if (! usurf->visible) {
1660 uifw_trace("uifw_set_visible: Change to Visible");
1662 ico_ivi_shell_set_toplevel(usurf->shsurf);
1664 /* Weston surface configure */
1665 uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d",
1666 (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y,
1667 usurf->width, usurf->height);
1668 ico_ivi_shell_set_surface_type(usurf->shsurf);
1669 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1670 usurf->width, usurf->height);
1672 restack = 1; /* need damage */
1674 if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) &&
1675 (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1676 (win_mgr_hook_animation != NULL)) {
1677 usurf->animation.pos_x = usurf->x;
1678 usurf->animation.pos_y = usurf->y;
1679 usurf->animation.pos_width = usurf->width;
1680 usurf->animation.pos_height = usurf->height;
1681 usurf->animation.no_configure = 0;
1682 retanima = (*win_mgr_hook_animation)(
1683 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
1684 ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS :
1685 ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1687 uifw_trace("uifw_set_visible: ret call anima = %d", retanima);
1690 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1691 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1692 uifw_trace("uifw_set_visible: Leave(No Change)");
1696 else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) {
1698 if (usurf->visible) {
1700 /* Weston surface configure */
1701 weston_surface_damage_below(usurf->surface);
1702 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1703 usurf->width, usurf->height);
1705 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1706 if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) &&
1707 (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1708 (win_mgr_hook_animation != NULL)) {
1709 usurf->animation.pos_x = usurf->x;
1710 usurf->animation.pos_y = usurf->y;
1711 usurf->animation.pos_width = usurf->width;
1712 usurf->animation.pos_height = usurf->height;
1713 usurf->animation.no_configure = 0;
1714 retanima = (*win_mgr_hook_animation)(
1715 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
1716 ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS :
1717 ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1720 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1722 uifw_trace("uifw_set_visible: Change to UnVisible");
1723 /* change visible to unvisible, restack surface list */
1725 /* Weston surface configure */
1726 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1727 usurf->width, usurf->height);
1730 uifw_trace("uifw_set_visible: UnVisible but animation");
1733 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1734 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1735 uifw_trace("uifw_set_visible: Leave(No Change)");
1739 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1740 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1741 uifw_trace("uifw_set_visible: Leave(No Change)");
1746 if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) {
1747 win_mgr_set_raise(usurf, raise);
1748 if (usurf->visible == 0) {
1753 raise = ICO_WINDOW_MGR_V_NOCHANGE;
1756 if ((restack == 1) && (usurf->surface) &&
1757 (usurf->surface->buffer_ref.buffer) && (usurf->surface->output)) {
1758 weston_surface_damage(usurf->surface);
1760 else if(restack & 2) {
1761 ico_window_mgr_restack_layer(usurf, 0);
1764 /* send event(VISIBLE) to manager */
1766 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
1768 (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 :
1769 ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 :
1770 ICO_WINDOW_MGR_V_NOCHANGE),
1771 raise, uclient ? 0 : 1, 0,0);
1773 uifw_trace("uifw_set_visible: Leave(OK)");
1776 /*--------------------------------------------------------------------------*/
1778 * @brief uifw_set_animation: set animation of surface visible/unvisible
1780 * @param[in] client Weyland client
1781 * @param[in] resource resource of request
1782 * @param[in] surfaceid UIFW surface id
1783 * @param[in] type how to change surface
1784 * @param[in] anmation animation name
1785 * @param[in] time animation time(ms), if 0, default time
1788 /*--------------------------------------------------------------------------*/
1790 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1791 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1794 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf(surfaceid);
1796 uifw_trace("uifw_set_transition: Enter(surf=%08x,type=%x,anim=%s,time=%d)",
1797 surfaceid, type, animation, time);
1800 if ((*animation != 0) && (*animation != ' ')) {
1801 animaid = ico_get_animation_name(animation);
1802 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1803 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1804 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1805 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1806 usurf->animation.next_anima = animaid;
1809 usurf->animation.hide_anima = animaid;
1812 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1813 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1814 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1815 usurf->animation.next_anima = animaid;
1818 usurf->animation.show_anima = animaid;
1821 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1822 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
1823 usurf->animation.next_anima = animaid;
1826 usurf->animation.move_anima = animaid;
1829 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1830 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
1831 usurf->animation.next_anima = animaid;
1834 usurf->animation.resize_anima = animaid;
1838 if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) {
1839 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1840 usurf->animation.hide_time = time;
1842 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1843 usurf->animation.show_time = time;
1845 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1846 usurf->animation.move_time = time;
1848 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1849 usurf->animation.resize_time = time;
1854 uifw_trace("uifw_set_animation: Leave(Surface(%08x) Not exist)", surfaceid);
1858 /*--------------------------------------------------------------------------*/
1860 * @brief uifw_set_attributes: set surface attributes
1862 * @param[in] client Weyland client
1863 * @param[in] resource resource of request
1864 * @param[in] surfaceid UIFW surface id
1865 * @param[in] attributes surface attributes
1868 /*--------------------------------------------------------------------------*/
1870 uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
1871 uint32_t surfaceid, uint32_t attributes)
1873 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf(surfaceid);
1875 uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes);
1878 usurf->attributes = attributes;
1879 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) ==
1880 (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) {
1881 usurf->attributes &=
1882 ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT);
1884 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) ==
1885 (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) {
1886 usurf->attributes &=
1887 ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM);
1890 uifw_trace("uifw_set_attributes: Leave");
1893 /*--------------------------------------------------------------------------*/
1895 * @brief uifw_visible_animation: surface visibility control with animation
1897 * @param[in] client Weyland client
1898 * @param[in] resource resource of request
1899 * @param[in] surfaceid surface id
1900 * @param[in] visible visible(1=show/0=hide)
1901 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
1902 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
1903 * @param[in] width surface width(if bigger than 16383, no change)
1904 * @param[in] height surface height(if bigger than 16383, no change)
1907 /*--------------------------------------------------------------------------*/
1909 uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
1910 uint32_t surfaceid, int32_t visible,
1911 int32_t x, int32_t y, int32_t width, int32_t height)
1913 struct uifw_win_surface *usurf;
1915 uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)",
1916 surfaceid, visible, x, y, width, height);
1918 usurf = ico_window_mgr_get_usurf(surfaceid);
1920 if ((! usurf) || (! usurf->surface)) {
1921 uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)");
1925 usurf->animation.pos_x = x;
1926 usurf->animation.pos_y = y;
1927 if (width > 0) usurf->animation.pos_width = width;
1928 else usurf->animation.pos_width = 1;
1929 if (height > 0) usurf->animation.pos_height = height;
1930 else usurf->animation.pos_height = 1;
1931 usurf->animation.no_configure = 0;
1933 uifw_set_visible(client, resource, surfaceid, visible,
1934 ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS);
1936 uifw_trace("uifw_visible_animation: Leave");
1939 /*--------------------------------------------------------------------------*/
1941 * @brief uifw_set_active: set active surface
1943 * @param[in] client Weyland client
1944 * @param[in] resource resource of request
1945 * @param[in] surfaceid UIFW surface id
1946 * @param[in] active target device
1949 /*--------------------------------------------------------------------------*/
1951 uifw_set_active(struct wl_client *client, struct wl_resource *resource,
1952 uint32_t surfaceid, int32_t active)
1954 struct uifw_win_surface *usurf;
1956 uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active);
1958 if ((surfaceid > 0) &&
1959 ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) {
1960 usurf = ico_window_mgr_get_usurf(surfaceid);
1966 switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) {
1967 case ICO_WINDOW_MGR_ACTIVE_POINTER:
1968 if (usurf != _ico_win_mgr->active_pointer_usurf) {
1969 if (_ico_win_mgr->active_pointer_usurf) {
1970 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
1971 _ico_win_mgr->active_pointer_usurf,
1972 (_ico_win_mgr->active_keyboard_usurf ==
1973 _ico_win_mgr->active_pointer_usurf) ?
1974 ICO_WINDOW_MGR_ACTIVE_KEYBOARD :
1975 ICO_WINDOW_MGR_ACTIVE_NONE,
1978 _ico_win_mgr->active_pointer_usurf = usurf;
1979 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
1981 ICO_WINDOW_MGR_ACTIVE_POINTER |
1982 (_ico_win_mgr->active_keyboard_usurf == usurf) ?
1983 ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0,
1985 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER);
1988 case ICO_WINDOW_MGR_ACTIVE_KEYBOARD:
1989 if (usurf != _ico_win_mgr->active_keyboard_usurf) {
1990 if (_ico_win_mgr->active_keyboard_usurf) {
1991 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
1992 _ico_win_mgr->active_keyboard_usurf,
1993 (_ico_win_mgr->active_keyboard_usurf ==
1994 _ico_win_mgr->active_pointer_usurf) ?
1995 ICO_WINDOW_MGR_ACTIVE_POINTER :
1996 ICO_WINDOW_MGR_ACTIVE_NONE,
1999 _ico_win_mgr->active_keyboard_usurf = usurf;
2000 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2002 ICO_WINDOW_MGR_ACTIVE_KEYBOARD |
2003 (_ico_win_mgr->active_pointer_usurf == usurf) ?
2004 ICO_WINDOW_MGR_ACTIVE_POINTER : 0,
2006 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2010 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
2011 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
2012 if (_ico_win_mgr->active_pointer_usurf) {
2013 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2014 _ico_win_mgr->active_pointer_usurf,
2015 ICO_WINDOW_MGR_ACTIVE_NONE,
2017 if (_ico_win_mgr->active_keyboard_usurf ==
2018 _ico_win_mgr->active_pointer_usurf) {
2019 _ico_win_mgr->active_keyboard_usurf = NULL;
2022 if (_ico_win_mgr->active_keyboard_usurf) {
2023 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2024 _ico_win_mgr->active_keyboard_usurf,
2025 ICO_WINDOW_MGR_ACTIVE_NONE,
2028 _ico_win_mgr->active_pointer_usurf = usurf;
2029 _ico_win_mgr->active_keyboard_usurf = usurf;
2030 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2032 ICO_WINDOW_MGR_ACTIVE_POINTER |
2033 ICO_WINDOW_MGR_ACTIVE_KEYBOARD,
2035 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2036 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2040 uifw_trace("uifw_set_active: Leave(Change Active)");
2043 win_mgr_set_active(NULL, active);
2044 uifw_trace("uifw_set_active: Leave(Reset active surface)");
2048 /*--------------------------------------------------------------------------*/
2050 * @brief uifw_set_layer_visible: layer visible control
2052 * @param[in] client Weyland client
2053 * @param[in] resource resource of request
2054 * @param[in] layer layer id
2055 * @param[in] visible visible(1=show/0=hide)
2058 /*--------------------------------------------------------------------------*/
2060 uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
2061 uint32_t layer, int32_t visible)
2063 struct uifw_win_layer *el;
2064 struct uifw_win_layer *new_el;
2065 struct uifw_win_surface *usurf;
2067 uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible);
2070 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2071 if (el->layer == layer) break;
2074 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
2075 /* layer not exist, create new layer */
2076 uifw_trace("uifw_set_layer_visible: New Layer %d", layer);
2077 new_el = win_mgr_create_layer(NULL, layer);
2079 uifw_trace("uifw_set_layer_visible: Leave(No Memory)");
2082 new_el->visible = (visible != 0) ? TRUE : FALSE;
2083 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2084 layer, new_el->visible, 0,0,0);
2085 uifw_trace("uifw_set_layer_visible: Leave(new layer)");
2089 /* control all surface in layer */
2090 if ((el->visible != FALSE) && (visible == 0)) {
2091 /* layer change to NOT visible */
2092 uifw_trace("uifw_set_layer_visible: change to not visible");
2093 el->visible = FALSE;
2095 else if ((el->visible == FALSE) && (visible != 0)) {
2096 /* layer change to visible */
2097 uifw_trace("uifw_set_layer_visible: change to visible");
2102 uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)",
2103 el->visible, visible);
2107 /* set damege area */
2108 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2109 if ((usurf->visible != FALSE) && (usurf->surface != NULL) &&
2110 (usurf->surface->output != NULL)) {
2111 /* Damage(redraw) target surface */
2112 weston_surface_damage_below(usurf->surface);
2116 /* rebild compositor surface list */
2117 ico_window_mgr_restack_layer(NULL, 0);
2119 /* send layer visible event to manager */
2120 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2121 layer, el->visible, 0,0,0);
2123 uifw_trace("uifw_set_layer_visible: Leave");
2126 /*--------------------------------------------------------------------------*/
2128 * @brief uifw_get_surfaces: get application surfaces
2130 * @param[in] client Weyland client
2131 * @param[in] resource resource of request
2132 * @param[in] appid application id
2135 /*--------------------------------------------------------------------------*/
2137 uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, const char *appid)
2139 struct uifw_client *uclient;
2140 struct uifw_win_layer *el;
2141 struct uifw_win_surface *usurf;
2142 struct wl_array reply;
2145 uifw_trace("uifw_get_surfaces: Enter(appid=%s)", appid);
2147 wl_array_init(&reply);
2149 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2150 if (strcmp(uclient->appid, appid) == 0) break;
2152 if (&uclient->link == &_ico_win_mgr->client_list) {
2153 uifw_trace("uifw_get_surfaces: appid=%s dose not exist", appid);
2156 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2157 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2158 if (usurf->uclient == uclient) {
2159 uifw_trace("uifw_get_surfaces: %s surf=%08x", appid, usurf->surfaceid);
2160 up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t));
2162 *up = usurf->surfaceid;
2168 ico_window_mgr_send_app_surfaces(resource, appid, &reply);
2170 wl_array_release(&reply);
2171 uifw_trace("uifw_get_surfaces: Leave");
2174 /*--------------------------------------------------------------------------*/
2176 * @brief win_mgr_check_surfacemap: check and change all surface
2178 * @param[in] animation weston animation table(unused)
2179 * @param[in] outout weston output table
2180 * @param[in] mseces current time(unused)
2183 /*--------------------------------------------------------------------------*/
2185 win_mgr_check_surfacemap(struct weston_animation *animation,
2186 struct weston_output *output, uint32_t msecs)
2188 struct uifw_surface_map *sm;
2190 wl_list_for_each(sm, &_ico_win_mgr->map_list, map_link) {
2191 if (sm->usurf->surface->output == output) {
2192 win_mgr_change_mapsurface(sm, 0);
2197 /*--------------------------------------------------------------------------*/
2199 * @brief win_mgr_change_mapsurface: check and change mapped surface
2201 * @param[in] sm map surface table
2202 * @param[in] event send event (if 0, send if changed)
2205 /*--------------------------------------------------------------------------*/
2207 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event)
2209 struct uifw_drm_buffer *drm_buffer;
2210 struct uifw_dri_image *dri_image;
2211 struct uifw_dri_region *dri_region;
2212 struct uifw_gl_surface_state *gl_state;
2213 struct weston_surface *es;
2214 uint32_t eglname = 0;
2220 /* check if buffered */
2221 es = sm->usurf->surface;
2222 if ((es == NULL) || (es->buffer_ref.buffer == NULL) ||
2223 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0) ||
2224 (es->buffer_ref.buffer->legacy_buffer == NULL) || (es->renderer_state == NULL) ||
2225 (((struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer)->driver_buffer
2227 /* surface has no buffer, error */
2228 uifw_trace("win_mgr_change_mapsurface: surface(%08x) has no buffer",
2229 sm->usurf->surfaceid);
2236 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
2243 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2244 if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2245 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
2247 else if (gl_state->buffer_type != BUFFER_TYPE_EGL) {
2251 drm_buffer = (struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer;
2252 dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer;
2253 dri_region = dri_image->region;
2254 width = es->buffer_ref.buffer->width;
2255 height = es->buffer_ref.buffer->height;
2256 stride = drm_buffer->stride[0];
2257 if (drm_buffer->format == 0x34325258) {
2258 format = EGL_TEXTURE_RGB;
2260 else if (drm_buffer->format == 0x34325241) {
2261 format = EGL_TEXTURE_RGBA;
2264 /* unknown format, error */
2265 format = EGL_NO_TEXTURE;
2267 eglname = dri_region->name;
2269 if ((sm->initflag == 0) && (width > 0) && (height > 0) && (stride > 0)) {
2271 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
2274 if ((width <= 0) || (height <= 0) || (stride <= 0)) {
2277 else if (event == 0) {
2278 if ((sm->width != width) || (sm->height != height) ||
2279 (sm->stride != stride)) {
2280 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
2282 else if ((eglname != sm->eglname) || (format != sm->format)) {
2283 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
2288 sm->height = height;
2289 sm->stride = stride;
2290 sm->eglname = eglname;
2291 sm->format = format;
2292 sm->eglname = eglname;
2297 uifw_trace("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x name=%08x "
2298 "w/h/s=%d/%d/%d format=%x",
2299 event, sm->usurf->surfaceid, sm->eglname, sm->width, sm->height,
2300 sm->stride, sm->format);
2301 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
2302 sm->usurf->surfaceid, sm->type, sm->eglname,
2303 sm->width, sm->height, sm->stride, sm->format);
2304 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
2305 /* free map table if error */
2306 wl_list_remove(&sm->surf_link);
2307 wl_list_remove(&sm->map_link);
2308 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2309 _ico_win_mgr->free_maptable = sm;
2312 uifw_trace("win_mgr_change_mapsurface: Leave");
2315 /*--------------------------------------------------------------------------*/
2317 * @brief uifw_map_surface: mapped surface buffer to system application
2319 * @param[in] client Weyland client
2320 * @param[in] resource resource of request
2321 * @param[in] surfaceid surface id
2322 * @param[in] framerate frame rate of surface update(frame/sec)
2325 /*--------------------------------------------------------------------------*/
2327 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
2328 uint32_t surfaceid, int32_t framerate)
2330 struct uifw_win_surface *usurf;
2331 struct weston_surface *es;
2332 struct uifw_surface_map *sm;
2333 struct weston_buffer *buffer;
2334 struct uifw_client *uclient;
2335 struct uifw_drm_buffer *drm_buffer;
2336 struct uifw_gl_surface_state *gl_state;
2338 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate);
2340 usurf = ico_window_mgr_get_usurf(surfaceid);
2342 /* surface dose not exist, error */
2343 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2344 surfaceid, 1, 0, 0, 0, 0, 0);
2345 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
2348 uclient = find_client_from_client(client);
2349 if ((! uclient) || (! uclient->mgr)) {
2350 /* client dose not exist, error */
2351 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2352 surfaceid, 2, 0, 0, 0, 0, 0);
2353 uifw_trace("uifw_map_surface: Leave(client=%08x dose not exist)", (int)client);
2357 es = usurf->surface;
2359 /* check if buffered */
2361 /* surface has no buffer, error */
2362 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2363 surfaceid, 3, 0, 0, 0, 0, 0);
2364 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no buffer)", surfaceid);
2368 /* check buffer type */
2369 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2371 if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2372 /* wl_shm_buffer not support */
2373 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2374 surfaceid, 4, 0, 0, 0, 0, 0);
2375 uifw_trace("uifw_map_surface: Leave(surface(%08x) is wl_shm_buffer, "
2376 "not support)", surfaceid);
2381 /* create map table */
2382 sm = _ico_win_mgr->free_maptable;
2384 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
2387 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
2389 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2390 surfaceid, 5, 0, 0, 0, 0, 0);
2391 uifw_trace("uifw_map_surface: Leave(malloc error)");
2395 memset(sm, 0, sizeof(struct uifw_surface_map));
2397 wl_list_init(&sm->map_link);
2398 wl_list_init(&sm->surf_link);
2400 sm->uclient = uclient;
2401 sm->type = ICO_WINDOW_MGR_MAP_TYPE_EGL;
2403 sm->framerate = framerate;
2404 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
2405 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
2407 buffer = es->buffer_ref.buffer;
2408 if ((buffer != NULL) && (gl_state != NULL) &&
2409 (gl_state->buffer_type == BUFFER_TYPE_EGL)) {
2410 sm->width = buffer->width;
2411 sm->height = buffer->height;
2412 drm_buffer = (struct uifw_drm_buffer *)buffer->legacy_buffer;
2413 if (drm_buffer != NULL) {
2414 sm->stride = drm_buffer->stride[0];
2415 if (drm_buffer->format == 0x34325258) {
2416 sm->format = EGL_TEXTURE_RGB;
2418 else if (drm_buffer->format == 0x34325241) {
2419 sm->format = EGL_TEXTURE_RGBA;
2422 /* unknown format, error */
2423 sm->format = EGL_NO_TEXTURE;
2425 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
2426 (gl_state != NULL)) {
2432 /* send map event */
2434 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP);
2436 uifw_trace("uifw_map_surface: Leave");
2439 /*--------------------------------------------------------------------------*/
2441 * @brief uifw_unmap_surface: unmap surface buffer
2443 * @param[in] client Weyland client
2444 * @param[in] resource resource of request
2445 * @param[in] surfaceid surface id
2448 /*--------------------------------------------------------------------------*/
2450 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2453 struct uifw_win_surface *usurf;
2454 struct uifw_surface_map *sm, *sm_tmp;
2455 struct uifw_client *uclient;
2457 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2459 usurf = ico_window_mgr_get_usurf(surfaceid);
2461 /* surface dose not exist, error */
2462 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2466 uclient = find_client_from_client(client);
2467 if ((! uclient) || (! uclient->mgr)) {
2468 /* client dose not exist, error */
2469 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2475 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2476 if (sm->uclient->mgr != NULL) {
2477 uifw_trace("uifw_unmap_surface: send MAP event(ev=%d surf=%08x name=%08x "
2478 "w/h/s=%d/%d/%d format=%x",
2479 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2480 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
2481 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2482 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2483 surfaceid, sm->type, sm->eglname, sm->width,
2484 sm->height, sm->stride, sm->format);
2489 wl_list_for_each_safe(sm, sm_tmp, &usurf->surf_map, surf_link) {
2490 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2491 /* send unmap event */
2492 if ((uclient != NULL) && (uclient->mgr != NULL)) {
2493 uifw_trace("uifw_unmap_surface: send MAP event(ev=%d surf=%08x name=%08x "
2494 "w/h/s=%d/%d/%d format=%x",
2495 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2496 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
2497 ico_window_mgr_send_map_surface(uclient->mgr->resource,
2498 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2499 surfaceid, sm->type, sm->eglname, sm->width,
2500 sm->height, sm->stride, sm->format);
2502 wl_list_remove(&sm->surf_link);
2503 wl_list_remove(&sm->map_link);
2504 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2505 _ico_win_mgr->free_maptable = sm;
2507 uifw_trace("uifw_unmap_surface: Leave");
2510 /*--------------------------------------------------------------------------*/
2512 * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen)
2514 * @param[in] surface Weston surface
2515 * @param[in] x X coordinate on screen
2516 * @param[in] y Y coordinate on screen
2517 * @param[in] width surface width
2518 * @param[in] height surface height
2519 * @return number of managers
2520 * @retval > 0 number of managers
2521 * @retval 0 manager not exist
2523 /*--------------------------------------------------------------------------*/
2525 win_mgr_surface_change_mgr(struct weston_surface *surface,
2526 const int x, const int y, const int width, const int height)
2529 struct uifw_win_surface *usurf;
2531 uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)",
2532 (int)surface, x, y, width, height);
2534 usurf = find_uifw_win_surface_by_ws(surface);
2536 uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)");
2540 num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2541 usurf, x, y, width, height, 1);
2543 uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr);
2547 /*--------------------------------------------------------------------------*/
2549 * @brief win_mgr_change_surface: surface change
2551 * @param[in] surface Weston surface
2552 * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager)
2553 * @param[in] manager request from manager(0=Client,1=Manager)
2556 /*--------------------------------------------------------------------------*/
2558 win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager)
2560 struct uifw_win_surface *usurf;
2561 struct weston_surface *es;
2566 uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager);
2569 usurf = find_uifw_win_surface_by_ws(surface);
2571 uifw_trace("win_mgr_change_surface: Leave(Not Exist)");
2574 es = usurf->surface;
2576 uifw_trace("win_mgr_change_surface: Leave(No weston surface)");
2580 /* if not configure surface, set surface size */
2581 if ((usurf->width <= 0) || (usurf->height <= 0)) {
2582 uifw_trace("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d",
2583 (int)es->geometry.x, (int)es->geometry.y, usurf->x, usurf->y,
2584 usurf->width, usurf->height, es->geometry.width, es->geometry.height);
2585 usurf->width = es->geometry.width;
2586 usurf->height = es->geometry.height;
2587 win_mgr_set_scale(usurf);
2588 if (usurf->visible) {
2589 weston_surface_set_position(usurf->surface,
2590 (float)(usurf->node_tbl->disp_x +
2591 usurf->x + usurf->xadd),
2592 (float)(usurf->node_tbl->disp_y +
2593 usurf->y + usurf->yadd));
2594 ico_window_mgr_restack_layer(usurf, 0);
2597 weston_surface_set_position(usurf->surface, (float)(ICO_IVI_MAX_COORDINATE+1),
2598 (float)(ICO_IVI_MAX_COORDINATE+1));
2602 /* send wayland event to client */
2603 if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) &&
2604 (usurf->width > 0) && (usurf->height > 0)) {
2605 if ((usurf->width != usurf->conf_width) ||
2606 (usurf->height != usurf->conf_height)) {
2607 usurf->conf_width = usurf->width;
2608 usurf->conf_height = usurf->height;
2609 uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ",
2610 usurf->surfaceid, (int)es, usurf->width, usurf->height);
2611 ico_ivi_shell_send_configure(es,
2612 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
2613 usurf->width, usurf->height);
2617 if (usurf->visible) {
2618 x = usurf->node_tbl->disp_x + usurf->x;
2619 y = usurf->node_tbl->disp_y + usurf->y;
2622 x = ICO_IVI_MAX_COORDINATE+1;
2623 y = ICO_IVI_MAX_COORDINATE+1;
2625 /* change geometry if request from manager */
2627 if ((usurf->width != es->geometry.width) ||
2628 (usurf->height != es->geometry.height) ||
2629 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
2630 win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height);
2635 /* send manager event to HomeScreen */
2638 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2639 usurf, usurf->x, usurf->y,
2640 usurf->width, usurf->height, 0);
2643 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2644 usurf, (int)es->geometry.x, (int)es->geometry.y,
2645 es->geometry.width, es->geometry.height, 1);
2649 /* change geometry if request from client */
2651 if ((usurf->width != es->geometry.width) || (usurf->height != es->geometry.height) ||
2652 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
2653 win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height);
2659 uifw_trace("win_mgr_change_surface: repaint");
2660 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
2662 uifw_trace("win_mgr_change_surface: Leave(OK)");
2665 /*--------------------------------------------------------------------------*/
2667 * @brief win_mgr_surface_configure: UIFW surface configure
2669 * @param[in] usurf UIFW surface
2670 * @param[in] x X coordinate on screen
2671 * @param[in] y Y coordinate on screen
2672 * @param[in] width surface width
2673 * @param[in] height surface height
2676 /*--------------------------------------------------------------------------*/
2678 win_mgr_surface_configure(struct uifw_win_surface *usurf,
2679 int x, int y, int width, int height)
2681 struct weston_surface *es;
2683 es = usurf->surface;
2684 if ((es != NULL) && (es->buffer_ref.buffer)) {
2685 if (usurf->client_width == 0) {
2686 usurf->client_width = es->geometry.width;
2687 if (usurf->client_width == 0)
2688 usurf->client_width = weston_surface_buffer_width(es);
2690 if (usurf->client_height == 0) {
2691 usurf->client_height = es->geometry.height;
2692 if (usurf->client_height == 0)
2693 usurf->client_height = weston_surface_buffer_height(es);
2696 /* not set geometry width/height */
2697 win_mgr_set_scale(usurf);
2698 weston_surface_set_position(es, x + usurf->xadd, y + usurf->yadd);
2702 /*--------------------------------------------------------------------------*/
2704 * @brief win_mgr_shell_configure: shell surface configure
2706 * @param[in] surface Weston surface
2709 /*--------------------------------------------------------------------------*/
2711 win_mgr_shell_configure(struct weston_surface *surface)
2713 struct uifw_win_surface *usurf;
2717 uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface);
2719 /* Find UIFW surface */
2720 usurf = find_uifw_win_surface_by_ws(surface);
2722 uifw_trace("win_mgr_shell_configure: Leave(Not Exist)");
2726 usurf->client_width = surface->geometry.width;
2727 usurf->client_height = surface->geometry.height;
2728 buf_width = weston_surface_buffer_width(surface);
2729 buf_height = weston_surface_buffer_height(surface);
2730 uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d",
2732 usurf->client_width, usurf->client_height, buf_width, buf_height);
2733 if (usurf->client_width > buf_width) usurf->client_width = buf_width;
2734 if (usurf->client_height > buf_height) usurf->client_height = buf_height;
2736 /* send event to manager */
2737 win_mgr_change_surface(surface, -1, 0);
2739 uifw_trace("win_mgr_shell_configure: Leave");
2742 /*--------------------------------------------------------------------------*/
2744 * @brief win_mgr_select_surface: select surface by Bottun/Touch
2746 * @param[in] surface Weston surface
2749 /*--------------------------------------------------------------------------*/
2751 win_mgr_select_surface(struct weston_surface *surface)
2753 struct uifw_win_surface *usurf;
2755 uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface);
2758 usurf = find_uifw_win_surface_by_ws(surface);
2760 uifw_trace("win_mgr_select_surface: Leave(Not Exist)");
2763 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2765 /* send active event to manager */
2766 if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2767 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) {
2768 uifw_trace("win_mgr_select_surface: not found manager, set active");
2769 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2770 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2773 uifw_trace("win_mgr_select_surface: Leave(OK)");
2776 /*--------------------------------------------------------------------------*/
2778 * @brief win_mgr_set_title: set tile name to surface
2780 * @param[in] surface weston surface
2781 * @param[in] title title name
2784 /*--------------------------------------------------------------------------*/
2786 win_mgr_set_title(struct weston_surface *surface, const char *title)
2788 struct uifw_win_surface *usurf;
2790 uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title);
2792 usurf = find_uifw_win_surface_by_ws(surface);
2794 uifw_trace("win_mgr_set_title: Leave(Not Exist)");
2797 if (((usurf->width > 0) && (usurf->height > 0)) &&
2798 ((usurf->created == 0) ||
2799 (strncmp(title, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) {
2800 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
2801 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
2802 if (usurf->created == 0) {
2803 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0);
2807 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0);
2811 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
2812 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
2814 uifw_trace("win_mgr_set_title: Leave");
2817 /*--------------------------------------------------------------------------*/
2819 * @brief win_mgr_surface_move: set tile name to surface
2821 * @param[in] surface weston surface
2822 * @param[in] title title name
2825 /*--------------------------------------------------------------------------*/
2827 win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy)
2829 struct uifw_win_surface *usurf;
2831 uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy);
2833 usurf = find_uifw_win_surface_by_ws(surface);
2835 uifw_trace("win_mgr_surface_move: Leave(Not Exist)");
2838 if (usurf->visible) {
2839 *dx = usurf->node_tbl->disp_x + usurf->x;
2840 *dy = usurf->node_tbl->disp_y + usurf->y;
2843 *dx = ICO_IVI_MAX_COORDINATE+1;
2844 *dy = ICO_IVI_MAX_COORDINATE+1;
2846 uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy);
2849 /*--------------------------------------------------------------------------*/
2851 * @brief ico_window_mgr_set_visible: change surface visibility
2853 * @param[in] usurf UIFW surface
2854 * @param[in] visible visible(=1)/unvisible(0)
2857 /*--------------------------------------------------------------------------*/
2859 ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible)
2862 if (usurf->visible == 0) {
2863 uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x)", (int)usurf);
2865 /* change unvisible to visible, restack surface list */
2866 ico_window_mgr_restack_layer(usurf, 0);
2870 if (usurf->visible != 0) {
2871 uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)", (int)usurf);
2873 /* change visible to unvisible, restack surface list */
2874 ico_window_mgr_restack_layer(usurf, 0);
2877 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
2878 usurf, usurf->visible, usurf->raise, 0, 0,0);
2881 /*--------------------------------------------------------------------------*/
2883 * @brief win_mgr_set_raise: change surface raise/lower
2885 * @param[in] usurf UIFW surface
2886 * @param[in] raise raise(=1)/lower(0)
2889 /*--------------------------------------------------------------------------*/
2891 win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise)
2893 uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%x",
2894 (int)usurf, raise, (int)usurf->win_layer->layer);
2896 wl_list_remove(&usurf->ivi_layer);
2898 /* raise ... surface stack to top of layer */
2899 wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer);
2901 uifw_trace("win_mgr_set_raise: Raise Link to Top");
2904 /* Lower ... surface stack to bottom of layer */
2905 wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer);
2907 uifw_trace("win_mgr_set_raise: Lower Link to Bottom");
2910 /* rebild compositor surface list */
2911 if (usurf->visible) {
2912 ico_window_mgr_restack_layer(usurf, 0);
2914 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
2915 usurf, usurf->visible, usurf->raise, 0, 0,0);
2917 uifw_trace("win_mgr_set_raise: Leave");
2920 /*--------------------------------------------------------------------------*/
2922 * @brief win_mgr_destroy_surface: surface destroy
2924 * @param[in] surface Weston surface
2927 /*--------------------------------------------------------------------------*/
2929 win_mgr_destroy_surface(struct weston_surface *surface)
2931 struct uifw_win_surface *usurf;
2932 struct uifw_win_surface *phash;
2933 struct uifw_win_surface *bhash;
2936 usurf = find_uifw_win_surface_by_ws(surface);
2938 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
2941 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
2944 if (&usurf->surf_map != usurf->surf_map.next) {
2945 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
2948 /* destroy active surface */
2949 if (usurf == _ico_win_mgr->active_pointer_usurf) {
2950 _ico_win_mgr->active_pointer_usurf = NULL;
2952 if (usurf == _ico_win_mgr->active_keyboard_usurf) {
2953 _ico_win_mgr->active_keyboard_usurf = NULL;
2956 /* destroy animation extenson */
2957 if (win_mgr_hook_animation) {
2958 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
2961 /* delete from layer list */
2962 wl_list_remove(&usurf->ivi_layer);
2963 ico_window_mgr_restack_layer(NULL, 0);
2965 /* delete from cleint list */
2966 wl_list_remove(&usurf->client_link);
2968 /* delete from hash table */
2969 hash = MAKE_IDHASH(usurf->surfaceid);
2970 phash = _ico_win_mgr->idhash[hash];
2972 while ((phash) && (phash != usurf)) {
2974 phash = phash->next_idhash;
2977 bhash->next_idhash = usurf->next_idhash;
2980 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
2983 hash = MAKE_WSHASH(usurf->surface);
2984 phash = _ico_win_mgr->wshash[hash];
2986 while ((phash) && (phash != usurf)) {
2988 phash = phash->next_wshash;
2991 bhash->next_wshash = usurf->next_wshash;
2994 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
2997 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED,
3000 hash = usurf->surfaceid & SURCAFE_ID_MASK;
3001 _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16));
3004 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
3007 /*--------------------------------------------------------------------------*/
3009 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
3011 * @param[in] client client
3012 * @param[in] data user data(unused)
3013 * @param[in] version protocol version(unused)
3014 * @param[in] id client object id
3017 /*--------------------------------------------------------------------------*/
3019 bind_ico_win_mgr(struct wl_client *client,
3020 void *data, uint32_t version, uint32_t id)
3022 struct wl_resource *add_resource;
3023 struct uifw_manager *mgr;
3024 struct uifw_client *uclient;
3026 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
3028 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
3030 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
3031 _ico_win_mgr, unbind_ico_win_mgr);
3034 /* Create client management tabel */
3035 uclient = find_client_from_client(client);
3037 win_mgr_bind_client(client, NULL);
3038 uclient = find_client_from_client(client);
3042 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
3044 uifw_error("bind_ico_win_mgr: Error, No Memory");
3047 memset(mgr, 0, sizeof(struct uifw_manager));
3048 mgr->resource = add_resource;
3052 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
3054 uifw_trace("bind_ico_win_mgr: Leave");
3057 /*--------------------------------------------------------------------------*/
3059 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
3061 * @param[in] resource client resource
3064 /*--------------------------------------------------------------------------*/
3066 unbind_ico_win_mgr(struct wl_resource *resource)
3068 struct uifw_manager *mgr, *itmp;
3070 uifw_trace("unbind_ico_win_mgr: Enter");
3072 /* Remove manager from manager list */
3073 _ico_win_mgr->num_manager = 0;
3074 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
3075 if (mgr->resource == resource) {
3076 wl_list_remove(&mgr->link);
3081 _ico_win_mgr->num_manager++;
3085 uifw_trace("unbind_ico_win_mgr: Leave");
3088 /*--------------------------------------------------------------------------*/
3090 * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen)
3092 * @param[in] event event code(if -1, not send event)
3093 * @param[in] usurf UIFW surface table
3094 * @param[in] param1 parameter 1
3096 * @param[in] param5 parameter 5
3097 * @return number of managers
3098 * @retval > 0 number of managers
3099 * @retval 0 manager not exist
3101 /*--------------------------------------------------------------------------*/
3103 ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
3104 const int param1, const int param2, const int param3,
3105 const int param4, const int param5)
3108 struct uifw_manager* mgr;
3110 /* if appid not fix, check and fix appid */
3111 if ((usurf != NULL) &&
3112 (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) {
3113 win_mgr_get_client_appid(usurf->uclient);
3116 /* send created if not send created event */
3117 if ((usurf != NULL) && (usurf->created == 0) &&
3118 (((usurf->width > 0) && (usurf->height > 0)) ||
3119 ((event != ICO_WINDOW_MGR_WINDOW_CREATED) &&
3120 (event != ICO_WINDOW_MGR_WINDOW_NAME)))) {
3121 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
3123 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED"
3124 "(surf=%08x,name=%s,pid=%d,appid=%s)", (int)mgr->resource,
3125 usurf->surfaceid, usurf->winname, usurf->uclient->pid,
3126 usurf->uclient->appid);
3127 ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid,
3128 usurf->winname, usurf->uclient->pid,
3129 usurf->uclient->appid);
3135 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
3140 case ICO_WINDOW_MGR_WINDOW_CREATED:
3141 /* Do nothing anymore because sended window create event */
3144 case ICO_WINDOW_MGR_WINDOW_NAME:
3145 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME"
3146 "(surf=%08x,name=%s)", (int)mgr->resource,
3147 usurf->surfaceid, usurf->winname);
3148 ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid,
3152 case ICO_WINDOW_MGR_WINDOW_DESTROYED:
3153 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED"
3154 "(surf=%08x)", (int)mgr->resource, usurf->surfaceid);
3155 ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid);
3158 case ICO_WINDOW_MGR_WINDOW_VISIBLE:
3159 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE"
3160 "(surf=%08x,vis=%d,raise=%d,hint=%d)",
3161 (int)mgr->resource, usurf->surfaceid, param1, param2, param3);
3162 ico_window_mgr_send_window_visible(mgr->resource,
3163 usurf->surfaceid, param1, param2, param3);
3166 case ICO_WINDOW_MGR_WINDOW_CONFIGURE:
3167 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE"
3168 "(surf=%08x,app=%s,node=%x,layer=%x,x/y=%d/%d,w/h=%d/%d,hint=%d)",
3169 (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid,
3170 usurf->node_tbl->node, usurf->win_layer->layer,
3171 param1, param2, param3, param4, param5);
3172 ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid,
3173 usurf->node_tbl->node,
3174 usurf->win_layer->layer,
3175 param1, param2, param3, param4, param5);
3178 case ICO_WINDOW_MGR_WINDOW_ACTIVE:
3179 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE"
3180 "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid,
3182 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
3186 case ICO_WINDOW_MGR_LAYER_VISIBLE:
3187 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE"
3188 "(layer=%x,visivle=%d)", (int)mgr->resource, param1, param2);
3189 ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2);
3193 uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event);
3201 /*--------------------------------------------------------------------------*/
3203 * @brief win_mgr_set_scale: set surface transform scale
3205 * @param[in] usurf UIFW surface
3206 * @return chagne display
3207 * @retval =1 change display
3208 * @retval =0 no change
3210 /*--------------------------------------------------------------------------*/
3212 win_mgr_set_scale(struct uifw_win_surface *usurf)
3214 struct weston_surface *es;
3219 es = usurf->surface;
3220 if ((es != NULL) && (es->buffer_ref.buffer)) {
3221 if (usurf->client_width == 0) usurf->client_width = es->geometry.width;
3222 if (usurf->client_height == 0) usurf->client_height = es->geometry.height;
3223 scalex = (float)usurf->width / (float)usurf->client_width;
3224 scaley = (float)usurf->height / (float)usurf->client_height;
3225 uifw_trace("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)",
3226 usurf->surfaceid, scalex, usurf->width, usurf->client_width,
3227 scaley, usurf->height, usurf->client_height);
3230 if (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT) {
3231 if (scalex > scaley) {
3233 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) {
3234 usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex);
3235 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) {
3240 else if (scalex < scaley) {
3242 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) {
3243 usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley);
3244 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) {
3249 uifw_trace("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d",
3250 usurf->surfaceid, usurf->xadd, usurf->yadd);
3252 if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) {
3253 usurf->scalex = scalex;
3254 usurf->scaley = scaley;
3255 if ((scalex != 1.0f) || (scaley != 1.0f)) {
3256 weston_matrix_init(&usurf->transform.matrix);
3257 weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f);
3258 uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform);
3259 if (usurf->set_transform == 0) {
3260 usurf->set_transform = 1;
3261 wl_list_init(&usurf->transform.link);
3262 wl_list_insert(&es->geometry.transformation_list, &usurf->transform.link);
3265 else if (usurf->set_transform != 0) {
3266 uifw_trace("win_mgr_set_scale: reset transform");
3267 usurf->set_transform = 0;
3268 wl_list_remove(&usurf->transform.link);
3270 weston_surface_geometry_dirty(es);
3271 weston_surface_update_transform(es);
3272 weston_surface_damage_below(es);
3273 weston_surface_damage(es);
3280 /*--------------------------------------------------------------------------*/
3282 * @brief ico_window_mgr_get_uclient: get UIFW client table
3284 * @param[in] appid application Id
3285 * @return UIFW client table
3286 * @retval !=NULL success(UIFW client table address)
3287 * @retval = NULL error(appid not exist)
3289 /*--------------------------------------------------------------------------*/
3290 WL_EXPORT struct uifw_client *
3291 ico_window_mgr_get_uclient(const char *appid)
3293 struct uifw_client *uclient;
3295 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3296 if (strcmp(uclient->appid, appid) == 0) {
3303 /*--------------------------------------------------------------------------*/
3305 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
3307 * @param[in] appid application Id
3308 * @param[in] winname window name
3309 * @return UIFW surface table
3310 * @retval !=NULL success(UIFW surface table address)
3311 * @retval = NULL error(appid or winname not exist)
3313 /*--------------------------------------------------------------------------*/
3314 WL_EXPORT struct uifw_win_surface *
3315 ico_window_mgr_get_client_usurf(const char *appid, const char *winname)
3317 struct uifw_client *uclient;
3318 struct uifw_win_surface *usurf;
3320 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3321 if (strcmp(uclient->appid, appid) == 0) {
3322 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
3323 if ((winname == NULL) || (*winname == 0) ||
3324 (strcmp(winname, usurf->winname) == 0)) {
3333 /*--------------------------------------------------------------------------*/
3335 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
3337 * @param[in] hook_animation hook routine
3340 /*--------------------------------------------------------------------------*/
3342 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
3344 win_mgr_hook_animation = hook_animation;
3347 /*--------------------------------------------------------------------------*/
3349 * @brief module_init: initialize ico_window_mgr
3350 * this function called from ico_pluign_loader
3352 * @param[in] es weston compositor
3353 * @param[in] argc number of arguments(unused)
3354 * @param[in] argv argument list(unused)
3359 /*--------------------------------------------------------------------------*/
3361 module_init(struct weston_compositor *ec, int *argc, char *argv[])
3367 struct weston_output *output;
3368 struct weston_config_section *section;
3369 char *displayno = NULL;
3371 uifw_info("ico_window_mgr: Enter(module_init)");
3373 /* get ivi debug level */
3374 section = weston_config_get_section(ec->config, "ivi-debug", NULL, NULL);
3376 weston_config_section_get_int(section, "flag", &_ico_ivi_debug_flag, 0);
3377 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
3380 /* get display number list */
3381 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
3383 weston_config_section_get_string(section, "displayno", &displayno, NULL);
3387 section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL);
3389 weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1);
3390 weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 109);
3391 weston_config_section_get_int(section, "input", &_ico_ivi_input_layer, 101);
3392 weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102);
3393 weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0);
3396 /* get animation default */
3397 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
3399 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
3400 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 600);
3401 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 15);
3403 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 600;
3404 if (_ico_ivi_animation_fps < 2) _ico_ivi_animation_fps = 15;
3406 /* create ico_window_mgr management table */
3407 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
3408 if (_ico_win_mgr == NULL) {
3409 uifw_error("ico_window_mgr: malloc failed");
3413 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
3414 _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8);
3415 if (! _ico_win_mgr->surfaceid_map) {
3416 uifw_error("ico_window_mgr: malloc failed");
3419 uifw_debug("ico_window_mgr: table=%08x", (int)_ico_win_mgr);
3420 memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8);
3422 _ico_win_mgr->compositor = ec;
3424 _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS;
3425 _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS;
3427 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
3428 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
3429 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
3430 uifw_error("ico_window_mgr: Error(wl_global_create)");
3434 wl_list_init(&_ico_win_mgr->client_list);
3435 wl_list_init(&_ico_win_mgr->manager_list);
3436 wl_list_init(&_ico_win_mgr->ivi_layer_list);
3437 wl_list_init(&_ico_win_mgr->map_list);
3439 _ico_win_mgr->free_maptable = NULL;
3441 /* create display list */
3442 if (displayno != NULL) {
3449 wl_list_for_each(output, &ec->output_list, link) {
3450 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
3451 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_surfacemap;
3452 wl_list_insert(output->animation_list.prev,
3453 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
3455 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
3457 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
3459 wl_list_for_each(output, &ec->output_list, link) {
3462 idx = strtol(p, (char **)0, 0);
3463 uifw_trace("ico_window_mgr: config Display.%d is %d", i, idx);
3465 if ((idx < 0) || (idx >= _ico_num_nodes)) {
3472 if (_ico_node_table[idx].node) {
3473 for (idx = 0; idx < _ico_num_nodes; idx++) {
3474 if (_ico_node_table[idx].node == 0) break;
3476 if (idx >= _ico_num_nodes) {
3477 uifw_error("ico_window_mgr: number of display overflow");
3481 _ico_node_table[idx].node = idx + 0x100;
3482 _ico_node_table[idx].displayno = i;
3483 _ico_node_table[idx].disp_x = output->x;
3484 _ico_node_table[idx].disp_y = output->y;
3485 _ico_node_table[idx].disp_width = output->width;
3486 _ico_node_table[idx].disp_height = output->height;
3488 if (i >= _ico_num_nodes) break;
3491 for (i = 0; i < _ico_num_nodes; i++) {
3492 _ico_node_table[i].node &= 0x0ff;
3493 uifw_trace("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
3494 i, _ico_node_table[i].displayno,
3495 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
3496 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
3498 if (displayno) free(displayno);
3500 /* my node Id ... this version fixed 0 */
3501 nodeId = ico_ivi_get_mynode();
3503 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
3504 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
3505 nodeId, _ico_win_mgr->surface_head);
3507 /* Hook to IVI-Shell */
3508 ico_ivi_shell_hook_bind(win_mgr_bind_client);
3509 ico_ivi_shell_hook_unbind(win_mgr_unbind_client);
3510 ico_ivi_shell_hook_create(win_mgr_register_surface);
3511 ico_ivi_shell_hook_destroy(win_mgr_destroy_surface);
3512 ico_ivi_shell_hook_map(win_mgr_map_surface);
3513 ico_ivi_shell_hook_configure(win_mgr_shell_configure);
3514 ico_ivi_shell_hook_select(win_mgr_select_surface);
3515 ico_ivi_shell_hook_title(win_mgr_set_title);
3516 ico_ivi_shell_hook_move(win_mgr_surface_move);
3518 uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d",
3519 _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps);
3520 uifw_info("ico_window_mgr: layer default=%d startup=%d background=%d",
3521 _ico_ivi_default_layer, _ico_ivi_startup_layer, _ico_ivi_background_layer);
3522 uifw_info("ico_window_mgr: layer input=%d cursor=%d",
3523 _ico_ivi_input_layer, _ico_ivi_cursor_layer);
3524 uifw_info("ico_window_mgr: debug flag=%x log level=%d",
3525 _ico_ivi_debug_flag, _ico_ivi_debug_level);
3527 uifw_info("ico_window_mgr: Leave(module_init)");