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_buffer (inport from wayland-1.2.0/src/wayland-server.h) */
72 struct uifw_wl_buffer { /* struct wl_buffer */
73 struct wl_resource resource;
74 int32_t width, height;
78 /* wl_drm_buffer (inport from mesa-9.1.3/src/egl/wayland/wayland-drm/wayland-drm.h) */
79 struct uifw_drm_buffer {
80 struct uifw_wl_buffer buffer;
81 void *drm; /* struct wl_drm */
83 const void *driver_format;
89 /* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h) */
90 struct uifw_intel_region { /* struct intel_region */
91 void *bo; /**< buffer manager's buffer */
92 uint32_t refcount; /**< Reference count for region */
93 uint32_t cpp; /**< bytes per pixel */
94 uint32_t width; /**< in pixels */
95 uint32_t height; /**< in pixels */
96 uint32_t pitch; /**< in bytes */
97 char *map; /**< only non-NULL when region is actually mapped */
98 uint32_t map_refcount; /**< Reference count for mapping */
99 uint32_t tiling; /**< Which tiling mode the region is in */
100 uint32_t name; /**< Global name for the bo */
101 void *screen; /* screen */
103 struct uifw_dri_image { /* struct __DRIimageRec */
104 struct uifw_intel_region *region;
111 void *planar_format; /* intel_image_format */
115 /* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c) */
121 struct uifw_gl_surface_state { /* struct gl_surface_state */
123 struct gl_shader *shader;
127 int needs_full_upload;
128 pixman_region32_t texture_damage;
130 void *images[3]; /* EGLImageKHR */
134 struct weston_buffer_reference buffer_ref;
135 enum buffer_type buffer_type;
136 int pitch; /* in pixels */
137 int height; /* in pixels */
140 /* Multi Windiw Manager */
142 struct weston_compositor *compositor; /* Weston compositor */
143 void *shell; /* shell(ico_ivi_shell) table address */
144 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
146 struct wl_list client_list; /* Clients */
147 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
148 int num_manager; /* Number of managers */
149 struct wl_list ivi_layer_list; /* Layer management table list */
150 struct uifw_win_layer *input_layer; /* layer table for input layer */
151 struct uifw_win_layer *cursor_layer; /* layer table for cursor layer */
152 struct wl_list map_list; /* surface map list */
153 struct uifw_surface_map *free_maptable; /* free maped surface table list */
154 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
155 /* animation for map check */
156 struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */
157 struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */
159 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
160 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
162 uint32_t surfaceid_count; /* Number of surface id */
163 uint32_t surfaceid_max; /* Maximum number of surface id */
164 uint16_t *surfaceid_map; /* SurfaceId assign bit map */
166 char shell_init; /* shell initialize flag */
167 char res; /* (unused) */
170 /* Internal macros */
172 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
174 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
176 /* function prototype */
177 /* get surface table from weston surface*/
178 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
179 struct weston_surface *wsurf);
180 /* get client table from weston client */
181 static struct uifw_client* find_client_from_client(struct wl_client *client);
182 /* assign new surface id */
183 static uint32_t generate_id(void);
184 /* bind shell client */
185 static void win_mgr_bind_client(struct wl_client *client, void *shell);
186 /* unind shell client */
187 static void win_mgr_unbind_client(struct wl_client *client);
188 /* get appid from pid */
189 static void win_mgr_get_client_appid(struct uifw_client *uclient);
190 /* create new surface */
191 static void win_mgr_register_surface(
192 struct wl_client *client, struct wl_resource *resource,
193 struct weston_surface *surface, struct shell_surface *shsurf);
194 /* surface destroy */
195 static void win_mgr_destroy_surface(struct weston_surface *surface);
196 /* map new surface */
197 static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width,
198 int32_t *height, int32_t *sx, int32_t *sy);
199 /* send surface change event to manager */
200 static void win_mgr_change_surface(struct weston_surface *surface,
201 const int to, const int manager);
202 /* window manager surface configure */
203 static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
204 int x, int y, int width, int height);
205 /* shell surface configure */
206 static void win_mgr_shell_configure(struct weston_surface *surface);
208 static void win_mgr_select_surface(struct weston_surface *surface);
209 /* surface set title */
210 static void win_mgr_set_title(struct weston_surface *surface, const char *title);
211 /* surface move request from shell */
212 static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy);
214 static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise);
215 /* surface change from manager */
216 static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x,
217 const int y, const int width, const int height);
218 /* create new layer */
219 static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf,
220 const uint32_t layer);
221 /* set surface layer */
222 static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer);
223 /* set active surface */
224 static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target);
226 /* declare manager */
227 static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource,
229 /* set window layer */
230 static void uifw_set_window_layer(struct wl_client *client,
231 struct wl_resource *resource,
232 uint32_t surfaceid, uint32_t layer);
233 /* set surface size and position */
234 static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
235 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
236 int32_t width, int32_t height, int32_t flags);
237 /* show/hide and raise/lower surface */
238 static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
239 uint32_t surfaceid, int32_t visible, int32_t raise,
241 /* set surface animation */
242 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
243 uint32_t surfaceid, int32_t type,
244 const char *animation, int32_t time);
245 /* set surface attributes */
246 static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
247 uint32_t surfaceid, uint32_t attributes);
248 /* surface visibility control with animation*/
249 static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
250 uint32_t surfaceid, int32_t visible,
251 int32_t x, int32_t y, int32_t width, int32_t height);
252 /* set active surface (form HomeScreen) */
253 static void uifw_set_active(struct wl_client *client, struct wl_resource *resource,
254 uint32_t surfaceid, int32_t active);
255 /* layer visibility control */
256 static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
257 uint32_t layer, int32_t visible);
258 /* get application surfaces */
259 static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
261 /* check and change all mapped surface */
262 static void win_mgr_check_surfacemap(struct weston_animation *animation,
263 struct weston_output *output, uint32_t msecs);
264 /* check and change mapped surface */
265 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event);
266 /* map surface to system application */
267 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
268 uint32_t surfaceid, int32_t framerate);
270 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
273 static void bind_ico_win_mgr(struct wl_client *client,
274 void *data, uint32_t version, uint32_t id);
276 static void unbind_ico_win_mgr(struct wl_resource *resource);
277 /* send event to manager */
278 static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
279 const int param1, const int param2, const int param3,
280 const int param4, const int param5);
281 /* set surface transform */
282 static int win_mgr_set_scale(struct uifw_win_surface *usurf);
283 /* convert animation name to Id value */
284 static int ico_get_animation_name(const char *animation);
285 /* hook for animation */
286 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
287 /* hook for input region */
288 static void (*win_mgr_hook_visible)(struct uifw_win_surface *usurf) = NULL;
289 static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL;
292 /* Multi Window Manager interface */
293 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
294 uifw_declare_manager,
295 uifw_set_window_layer,
296 uifw_set_positionsize,
300 uifw_visible_animation,
302 uifw_set_layer_visible,
308 /* plugin common value(without ico_plugin_loader) */
309 static int _ico_ivi_debug_flag = 0; /* Debug flags */
310 static int _ico_ivi_debug_level = 3; /* Debug Level */
311 static char *_ico_ivi_animation_name = NULL; /* Default animation name */
312 static int _ico_ivi_animation_time = 500; /* Default animation time */
313 static int _ico_ivi_animation_fps = 15; /* Animation frame rate */
314 static int _ico_ivi_background_layer = 0; /* Background layer */
315 static int _ico_ivi_default_layer = 1; /* Deafult layer id at surface create*/
316 static int _ico_ivi_input_layer = 101; /* Input layer id */
317 static int _ico_ivi_cursor_layer = 102; /* Cursor layer id */
318 static int _ico_ivi_startup_layer = 109; /* Deafult layer id at system startup*/
320 /* static management table */
321 static struct ico_win_mgr *_ico_win_mgr = NULL;
322 static int _ico_num_nodes = 0;
323 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
326 /*--------------------------------------------------------------------------*/
328 * @brief ico_ivi_debugflag: get debug flags
331 * @return debug flags
333 /*--------------------------------------------------------------------------*/
335 ico_ivi_debugflag(void)
337 return _ico_ivi_debug_flag;
340 /*--------------------------------------------------------------------------*/
342 * @brief ico_ivi_debuglevel: answer debug output level.
345 * @return debug output level
346 * @retval 0 No debug output
347 * @retval 1 Only error output
348 * @retval 2 Error and Warning output
349 * @retval 3 Error, Warning and information output
350 * @retval 4 All output with debug write
352 /*--------------------------------------------------------------------------*/
354 ico_ivi_debuglevel(void)
356 return _ico_ivi_debug_level;
359 /*--------------------------------------------------------------------------*/
361 * @brief ico_ivi_default_animation_name: get default animation name
364 * @return Default animation name
366 /*--------------------------------------------------------------------------*/
367 WL_EXPORT const char *
368 ico_ivi_default_animation_name(void)
370 return _ico_ivi_animation_name;
373 /*--------------------------------------------------------------------------*/
375 * @brief ico_ivi_default_animation_time: get default animation time
378 * @return Default animation time(miri sec)
380 /*--------------------------------------------------------------------------*/
382 ico_ivi_default_animation_time(void)
384 return _ico_ivi_animation_time;
387 /*--------------------------------------------------------------------------*/
389 * @brief ico_ivi_default_animation_fps: get default animation frame rate
392 * @return Default animation frame rate(frames/sec)
394 /*--------------------------------------------------------------------------*/
396 ico_ivi_default_animation_fps(void)
398 return _ico_ivi_animation_fps;
401 /*--------------------------------------------------------------------------*/
403 * @brief ico_ivi_get_mynode: Get my NodeId
406 * @return NodeId of my node
408 /*--------------------------------------------------------------------------*/
410 ico_ivi_get_mynode(void)
412 /* Reference Platform 0.90 only support 1 ECU */
416 /*--------------------------------------------------------------------------*/
418 * @brief ico_window_mgr_set_weston_surface: set weston surface
420 * @param[in] usurf UIFW surface
421 * @param[in] x X coordinate on screen
422 * @param[in] y Y coordinate on screen
423 * @param[in] width width
424 * @param[in] height height
427 /*--------------------------------------------------------------------------*/
429 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
430 int x, int y, int width, int height)
432 struct weston_surface *es = usurf->surface;
433 int buf_width, buf_height;
436 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
441 if (es->buffer_ref.buffer != NULL) {
442 buf_width = weston_surface_buffer_width(es);
443 buf_height = weston_surface_buffer_height(es);
444 if ((width <= 0) || (height <= 0)) {
446 usurf->width = buf_width;
448 usurf->height = buf_height;
450 if (usurf->width > buf_width) {
452 x += (usurf->width - buf_width)/2;
454 if (usurf->height > buf_height) {
456 y += (usurf->height - buf_height)/2;
458 if (usurf->visible) {
459 x += usurf->node_tbl->disp_x;
460 y += usurf->node_tbl->disp_y;
463 x = ICO_IVI_MAX_COORDINATE+1;
464 y = ICO_IVI_MAX_COORDINATE+1;
466 if ((es->geometry.x != x) || (es->geometry.y != y) ||
467 (es->geometry.width != width) || (es->geometry.height != height)) {
468 weston_surface_damage_below(es);
469 win_mgr_surface_configure(usurf, x, y, width, height);
471 weston_surface_damage(es);
472 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
476 /*--------------------------------------------------------------------------*/
478 * @brief ico_window_mgr_set_weston_surface: set weston surface
480 * @param[in] usurf UIFW surface
481 * @param[in] x X coordinate on screen
482 * @param[in] y Y coordinate on screen
483 * @param[in] width width
484 * @param[in] height height
487 /*--------------------------------------------------------------------------*/
489 ico_window_mgr_change_surface(struct uifw_win_surface *usurf,
490 const int to, const int manager)
492 uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)",
493 usurf->surfaceid, to, manager);
494 win_mgr_change_surface(usurf->surface, to, manager);
495 uifw_trace("ico_window_mgr_change_surface: Leave");
498 /*--------------------------------------------------------------------------*/
500 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
502 * @param[in] surfaceid UIFW surface id
503 * @return UIFW surface table address
504 * @retval !=NULL success(surface table address)
505 * @retval NULL error(surface id dose not exist)
507 /*--------------------------------------------------------------------------*/
508 WL_EXPORT struct uifw_win_surface *
509 ico_window_mgr_get_usurf(const uint32_t surfaceid)
511 struct uifw_win_surface *usurf;
513 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
516 if (usurf->surfaceid == surfaceid) {
519 usurf = usurf->next_idhash;
521 uifw_trace("ico_window_mgr_get_usurf: NULL");
525 /*--------------------------------------------------------------------------*/
527 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
529 * @param[in] surfaceid UIFW surface id
530 * @param[in] client Wayland client
531 * @return UIFW surface table address
532 * @retval !=NULL success(surface table address)
533 * @retval NULL error(surface id or client dose not exist)
535 /*--------------------------------------------------------------------------*/
536 WL_EXPORT struct uifw_win_surface *
537 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
539 struct uifw_win_surface *usurf;
540 struct uifw_client *uclient;
542 if (surfaceid == ICO_WINDOW_MGR_V_MAINSURFACE) {
543 uclient = find_client_from_client(client);
545 if (&uclient->surface_link != uclient->surface_link.next) {
546 usurf = container_of(uclient->surface_link.next,
547 struct uifw_win_surface, client_link);
558 usurf = ico_window_mgr_get_usurf(surfaceid);
563 /*--------------------------------------------------------------------------*/
565 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
567 * @param[in] wsurf Weston surface
568 * @return UIFW surface table address
569 * @retval !=NULL success(surface table address)
570 * @retval NULL error(surface dose not exist)
572 /*--------------------------------------------------------------------------*/
573 static struct uifw_win_surface *
574 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
576 struct uifw_win_surface *usurf;
578 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
581 if (usurf->surface == wsurf) {
584 usurf = usurf->next_wshash;
586 uifw_trace("find_uifw_win_surface_by_ws: NULL");
590 /*--------------------------------------------------------------------------*/
592 * @brief find_client_from_client: find UIFW client by wayland client
594 * @param[in] client Wayland client
595 * @return UIFW client table address
596 * @retval !=NULL success(client table address)
597 * @retval NULL error(client dose not exist)
599 /*--------------------------------------------------------------------------*/
600 static struct uifw_client*
601 find_client_from_client(struct wl_client *client)
603 struct uifw_client *uclient;
605 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
606 if (uclient->client == client) {
610 uifw_trace("find_client_from_client: client.%08x is NULL", (int)client);
614 /*--------------------------------------------------------------------------*/
616 * @brief ico_window_mgr_get_appid: find application id by wayland client
618 * @param[in] client Wayland client
619 * @return application id
620 * @retval !=NULL success(application id)
621 * @retval NULL error(client dose not exist)
623 /*--------------------------------------------------------------------------*/
625 ico_window_mgr_get_appid(struct wl_client* client)
627 struct uifw_client *uclient;
629 uclient = find_client_from_client(client);
634 return uclient->appid;
637 /*--------------------------------------------------------------------------*/
639 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
641 * @param[in] displayno display number
642 * @param[out] x relative X coordinate
643 * @param[out] y relative Y coordinate
646 /*--------------------------------------------------------------------------*/
648 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
650 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
653 *x = _ico_node_table[displayno].disp_x;
654 *y = _ico_node_table[displayno].disp_y;
657 /*--------------------------------------------------------------------------*/
659 * @brief generate_id: generate uniq id for UIFW surface id
662 * @return uniq id for UIFW surface id
664 /*--------------------------------------------------------------------------*/
675 _ico_win_mgr->surfaceid_count ++;
677 /* serach free id from bitmap */
678 for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) {
679 if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) {
680 _ico_win_mgr->surfaceid_count = 0;
682 if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) {
683 /* find free id from bitmap */
684 map = 1 << (_ico_win_mgr->surfaceid_count % 16);
685 for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) {
686 if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map)
688 _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map;
689 _ico_win_mgr->surfaceid_count
690 = (_ico_win_mgr->surfaceid_count/16)*16 + i;
692 surfaceId = (_ico_win_mgr->surfaceid_count + 1)
693 | _ico_win_mgr->surface_head;
694 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
700 _ico_win_mgr->surfaceid_count += 16;
703 /* no free id in bitmap, extend bitmap */
704 if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) {
705 /* too many surfaces, system error */
706 uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort",
707 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
708 fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n",
709 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
713 new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8);
714 memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8);
715 memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8);
716 _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max;
717 new_map[_ico_win_mgr->surfaceid_count/16] |= 1;
718 _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS;
719 free(_ico_win_mgr->surfaceid_map);
720 _ico_win_mgr->surfaceid_map = new_map;
722 uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)",
723 _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max);
724 surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head;
726 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
730 /*--------------------------------------------------------------------------*/
732 * @brief win_mgr_bind_client: desktop_shell from client
734 * @param[in] client Wayland client
735 * @param[in] shell shell(ico_ivi_shell) table address
738 /*--------------------------------------------------------------------------*/
740 win_mgr_bind_client(struct wl_client *client, void *shell)
742 struct uifw_client *uclient;
748 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
749 (int)client, (int)shell);
751 /* save shell table address */
753 _ico_win_mgr->shell = shell;
757 uclient = find_client_from_client(client);
759 /* client not exist, create client management table */
760 uifw_trace("win_mgr_bind_client: Create Client");
761 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
763 uifw_error("win_mgr_bind_client: Error, No Memory");
766 memset(uclient, 0, sizeof(struct uifw_client));
767 uclient->client = client;
768 wl_list_init(&uclient->surface_link);
774 wl_client_get_credentials(client, &pid, &uid, &gid);
775 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
776 (int)client, (int)pid, (int)uid, (int)gid);
778 uclient->pid = (int)pid;
779 /* get applicationId from AppCore(AUL) */
780 win_mgr_get_client_appid(uclient);
782 /* weston internal client, not manage */
783 if (strcmp(uclient->appid, "weston") == 0) {
785 uifw_trace("win_mgr_bind_client: client=%08x is internal, delete", (int)client);
787 else if (newclient > 0) {
788 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
792 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
794 uifw_trace("win_mgr_bind_client: Leave");
797 /*--------------------------------------------------------------------------*/
799 * @brief win_mgr_unbind_client: unbind desktop_shell from client
801 * @param[in] client Wayland client
804 /*--------------------------------------------------------------------------*/
806 win_mgr_unbind_client(struct wl_client *client)
808 struct uifw_client *uclient;
810 uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client);
812 uclient = find_client_from_client(client);
814 /* Client exist, Destory client management table */
815 wl_list_remove(&uclient->link);
818 uifw_trace("win_mgr_unbind_client: Leave");
821 /*--------------------------------------------------------------------------*/
823 * @brief win_mgr_get_client_appid: get applicationId from pid
825 * @param[in] uclient UIFW client management table
828 /*--------------------------------------------------------------------------*/
830 win_mgr_get_client_appid(struct uifw_client *uclient)
838 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
839 i = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
840 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
841 "pid=%d appid=<%s>", i, uclient->pid, uclient->appid);
842 if (uclient->appid[0] != 0) {
843 /* OK, end of get appid */
844 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
847 /* client dose not exist in AppCore, search Linux process table */
848 uclient->fixed_appid ++;
849 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
850 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
851 fd = open(procpath, O_RDONLY);
853 size = read(fd, procpath, sizeof(procpath));
854 for (; size > 0; size--) {
855 if (procpath[size-1]) break;
858 /* get program base name */
860 for (j = 0; j < size; j++) {
861 if (procpath[j] == 0) break;
862 if (procpath[j] == '/') i = j + 1;
865 for (; i < size; i++) {
866 uclient->appid[j] = procpath[i];
867 if ((uclient->appid[j] == 0) ||
868 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
871 /* search application number in apprication start option */
872 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
873 for (; i < size; i++) {
874 if ((procpath[i] == 0) &&
875 (procpath[i+1] == '@')) {
876 strncpy(&uclient->appid[j], &procpath[i+1],
877 ICO_IVI_APPID_LENGTH - j - 2);
884 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
885 if (uclient->appid[i] != ' ') break;
887 uclient->appid[i+1] = 0;
888 if (uclient->appid[0]) {
889 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
890 "Process table", uclient->pid, uclient->appid);
893 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
895 sprintf(uclient->appid, "?%d?", uclient->pid);
900 /*--------------------------------------------------------------------------*/
902 * @brief ico_get_animation_name: convert animation name to Id value
904 * @param[in] animation animation name
905 * @return animation Id value
907 /*--------------------------------------------------------------------------*/
909 ico_get_animation_name(const char *animation)
911 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
913 if (strcasecmp(animation, "none") == 0) {
914 return ICO_WINDOW_MGR_ANIMATION_NONE;
917 if (win_mgr_hook_animation) {
918 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
921 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
926 /*--------------------------------------------------------------------------*/
928 * @brief win_mgr_register_surface: create UIFW surface
930 * @param[in] client Wayland client
931 * @param[in] resource client resource
932 * @param[in] surface Weston surface
933 * @param[in] shsurf shell surface
936 /*--------------------------------------------------------------------------*/
938 win_mgr_register_surface(struct wl_client *client, struct wl_resource *resource,
939 struct weston_surface *surface, struct shell_surface *shsurf)
941 struct uifw_win_surface *usurf;
942 struct uifw_win_surface *phash;
943 struct uifw_win_surface *bhash;
946 uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x)",
947 (int)surface, (int)client, (int)resource);
949 /* check new surface */
950 if (find_uifw_win_surface_by_ws(surface)) {
951 /* surface exist, NOP */
952 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
956 /* set default color and shader */
957 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
959 /* create UIFW surface management table */
960 usurf = malloc(sizeof(struct uifw_win_surface));
962 uifw_error("win_mgr_register_surface: No Memory");
966 memset(usurf, 0, sizeof(struct uifw_win_surface));
968 usurf->surfaceid = generate_id();
969 usurf->surface = surface;
970 usurf->shsurf = shsurf;
971 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
972 wl_list_init(&usurf->ivi_layer);
973 wl_list_init(&usurf->client_link);
974 wl_list_init(&usurf->animation.animation.link);
975 wl_list_init(&usurf->surf_map);
976 wl_list_init(&usurf->input_region);
977 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
978 usurf->animation.hide_time = ico_ivi_default_animation_time();;
979 usurf->animation.show_anima = usurf->animation.hide_anima;
980 usurf->animation.show_time = usurf->animation.hide_time;
981 usurf->animation.move_anima = usurf->animation.hide_anima;
982 usurf->animation.move_time = usurf->animation.hide_time;
983 usurf->animation.resize_anima = usurf->animation.hide_anima;
984 usurf->animation.resize_time = usurf->animation.hide_time;
986 if ((_ico_win_mgr->num_manager <= 0) ||
987 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE)) {
988 uifw_trace("win_mgr_register_surface: No Manager, Force visible");
992 uifw_trace("win_mgr_register_surface: Manager exist, Not visible");
997 usurf->uclient = find_client_from_client(client);
998 if (! usurf->uclient) {
999 /* client not exist, create client management table */
1000 uifw_trace("win_mgr_register_surface: Create Client");
1001 win_mgr_bind_client(client, NULL);
1002 usurf->uclient = find_client_from_client(client);
1003 if (! usurf->uclient) {
1004 uifw_error("win_mgr_register_surface: No Memory");
1008 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1010 /* make surface id hash table */
1011 hash = MAKE_IDHASH(usurf->surfaceid);
1012 phash = _ico_win_mgr->idhash[hash];
1016 phash = phash->next_idhash;
1019 bhash->next_idhash = usurf;
1022 _ico_win_mgr->idhash[hash] = usurf;
1025 /* make weston surface hash table */
1026 hash = MAKE_WSHASH(usurf->surface);
1027 phash = _ico_win_mgr->wshash[hash];
1031 phash = phash->next_wshash;
1034 bhash->next_wshash = usurf;
1037 _ico_win_mgr->wshash[hash] = usurf;
1039 /* set default layer id */
1040 win_mgr_set_layer(usurf, (_ico_win_mgr->num_manager > 0) ? _ico_ivi_default_layer :
1041 _ico_ivi_startup_layer);
1042 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1045 /*--------------------------------------------------------------------------*/
1047 * @brief win_mgr_map_surface: map surface
1049 * @param[in] surface Weston surface
1050 * @param[in] width surface width
1051 * @param[in] height surface height
1052 * @param[in] sx X coordinate on screen
1053 * @param[in] sy Y coordinate on screen
1056 /*--------------------------------------------------------------------------*/
1058 win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height,
1059 int32_t *sx, int32_t *sy)
1061 struct uifw_win_surface *usurf;
1063 uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)",
1064 (int)surface, *sx, *sy, *width, *height);
1066 usurf = find_uifw_win_surface_by_ws(surface);
1069 uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d",
1070 usurf->surfaceid, usurf->width, usurf->height, usurf->visible);
1071 if ((usurf->width > 0) && (usurf->height > 0)) {
1072 uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize"
1073 "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d",
1074 usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height,
1076 *width = usurf->width;
1077 *height = usurf->height;
1078 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1079 usurf->node_tbl->disp_y + usurf->y,
1080 usurf->width, usurf->height);
1083 uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, "
1084 "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)",
1085 usurf->surfaceid, *sx, *sy, *width, *height);
1086 usurf->width = *width;
1087 usurf->height = *height;
1090 if (usurf->x < 0) usurf->x = 0;
1091 if (usurf->y < 0) usurf->y = 0;
1093 if (_ico_win_mgr->num_manager > 0) {
1094 /* HomeScreen exist, coodinate set by HomeScreen */
1095 if (usurf->visible) {
1096 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1097 usurf->node_tbl->disp_y + usurf->y,
1098 usurf->width, usurf->height);
1101 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1102 ICO_IVI_MAX_COORDINATE+1,
1103 usurf->width, usurf->height);
1105 uifw_trace("win_mgr_map_surface: Change size/position x/y=%d/%d w/h=%d/%d",
1106 (int)surface->geometry.x, (int)surface->geometry.y,
1107 surface->geometry.width, surface->geometry.height);
1109 if ((_ico_win_mgr->num_manager <= 0) ||
1110 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE)) {
1111 uifw_trace("win_mgr_map_surface: Np HomeScreen, chaneg to Visible");
1112 ico_window_mgr_set_visible(usurf, 1);
1116 if (usurf->visible) {
1117 ico_window_mgr_restack_layer(NULL, FALSE);
1119 uifw_trace("win_mgr_map_surface: Leave");
1122 uifw_trace("win_mgr_map_surface: Leave(No UIFW Surface)");
1126 /*--------------------------------------------------------------------------*/
1128 * @brief ico_window_mgr_restack_layer: restack surface list
1130 * @param[in] usurf UIFW surface (if NULL, no surface)
1131 * @param[in] omit_touch omit touch layer flag (TRUE=omit/FALSE=not omit)
1134 /*--------------------------------------------------------------------------*/
1136 ico_window_mgr_restack_layer(struct uifw_win_surface *usurf, const int omit_touch)
1138 struct uifw_win_surface *eu;
1139 struct uifw_win_layer *el;
1140 int32_t buf_width, buf_height;
1142 struct weston_layer *wlayer;
1143 struct weston_surface *surface, *surfacetmp;
1144 int num_visible = 0;
1148 /* save current visible */
1150 old_visible = ico_window_mgr_is_visible(usurf);
1153 /* set layer type */
1154 ico_ivi_shell_set_layertype();
1156 /* make compositor surface list */
1157 wlayer = ico_ivi_shell_weston_layer();
1159 uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x,omit=%d) layer=%08x",
1160 (int)usurf, omit_touch, (int)wlayer);
1162 /* remove all surfaces in panel_layer */
1163 wl_list_for_each_safe(surface, surfacetmp, &wlayer->surface_list, layer_link) {
1164 wl_list_remove(&surface->layer_link);
1165 wl_list_init(&surface->layer_link);
1167 wl_list_init(&wlayer->surface_list);
1169 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1170 if (el->layer_type == ICO_WINDOW_MGR_LAYER_TYPE_CURSOR) continue;
1171 wl_list_for_each (eu, &el->surface_list, ivi_layer) {
1172 if (eu->surface == NULL) continue;
1174 /* target only panel or unknown layer */
1175 layer_type = ico_ivi_shell_layertype(eu->surface);
1176 if ((layer_type != LAYER_TYPE_PANEL) && (layer_type != LAYER_TYPE_UNKNOWN)) {
1179 wl_list_remove(&eu->surface->layer_link);
1180 wl_list_init(&eu->surface->layer_link);
1182 if (eu->mapped != 0) {
1183 if ((el->visible == FALSE) || (eu->visible == FALSE) ||
1184 ((omit_touch != FALSE) &&
1185 (el->layer_type == ICO_WINDOW_MGR_LAYER_TYPE_INPUT))) {
1186 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1187 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1189 else if (eu->surface->buffer_ref.buffer) {
1190 buf_width = weston_surface_buffer_width(eu->surface);
1191 buf_height = weston_surface_buffer_height(eu->surface);
1192 if (eu->width > buf_width) {
1193 new_x = (float)(eu->x +
1194 (eu->width - eu->surface->geometry.width)/2);
1197 new_x = (float)eu->x;
1199 if (eu->height > buf_height) {
1200 new_y = (float) (eu->y +
1201 (eu->height - eu->surface->geometry.height)/2);
1204 new_y = (float)eu->y;
1206 new_x += eu->node_tbl->disp_x + eu->xadd;
1207 new_y += eu->node_tbl->disp_y + eu->yadd;
1211 new_x = (float)(eu->x + eu->node_tbl->disp_x + eu->xadd);
1212 new_y = (float)(eu->y + eu->node_tbl->disp_y + eu->yadd);
1214 wl_list_insert(wlayer->surface_list.prev, &eu->surface->layer_link);
1215 if ((eu->restrain_configure == 0) &&
1216 ((new_x != eu->surface->geometry.x) ||
1217 (new_y != eu->surface->geometry.y))) {
1218 weston_surface_damage_below(eu->surface);
1219 weston_surface_set_position(eu->surface, (float)new_x, (float)new_y);
1220 weston_surface_damage(eu->surface);
1222 #if 0 /* too many debug log */
1223 uifw_trace("ico_window_mgr_restack_layer:%3d(%d).%08x(%08x:%d) "
1224 "x/y=%d/%d w/h=%d/%d",
1225 el->layer, el->visible, eu->surfaceid, (int)eu->surface,
1226 eu->visible, (int)eu->surface->geometry.x,
1227 (int)eu->surface->geometry.y, eu->surface->geometry.width,
1228 eu->surface->geometry.height);
1234 /* damage(redraw) target surfacem if target exist */
1236 weston_surface_damage(usurf->surface);
1239 /* composit and draw screen(plane) */
1240 if (omit_touch == FALSE) {
1241 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
1243 if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) &&
1244 (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) {
1245 /* start shell fade */
1246 _ico_win_mgr->shell_init = 1;
1247 ico_ivi_shell_startup(_ico_win_mgr->shell);
1251 /* if visible change, call hook for input region */
1252 if ((usurf != NULL) && (win_mgr_hook_visible != NULL)) {
1253 if (old_visible != ico_window_mgr_is_visible(usurf)) {
1254 (*win_mgr_hook_visible)(usurf);
1257 uifw_trace("ico_window_mgr_restack_layer: Leave");
1260 /*--------------------------------------------------------------------------*/
1262 * @brief ico_window_mgr_input_layer: input layer control
1264 * @param[in] omit omit input layer flag (TRUE=omit/FALSE=not omit)
1267 /*--------------------------------------------------------------------------*/
1269 ico_window_mgr_input_layer(int omit)
1271 struct uifw_win_surface *eu;
1273 /* check current input layer mode */
1274 if ((_ico_win_mgr->input_layer == NULL) ||
1275 ((omit != FALSE) && (_ico_win_mgr->input_layer->visible == FALSE))) {
1276 uifw_trace("ico_window_mgr_input_layer: input layer not exist or hide");
1280 wl_list_for_each (eu, &_ico_win_mgr->input_layer->surface_list, ivi_layer) {
1281 if ((eu->surface == NULL) || (eu->mapped == 0)) continue;
1283 if (omit != FALSE) {
1284 eu->animation.pos_x = (int)eu->surface->geometry.x;
1285 eu->animation.pos_y = (int)eu->surface->geometry.y;
1286 eu->surface->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1);
1287 eu->surface->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1);
1290 eu->surface->geometry.x = (float)eu->animation.pos_x;
1291 eu->surface->geometry.y = (float)eu->animation.pos_y;
1296 /*--------------------------------------------------------------------------*/
1298 * @brief win_mgr_create_layer: create new layer
1300 * @param[in] usurf UIFW surface, (if need)
1301 * @param[in] layer layer id
1303 * @retval != NULL success(layer management table)
1304 * @retval == NULL error(No Memory)
1306 /*--------------------------------------------------------------------------*/
1307 static struct uifw_win_layer *
1308 win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1310 struct uifw_win_layer *el;
1311 struct uifw_win_layer *new_el;
1313 new_el = malloc(sizeof(struct uifw_win_layer));
1315 uifw_trace("win_mgr_create_layer: Leave(No Memory)");
1319 memset(new_el, 0, sizeof(struct uifw_win_layer));
1320 new_el->layer = layer;
1321 if ((int)layer == _ico_ivi_background_layer ) {
1322 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_BACKGROUND;
1324 else if ((int)layer == _ico_ivi_input_layer ) {
1325 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_INPUT;
1326 _ico_win_mgr->input_layer = new_el;
1328 else if ((int)layer == _ico_ivi_cursor_layer ) {
1329 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_CURSOR;
1330 _ico_win_mgr->cursor_layer = new_el;
1333 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_NORMAL;
1335 new_el->visible = TRUE;
1336 wl_list_init(&new_el->surface_list);
1337 wl_list_init(&new_el->link);
1339 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1340 if (layer >= el->layer) break;
1342 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1343 wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link);
1346 wl_list_insert(el->link.prev, &new_el->link);
1350 wl_list_remove(&usurf->ivi_layer);
1351 wl_list_insert(&new_el->surface_list, &usurf->ivi_layer);
1352 usurf->win_layer = new_el;
1357 /*--------------------------------------------------------------------------*/
1359 * @brief win_mgr_set_layer: set(or change) surface layer
1361 * @param[in] usurf UIFW surface
1362 * @param[in] layer layer id
1365 /*--------------------------------------------------------------------------*/
1367 win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1369 struct uifw_win_layer *el;
1370 struct uifw_win_layer *new_el;
1372 uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)",
1373 usurf->surfaceid, (int)usurf->surface, layer);
1375 /* check if same layer */
1376 if ((usurf->win_layer != NULL) && (usurf->win_layer->layer == layer)) {
1377 uifw_trace("win_mgr_set_layer: Leave(Same Layer)");
1381 /* search existing layer */
1382 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1383 if (el->layer == layer) break;
1386 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1387 /* layer not exist, create new layer */
1388 uifw_trace("win_mgr_set_layer: New Layer %d", layer);
1389 new_el = win_mgr_create_layer(usurf, layer);
1391 uifw_trace("win_mgr_set_layer: Leave(No Memory)");
1396 uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer);
1397 wl_list_remove(&usurf->ivi_layer);
1398 wl_list_insert(&el->surface_list, &usurf->ivi_layer);
1399 usurf->win_layer = el;
1402 /* rebild compositor surface list */
1403 if (usurf->visible) {
1404 ico_window_mgr_restack_layer(usurf, 0);
1406 uifw_trace("win_mgr_set_layer: Leave");
1409 /*--------------------------------------------------------------------------*/
1411 * @brief win_mgr_set_active: set(or change) active surface
1413 * @param[in] usurf UIFW surface
1414 * @param[in] target target device
1417 /*--------------------------------------------------------------------------*/
1419 win_mgr_set_active(struct uifw_win_surface *usurf, const int target)
1421 struct weston_seat *seat;
1422 struct weston_surface *surface;
1423 int object = target;
1426 uifw_trace("win_mgr_set_active: Enter(%08x,%x)", (int)usurf, target);
1428 if ((usurf) && (usurf->shsurf) && (usurf->surface)) {
1429 surface = usurf->surface;
1430 if ((target & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) {
1432 if (_ico_win_mgr->active_pointer_usurf == usurf) {
1433 object |= ICO_WINDOW_MGR_ACTIVE_POINTER;
1435 if (_ico_win_mgr->active_keyboard_usurf == usurf) {
1436 object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1440 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1441 _ico_win_mgr->active_pointer_usurf = usurf;
1443 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1444 _ico_win_mgr->active_keyboard_usurf = usurf;
1451 object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1453 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1454 _ico_win_mgr->active_pointer_usurf = NULL;
1456 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1457 _ico_win_mgr->active_keyboard_usurf = NULL;
1461 wl_list_for_each(seat, &_ico_win_mgr->compositor->seat_list, link) {
1462 if ((object & ICO_WINDOW_MGR_ACTIVE_POINTER) && (seat->pointer)) {
1464 if (seat->pointer->focus != surface) {
1465 uifw_trace("win_mgr_set_active: pointer change surface(%08x=>%08x)",
1466 (int)seat->pointer->focus, (int)surface);
1467 weston_surface_from_global_fixed(surface,
1471 weston_pointer_set_focus(seat->pointer, surface, sx, sy);
1474 uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)",
1479 uifw_trace("win_mgr_set_active: pointer reset surface(%08x)",
1480 (int)seat->pointer->focus);
1481 weston_pointer_set_focus(seat->pointer, NULL,
1482 wl_fixed_from_int(0), wl_fixed_from_int(0));
1485 if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) {
1487 if (seat->keyboard->focus != surface) {
1488 weston_keyboard_set_focus(seat->keyboard, surface);
1489 uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)",
1490 (int)seat->keyboard->focus, (int)surface);
1493 uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)",
1498 uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)",
1499 (int)seat->keyboard);
1500 weston_keyboard_set_focus(seat->keyboard, NULL);
1504 uifw_trace("win_mgr_set_active: Leave(%08x)", (int)usurf);
1507 /*--------------------------------------------------------------------------*/
1509 * @brief ico_window_mgr_ismykeyboard: check active keyboard
1511 * @param[in] usurf UIFW surface
1512 * @return check result
1513 * @retval =1 usurf is active keyboard surface
1514 * @retval =0 usurf is not active
1516 /*--------------------------------------------------------------------------*/
1518 ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf)
1520 return (_ico_win_mgr->active_keyboard_usurf == usurf) ? 1 : 0;
1523 /*--------------------------------------------------------------------------*/
1525 * @brief uifw_declare_manager: declare manager(ex.SystemController) client
1527 * @param[in] client Weyland client
1528 * @param[in] resource resource of request
1529 * @param[in] manager manager(1=manager, 0=not manager)
1532 /*--------------------------------------------------------------------------*/
1534 uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager)
1536 struct uifw_manager* mgr;
1537 struct uifw_win_surface *usurf;
1538 struct uifw_client *uclient;
1539 struct uifw_win_layer *el;
1541 uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d",
1542 (int)client, manager);
1544 uclient = find_client_from_client(client);
1546 uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client);
1550 uclient->manager = manager;
1552 /* client set to manager */
1553 _ico_win_mgr->num_manager = 0;
1554 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1555 if (mgr->resource == resource) {
1556 if (mgr->manager != manager) {
1557 uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d",
1558 (int)client, mgr->manager, manager);
1559 mgr->manager = manager;
1562 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1563 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
1564 /* send window create event to manager */
1565 if (usurf->created != 0) {
1566 uifw_trace("uifw_declare_manager: Send manager(%08x) "
1567 "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)",
1568 (int)resource, usurf->surfaceid,
1569 usurf->uclient->pid, usurf->uclient->appid);
1570 ico_window_mgr_send_window_created(resource,
1573 usurf->uclient->pid,
1574 usurf->uclient->appid);
1582 _ico_win_mgr->num_manager++;
1585 uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager);
1588 /*--------------------------------------------------------------------------*/
1590 * @brief uifw_set_window_layer: set layer id to surface
1592 * @param[in] client Weyland client
1593 * @param[in] resource resource of request
1594 * @param[in] surfaceid UIFW surface id
1595 * @param[in] layer layer id
1598 /*--------------------------------------------------------------------------*/
1600 uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource,
1601 uint32_t surfaceid, uint32_t layer)
1603 if (layer == ICO_WINDOW_MGR_V_LAYER_INPUT) {
1604 layer = _ico_ivi_input_layer;
1606 else if (layer == ICO_WINDOW_MGR_V_LAYER_CURSOR) {
1607 layer = _ico_ivi_cursor_layer;
1609 else if (layer == ICO_WINDOW_MGR_V_LAYER_STARTUP) {
1610 layer = _ico_ivi_startup_layer;
1613 uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d",
1614 (int)resource, surfaceid, layer);
1616 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1619 uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid);
1623 if (usurf->win_layer->layer != layer) {
1624 win_mgr_set_layer(usurf, layer);
1625 win_mgr_change_surface(usurf->surface, -1, 1);
1627 uifw_trace("uifw_set_window_layer: Leave");
1630 /*--------------------------------------------------------------------------*/
1632 * @brief uifw_set_positionsize: set surface position and size
1634 * @param[in] client Weyland client
1635 * @param[in] resource resource of request
1636 * @param[in] surfaceid UIFW surface id
1637 * @param[in] node surface node id
1638 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
1639 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
1640 * @param[in] width surface width(if bigger than 16383, no change)
1641 * @param[in] height surface height(if bigger than 16383, no change)
1642 * @param[in] flags with/without animation and client configure flag
1645 /*--------------------------------------------------------------------------*/
1647 uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
1648 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
1649 int32_t width, int32_t height, int32_t flags)
1651 struct uifw_client *uclient;
1652 struct uifw_win_surface *usurf;
1653 struct weston_surface *es;
1657 uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x",
1658 surfaceid, node, x, y, width, height, flags);
1660 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1662 uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid);
1666 uclient = find_client_from_client(client);
1669 if (((int)node) >= _ico_num_nodes) {
1670 uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)",
1671 node, _ico_num_nodes);
1672 if ((ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE) == 0) {
1673 if (usurf->visible) {
1674 /* no display, change to hide */
1675 uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE,
1676 ICO_WINDOW_MGR_V_NOCHANGE, 0);
1682 usurf->node_tbl = &_ico_node_table[node];
1684 es = usurf->surface;
1686 /* weston surface exist */
1687 es = usurf->surface;
1688 retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
1690 /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */
1691 if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x;
1692 if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y;
1693 if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width;
1694 if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height;
1696 /* check animation */
1697 if ((usurf->animation.restrain_configure != 0) &&
1698 (x == usurf->x) && (y == usurf->y) &&
1699 (width == usurf->width) && (height == usurf->height)) {
1700 uifw_trace("uifw_set_positionsize: Leave(same position size at animation)");
1705 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
1706 (uclient->manager == 0)) uclient = NULL;
1709 if ((usurf->width > 0) && (usurf->height > 0)) {
1710 win_mgr_surface_change_mgr(es, x, y, width, height);
1711 uifw_trace("uifw_set_positionsize: Leave(Request from App)");
1715 uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d",
1717 /* Initiale position is (0,0) */
1718 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x),
1719 (float)(usurf->node_tbl->disp_y));
1722 uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d",
1723 (int)es->geometry.x, (int)es->geometry.y,
1724 (int)es->geometry.width, (int)es->geometry.height);
1726 usurf->animation.pos_x = usurf->x;
1727 usurf->animation.pos_y = usurf->y;
1728 usurf->animation.pos_width = usurf->width;
1729 usurf->animation.pos_height = usurf->height;
1730 usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0;
1733 usurf->width = width;
1734 usurf->height = height;
1735 if (_ico_win_mgr->num_manager <= 0) {
1736 /* no manager(HomeScreen), set geometory */
1737 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x + x),
1738 (float)(usurf->node_tbl->disp_y + y));
1740 if ((es->output) && (es->buffer_ref.buffer) &&
1741 (es->geometry.width > 0) && (es->geometry.height > 0)) {
1742 uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)",
1744 if (usurf->visible) {
1745 if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) &&
1746 (win_mgr_hook_animation != NULL)) {
1747 /* with animation */
1748 if ((x != (usurf->surface->geometry.x - usurf->node_tbl->disp_x)) ||
1749 (y != (usurf->surface->geometry.y - usurf->node_tbl->disp_y))) {
1750 op = ICO_WINDOW_MGR_ANIMATION_OPMOVE;
1752 else if ((width != usurf->surface->geometry.width) ||
1753 (height != usurf->surface->geometry.height)) {
1754 op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE;
1757 op = ICO_WINDOW_MGR_ANIMATION_OPNONE;
1759 if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) &&
1760 (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) ||
1761 ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) &&
1762 (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) {
1763 retanima = (*win_mgr_hook_animation)(op, (void *)usurf);
1764 uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima);
1767 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
1768 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
1769 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1770 usurf->width, usurf->height);
1774 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
1775 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
1776 win_mgr_change_surface(es,
1777 (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1);
1779 uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output);
1784 usurf->width = width;
1785 usurf->height = height;
1786 uifw_trace("uifw_set_positionsize: Leave(OK,but no buffer)");
1790 /*--------------------------------------------------------------------------*/
1792 * @brief uifw_set_visible: surface visible/raise control
1794 * @param[in] client Weyland client
1795 * @param[in] resource resource of request
1796 * @param[in] surfaceid UIFW surface id
1797 * @param[in] visible visible(1=show/0=hide/other=no change)
1798 * @param[in] raise raise(1=raise/0=lower/other=no change)
1799 * @param[in] flags with/without animation
1802 /*--------------------------------------------------------------------------*/
1804 uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
1805 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags)
1807 struct uifw_win_surface *usurf;
1808 struct uifw_client *uclient;
1812 uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)",
1813 surfaceid, visible, raise, flags);
1815 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1816 if ((! usurf) || (! usurf->surface)) {
1817 uifw_trace("uifw_set_visible: Leave(Surface Not Exist)");
1821 uclient = find_client_from_client(client);
1823 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
1824 (uclient->manager == 0)) {
1825 uifw_trace("uifw_set_visible: Request from App(%s), not Manager",
1830 uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid);
1834 uifw_trace("uifw_set_visible: Request from Unknown App, not Manager");
1839 if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) {
1841 if (! usurf->visible) {
1843 uifw_trace("uifw_set_visible: Change to Visible");
1845 ico_ivi_shell_set_toplevel(usurf->shsurf);
1847 /* Weston surface configure */
1848 uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d",
1849 (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y,
1850 usurf->width, usurf->height);
1851 ico_ivi_shell_set_surface_type(usurf->shsurf);
1852 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1853 usurf->width, usurf->height);
1855 restack = 1; /* need damage */
1857 if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) &&
1858 (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1859 (win_mgr_hook_animation != NULL)) {
1860 usurf->animation.pos_x = usurf->x;
1861 usurf->animation.pos_y = usurf->y;
1862 usurf->animation.pos_width = usurf->width;
1863 usurf->animation.pos_height = usurf->height;
1864 usurf->animation.no_configure = 0;
1865 retanima = (*win_mgr_hook_animation)(
1866 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
1867 ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS :
1868 ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1870 uifw_trace("uifw_set_visible: ret call anima = %d", retanima);
1873 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1874 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1875 uifw_trace("uifw_set_visible: Leave(No Change)");
1879 else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) {
1881 if (usurf->visible) {
1883 /* Weston surface configure */
1884 weston_surface_damage_below(usurf->surface);
1885 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1886 usurf->width, usurf->height);
1888 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1889 if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) &&
1890 (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1891 (win_mgr_hook_animation != NULL)) {
1892 usurf->animation.pos_x = usurf->x;
1893 usurf->animation.pos_y = usurf->y;
1894 usurf->animation.pos_width = usurf->width;
1895 usurf->animation.pos_height = usurf->height;
1896 usurf->animation.no_configure = 0;
1897 retanima = (*win_mgr_hook_animation)(
1898 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
1899 ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS :
1900 ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1903 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1905 uifw_trace("uifw_set_visible: Change to UnVisible");
1906 /* change visible to unvisible, restack surface list */
1908 /* Weston surface configure */
1909 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1910 usurf->width, usurf->height);
1913 uifw_trace("uifw_set_visible: UnVisible but animation");
1916 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1917 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1918 uifw_trace("uifw_set_visible: Leave(No Change)");
1922 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1923 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1924 uifw_trace("uifw_set_visible: Leave(No Change)");
1929 if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) {
1930 win_mgr_set_raise(usurf, raise);
1931 if (usurf->visible == 0) {
1936 raise = ICO_WINDOW_MGR_V_NOCHANGE;
1940 ico_window_mgr_restack_layer(usurf, 0);
1943 /* send event(VISIBLE) to manager */
1945 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
1947 (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 :
1948 ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 :
1949 ICO_WINDOW_MGR_V_NOCHANGE),
1950 raise, uclient ? 0 : 1, 0,0);
1952 uifw_trace("uifw_set_visible: Leave(OK)");
1955 /*--------------------------------------------------------------------------*/
1957 * @brief uifw_set_animation: set animation of surface visible/unvisible
1959 * @param[in] client Weyland client
1960 * @param[in] resource resource of request
1961 * @param[in] surfaceid UIFW surface id
1962 * @param[in] type how to change surface
1963 * @param[in] anmation animation name
1964 * @param[in] time animation time(ms), if 0, default time
1967 /*--------------------------------------------------------------------------*/
1969 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1970 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1973 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1975 uifw_trace("uifw_set_transition: Enter(surf=%08x,type=%x,anim=%s,time=%d)",
1976 surfaceid, type, animation, time);
1979 if ((*animation != 0) && (*animation != ' ')) {
1980 animaid = ico_get_animation_name(animation);
1981 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1982 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1983 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1984 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1985 usurf->animation.next_anima = animaid;
1988 usurf->animation.hide_anima = animaid;
1991 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1992 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1993 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1994 usurf->animation.next_anima = animaid;
1997 usurf->animation.show_anima = animaid;
2000 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
2001 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
2002 usurf->animation.next_anima = animaid;
2005 usurf->animation.move_anima = animaid;
2008 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
2009 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
2010 usurf->animation.next_anima = animaid;
2013 usurf->animation.resize_anima = animaid;
2017 if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) {
2018 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
2019 usurf->animation.hide_time = time;
2021 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
2022 usurf->animation.show_time = time;
2024 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
2025 usurf->animation.move_time = time;
2027 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
2028 usurf->animation.resize_time = time;
2033 uifw_trace("uifw_set_animation: Leave(Surface(%08x) Not exist)", surfaceid);
2037 /*--------------------------------------------------------------------------*/
2039 * @brief uifw_set_attributes: set surface attributes
2041 * @param[in] client Weyland client
2042 * @param[in] resource resource of request
2043 * @param[in] surfaceid UIFW surface id
2044 * @param[in] attributes surface attributes
2047 /*--------------------------------------------------------------------------*/
2049 uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
2050 uint32_t surfaceid, uint32_t attributes)
2052 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2054 uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes);
2057 usurf->attributes = attributes;
2058 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) ==
2059 (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) {
2060 usurf->attributes &=
2061 ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT);
2063 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) ==
2064 (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) {
2065 usurf->attributes &=
2066 ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM);
2069 uifw_trace("uifw_set_attributes: Leave");
2072 /*--------------------------------------------------------------------------*/
2074 * @brief uifw_visible_animation: surface visibility control with animation
2076 * @param[in] client Weyland client
2077 * @param[in] resource resource of request
2078 * @param[in] surfaceid surface id
2079 * @param[in] visible visible(1=show/0=hide)
2080 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
2081 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
2082 * @param[in] width surface width(if bigger than 16383, no change)
2083 * @param[in] height surface height(if bigger than 16383, no change)
2086 /*--------------------------------------------------------------------------*/
2088 uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
2089 uint32_t surfaceid, int32_t visible,
2090 int32_t x, int32_t y, int32_t width, int32_t height)
2092 struct uifw_win_surface *usurf;
2094 uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)",
2095 surfaceid, visible, x, y, width, height);
2097 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2099 if ((! usurf) || (! usurf->surface)) {
2100 uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)");
2104 usurf->animation.pos_x = x;
2105 usurf->animation.pos_y = y;
2106 if (width > 0) usurf->animation.pos_width = width;
2107 else usurf->animation.pos_width = 1;
2108 if (height > 0) usurf->animation.pos_height = height;
2109 else usurf->animation.pos_height = 1;
2110 usurf->animation.no_configure = 0;
2112 uifw_set_visible(client, resource, surfaceid, visible,
2113 ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS);
2115 uifw_trace("uifw_visible_animation: Leave");
2118 /*--------------------------------------------------------------------------*/
2120 * @brief uifw_set_active: set active surface
2122 * @param[in] client Weyland client
2123 * @param[in] resource resource of request
2124 * @param[in] surfaceid UIFW surface id
2125 * @param[in] active target device
2128 /*--------------------------------------------------------------------------*/
2130 uifw_set_active(struct wl_client *client, struct wl_resource *resource,
2131 uint32_t surfaceid, int32_t active)
2133 struct uifw_win_surface *usurf;
2135 uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active);
2137 if ((surfaceid > 0) &&
2138 ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) {
2139 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2145 switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) {
2146 case ICO_WINDOW_MGR_ACTIVE_POINTER:
2147 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2148 if (_ico_win_mgr->active_pointer_usurf) {
2149 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2150 _ico_win_mgr->active_pointer_usurf,
2151 (_ico_win_mgr->active_keyboard_usurf ==
2152 _ico_win_mgr->active_pointer_usurf) ?
2153 ICO_WINDOW_MGR_ACTIVE_KEYBOARD :
2154 ICO_WINDOW_MGR_ACTIVE_NONE,
2157 _ico_win_mgr->active_pointer_usurf = usurf;
2158 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2160 ICO_WINDOW_MGR_ACTIVE_POINTER |
2161 (_ico_win_mgr->active_keyboard_usurf == usurf) ?
2162 ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0,
2164 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER);
2167 case ICO_WINDOW_MGR_ACTIVE_KEYBOARD:
2168 if (usurf != _ico_win_mgr->active_keyboard_usurf) {
2169 if (_ico_win_mgr->active_keyboard_usurf) {
2170 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2171 _ico_win_mgr->active_keyboard_usurf,
2172 (_ico_win_mgr->active_keyboard_usurf ==
2173 _ico_win_mgr->active_pointer_usurf) ?
2174 ICO_WINDOW_MGR_ACTIVE_POINTER :
2175 ICO_WINDOW_MGR_ACTIVE_NONE,
2178 _ico_win_mgr->active_keyboard_usurf = usurf;
2179 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2181 ICO_WINDOW_MGR_ACTIVE_KEYBOARD |
2182 (_ico_win_mgr->active_pointer_usurf == usurf) ?
2183 ICO_WINDOW_MGR_ACTIVE_POINTER : 0,
2185 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2189 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
2190 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
2191 if (_ico_win_mgr->active_pointer_usurf) {
2192 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2193 _ico_win_mgr->active_pointer_usurf,
2194 ICO_WINDOW_MGR_ACTIVE_NONE,
2196 if (_ico_win_mgr->active_keyboard_usurf ==
2197 _ico_win_mgr->active_pointer_usurf) {
2198 _ico_win_mgr->active_keyboard_usurf = NULL;
2201 if (_ico_win_mgr->active_keyboard_usurf) {
2202 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2203 _ico_win_mgr->active_keyboard_usurf,
2204 ICO_WINDOW_MGR_ACTIVE_NONE,
2207 _ico_win_mgr->active_pointer_usurf = usurf;
2208 _ico_win_mgr->active_keyboard_usurf = usurf;
2209 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2211 ICO_WINDOW_MGR_ACTIVE_POINTER |
2212 ICO_WINDOW_MGR_ACTIVE_KEYBOARD,
2214 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2215 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2219 uifw_trace("uifw_set_active: Leave(Change Active)");
2222 win_mgr_set_active(NULL, active);
2223 uifw_trace("uifw_set_active: Leave(Reset active surface)");
2227 /*--------------------------------------------------------------------------*/
2229 * @brief uifw_set_layer_visible: layer visible control
2231 * @param[in] client Weyland client
2232 * @param[in] resource resource of request
2233 * @param[in] layer layer id
2234 * @param[in] visible visible(1=show/0=hide)
2237 /*--------------------------------------------------------------------------*/
2239 uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
2240 uint32_t layer, int32_t visible)
2242 struct uifw_win_layer *el;
2243 struct uifw_win_layer *new_el;
2244 struct uifw_win_surface *usurf;
2246 if (layer == ICO_WINDOW_MGR_V_LAYER_INPUT) {
2247 layer = _ico_ivi_input_layer;
2249 else if (layer == ICO_WINDOW_MGR_V_LAYER_CURSOR) {
2250 layer = _ico_ivi_cursor_layer;
2252 else if (layer == ICO_WINDOW_MGR_V_LAYER_STARTUP) {
2253 layer = _ico_ivi_startup_layer;
2256 uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible);
2259 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2260 if (el->layer == layer) break;
2263 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
2264 /* layer not exist, create new layer */
2265 uifw_trace("uifw_set_layer_visible: New Layer %d", layer);
2266 new_el = win_mgr_create_layer(NULL, layer);
2268 uifw_trace("uifw_set_layer_visible: Leave(No Memory)");
2271 new_el->visible = (visible != 0) ? TRUE : FALSE;
2272 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2273 layer, new_el->visible, 0,0,0);
2274 uifw_trace("uifw_set_layer_visible: Leave(new layer)");
2278 /* control all surface in layer */
2279 if ((el->visible != FALSE) && (visible == 0)) {
2280 /* layer change to NOT visible */
2281 uifw_trace("uifw_set_layer_visible: change to not visible");
2282 el->visible = FALSE;
2284 else if ((el->visible == FALSE) && (visible != 0)) {
2285 /* layer change to visible */
2286 uifw_trace("uifw_set_layer_visible: change to visible");
2291 uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)",
2292 el->visible, visible);
2296 /* set damege area */
2297 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2298 if ((usurf->visible != FALSE) && (usurf->surface != NULL) &&
2299 (usurf->surface->output != NULL)) {
2300 /* Damage(redraw) target surface */
2301 weston_surface_damage_below(usurf->surface);
2305 /* rebild compositor surface list */
2306 ico_window_mgr_restack_layer(NULL, 0);
2308 /* send layer visible event to manager */
2309 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2310 layer, el->visible, 0,0,0);
2312 uifw_trace("uifw_set_layer_visible: Leave");
2315 /*--------------------------------------------------------------------------*/
2317 * @brief uifw_get_surfaces: get application surfaces
2319 * @param[in] client Weyland client
2320 * @param[in] resource resource of request
2321 * @param[in] appid application id
2324 /*--------------------------------------------------------------------------*/
2326 uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, const char *appid)
2328 struct uifw_client *uclient;
2329 struct uifw_win_layer *el;
2330 struct uifw_win_surface *usurf;
2331 struct wl_array reply;
2334 uifw_trace("uifw_get_surfaces: Enter(appid=%s)", appid);
2336 wl_array_init(&reply);
2338 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2339 if (strcmp(uclient->appid, appid) == 0) break;
2341 if (&uclient->link == &_ico_win_mgr->client_list) {
2342 uifw_trace("uifw_get_surfaces: appid=%s dose not exist", appid);
2345 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2346 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2347 if (usurf->uclient == uclient) {
2348 uifw_trace("uifw_get_surfaces: %s surf=%08x", appid, usurf->surfaceid);
2349 up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t));
2351 *up = usurf->surfaceid;
2357 ico_window_mgr_send_app_surfaces(resource, appid, &reply);
2359 wl_array_release(&reply);
2360 uifw_trace("uifw_get_surfaces: Leave");
2363 /*--------------------------------------------------------------------------*/
2365 * @brief win_mgr_check_surfacemap: check and change all surface
2367 * @param[in] animation weston animation table(unused)
2368 * @param[in] outout weston output table
2369 * @param[in] mseces current time(unused)
2372 /*--------------------------------------------------------------------------*/
2374 win_mgr_check_surfacemap(struct weston_animation *animation,
2375 struct weston_output *output, uint32_t msecs)
2377 struct uifw_surface_map *sm;
2379 wl_list_for_each(sm, &_ico_win_mgr->map_list, map_link) {
2380 if (sm->usurf->surface->output == output) {
2381 win_mgr_change_mapsurface(sm, 0);
2386 /*--------------------------------------------------------------------------*/
2388 * @brief win_mgr_change_mapsurface: check and change mapped surface
2390 * @param[in] sm map surface table
2391 * @param[in] event send event (if 0, send if changed)
2394 /*--------------------------------------------------------------------------*/
2396 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event)
2398 struct uifw_drm_buffer *drm_buffer;
2399 struct uifw_dri_image *dri_image;
2400 struct uifw_intel_region *dri_region;
2401 struct uifw_gl_surface_state *gl_state;
2402 struct weston_surface *es;
2403 uint32_t eglname = 0;
2409 /* check if buffered */
2410 es = sm->usurf->surface;
2411 if ((es == NULL) || (es->buffer_ref.buffer == NULL) ||
2412 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0) ||
2413 (es->buffer_ref.buffer->legacy_buffer == NULL) || (es->renderer_state == NULL) ||
2414 (((struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer)->driver_buffer
2416 /* surface has no buffer, error */
2417 uifw_trace("win_mgr_change_mapsurface: surface(%08x) has no buffer",
2418 sm->usurf->surfaceid);
2425 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
2432 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2433 if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2434 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
2436 else if (gl_state->buffer_type != BUFFER_TYPE_EGL) {
2440 drm_buffer = (struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer;
2441 dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer;
2442 dri_region = dri_image->region;
2443 width = es->buffer_ref.buffer->width;
2444 height = es->buffer_ref.buffer->height;
2445 stride = drm_buffer->stride[0];
2446 if (drm_buffer->format == 0x34325258) {
2447 format = EGL_TEXTURE_RGB;
2449 else if (drm_buffer->format == 0x34325241) {
2450 format = EGL_TEXTURE_RGBA;
2453 /* unknown format, error */
2454 format = EGL_NO_TEXTURE;
2456 eglname = dri_region->name;
2458 if ((sm->initflag == 0) && (width > 0) && (height > 0) && (stride > 0)) {
2460 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
2463 if ((width <= 0) || (height <= 0) || (stride <= 0)) {
2466 else if (event == 0) {
2467 if ((sm->width != width) || (sm->height != height) ||
2468 (sm->stride != stride)) {
2469 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
2471 else if ((eglname != sm->eglname) || (format != sm->format)) {
2472 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
2477 sm->height = height;
2478 sm->stride = stride;
2479 sm->eglname = eglname;
2480 sm->format = format;
2481 sm->eglname = eglname;
2486 #if 0 /* too many log */
2487 uifw_trace("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x name=%08x "
2488 "w/h/s=%d/%d/%d format=%x",
2489 event, sm->usurf->surfaceid, sm->eglname, sm->width, sm->height,
2490 sm->stride, sm->format);
2492 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
2493 sm->usurf->surfaceid, sm->type, sm->eglname,
2494 sm->width, sm->height, sm->stride, sm->format);
2495 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
2496 /* free map table if error */
2497 wl_list_remove(&sm->surf_link);
2498 wl_list_remove(&sm->map_link);
2499 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2500 _ico_win_mgr->free_maptable = sm;
2505 /*--------------------------------------------------------------------------*/
2507 * @brief uifw_map_surface: mapped surface buffer to system application
2509 * @param[in] client Weyland client
2510 * @param[in] resource resource of request
2511 * @param[in] surfaceid surface id
2512 * @param[in] framerate frame rate of surface update(frame/sec)
2515 /*--------------------------------------------------------------------------*/
2517 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
2518 uint32_t surfaceid, int32_t framerate)
2520 struct uifw_win_surface *usurf;
2521 struct weston_surface *es;
2522 struct uifw_surface_map *sm;
2523 struct weston_buffer *buffer;
2524 struct uifw_client *uclient;
2525 struct uifw_drm_buffer *drm_buffer;
2526 struct uifw_gl_surface_state *gl_state;
2528 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate);
2530 usurf = ico_window_mgr_get_usurf(surfaceid);
2532 /* surface dose not exist, error */
2533 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2534 surfaceid, 1, 0, 0, 0, 0, 0);
2535 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
2538 uclient = find_client_from_client(client);
2539 if ((! uclient) || (! uclient->mgr)) {
2540 /* client dose not exist, error */
2541 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2542 surfaceid, 2, 0, 0, 0, 0, 0);
2543 uifw_trace("uifw_map_surface: Leave(client=%08x dose not exist)", (int)client);
2547 es = usurf->surface;
2549 /* check if buffered */
2550 if ((es == NULL) || (es->buffer_ref.buffer == NULL)) {
2551 /* surface has no buffer, error */
2552 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2553 surfaceid, 3, 0, 0, 0, 0, 0);
2554 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no buffer)", surfaceid);
2558 /* check buffer type */
2559 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2560 if ((gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) {
2561 /* wl_shm_buffer not support */
2562 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2563 surfaceid, 4, 0, 0, 0, 0, 0);
2564 uifw_trace("uifw_map_surface: Leave(surface(%08x) is wl_shm_buffer, "
2565 "not support)", surfaceid);
2569 /* create map table */
2570 sm = _ico_win_mgr->free_maptable;
2572 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
2575 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
2577 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2578 surfaceid, 5, 0, 0, 0, 0, 0);
2579 uifw_trace("uifw_map_surface: Leave(malloc error)");
2583 memset(sm, 0, sizeof(struct uifw_surface_map));
2585 wl_list_init(&sm->map_link);
2586 wl_list_init(&sm->surf_link);
2588 sm->uclient = uclient;
2589 sm->type = ICO_WINDOW_MGR_MAP_TYPE_EGL;
2591 sm->framerate = framerate;
2592 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
2593 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
2595 buffer = es->buffer_ref.buffer;
2596 if (gl_state->buffer_type == BUFFER_TYPE_EGL) {
2597 sm->width = buffer->width;
2598 sm->height = buffer->height;
2599 drm_buffer = (struct uifw_drm_buffer *)buffer->legacy_buffer;
2600 if (drm_buffer != NULL) {
2601 sm->stride = drm_buffer->stride[0];
2602 if (drm_buffer->format == 0x34325258) {
2603 sm->format = EGL_TEXTURE_RGB;
2605 else if (drm_buffer->format == 0x34325241) {
2606 sm->format = EGL_TEXTURE_RGBA;
2609 /* unknown format, error */
2610 sm->format = EGL_NO_TEXTURE;
2612 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
2613 (gl_state != NULL)) {
2619 /* send map event */
2621 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP);
2623 uifw_trace("uifw_map_surface: Leave");
2626 /*--------------------------------------------------------------------------*/
2628 * @brief uifw_unmap_surface: unmap surface buffer
2630 * @param[in] client Weyland client
2631 * @param[in] resource resource of request
2632 * @param[in] surfaceid surface id
2635 /*--------------------------------------------------------------------------*/
2637 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2640 struct uifw_win_surface *usurf;
2641 struct uifw_surface_map *sm, *sm_tmp;
2642 struct uifw_client *uclient;
2644 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2646 usurf = ico_window_mgr_get_usurf(surfaceid);
2648 /* surface dose not exist, error */
2649 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2653 uclient = find_client_from_client(client);
2654 if ((! uclient) || (! uclient->mgr)) {
2655 /* client dose not exist, error */
2656 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2662 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2663 if (sm->uclient->mgr != NULL) {
2664 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x "
2665 "w/h/s=%d/%d/%d format=%x",
2666 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2667 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
2668 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2669 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2670 surfaceid, sm->type, sm->eglname, sm->width,
2671 sm->height, sm->stride, sm->format);
2676 wl_list_for_each_safe(sm, sm_tmp, &usurf->surf_map, surf_link) {
2677 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2678 /* send unmap event */
2679 if ((uclient != NULL) && (uclient->mgr != NULL)) {
2680 uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x "
2681 "w/h/s=%d/%d/%d format=%x",
2682 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2683 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
2684 ico_window_mgr_send_map_surface(uclient->mgr->resource,
2685 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2686 surfaceid, sm->type, sm->eglname, sm->width,
2687 sm->height, sm->stride, sm->format);
2689 wl_list_remove(&sm->surf_link);
2690 wl_list_remove(&sm->map_link);
2691 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2692 _ico_win_mgr->free_maptable = sm;
2694 uifw_trace("uifw_unmap_surface: Leave");
2697 /*--------------------------------------------------------------------------*/
2699 * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen)
2701 * @param[in] surface Weston surface
2702 * @param[in] x X coordinate on screen
2703 * @param[in] y Y coordinate on screen
2704 * @param[in] width surface width
2705 * @param[in] height surface height
2706 * @return number of managers
2707 * @retval > 0 number of managers
2708 * @retval 0 manager not exist
2710 /*--------------------------------------------------------------------------*/
2712 win_mgr_surface_change_mgr(struct weston_surface *surface,
2713 const int x, const int y, const int width, const int height)
2716 struct uifw_win_surface *usurf;
2718 uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)",
2719 (int)surface, x, y, width, height);
2721 usurf = find_uifw_win_surface_by_ws(surface);
2723 uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)");
2727 num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2728 usurf, x, y, width, height, 1);
2730 uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr);
2734 /*--------------------------------------------------------------------------*/
2736 * @brief win_mgr_change_surface: surface change
2738 * @param[in] surface Weston surface
2739 * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager)
2740 * @param[in] manager request from manager(0=Client,1=Manager)
2743 /*--------------------------------------------------------------------------*/
2745 win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager)
2747 struct uifw_win_surface *usurf;
2748 struct weston_surface *es;
2753 uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager);
2756 usurf = find_uifw_win_surface_by_ws(surface);
2758 uifw_trace("win_mgr_change_surface: Leave(Not Exist)");
2761 es = usurf->surface;
2763 uifw_trace("win_mgr_change_surface: Leave(No weston surface)");
2767 /* set surface size */
2768 uifw_debug("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d",
2769 (int)es->geometry.x, (int)es->geometry.y, usurf->x, usurf->y,
2770 usurf->width, usurf->height, es->geometry.width, es->geometry.height);
2771 if ((usurf->width <= 0) || (usurf->height <= 0)) {
2772 usurf->width = es->geometry.width;
2773 usurf->height = es->geometry.height;
2775 win_mgr_set_scale(usurf);
2776 if (usurf->visible) {
2777 weston_surface_set_position(usurf->surface,
2778 (float)(usurf->node_tbl->disp_x +
2779 usurf->x + usurf->xadd),
2780 (float)(usurf->node_tbl->disp_y +
2781 usurf->y + usurf->yadd));
2782 ico_window_mgr_restack_layer(usurf, 0);
2785 weston_surface_set_position(usurf->surface, (float)(ICO_IVI_MAX_COORDINATE+1),
2786 (float)(ICO_IVI_MAX_COORDINATE+1));
2789 /* send wayland event to client */
2790 if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) &&
2791 (usurf->width > 0) && (usurf->height > 0)) {
2792 if ((usurf->width != usurf->conf_width) ||
2793 (usurf->height != usurf->conf_height)) {
2794 usurf->conf_width = usurf->width;
2795 usurf->conf_height = usurf->height;
2796 uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ",
2797 usurf->surfaceid, (int)es, usurf->width, usurf->height);
2798 ico_ivi_shell_send_configure(es,
2799 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
2800 usurf->width, usurf->height);
2804 if (usurf->visible) {
2805 x = usurf->node_tbl->disp_x + usurf->x;
2806 y = usurf->node_tbl->disp_y + usurf->y;
2809 x = ICO_IVI_MAX_COORDINATE+1;
2810 y = ICO_IVI_MAX_COORDINATE+1;
2812 /* change geometry if request from manager */
2814 if ((usurf->width != es->geometry.width) ||
2815 (usurf->height != es->geometry.height) ||
2816 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
2817 win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height);
2822 /* send manager event to HomeScreen */
2825 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2826 usurf, usurf->x, usurf->y,
2827 usurf->width, usurf->height, 0);
2830 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2831 usurf, (int)es->geometry.x, (int)es->geometry.y,
2832 es->geometry.width, es->geometry.height, 1);
2836 /* change geometry if request from client */
2838 if ((usurf->width != es->geometry.width) || (usurf->height != es->geometry.height) ||
2839 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
2840 win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height);
2846 uifw_trace("win_mgr_change_surface: repaint");
2847 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
2849 uifw_trace("win_mgr_change_surface: Leave(OK)");
2852 /*--------------------------------------------------------------------------*/
2854 * @brief win_mgr_surface_configure: UIFW surface configure
2856 * @param[in] usurf UIFW surface
2857 * @param[in] x X coordinate on screen
2858 * @param[in] y Y coordinate on screen
2859 * @param[in] width surface width
2860 * @param[in] height surface height
2863 /*--------------------------------------------------------------------------*/
2865 win_mgr_surface_configure(struct uifw_win_surface *usurf,
2866 int x, int y, int width, int height)
2868 struct weston_surface *es;
2870 es = usurf->surface;
2871 if ((es != NULL) && (es->buffer_ref.buffer)) {
2872 if (usurf->client_width == 0) {
2873 usurf->client_width = es->geometry.width;
2874 if (usurf->client_width == 0)
2875 usurf->client_width = weston_surface_buffer_width(es);
2877 if (usurf->client_height == 0) {
2878 usurf->client_height = es->geometry.height;
2879 if (usurf->client_height == 0)
2880 usurf->client_height = weston_surface_buffer_height(es);
2883 /* not set geometry width/height */
2884 win_mgr_set_scale(usurf);
2885 weston_surface_set_position(es, x + usurf->xadd, y + usurf->yadd);
2889 /*--------------------------------------------------------------------------*/
2891 * @brief win_mgr_shell_configure: shell surface configure
2893 * @param[in] surface Weston surface
2896 /*--------------------------------------------------------------------------*/
2898 win_mgr_shell_configure(struct weston_surface *surface)
2900 struct uifw_win_surface *usurf;
2904 uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface);
2906 /* Find UIFW surface */
2907 usurf = find_uifw_win_surface_by_ws(surface);
2909 uifw_trace("win_mgr_shell_configure: Leave(Not Exist)");
2913 usurf->client_width = surface->geometry.width;
2914 usurf->client_height = surface->geometry.height;
2915 buf_width = weston_surface_buffer_width(surface);
2916 buf_height = weston_surface_buffer_height(surface);
2917 uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d",
2919 usurf->client_width, usurf->client_height, buf_width, buf_height);
2920 if (usurf->client_width > buf_width) usurf->client_width = buf_width;
2921 if (usurf->client_height > buf_height) usurf->client_height = buf_height;
2923 /* send event to manager */
2924 win_mgr_change_surface(surface, -1, 0);
2926 uifw_trace("win_mgr_shell_configure: Leave");
2929 /*--------------------------------------------------------------------------*/
2931 * @brief win_mgr_select_surface: select surface by Bottun/Touch
2933 * @param[in] surface Weston surface
2936 /*--------------------------------------------------------------------------*/
2938 win_mgr_select_surface(struct weston_surface *surface)
2940 struct uifw_win_surface *usurf;
2942 uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface);
2945 usurf = find_uifw_win_surface_by_ws(surface);
2947 uifw_trace("win_mgr_select_surface: Leave(Not Exist)");
2950 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2952 /* send active event to manager */
2953 if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2954 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) {
2955 uifw_trace("win_mgr_select_surface: not found manager, set active");
2956 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2957 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2960 uifw_trace("win_mgr_select_surface: Leave(OK)");
2963 /*--------------------------------------------------------------------------*/
2965 * @brief win_mgr_set_title: set tile name to surface
2967 * @param[in] surface weston surface
2968 * @param[in] title title name
2971 /*--------------------------------------------------------------------------*/
2973 win_mgr_set_title(struct weston_surface *surface, const char *title)
2975 struct uifw_win_surface *usurf;
2977 uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title);
2979 usurf = find_uifw_win_surface_by_ws(surface);
2981 uifw_trace("win_mgr_set_title: Leave(Not Exist)");
2984 if (((usurf->width > 0) && (usurf->height > 0)) &&
2985 ((usurf->created == 0) ||
2986 (strncmp(title, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) {
2987 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
2988 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
2989 if (usurf->created == 0) {
2990 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0);
2994 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0);
2998 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
2999 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
3001 uifw_trace("win_mgr_set_title: Leave");
3004 /*--------------------------------------------------------------------------*/
3006 * @brief win_mgr_surface_move: set tile name to surface
3008 * @param[in] surface weston surface
3009 * @param[in] title title name
3012 /*--------------------------------------------------------------------------*/
3014 win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy)
3016 struct uifw_win_surface *usurf;
3018 uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy);
3020 usurf = find_uifw_win_surface_by_ws(surface);
3022 uifw_trace("win_mgr_surface_move: Leave(Not Exist)");
3025 if (usurf->visible) {
3026 *dx = usurf->node_tbl->disp_x + usurf->x;
3027 *dy = usurf->node_tbl->disp_y + usurf->y;
3030 *dx = ICO_IVI_MAX_COORDINATE+1;
3031 *dy = ICO_IVI_MAX_COORDINATE+1;
3033 uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy);
3036 /*--------------------------------------------------------------------------*/
3038 * @brief ico_window_mgr_set_visible: change surface visibility
3040 * @param[in] usurf UIFW surface
3041 * @param[in] visible visible(=1)/unvisible(0)
3044 /*--------------------------------------------------------------------------*/
3046 ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible)
3049 if (usurf->visible == 0) {
3050 uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x)", (int)usurf);
3052 /* change unvisible to visible, restack surface list */
3053 ico_window_mgr_restack_layer(usurf, 0);
3057 if (usurf->visible != 0) {
3058 uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)", (int)usurf);
3060 /* change visible to unvisible, restack surface list */
3061 ico_window_mgr_restack_layer(usurf, 0);
3064 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3065 usurf, usurf->visible, usurf->raise, 0, 0,0);
3068 /*--------------------------------------------------------------------------*/
3070 * @brief win_mgr_set_raise: change surface raise/lower
3072 * @param[in] usurf UIFW surface
3073 * @param[in] raise raise(=1)/lower(0)
3076 /*--------------------------------------------------------------------------*/
3078 win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise)
3080 uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%x",
3081 (int)usurf, raise, (int)usurf->win_layer->layer);
3083 wl_list_remove(&usurf->ivi_layer);
3085 /* raise ... surface stack to top of layer */
3086 wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer);
3088 uifw_trace("win_mgr_set_raise: Raise Link to Top");
3091 /* Lower ... surface stack to bottom of layer */
3092 wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer);
3094 uifw_trace("win_mgr_set_raise: Lower Link to Bottom");
3097 /* rebild compositor surface list */
3098 if (usurf->visible) {
3099 ico_window_mgr_restack_layer(usurf, 0);
3101 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3102 usurf, usurf->visible, usurf->raise, 0, 0,0);
3104 uifw_trace("win_mgr_set_raise: Leave");
3107 /*--------------------------------------------------------------------------*/
3109 * @brief win_mgr_destroy_surface: surface destroy
3111 * @param[in] surface Weston surface
3114 /*--------------------------------------------------------------------------*/
3116 win_mgr_destroy_surface(struct weston_surface *surface)
3118 struct uifw_win_surface *usurf;
3119 struct uifw_win_surface *phash;
3120 struct uifw_win_surface *bhash;
3123 usurf = find_uifw_win_surface_by_ws(surface);
3125 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
3128 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
3130 /* destory input region */
3131 if (win_mgr_hook_destory) {
3132 (*win_mgr_hook_destory)(usurf);
3136 if (&usurf->surf_map != usurf->surf_map.next) {
3137 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
3140 /* destroy active surface */
3141 if (usurf == _ico_win_mgr->active_pointer_usurf) {
3142 _ico_win_mgr->active_pointer_usurf = NULL;
3144 if (usurf == _ico_win_mgr->active_keyboard_usurf) {
3145 _ico_win_mgr->active_keyboard_usurf = NULL;
3148 /* destroy animation extenson */
3149 if (win_mgr_hook_animation) {
3150 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
3153 /* delete from layer list */
3154 wl_list_remove(&usurf->ivi_layer);
3155 ico_window_mgr_restack_layer(NULL, 0);
3157 /* delete from cleint list */
3158 wl_list_remove(&usurf->client_link);
3160 /* delete from hash table */
3161 hash = MAKE_IDHASH(usurf->surfaceid);
3162 phash = _ico_win_mgr->idhash[hash];
3164 while ((phash) && (phash != usurf)) {
3166 phash = phash->next_idhash;
3169 bhash->next_idhash = usurf->next_idhash;
3172 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
3175 hash = MAKE_WSHASH(usurf->surface);
3176 phash = _ico_win_mgr->wshash[hash];
3178 while ((phash) && (phash != usurf)) {
3180 phash = phash->next_wshash;
3183 bhash->next_wshash = usurf->next_wshash;
3186 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
3189 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED,
3192 hash = usurf->surfaceid & SURCAFE_ID_MASK;
3193 _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16));
3196 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
3199 /*--------------------------------------------------------------------------*/
3201 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
3203 * @param[in] client client
3204 * @param[in] data user data(unused)
3205 * @param[in] version protocol version(unused)
3206 * @param[in] id client object id
3209 /*--------------------------------------------------------------------------*/
3211 bind_ico_win_mgr(struct wl_client *client,
3212 void *data, uint32_t version, uint32_t id)
3214 struct wl_resource *add_resource;
3215 struct uifw_manager *mgr;
3216 struct uifw_client *uclient;
3218 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
3220 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
3222 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
3223 _ico_win_mgr, unbind_ico_win_mgr);
3226 /* Create client management tabel */
3227 uclient = find_client_from_client(client);
3229 win_mgr_bind_client(client, NULL);
3230 uclient = find_client_from_client(client);
3234 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
3236 uifw_error("bind_ico_win_mgr: Error, No Memory");
3239 memset(mgr, 0, sizeof(struct uifw_manager));
3240 mgr->resource = add_resource;
3244 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
3246 uifw_trace("bind_ico_win_mgr: Leave");
3249 /*--------------------------------------------------------------------------*/
3251 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
3253 * @param[in] resource client resource
3256 /*--------------------------------------------------------------------------*/
3258 unbind_ico_win_mgr(struct wl_resource *resource)
3260 struct uifw_manager *mgr, *itmp;
3262 uifw_trace("unbind_ico_win_mgr: Enter");
3264 /* Remove manager from manager list */
3265 _ico_win_mgr->num_manager = 0;
3266 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
3267 if (mgr->resource == resource) {
3268 wl_list_remove(&mgr->link);
3273 _ico_win_mgr->num_manager++;
3277 uifw_trace("unbind_ico_win_mgr: Leave");
3280 /*--------------------------------------------------------------------------*/
3282 * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen)
3284 * @param[in] event event code(if -1, not send event)
3285 * @param[in] usurf UIFW surface table
3286 * @param[in] param1 parameter 1
3288 * @param[in] param5 parameter 5
3289 * @return number of managers
3290 * @retval > 0 number of managers
3291 * @retval 0 manager not exist
3293 /*--------------------------------------------------------------------------*/
3295 ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
3296 const int param1, const int param2, const int param3,
3297 const int param4, const int param5)
3300 struct uifw_manager* mgr;
3302 /* if appid not fix, check and fix appid */
3303 if ((usurf != NULL) &&
3304 (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) {
3305 win_mgr_get_client_appid(usurf->uclient);
3308 /* send created if not send created event */
3309 if ((usurf != NULL) && (usurf->created == 0) &&
3310 (((usurf->width > 0) && (usurf->height > 0)) ||
3311 ((event != ICO_WINDOW_MGR_WINDOW_CREATED) &&
3312 (event != ICO_WINDOW_MGR_WINDOW_NAME)))) {
3313 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
3315 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED"
3316 "(surf=%08x,name=%s,pid=%d,appid=%s)", (int)mgr->resource,
3317 usurf->surfaceid, usurf->winname, usurf->uclient->pid,
3318 usurf->uclient->appid);
3319 ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid,
3320 usurf->winname, usurf->uclient->pid,
3321 usurf->uclient->appid);
3327 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
3332 case ICO_WINDOW_MGR_WINDOW_CREATED:
3333 /* Do nothing anymore because sended window create event */
3336 case ICO_WINDOW_MGR_WINDOW_NAME:
3337 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME"
3338 "(surf=%08x,name=%s)", (int)mgr->resource,
3339 usurf->surfaceid, usurf->winname);
3340 ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid,
3344 case ICO_WINDOW_MGR_WINDOW_DESTROYED:
3345 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED"
3346 "(surf=%08x)", (int)mgr->resource, usurf->surfaceid);
3347 ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid);
3350 case ICO_WINDOW_MGR_WINDOW_VISIBLE:
3351 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE"
3352 "(surf=%08x,vis=%d,raise=%d,hint=%d)",
3353 (int)mgr->resource, usurf->surfaceid, param1, param2, param3);
3354 ico_window_mgr_send_window_visible(mgr->resource,
3355 usurf->surfaceid, param1, param2, param3);
3358 case ICO_WINDOW_MGR_WINDOW_CONFIGURE:
3359 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE"
3360 "(surf=%08x,app=%s,node=%x,layer=%x,x/y=%d/%d,w/h=%d/%d,hint=%d)",
3361 (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid,
3362 usurf->node_tbl->node, usurf->win_layer->layer,
3363 param1, param2, param3, param4, param5);
3364 ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid,
3365 usurf->node_tbl->node,
3366 usurf->win_layer->layer,
3367 param1, param2, param3, param4, param5);
3370 case ICO_WINDOW_MGR_WINDOW_ACTIVE:
3371 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE"
3372 "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid,
3374 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
3378 case ICO_WINDOW_MGR_LAYER_VISIBLE:
3379 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE"
3380 "(layer=%x,visivle=%d)", (int)mgr->resource, param1, param2);
3381 ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2);
3385 uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event);
3393 /*--------------------------------------------------------------------------*/
3395 * @brief win_mgr_set_scale: set surface transform scale
3397 * @param[in] usurf UIFW surface
3398 * @return chagne display
3399 * @retval =1 change display
3400 * @retval =0 no change
3402 /*--------------------------------------------------------------------------*/
3404 win_mgr_set_scale(struct uifw_win_surface *usurf)
3406 struct weston_surface *es;
3411 es = usurf->surface;
3412 if ((es != NULL) && (es->buffer_ref.buffer)) {
3413 if (usurf->client_width == 0) usurf->client_width = es->geometry.width;
3414 if (usurf->client_height == 0) usurf->client_height = es->geometry.height;
3415 scalex = (float)usurf->width / (float)usurf->client_width;
3416 scaley = (float)usurf->height / (float)usurf->client_height;
3417 uifw_debug("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)",
3418 usurf->surfaceid, scalex, usurf->width, usurf->client_width,
3419 scaley, usurf->height, usurf->client_height);
3422 if (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT) {
3423 if (scalex > scaley) {
3425 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) {
3426 usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex);
3427 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) {
3432 else if (scalex < scaley) {
3434 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) {
3435 usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley);
3436 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) {
3441 uifw_trace("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d",
3442 usurf->surfaceid, usurf->xadd, usurf->yadd);
3444 if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) {
3445 usurf->scalex = scalex;
3446 usurf->scaley = scaley;
3447 if ((scalex != 1.0f) || (scaley != 1.0f)) {
3448 weston_matrix_init(&usurf->transform.matrix);
3449 weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f);
3450 uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform);
3451 if (usurf->set_transform == 0) {
3452 usurf->set_transform = 1;
3453 wl_list_init(&usurf->transform.link);
3454 wl_list_insert(&es->geometry.transformation_list, &usurf->transform.link);
3457 else if (usurf->set_transform != 0) {
3458 uifw_trace("win_mgr_set_scale: reset transform");
3459 usurf->set_transform = 0;
3460 wl_list_remove(&usurf->transform.link);
3462 weston_surface_geometry_dirty(es);
3463 weston_surface_update_transform(es);
3464 weston_surface_damage_below(es);
3465 weston_surface_damage(es);
3472 /*--------------------------------------------------------------------------*/
3474 * @brief ico_window_mgr_get_uclient: get UIFW client table
3476 * @param[in] appid application Id
3477 * @return UIFW client table
3478 * @retval !=NULL success(UIFW client table address)
3479 * @retval = NULL error(appid not exist)
3481 /*--------------------------------------------------------------------------*/
3482 WL_EXPORT struct uifw_client *
3483 ico_window_mgr_get_uclient(const char *appid)
3485 struct uifw_client *uclient;
3487 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3488 if (strcmp(uclient->appid, appid) == 0) {
3495 /*--------------------------------------------------------------------------*/
3497 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
3499 * @param[in] target surface window name and application Id(winname@appid)
3500 * @return UIFW surface table
3501 * @retval !=NULL success(UIFW surface table address)
3502 * @retval = NULL error(appid or winname not exist)
3504 /*--------------------------------------------------------------------------*/
3505 WL_EXPORT struct uifw_win_surface *
3506 ico_window_mgr_get_client_usurf(const char *target)
3508 struct uifw_client *uclient;
3509 struct uifw_win_surface *usurf;
3511 char winname[ICO_IVI_WINNAME_LENGTH];
3512 char appid[ICO_IVI_APPID_LENGTH];
3514 /* get window name and application id */
3516 for (i = 0; target[i]; i++) {
3517 if (target[i] == '@') {
3518 if (target[i+1] != '@') break;
3521 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
3522 winname[j++] = target[i];
3526 if (target[i] == '@') {
3534 for ( ; target[i]; i++) {
3535 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
3536 if (j < (ICO_IVI_APPID_LENGTH-1)) {
3537 appid[j++] = target[i];
3541 #if 0 /* too many debug log */
3542 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
3543 target, appid, winname);
3546 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3547 if (strcmp(uclient->appid, appid) == 0) {
3548 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
3549 if ((winname[0] == 0) ||
3550 (strcmp(winname, usurf->winname) == 0)) {
3559 /*--------------------------------------------------------------------------*/
3561 * @brief ico_window_mgr_is_visible: check surface visible
3563 * @param[in] usurf UIFW surface
3564 * @return visibility
3565 * @retval =1 visible
3566 * @retval =0 not visible
3567 * @retval =-1 surface visible but layer not vlsible
3568 * @retval =-2 surface visible but lower
3570 /*--------------------------------------------------------------------------*/
3572 ico_window_mgr_is_visible(struct uifw_win_surface *usurf)
3574 if ((usurf->visible == 0) || (usurf->surface == NULL) ||
3575 (usurf->mapped == 0) || (usurf->surface->buffer_ref.buffer == NULL)) {
3578 if (usurf->win_layer->visible == 0) {
3584 /*--------------------------------------------------------------------------*/
3586 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
3588 * @param[in] hook_animation hook routine
3591 /*--------------------------------------------------------------------------*/
3593 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
3595 win_mgr_hook_animation = hook_animation;
3598 /*--------------------------------------------------------------------------*/
3600 * @brief ico_window_mgr_set_hook_visible: set input region hook routine
3602 * @param[in] hook_visible hook routine
3605 /*--------------------------------------------------------------------------*/
3607 ico_window_mgr_set_hook_visible(void (*hook_visible)(struct uifw_win_surface *usurf))
3609 win_mgr_hook_visible = hook_visible;
3612 /*--------------------------------------------------------------------------*/
3614 * @brief ico_window_mgr_set_hook_destory: set input region hook routine
3616 * @param[in] hook_destroy hook routine
3619 /*--------------------------------------------------------------------------*/
3621 ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf))
3623 win_mgr_hook_destory = hook_destroy;
3626 /*--------------------------------------------------------------------------*/
3628 * @brief module_init: initialize ico_window_mgr
3629 * this function called from ico_pluign_loader
3631 * @param[in] es weston compositor
3632 * @param[in] argc number of arguments(unused)
3633 * @param[in] argv argument list(unused)
3638 /*--------------------------------------------------------------------------*/
3640 module_init(struct weston_compositor *ec, int *argc, char *argv[])
3646 struct weston_output *output;
3647 struct weston_config_section *section;
3648 char *displayno = NULL;
3650 uifw_info("ico_window_mgr: Enter(module_init)");
3652 /* get ivi debug level */
3653 section = weston_config_get_section(ec->config, "ivi-debug", NULL, NULL);
3655 weston_config_section_get_int(section, "flag", &_ico_ivi_debug_flag, 0);
3656 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
3659 /* get display number list */
3660 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
3662 weston_config_section_get_string(section, "displayno", &displayno, NULL);
3666 section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL);
3668 weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1);
3669 weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 109);
3670 weston_config_section_get_int(section, "input", &_ico_ivi_input_layer, 101);
3671 weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102);
3672 weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0);
3675 /* get animation default */
3676 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
3678 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
3679 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 600);
3680 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 15);
3682 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 600;
3683 if (_ico_ivi_animation_fps < 2) _ico_ivi_animation_fps = 15;
3685 /* create ico_window_mgr management table */
3686 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
3687 if (_ico_win_mgr == NULL) {
3688 uifw_error("ico_window_mgr: malloc failed");
3692 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
3693 _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8);
3694 if (! _ico_win_mgr->surfaceid_map) {
3695 uifw_error("ico_window_mgr: malloc failed");
3698 uifw_debug("ico_window_mgr: table=%08x", (int)_ico_win_mgr);
3699 memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8);
3701 _ico_win_mgr->compositor = ec;
3703 _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS;
3704 _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS;
3706 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
3707 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
3708 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
3709 uifw_error("ico_window_mgr: Error(wl_global_create)");
3713 wl_list_init(&_ico_win_mgr->client_list);
3714 wl_list_init(&_ico_win_mgr->manager_list);
3715 wl_list_init(&_ico_win_mgr->ivi_layer_list);
3716 wl_list_init(&_ico_win_mgr->map_list);
3718 _ico_win_mgr->free_maptable = NULL;
3720 /* create display list */
3721 if (displayno != NULL) {
3728 wl_list_for_each(output, &ec->output_list, link) {
3729 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
3730 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_surfacemap;
3731 wl_list_insert(output->animation_list.prev,
3732 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
3734 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
3736 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
3738 wl_list_for_each(output, &ec->output_list, link) {
3741 idx = strtol(p, (char **)0, 0);
3742 uifw_trace("ico_window_mgr: config Display.%d is %d", i, idx);
3744 if ((idx < 0) || (idx >= _ico_num_nodes)) {
3751 if (_ico_node_table[idx].node) {
3752 for (idx = 0; idx < _ico_num_nodes; idx++) {
3753 if (_ico_node_table[idx].node == 0) break;
3755 if (idx >= _ico_num_nodes) {
3756 uifw_error("ico_window_mgr: number of display overflow");
3760 _ico_node_table[idx].node = idx + 0x100;
3761 _ico_node_table[idx].displayno = i;
3762 _ico_node_table[idx].disp_x = output->x;
3763 _ico_node_table[idx].disp_y = output->y;
3764 _ico_node_table[idx].disp_width = output->width;
3765 _ico_node_table[idx].disp_height = output->height;
3767 if (i >= _ico_num_nodes) break;
3770 for (i = 0; i < _ico_num_nodes; i++) {
3771 _ico_node_table[i].node &= 0x0ff;
3772 uifw_trace("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
3773 i, _ico_node_table[i].displayno,
3774 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
3775 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
3777 if (displayno) free(displayno);
3779 /* my node Id ... this version fixed 0 */
3780 nodeId = ico_ivi_get_mynode();
3782 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
3783 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
3784 nodeId, _ico_win_mgr->surface_head);
3786 /* Hook to IVI-Shell */
3787 ico_ivi_shell_hook_bind(win_mgr_bind_client);
3788 ico_ivi_shell_hook_unbind(win_mgr_unbind_client);
3789 ico_ivi_shell_hook_create(win_mgr_register_surface);
3790 ico_ivi_shell_hook_destroy(win_mgr_destroy_surface);
3791 ico_ivi_shell_hook_map(win_mgr_map_surface);
3792 ico_ivi_shell_hook_configure(win_mgr_shell_configure);
3793 ico_ivi_shell_hook_select(win_mgr_select_surface);
3794 ico_ivi_shell_hook_title(win_mgr_set_title);
3795 ico_ivi_shell_hook_move(win_mgr_surface_move);
3797 uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d",
3798 _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps);
3799 uifw_info("ico_window_mgr: layer default=%d startup=%d background=%d",
3800 _ico_ivi_default_layer, _ico_ivi_startup_layer, _ico_ivi_background_layer);
3801 uifw_info("ico_window_mgr: layer input=%d cursor=%d",
3802 _ico_ivi_input_layer, _ico_ivi_cursor_layer);
3803 uifw_info("ico_window_mgr: debug flag=%x log level=%d",
3804 _ico_ivi_debug_flag, _ico_ivi_debug_level);
3806 uifw_info("ico_window_mgr: Leave(module_init)");