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 wl_list map_list; /* surface map list */
151 struct uifw_surface_map *free_maptable; /* free maped surface table list */
152 struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY];
153 /* animation for map check */
154 struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */
155 struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */
157 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
158 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
160 uint32_t surfaceid_count; /* Number of surface id */
161 uint32_t surfaceid_max; /* Maximum number of surface id */
162 uint16_t *surfaceid_map; /* SurfaceId assign bit map */
164 char shell_init; /* shell initialize flag */
165 char res; /* (unused) */
168 /* Internal macros */
170 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
172 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
174 /* function prototype */
175 /* get surface table from weston surface*/
176 static struct uifw_win_surface *find_uifw_win_surface_by_ws(
177 struct weston_surface *wsurf);
178 /* get client table from weston client */
179 static struct uifw_client* find_client_from_client(struct wl_client *client);
180 /* assign new surface id */
181 static uint32_t generate_id(void);
182 /* bind shell client */
183 static void win_mgr_bind_client(struct wl_client *client, void *shell);
184 /* unind shell client */
185 static void win_mgr_unbind_client(struct wl_client *client);
186 /* get appid from pid */
187 static void win_mgr_get_client_appid(struct uifw_client *uclient);
188 /* create new surface */
189 static void win_mgr_register_surface(
190 struct wl_client *client, struct wl_resource *resource,
191 struct weston_surface *surface, struct shell_surface *shsurf);
192 /* surface destroy */
193 static void win_mgr_destroy_surface(struct weston_surface *surface);
194 /* map new surface */
195 static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width,
196 int32_t *height, int32_t *sx, int32_t *sy);
197 /* send surface change event to manager */
198 static void win_mgr_change_surface(struct weston_surface *surface,
199 const int to, const int manager);
200 /* window manager surface configure */
201 static void win_mgr_surface_configure(struct uifw_win_surface *usurf,
202 int x, int y, int width, int height);
203 /* shell surface configure */
204 static void win_mgr_shell_configure(struct weston_surface *surface);
206 static void win_mgr_select_surface(struct weston_surface *surface);
207 /* surface set title */
208 static void win_mgr_set_title(struct weston_surface *surface, const char *title);
209 /* surface move request from shell */
210 static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy);
212 static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise);
213 /* surface change from manager */
214 static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x,
215 const int y, const int width, const int height);
216 /* create new layer */
217 static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf,
218 const uint32_t layer);
219 /* set surface layer */
220 static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer);
221 /* set active surface */
222 static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target);
224 /* declare manager */
225 static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource,
227 /* set window layer */
228 static void uifw_set_window_layer(struct wl_client *client,
229 struct wl_resource *resource,
230 uint32_t surfaceid, uint32_t layer);
231 /* set surface size and position */
232 static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
233 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
234 int32_t width, int32_t height, int32_t flags);
235 /* show/hide and raise/lower surface */
236 static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
237 uint32_t surfaceid, int32_t visible, int32_t raise,
239 /* set surface animation */
240 static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
241 uint32_t surfaceid, int32_t type,
242 const char *animation, int32_t time);
243 /* set surface attributes */
244 static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
245 uint32_t surfaceid, uint32_t attributes);
246 /* surface visibility control with animation*/
247 static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
248 uint32_t surfaceid, int32_t visible,
249 int32_t x, int32_t y, int32_t width, int32_t height);
250 /* set active surface (form HomeScreen) */
251 static void uifw_set_active(struct wl_client *client, struct wl_resource *resource,
252 uint32_t surfaceid, int32_t active);
253 /* layer visibility control */
254 static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
255 uint32_t layer, int32_t visible);
256 /* get application surfaces */
257 static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource,
259 /* check and change all mapped surface */
260 static void win_mgr_check_surfacemap(struct weston_animation *animation,
261 struct weston_output *output, uint32_t msecs);
262 /* check and change mapped surface */
263 static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event);
264 /* map surface to system application */
265 static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
266 uint32_t surfaceid, int32_t framerate);
268 static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
271 static void bind_ico_win_mgr(struct wl_client *client,
272 void *data, uint32_t version, uint32_t id);
274 static void unbind_ico_win_mgr(struct wl_resource *resource);
275 /* send event to manager */
276 static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
277 const int param1, const int param2, const int param3,
278 const int param4, const int param5);
279 /* set surface transform */
280 static int win_mgr_set_scale(struct uifw_win_surface *usurf);
281 /* convert animation name to Id value */
282 static int ico_get_animation_name(const char *animation);
283 /* hook for animation */
284 static int (*win_mgr_hook_animation)(const int op, void *data) = NULL;
287 /* Multi Window Manager interface */
288 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
289 uifw_declare_manager,
290 uifw_set_window_layer,
291 uifw_set_positionsize,
295 uifw_visible_animation,
297 uifw_set_layer_visible,
303 /* plugin common value(without ico_plugin_loader) */
304 static int _ico_ivi_debug_flag = 0; /* Debug flags */
305 static int _ico_ivi_debug_level = 3; /* Debug Level */
306 static char *_ico_ivi_animation_name = NULL; /* Default animation name */
307 static int _ico_ivi_animation_time = 500; /* Default animation time */
308 static int _ico_ivi_animation_fps = 15; /* Animation frame rate */
309 static int _ico_ivi_background_layer = 0; /* Background layer */
310 static int _ico_ivi_default_layer = 1; /* Deafult layer id at surface create*/
311 static int _ico_ivi_input_layer = 101; /* Input layer id */
312 static int _ico_ivi_cursor_layer = 102; /* Cursor layer id */
313 static int _ico_ivi_startup_layer = 109; /* Deafult layer id at system startup*/
315 /* static management table */
316 static struct ico_win_mgr *_ico_win_mgr = NULL;
317 static int _ico_num_nodes = 0;
318 static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY];
321 /*--------------------------------------------------------------------------*/
323 * @brief ico_ivi_debugflag: get debug flags
326 * @return debug flags
328 /*--------------------------------------------------------------------------*/
330 ico_ivi_debugflag(void)
332 return _ico_ivi_debug_flag;
335 /*--------------------------------------------------------------------------*/
337 * @brief ico_ivi_debuglevel: answer debug output level.
340 * @return debug output level
341 * @retval 0 No debug output
342 * @retval 1 Only error output
343 * @retval 2 Error and Warning output
344 * @retval 3 Error, Warning and information output
345 * @retval 4 All output with debug write
347 /*--------------------------------------------------------------------------*/
349 ico_ivi_debuglevel(void)
351 return _ico_ivi_debug_level;
354 /*--------------------------------------------------------------------------*/
356 * @brief ico_ivi_default_animation_name: get default animation name
359 * @return Default animation name
361 /*--------------------------------------------------------------------------*/
362 WL_EXPORT const char *
363 ico_ivi_default_animation_name(void)
365 return _ico_ivi_animation_name;
368 /*--------------------------------------------------------------------------*/
370 * @brief ico_ivi_default_animation_time: get default animation time
373 * @return Default animation time(miri sec)
375 /*--------------------------------------------------------------------------*/
377 ico_ivi_default_animation_time(void)
379 return _ico_ivi_animation_time;
382 /*--------------------------------------------------------------------------*/
384 * @brief ico_ivi_default_animation_fps: get default animation frame rate
387 * @return Default animation frame rate(frames/sec)
389 /*--------------------------------------------------------------------------*/
391 ico_ivi_default_animation_fps(void)
393 return _ico_ivi_animation_fps;
396 /*--------------------------------------------------------------------------*/
398 * @brief ico_ivi_get_mynode: Get my NodeId
401 * @return NodeId of my node
403 /*--------------------------------------------------------------------------*/
405 ico_ivi_get_mynode(void)
407 /* Reference Platform 0.90 only support 1 ECU */
411 /*--------------------------------------------------------------------------*/
413 * @brief ico_window_mgr_set_weston_surface: set weston surface
415 * @param[in] usurf UIFW surface
416 * @param[in] x X coordinate on screen
417 * @param[in] y Y coordinate on screen
418 * @param[in] width width
419 * @param[in] height height
422 /*--------------------------------------------------------------------------*/
424 ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf,
425 int x, int y, int width, int height)
427 struct weston_surface *es = usurf->surface;
428 int buf_width, buf_height;
431 uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface",
436 if (es->buffer_ref.buffer != NULL) {
437 buf_width = weston_surface_buffer_width(es);
438 buf_height = weston_surface_buffer_height(es);
439 if ((width <= 0) || (height <= 0)) {
441 usurf->width = buf_width;
443 usurf->height = buf_height;
445 if (usurf->width > buf_width) {
447 x += (usurf->width - buf_width)/2;
449 if (usurf->height > buf_height) {
451 y += (usurf->height - buf_height)/2;
453 if (usurf->visible) {
454 x += usurf->node_tbl->disp_x;
455 y += usurf->node_tbl->disp_y;
458 x = ICO_IVI_MAX_COORDINATE+1;
459 y = ICO_IVI_MAX_COORDINATE+1;
461 if ((es->geometry.x != x) || (es->geometry.y != y) ||
462 (es->geometry.width != width) || (es->geometry.height != height)) {
463 weston_surface_damage_below(es);
464 win_mgr_surface_configure(usurf, x, y, width, height);
466 weston_surface_damage(es);
467 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
471 /*--------------------------------------------------------------------------*/
473 * @brief ico_window_mgr_set_weston_surface: set weston surface
475 * @param[in] usurf UIFW surface
476 * @param[in] x X coordinate on screen
477 * @param[in] y Y coordinate on screen
478 * @param[in] width width
479 * @param[in] height height
482 /*--------------------------------------------------------------------------*/
484 ico_window_mgr_change_surface(struct uifw_win_surface *usurf,
485 const int to, const int manager)
487 uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)",
488 usurf->surfaceid, to, manager);
489 win_mgr_change_surface(usurf->surface, to, manager);
490 uifw_trace("ico_window_mgr_change_surface: Leave");
493 /*--------------------------------------------------------------------------*/
495 * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id
497 * @param[in] surfaceid UIFW surface id
498 * @return UIFW surface table address
499 * @retval !=NULL success(surface table address)
500 * @retval NULL error(surface id dose not exist)
502 /*--------------------------------------------------------------------------*/
503 WL_EXPORT struct uifw_win_surface *
504 ico_window_mgr_get_usurf(const uint32_t surfaceid)
506 struct uifw_win_surface *usurf;
508 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
511 if (usurf->surfaceid == surfaceid) {
514 usurf = usurf->next_idhash;
516 uifw_trace("ico_window_mgr_get_usurf: NULL");
520 /*--------------------------------------------------------------------------*/
522 * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client
524 * @param[in] surfaceid UIFW surface id
525 * @param[in] client Wayland client
526 * @return UIFW surface table address
527 * @retval !=NULL success(surface table address)
528 * @retval NULL error(surface id or client dose not exist)
530 /*--------------------------------------------------------------------------*/
531 WL_EXPORT struct uifw_win_surface *
532 ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client)
534 struct uifw_win_surface *usurf;
535 struct uifw_client *uclient;
537 if (surfaceid == ICO_WINDOW_MGR_V_MAINSURFACE) {
538 uclient = find_client_from_client(client);
540 if (&uclient->surface_link != uclient->surface_link.next) {
541 usurf = container_of(uclient->surface_link.next,
542 struct uifw_win_surface, client_link);
553 usurf = ico_window_mgr_get_usurf(surfaceid);
558 /*--------------------------------------------------------------------------*/
560 * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface
562 * @param[in] wsurf Weston surface
563 * @return UIFW surface table address
564 * @retval !=NULL success(surface table address)
565 * @retval NULL error(surface dose not exist)
567 /*--------------------------------------------------------------------------*/
568 static struct uifw_win_surface *
569 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
571 struct uifw_win_surface *usurf;
573 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
576 if (usurf->surface == wsurf) {
579 usurf = usurf->next_wshash;
581 uifw_trace("find_uifw_win_surface_by_ws: NULL");
585 /*--------------------------------------------------------------------------*/
587 * @brief find_client_from_client: find UIFW client by wayland client
589 * @param[in] client Wayland client
590 * @return UIFW client table address
591 * @retval !=NULL success(client table address)
592 * @retval NULL error(client dose not exist)
594 /*--------------------------------------------------------------------------*/
595 static struct uifw_client*
596 find_client_from_client(struct wl_client *client)
598 struct uifw_client *uclient;
600 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
601 if (uclient->client == client) {
605 uifw_trace("find_client_from_client: client.%08x is NULL", (int)client);
609 /*--------------------------------------------------------------------------*/
611 * @brief ico_window_mgr_get_appid: find application id by wayland client
613 * @param[in] client Wayland client
614 * @return application id
615 * @retval !=NULL success(application id)
616 * @retval NULL error(client dose not exist)
618 /*--------------------------------------------------------------------------*/
620 ico_window_mgr_get_appid(struct wl_client* client)
622 struct uifw_client *uclient;
624 uclient = find_client_from_client(client);
629 return uclient->appid;
632 /*--------------------------------------------------------------------------*/
634 * @brief ico_window_mgr_get_display_coordinate: get display coordinate
636 * @param[in] displayno display number
637 * @param[out] x relative X coordinate
638 * @param[out] y relative Y coordinate
641 /*--------------------------------------------------------------------------*/
643 ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y)
645 if ((displayno <= _ico_num_nodes) || (displayno < 0)) {
648 *x = _ico_node_table[displayno].disp_x;
649 *y = _ico_node_table[displayno].disp_y;
652 /*--------------------------------------------------------------------------*/
654 * @brief generate_id: generate uniq id for UIFW surface id
657 * @return uniq id for UIFW surface id
659 /*--------------------------------------------------------------------------*/
670 _ico_win_mgr->surfaceid_count ++;
672 /* serach free id from bitmap */
673 for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) {
674 if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) {
675 _ico_win_mgr->surfaceid_count = 0;
677 if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) {
678 /* find free id from bitmap */
679 map = 1 << (_ico_win_mgr->surfaceid_count % 16);
680 for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) {
681 if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map)
683 _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map;
684 _ico_win_mgr->surfaceid_count
685 = (_ico_win_mgr->surfaceid_count/16)*16 + i;
687 surfaceId = (_ico_win_mgr->surfaceid_count + 1)
688 | _ico_win_mgr->surface_head;
689 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
695 _ico_win_mgr->surfaceid_count += 16;
698 /* no free id in bitmap, extend bitmap */
699 if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) {
700 /* too many surfaces, system error */
701 uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort",
702 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
703 fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n",
704 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
708 new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8);
709 memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8);
710 memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8);
711 _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max;
712 new_map[_ico_win_mgr->surfaceid_count/16] |= 1;
713 _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS;
714 free(_ico_win_mgr->surfaceid_map);
715 _ico_win_mgr->surfaceid_map = new_map;
717 uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)",
718 _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max);
719 surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head;
721 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
725 /*--------------------------------------------------------------------------*/
727 * @brief win_mgr_bind_client: desktop_shell from client
729 * @param[in] client Wayland client
730 * @param[in] shell shell(ico_ivi_shell) table address
733 /*--------------------------------------------------------------------------*/
735 win_mgr_bind_client(struct wl_client *client, void *shell)
737 struct uifw_client *uclient;
743 uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)",
744 (int)client, (int)shell);
746 /* save shell table address */
748 _ico_win_mgr->shell = shell;
752 uclient = find_client_from_client(client);
754 /* client not exist, create client management table */
755 uifw_trace("win_mgr_bind_client: Create Client");
756 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
758 uifw_error("win_mgr_bind_client: Error, No Memory");
761 memset(uclient, 0, sizeof(struct uifw_client));
762 uclient->client = client;
763 wl_list_init(&uclient->surface_link);
769 wl_client_get_credentials(client, &pid, &uid, &gid);
770 uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d",
771 (int)client, (int)pid, (int)uid, (int)gid);
773 uclient->pid = (int)pid;
774 /* get applicationId from AppCore(AUL) */
775 win_mgr_get_client_appid(uclient);
777 /* weston internal client, not manage */
778 if (strcmp(uclient->appid, "weston") == 0) {
780 uifw_trace("win_mgr_bind_client: client=%08x is internal, delete", (int)client);
782 else if (newclient > 0) {
783 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
787 uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client);
789 uifw_trace("win_mgr_bind_client: Leave");
792 /*--------------------------------------------------------------------------*/
794 * @brief win_mgr_unbind_client: unbind desktop_shell from client
796 * @param[in] client Wayland client
799 /*--------------------------------------------------------------------------*/
801 win_mgr_unbind_client(struct wl_client *client)
803 struct uifw_client *uclient;
805 uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client);
807 uclient = find_client_from_client(client);
809 /* Client exist, Destory client management table */
810 wl_list_remove(&uclient->link);
813 uifw_trace("win_mgr_unbind_client: Leave");
816 /*--------------------------------------------------------------------------*/
818 * @brief win_mgr_get_client_appid: get applicationId from pid
820 * @param[in] uclient UIFW client management table
823 /*--------------------------------------------------------------------------*/
825 win_mgr_get_client_appid(struct uifw_client *uclient)
833 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
834 i = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH);
835 uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d "
836 "pid=%d appid=<%s>", i, uclient->pid, uclient->appid);
837 if (uclient->appid[0] != 0) {
838 /* OK, end of get appid */
839 uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT;
842 /* client dose not exist in AppCore, search Linux process table */
843 uclient->fixed_appid ++;
844 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
845 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
846 fd = open(procpath, O_RDONLY);
848 size = read(fd, procpath, sizeof(procpath));
849 for (; size > 0; size--) {
850 if (procpath[size-1]) break;
853 /* get program base name */
855 for (j = 0; j < size; j++) {
856 if (procpath[j] == 0) break;
857 if (procpath[j] == '/') i = j + 1;
860 for (; i < size; i++) {
861 uclient->appid[j] = procpath[i];
862 if ((uclient->appid[j] == 0) ||
863 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
866 /* search application number in apprication start option */
867 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
868 for (; i < size; i++) {
869 if ((procpath[i] == 0) &&
870 (procpath[i+1] == '@')) {
871 strncpy(&uclient->appid[j], &procpath[i+1],
872 ICO_IVI_APPID_LENGTH - j - 2);
879 for (i = strlen(uclient->appid)-1; i >= 0; i--) {
880 if (uclient->appid[i] != ' ') break;
882 uclient->appid[i+1] = 0;
883 if (uclient->appid[0]) {
884 uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from "
885 "Process table", uclient->pid, uclient->appid);
888 uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table",
890 sprintf(uclient->appid, "?%d?", uclient->pid);
895 /*--------------------------------------------------------------------------*/
897 * @brief ico_get_animation_name: convert animation name to Id value
899 * @param[in] animation animation name
900 * @return animation Id value
902 /*--------------------------------------------------------------------------*/
904 ico_get_animation_name(const char *animation)
906 int anima = ICO_WINDOW_MGR_ANIMATION_NONE;
908 if (strcasecmp(animation, "none") == 0) {
909 return ICO_WINDOW_MGR_ANIMATION_NONE;
912 if (win_mgr_hook_animation) {
913 anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation);
916 anima = ICO_WINDOW_MGR_ANIMATION_NONE;
921 /*--------------------------------------------------------------------------*/
923 * @brief win_mgr_register_surface: create UIFW surface
925 * @param[in] client Wayland client
926 * @param[in] resource client resource
927 * @param[in] surface Weston surface
928 * @param[in] shsurf shell surface
931 /*--------------------------------------------------------------------------*/
933 win_mgr_register_surface(struct wl_client *client, struct wl_resource *resource,
934 struct weston_surface *surface, struct shell_surface *shsurf)
936 struct uifw_win_surface *usurf;
937 struct uifw_win_surface *phash;
938 struct uifw_win_surface *bhash;
941 uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x)",
942 (int)surface, (int)client, (int)resource);
944 /* check new surface */
945 if (find_uifw_win_surface_by_ws(surface)) {
946 /* surface exist, NOP */
947 uifw_trace("win_mgr_register_surface: Leave(Already Exist)");
951 /* set default color and shader */
952 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
954 /* create UIFW surface management table */
955 usurf = malloc(sizeof(struct uifw_win_surface));
957 uifw_error("win_mgr_register_surface: No Memory");
961 memset(usurf, 0, sizeof(struct uifw_win_surface));
963 usurf->surfaceid = generate_id();
964 usurf->surface = surface;
965 usurf->shsurf = shsurf;
966 usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */
967 wl_list_init(&usurf->ivi_layer);
968 wl_list_init(&usurf->client_link);
969 wl_list_init(&usurf->animation.animation.link);
970 wl_list_init(&usurf->surf_map);
971 usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name());
972 usurf->animation.hide_time = ico_ivi_default_animation_time();;
973 usurf->animation.show_anima = usurf->animation.hide_anima;
974 usurf->animation.show_time = usurf->animation.hide_time;
975 usurf->animation.move_anima = usurf->animation.hide_anima;
976 usurf->animation.move_time = usurf->animation.hide_time;
977 usurf->animation.resize_anima = usurf->animation.hide_anima;
978 usurf->animation.resize_time = usurf->animation.hide_time;
980 if ((_ico_win_mgr->num_manager <= 0) ||
981 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE)) {
982 uifw_trace("win_mgr_register_surface: No Manager, Force visible");
986 uifw_trace("win_mgr_register_surface: Manager exist, Not visible");
991 usurf->uclient = find_client_from_client(client);
992 if (! usurf->uclient) {
993 /* client not exist, create client management table */
994 uifw_trace("win_mgr_register_surface: Create Client");
995 win_mgr_bind_client(client, NULL);
996 usurf->uclient = find_client_from_client(client);
997 if (! usurf->uclient) {
998 uifw_error("win_mgr_register_surface: No Memory");
1002 wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link);
1004 /* make surface id hash table */
1005 hash = MAKE_IDHASH(usurf->surfaceid);
1006 phash = _ico_win_mgr->idhash[hash];
1010 phash = phash->next_idhash;
1013 bhash->next_idhash = usurf;
1016 _ico_win_mgr->idhash[hash] = usurf;
1019 /* make weston surface hash table */
1020 hash = MAKE_WSHASH(usurf->surface);
1021 phash = _ico_win_mgr->wshash[hash];
1025 phash = phash->next_wshash;
1028 bhash->next_wshash = usurf;
1031 _ico_win_mgr->wshash[hash] = usurf;
1033 /* set default layer id */
1034 win_mgr_set_layer(usurf, (_ico_win_mgr->num_manager > 0) ? _ico_ivi_default_layer :
1035 _ico_ivi_startup_layer);
1036 uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid);
1039 /*--------------------------------------------------------------------------*/
1041 * @brief win_mgr_map_surface: map surface
1043 * @param[in] surface Weston surface
1044 * @param[in] width surface width
1045 * @param[in] height surface height
1046 * @param[in] sx X coordinate on screen
1047 * @param[in] sy Y coordinate on screen
1050 /*--------------------------------------------------------------------------*/
1052 win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height,
1053 int32_t *sx, int32_t *sy)
1055 struct uifw_win_surface *usurf;
1057 uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)",
1058 (int)surface, *sx, *sy, *width, *height);
1060 usurf = find_uifw_win_surface_by_ws(surface);
1063 uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d",
1064 usurf->surfaceid, usurf->width, usurf->height, usurf->visible);
1065 if ((usurf->width > 0) && (usurf->height > 0)) {
1066 uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize"
1067 "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d",
1068 usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height,
1070 *width = usurf->width;
1071 *height = usurf->height;
1072 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1073 usurf->node_tbl->disp_y + usurf->y,
1074 usurf->width, usurf->height);
1077 uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, "
1078 "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)",
1079 usurf->surfaceid, *sx, *sy, *width, *height);
1080 usurf->width = *width;
1081 usurf->height = *height;
1084 if (usurf->x < 0) usurf->x = 0;
1085 if (usurf->y < 0) usurf->y = 0;
1087 if (_ico_win_mgr->num_manager > 0) {
1088 /* HomeScreen exist, coodinate set by HomeScreen */
1089 if (usurf->visible) {
1090 win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x,
1091 usurf->node_tbl->disp_y + usurf->y,
1092 usurf->width, usurf->height);
1095 win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1,
1096 ICO_IVI_MAX_COORDINATE+1,
1097 usurf->width, usurf->height);
1099 uifw_trace("win_mgr_map_surface: Change size/position x/y=%d/%d w/h=%d/%d",
1100 (int)surface->geometry.x, (int)surface->geometry.y,
1101 surface->geometry.width, surface->geometry.height);
1103 if ((_ico_win_mgr->num_manager <= 0) ||
1104 (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE)) {
1105 uifw_trace("win_mgr_map_surface: Np HomeScreen, chaneg to Visible");
1106 ico_window_mgr_set_visible(usurf, 1);
1110 if (usurf->visible) {
1111 ico_window_mgr_restack_layer(NULL, FALSE);
1113 uifw_trace("win_mgr_map_surface: Leave");
1116 uifw_trace("win_mgr_map_surface: Leave(No UIFW Surface)");
1120 /*--------------------------------------------------------------------------*/
1122 * @brief ico_window_mgr_restack_layer: restack surface list
1124 * @param[in] usurf UIFW surface (if NULL, no surface)
1125 * @param[in] omit_touch omit touch layer flag (TRUE=omit/FALSE=not omit)
1128 /*--------------------------------------------------------------------------*/
1130 ico_window_mgr_restack_layer(struct uifw_win_surface *usurf, const int omit_touch)
1132 struct uifw_win_surface *eu;
1133 struct uifw_win_layer *el;
1134 int32_t buf_width, buf_height;
1136 struct weston_layer *wlayer;
1137 struct weston_surface *surface, *surfacetmp;
1138 int num_visible = 0;
1141 /* set layer type */
1142 ico_ivi_shell_set_layertype();
1144 /* make compositor surface list */
1145 wlayer = ico_ivi_shell_weston_layer();
1147 uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x,omit=%d) layer=%08x",
1148 (int)usurf, omit_touch, (int)wlayer);
1150 /* remove all surfaces in panel_layer */
1151 wl_list_for_each_safe(surface, surfacetmp, &wlayer->surface_list, layer_link) {
1152 wl_list_remove(&surface->layer_link);
1153 wl_list_init(&surface->layer_link);
1155 wl_list_init(&wlayer->surface_list);
1157 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1158 if (el->layer_type == ICO_WINDOW_MGR_LAYER_TYPE_CURSOR) continue;
1159 wl_list_for_each (eu, &el->surface_list, ivi_layer) {
1160 if (eu->surface == NULL) continue;
1162 /* target only panel or unknown layer */
1163 layer_type = ico_ivi_shell_layertype(eu->surface);
1164 if ((layer_type != LAYER_TYPE_PANEL) && (layer_type != LAYER_TYPE_UNKNOWN)) {
1167 wl_list_remove(&eu->surface->layer_link);
1168 wl_list_init(&eu->surface->layer_link);
1170 if (eu->mapped != 0) {
1171 if ((el->visible == FALSE) || (eu->visible == FALSE) ||
1172 ((omit_touch != FALSE) &&
1173 (el->layer_type == ICO_WINDOW_MGR_LAYER_TYPE_INPUT))) {
1174 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1175 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1177 else if (eu->surface->buffer_ref.buffer) {
1178 buf_width = weston_surface_buffer_width(eu->surface);
1179 buf_height = weston_surface_buffer_height(eu->surface);
1180 if (eu->width > buf_width) {
1181 new_x = (float)(eu->x +
1182 (eu->width - eu->surface->geometry.width)/2);
1185 new_x = (float)eu->x;
1187 if (eu->height > buf_height) {
1188 new_y = (float) (eu->y +
1189 (eu->height - eu->surface->geometry.height)/2);
1192 new_y = (float)eu->y;
1194 new_x += eu->node_tbl->disp_x + eu->xadd;
1195 new_y += eu->node_tbl->disp_y + eu->yadd;
1199 new_x = (float)(eu->x + eu->node_tbl->disp_x + eu->xadd);
1200 new_y = (float)(eu->y + eu->node_tbl->disp_y + eu->yadd);
1202 wl_list_insert(wlayer->surface_list.prev, &eu->surface->layer_link);
1203 if ((eu->restrain_configure == 0) &&
1204 ((new_x != eu->surface->geometry.x) ||
1205 (new_y != eu->surface->geometry.y))) {
1206 weston_surface_damage_below(eu->surface);
1207 weston_surface_set_position(eu->surface, (float)new_x, (float)new_y);
1208 weston_surface_damage(eu->surface);
1210 #if 0 /* too many debug log */
1211 uifw_trace("ico_window_mgr_restack_layer:%3d(%d).%08x(%08x:%d) "
1212 "x/y=%d/%d w/h=%d/%d",
1213 el->layer, el->visible, eu->surfaceid, (int)eu->surface,
1214 eu->visible, (int)eu->surface->geometry.x,
1215 (int)eu->surface->geometry.y, eu->surface->geometry.width,
1216 eu->surface->geometry.height);
1222 /* damage(redraw) target surfacem if target exist */
1224 weston_surface_damage(usurf->surface);
1227 /* composit and draw screen(plane) */
1228 if (omit_touch == FALSE) {
1229 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
1231 if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) &&
1232 (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) {
1233 /* start shell fade */
1234 _ico_win_mgr->shell_init = 1;
1235 ico_ivi_shell_startup(_ico_win_mgr->shell);
1238 uifw_trace("ico_window_mgr_restack_layer: Leave");
1241 /*--------------------------------------------------------------------------*/
1243 * @brief win_mgr_create_layer: create new layer
1245 * @param[in] usurf UIFW surface, (if need)
1246 * @param[in] layer layer id
1248 * @retval != NULL success(layer management table)
1249 * @retval == NULL error(No Memory)
1251 /*--------------------------------------------------------------------------*/
1252 static struct uifw_win_layer *
1253 win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1255 struct uifw_win_layer *el;
1256 struct uifw_win_layer *new_el;
1258 new_el = malloc(sizeof(struct uifw_win_layer));
1260 uifw_trace("win_mgr_create_layer: Leave(No Memory)");
1264 memset(new_el, 0, sizeof(struct uifw_win_layer));
1265 new_el->layer = layer;
1266 if ((int)layer == _ico_ivi_background_layer ) {
1267 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_BACKGROUND;
1269 else if ((int)layer == _ico_ivi_input_layer ) {
1270 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_INPUT;
1272 else if ((int)layer == _ico_ivi_cursor_layer ) {
1273 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_CURSOR;
1276 new_el->layer_type = ICO_WINDOW_MGR_LAYER_TYPE_NORMAL;
1278 new_el->visible = TRUE;
1279 wl_list_init(&new_el->surface_list);
1280 wl_list_init(&new_el->link);
1282 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1283 if (layer >= el->layer) break;
1285 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1286 wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link);
1289 wl_list_insert(el->link.prev, &new_el->link);
1293 wl_list_remove(&usurf->ivi_layer);
1294 wl_list_insert(&new_el->surface_list, &usurf->ivi_layer);
1295 usurf->win_layer = new_el;
1300 /*--------------------------------------------------------------------------*/
1302 * @brief win_mgr_set_layer: set(or change) surface layer
1304 * @param[in] usurf UIFW surface
1305 * @param[in] layer layer id
1308 /*--------------------------------------------------------------------------*/
1310 win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer)
1312 struct uifw_win_layer *el;
1313 struct uifw_win_layer *new_el;
1315 uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)",
1316 usurf->surfaceid, (int)usurf->surface, layer);
1318 /* check if same layer */
1319 if ((usurf->win_layer != NULL) && (usurf->win_layer->layer == layer)) {
1320 uifw_trace("win_mgr_set_layer: Leave(Same Layer)");
1324 /* search existing layer */
1325 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1326 if (el->layer == layer) break;
1329 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
1330 /* layer not exist, create new layer */
1331 uifw_trace("win_mgr_set_layer: New Layer %d", layer);
1332 new_el = win_mgr_create_layer(usurf, layer);
1334 uifw_trace("win_mgr_set_layer: Leave(No Memory)");
1339 uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer);
1340 wl_list_remove(&usurf->ivi_layer);
1341 wl_list_insert(&el->surface_list, &usurf->ivi_layer);
1342 usurf->win_layer = el;
1345 /* rebild compositor surface list */
1346 if (usurf->visible) {
1347 ico_window_mgr_restack_layer(usurf, 0);
1349 uifw_trace("win_mgr_set_layer: Leave");
1352 /*--------------------------------------------------------------------------*/
1354 * @brief win_mgr_set_active: set(or change) active surface
1356 * @param[in] usurf UIFW surface
1357 * @param[in] target target device
1360 /*--------------------------------------------------------------------------*/
1362 win_mgr_set_active(struct uifw_win_surface *usurf, const int target)
1364 struct weston_seat *seat;
1365 struct weston_surface *surface;
1366 int object = target;
1369 uifw_trace("win_mgr_set_active: Enter(%08x,%x)", (int)usurf, target);
1371 if ((usurf) && (usurf->shsurf) && (usurf->surface)) {
1372 surface = usurf->surface;
1373 if ((target & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) {
1375 if (_ico_win_mgr->active_pointer_usurf == usurf) {
1376 object |= ICO_WINDOW_MGR_ACTIVE_POINTER;
1378 if (_ico_win_mgr->active_keyboard_usurf == usurf) {
1379 object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1383 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1384 _ico_win_mgr->active_pointer_usurf = usurf;
1386 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1387 _ico_win_mgr->active_keyboard_usurf = usurf;
1394 object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD;
1396 if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1397 _ico_win_mgr->active_pointer_usurf = NULL;
1399 if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1400 _ico_win_mgr->active_keyboard_usurf = NULL;
1404 wl_list_for_each(seat, &_ico_win_mgr->compositor->seat_list, link) {
1405 if ((object & ICO_WINDOW_MGR_ACTIVE_POINTER) && (seat->pointer)) {
1407 if (seat->pointer->focus != surface) {
1408 uifw_trace("win_mgr_set_active: pointer change surface(%08x=>%08x)",
1409 (int)seat->pointer->focus, (int)surface);
1410 weston_surface_from_global_fixed(surface,
1414 weston_pointer_set_focus(seat->pointer, surface, sx, sy);
1417 uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)",
1422 uifw_trace("win_mgr_set_active: pointer reset surface(%08x)",
1423 (int)seat->pointer->focus);
1424 weston_pointer_set_focus(seat->pointer, NULL,
1425 wl_fixed_from_int(0), wl_fixed_from_int(0));
1428 if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) {
1430 if (seat->keyboard->focus != surface) {
1431 weston_keyboard_set_focus(seat->keyboard, surface);
1432 uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)",
1433 (int)seat->keyboard->focus, (int)surface);
1436 uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)",
1441 uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)",
1442 (int)seat->keyboard);
1443 weston_keyboard_set_focus(seat->keyboard, NULL);
1447 uifw_trace("win_mgr_set_active: Leave(%08x)", (int)usurf);
1450 /*--------------------------------------------------------------------------*/
1452 * @brief ico_window_mgr_ismykeyboard: check active keyboard
1454 * @param[in] usurf UIFW surface
1455 * @return check result
1456 * @retval =1 usurf is active keyboard surface
1457 * @retval =0 usurf is not active
1459 /*--------------------------------------------------------------------------*/
1461 ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf)
1463 return (_ico_win_mgr->active_keyboard_usurf == usurf) ? 1 : 0;
1466 /*--------------------------------------------------------------------------*/
1468 * @brief uifw_declare_manager: declare manager(ex.SystemController) client
1470 * @param[in] client Weyland client
1471 * @param[in] resource resource of request
1472 * @param[in] manager manager(1=manager, 0=not manager)
1475 /*--------------------------------------------------------------------------*/
1477 uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager)
1479 struct uifw_manager* mgr;
1480 struct uifw_win_surface *usurf;
1481 struct uifw_client *uclient;
1482 struct uifw_win_layer *el;
1484 uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d",
1485 (int)client, manager);
1487 uclient = find_client_from_client(client);
1489 uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client);
1493 uclient->manager = manager;
1495 /* client set to manager */
1496 _ico_win_mgr->num_manager = 0;
1497 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1498 if (mgr->resource == resource) {
1499 if (mgr->manager != manager) {
1500 uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d",
1501 (int)client, mgr->manager, manager);
1502 mgr->manager = manager;
1505 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
1506 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
1507 /* send window create event to manager */
1508 if (usurf->created != 0) {
1509 uifw_trace("uifw_declare_manager: Send manager(%08x) "
1510 "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)",
1511 (int)resource, usurf->surfaceid,
1512 usurf->uclient->pid, usurf->uclient->appid);
1513 ico_window_mgr_send_window_created(resource,
1516 usurf->uclient->pid,
1517 usurf->uclient->appid);
1525 _ico_win_mgr->num_manager++;
1528 uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager);
1531 /*--------------------------------------------------------------------------*/
1533 * @brief uifw_set_window_layer: set layer id to surface
1535 * @param[in] client Weyland client
1536 * @param[in] resource resource of request
1537 * @param[in] surfaceid UIFW surface id
1538 * @param[in] layer layer id
1541 /*--------------------------------------------------------------------------*/
1543 uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource,
1544 uint32_t surfaceid, uint32_t layer)
1546 if (layer == ICO_WINDOW_MGR_V_LAYER_INPUT) {
1547 layer = _ico_ivi_input_layer;
1549 else if (layer == ICO_WINDOW_MGR_V_LAYER_CURSOR) {
1550 layer = _ico_ivi_cursor_layer;
1553 uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d",
1554 (int)resource, surfaceid, layer);
1556 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1559 uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid);
1563 if (usurf->win_layer->layer != layer) {
1564 win_mgr_set_layer(usurf, layer);
1565 win_mgr_change_surface(usurf->surface, -1, 1);
1567 uifw_trace("uifw_set_window_layer: Leave");
1570 /*--------------------------------------------------------------------------*/
1572 * @brief uifw_set_positionsize: set surface position and size
1574 * @param[in] client Weyland client
1575 * @param[in] resource resource of request
1576 * @param[in] surfaceid UIFW surface id
1577 * @param[in] node surface node id
1578 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
1579 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
1580 * @param[in] width surface width(if bigger than 16383, no change)
1581 * @param[in] height surface height(if bigger than 16383, no change)
1582 * @param[in] flags with/without animation and client configure flag
1585 /*--------------------------------------------------------------------------*/
1587 uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
1588 uint32_t surfaceid, uint32_t node, int32_t x, int32_t y,
1589 int32_t width, int32_t height, int32_t flags)
1591 struct uifw_client *uclient;
1592 struct uifw_win_surface *usurf;
1593 struct weston_surface *es;
1597 uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x",
1598 surfaceid, node, x, y, width, height, flags);
1600 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1602 uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid);
1606 uclient = find_client_from_client(client);
1609 if (((int)node) >= _ico_num_nodes) {
1610 uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)",
1611 node, _ico_num_nodes);
1612 if ((ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE) == 0) {
1613 if (usurf->visible) {
1614 /* no display, change to hide */
1615 uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE,
1616 ICO_WINDOW_MGR_V_NOCHANGE, 0);
1622 usurf->node_tbl = &_ico_node_table[node];
1624 es = usurf->surface;
1626 /* weston surface exist */
1627 es = usurf->surface;
1628 retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA;
1630 /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */
1631 if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x;
1632 if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y;
1633 if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width;
1634 if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height;
1636 /* check animation */
1637 if ((usurf->animation.restrain_configure != 0) &&
1638 (x == usurf->x) && (y == usurf->y) &&
1639 (width == usurf->width) && (height == usurf->height)) {
1640 uifw_trace("uifw_set_positionsize: Leave(same position size at animation)");
1645 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
1646 (uclient->manager == 0)) uclient = NULL;
1649 if ((usurf->width > 0) && (usurf->height > 0)) {
1650 win_mgr_surface_change_mgr(es, x, y, width, height);
1651 uifw_trace("uifw_set_positionsize: Leave(Request from App)");
1655 uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d",
1657 /* Initiale position is (0,0) */
1658 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x),
1659 (float)(usurf->node_tbl->disp_y));
1662 uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d",
1663 (int)es->geometry.x, (int)es->geometry.y,
1664 (int)es->geometry.width, (int)es->geometry.height);
1666 usurf->animation.pos_x = usurf->x;
1667 usurf->animation.pos_y = usurf->y;
1668 usurf->animation.pos_width = usurf->width;
1669 usurf->animation.pos_height = usurf->height;
1670 usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0;
1673 usurf->width = width;
1674 usurf->height = height;
1675 if (_ico_win_mgr->num_manager <= 0) {
1676 /* no manager(HomeScreen), set geometory */
1677 weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x + x),
1678 (float)(usurf->node_tbl->disp_y + y));
1680 if ((es->output) && (es->buffer_ref.buffer) &&
1681 (es->geometry.width > 0) && (es->geometry.height > 0)) {
1682 uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)",
1684 if (usurf->visible) {
1685 if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) &&
1686 (win_mgr_hook_animation != NULL)) {
1687 /* with animation */
1688 if ((x != (usurf->surface->geometry.x - usurf->node_tbl->disp_x)) ||
1689 (y != (usurf->surface->geometry.y - usurf->node_tbl->disp_y))) {
1690 op = ICO_WINDOW_MGR_ANIMATION_OPMOVE;
1692 else if ((width != usurf->surface->geometry.width) ||
1693 (height != usurf->surface->geometry.height)) {
1694 op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE;
1697 op = ICO_WINDOW_MGR_ANIMATION_OPNONE;
1699 if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) &&
1700 (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) ||
1701 ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) &&
1702 (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) {
1703 retanima = (*win_mgr_hook_animation)(op, (void *)usurf);
1704 uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima);
1707 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
1708 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
1709 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1710 usurf->width, usurf->height);
1714 if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) ||
1715 (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) {
1716 win_mgr_change_surface(es,
1717 (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1);
1719 uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output);
1724 usurf->width = width;
1725 usurf->height = height;
1726 uifw_trace("uifw_set_positionsize: Leave(OK,but no buffer)");
1730 /*--------------------------------------------------------------------------*/
1732 * @brief uifw_set_visible: surface visible/raise control
1734 * @param[in] client Weyland client
1735 * @param[in] resource resource of request
1736 * @param[in] surfaceid UIFW surface id
1737 * @param[in] visible visible(1=show/0=hide/other=no change)
1738 * @param[in] raise raise(1=raise/0=lower/other=no change)
1739 * @param[in] flags with/without animation
1742 /*--------------------------------------------------------------------------*/
1744 uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
1745 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags)
1747 struct uifw_win_surface *usurf;
1748 struct uifw_client *uclient;
1752 uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)",
1753 surfaceid, visible, raise, flags);
1755 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1756 if ((! usurf) || (! usurf->surface)) {
1757 uifw_trace("uifw_set_visible: Leave(Surface Not Exist)");
1761 uclient = find_client_from_client(client);
1763 if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) &&
1764 (uclient->manager == 0)) {
1765 uifw_trace("uifw_set_visible: Request from App(%s), not Manager",
1770 uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid);
1774 uifw_trace("uifw_set_visible: Request from Unknown App, not Manager");
1779 if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) {
1781 if (! usurf->visible) {
1783 uifw_trace("uifw_set_visible: Change to Visible");
1785 ico_ivi_shell_set_toplevel(usurf->shsurf);
1787 /* Weston surface configure */
1788 uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d",
1789 (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y,
1790 usurf->width, usurf->height);
1791 ico_ivi_shell_set_surface_type(usurf->shsurf);
1792 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1793 usurf->width, usurf->height);
1795 restack = 1; /* need damage */
1797 if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) &&
1798 (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1799 (win_mgr_hook_animation != NULL)) {
1800 usurf->animation.pos_x = usurf->x;
1801 usurf->animation.pos_y = usurf->y;
1802 usurf->animation.pos_width = usurf->width;
1803 usurf->animation.pos_height = usurf->height;
1804 usurf->animation.no_configure = 0;
1805 retanima = (*win_mgr_hook_animation)(
1806 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
1807 ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS :
1808 ICO_WINDOW_MGR_ANIMATION_OPSHOW,
1810 uifw_trace("uifw_set_visible: ret call anima = %d", retanima);
1813 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1814 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1815 uifw_trace("uifw_set_visible: Leave(No Change)");
1819 else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) {
1821 if (usurf->visible) {
1823 /* Weston surface configure */
1824 weston_surface_damage_below(usurf->surface);
1825 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1826 usurf->width, usurf->height);
1828 retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA;
1829 if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) &&
1830 (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) &&
1831 (win_mgr_hook_animation != NULL)) {
1832 usurf->animation.pos_x = usurf->x;
1833 usurf->animation.pos_y = usurf->y;
1834 usurf->animation.pos_width = usurf->width;
1835 usurf->animation.pos_height = usurf->height;
1836 usurf->animation.no_configure = 0;
1837 retanima = (*win_mgr_hook_animation)(
1838 (flags & ICO_WINDOW_MGR_ANIMATION_POS) ?
1839 ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS :
1840 ICO_WINDOW_MGR_ANIMATION_OPHIDE,
1843 if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) {
1845 uifw_trace("uifw_set_visible: Change to UnVisible");
1846 /* change visible to unvisible, restack surface list */
1848 /* Weston surface configure */
1849 ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y,
1850 usurf->width, usurf->height);
1853 uifw_trace("uifw_set_visible: UnVisible but animation");
1856 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1857 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1858 uifw_trace("uifw_set_visible: Leave(No Change)");
1862 else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) &&
1863 (raise != ICO_WINDOW_MGR_RAISE_RAISE)) {
1864 uifw_trace("uifw_set_visible: Leave(No Change)");
1869 if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) {
1870 win_mgr_set_raise(usurf, raise);
1871 if (usurf->visible == 0) {
1876 raise = ICO_WINDOW_MGR_V_NOCHANGE;
1880 ico_window_mgr_restack_layer(usurf, 0);
1883 /* send event(VISIBLE) to manager */
1885 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
1887 (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 :
1888 ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 :
1889 ICO_WINDOW_MGR_V_NOCHANGE),
1890 raise, uclient ? 0 : 1, 0,0);
1892 uifw_trace("uifw_set_visible: Leave(OK)");
1895 /*--------------------------------------------------------------------------*/
1897 * @brief uifw_set_animation: set animation of surface visible/unvisible
1899 * @param[in] client Weyland client
1900 * @param[in] resource resource of request
1901 * @param[in] surfaceid UIFW surface id
1902 * @param[in] type how to change surface
1903 * @param[in] anmation animation name
1904 * @param[in] time animation time(ms), if 0, default time
1907 /*--------------------------------------------------------------------------*/
1909 uifw_set_animation(struct wl_client *client, struct wl_resource *resource,
1910 uint32_t surfaceid, int32_t type, const char *animation, int32_t time)
1913 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1915 uifw_trace("uifw_set_transition: Enter(surf=%08x,type=%x,anim=%s,time=%d)",
1916 surfaceid, type, animation, time);
1919 if ((*animation != 0) && (*animation != ' ')) {
1920 animaid = ico_get_animation_name(animation);
1921 uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid);
1922 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1923 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) ||
1924 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) {
1925 usurf->animation.next_anima = animaid;
1928 usurf->animation.hide_anima = animaid;
1931 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1932 if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) ||
1933 (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) {
1934 usurf->animation.next_anima = animaid;
1937 usurf->animation.show_anima = animaid;
1940 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1941 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) {
1942 usurf->animation.next_anima = animaid;
1945 usurf->animation.move_anima = animaid;
1948 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1949 if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) {
1950 usurf->animation.next_anima = animaid;
1953 usurf->animation.resize_anima = animaid;
1957 if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) {
1958 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) {
1959 usurf->animation.hide_time = time;
1961 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) {
1962 usurf->animation.show_time = time;
1964 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) {
1965 usurf->animation.move_time = time;
1967 if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) {
1968 usurf->animation.resize_time = time;
1973 uifw_trace("uifw_set_animation: Leave(Surface(%08x) Not exist)", surfaceid);
1977 /*--------------------------------------------------------------------------*/
1979 * @brief uifw_set_attributes: set surface attributes
1981 * @param[in] client Weyland client
1982 * @param[in] resource resource of request
1983 * @param[in] surfaceid UIFW surface id
1984 * @param[in] attributes surface attributes
1987 /*--------------------------------------------------------------------------*/
1989 uifw_set_attributes(struct wl_client *client, struct wl_resource *resource,
1990 uint32_t surfaceid, uint32_t attributes)
1992 struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
1994 uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes);
1997 usurf->attributes = attributes;
1998 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) ==
1999 (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) {
2000 usurf->attributes &=
2001 ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT);
2003 if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) ==
2004 (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) {
2005 usurf->attributes &=
2006 ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM);
2009 uifw_trace("uifw_set_attributes: Leave");
2012 /*--------------------------------------------------------------------------*/
2014 * @brief uifw_visible_animation: surface visibility control with animation
2016 * @param[in] client Weyland client
2017 * @param[in] resource resource of request
2018 * @param[in] surfaceid surface id
2019 * @param[in] visible visible(1=show/0=hide)
2020 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
2021 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
2022 * @param[in] width surface width(if bigger than 16383, no change)
2023 * @param[in] height surface height(if bigger than 16383, no change)
2026 /*--------------------------------------------------------------------------*/
2028 uifw_visible_animation(struct wl_client *client, struct wl_resource *resource,
2029 uint32_t surfaceid, int32_t visible,
2030 int32_t x, int32_t y, int32_t width, int32_t height)
2032 struct uifw_win_surface *usurf;
2034 uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)",
2035 surfaceid, visible, x, y, width, height);
2037 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2039 if ((! usurf) || (! usurf->surface)) {
2040 uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)");
2044 usurf->animation.pos_x = x;
2045 usurf->animation.pos_y = y;
2046 if (width > 0) usurf->animation.pos_width = width;
2047 else usurf->animation.pos_width = 1;
2048 if (height > 0) usurf->animation.pos_height = height;
2049 else usurf->animation.pos_height = 1;
2050 usurf->animation.no_configure = 0;
2052 uifw_set_visible(client, resource, surfaceid, visible,
2053 ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS);
2055 uifw_trace("uifw_visible_animation: Leave");
2058 /*--------------------------------------------------------------------------*/
2060 * @brief uifw_set_active: set active surface
2062 * @param[in] client Weyland client
2063 * @param[in] resource resource of request
2064 * @param[in] surfaceid UIFW surface id
2065 * @param[in] active target device
2068 /*--------------------------------------------------------------------------*/
2070 uifw_set_active(struct wl_client *client, struct wl_resource *resource,
2071 uint32_t surfaceid, int32_t active)
2073 struct uifw_win_surface *usurf;
2075 uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active);
2077 if ((surfaceid > 0) &&
2078 ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) {
2079 usurf = ico_window_mgr_get_usurf_client(surfaceid, client);
2085 switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) {
2086 case ICO_WINDOW_MGR_ACTIVE_POINTER:
2087 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2088 if (_ico_win_mgr->active_pointer_usurf) {
2089 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2090 _ico_win_mgr->active_pointer_usurf,
2091 (_ico_win_mgr->active_keyboard_usurf ==
2092 _ico_win_mgr->active_pointer_usurf) ?
2093 ICO_WINDOW_MGR_ACTIVE_KEYBOARD :
2094 ICO_WINDOW_MGR_ACTIVE_NONE,
2097 _ico_win_mgr->active_pointer_usurf = usurf;
2098 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2100 ICO_WINDOW_MGR_ACTIVE_POINTER |
2101 (_ico_win_mgr->active_keyboard_usurf == usurf) ?
2102 ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0,
2104 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER);
2107 case ICO_WINDOW_MGR_ACTIVE_KEYBOARD:
2108 if (usurf != _ico_win_mgr->active_keyboard_usurf) {
2109 if (_ico_win_mgr->active_keyboard_usurf) {
2110 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2111 _ico_win_mgr->active_keyboard_usurf,
2112 (_ico_win_mgr->active_keyboard_usurf ==
2113 _ico_win_mgr->active_pointer_usurf) ?
2114 ICO_WINDOW_MGR_ACTIVE_POINTER :
2115 ICO_WINDOW_MGR_ACTIVE_NONE,
2118 _ico_win_mgr->active_keyboard_usurf = usurf;
2119 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2121 ICO_WINDOW_MGR_ACTIVE_KEYBOARD |
2122 (_ico_win_mgr->active_pointer_usurf == usurf) ?
2123 ICO_WINDOW_MGR_ACTIVE_POINTER : 0,
2125 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2129 if ((usurf != _ico_win_mgr->active_pointer_usurf) ||
2130 (usurf != _ico_win_mgr->active_keyboard_usurf)) {
2131 if (_ico_win_mgr->active_pointer_usurf) {
2132 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2133 _ico_win_mgr->active_pointer_usurf,
2134 ICO_WINDOW_MGR_ACTIVE_NONE,
2136 if (_ico_win_mgr->active_keyboard_usurf ==
2137 _ico_win_mgr->active_pointer_usurf) {
2138 _ico_win_mgr->active_keyboard_usurf = NULL;
2141 if (_ico_win_mgr->active_keyboard_usurf) {
2142 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2143 _ico_win_mgr->active_keyboard_usurf,
2144 ICO_WINDOW_MGR_ACTIVE_NONE,
2147 _ico_win_mgr->active_pointer_usurf = usurf;
2148 _ico_win_mgr->active_keyboard_usurf = usurf;
2149 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2151 ICO_WINDOW_MGR_ACTIVE_POINTER |
2152 ICO_WINDOW_MGR_ACTIVE_KEYBOARD,
2154 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2155 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2159 uifw_trace("uifw_set_active: Leave(Change Active)");
2162 win_mgr_set_active(NULL, active);
2163 uifw_trace("uifw_set_active: Leave(Reset active surface)");
2167 /*--------------------------------------------------------------------------*/
2169 * @brief uifw_set_layer_visible: layer visible control
2171 * @param[in] client Weyland client
2172 * @param[in] resource resource of request
2173 * @param[in] layer layer id
2174 * @param[in] visible visible(1=show/0=hide)
2177 /*--------------------------------------------------------------------------*/
2179 uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
2180 uint32_t layer, int32_t visible)
2182 struct uifw_win_layer *el;
2183 struct uifw_win_layer *new_el;
2184 struct uifw_win_surface *usurf;
2186 if (layer == ICO_WINDOW_MGR_V_LAYER_INPUT) {
2187 layer = _ico_ivi_input_layer;
2189 else if (layer == ICO_WINDOW_MGR_V_LAYER_CURSOR) {
2190 layer = _ico_ivi_cursor_layer;
2193 uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible);
2196 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2197 if (el->layer == layer) break;
2200 if (&el->link == &_ico_win_mgr->ivi_layer_list) {
2201 /* layer not exist, create new layer */
2202 uifw_trace("uifw_set_layer_visible: New Layer %d", layer);
2203 new_el = win_mgr_create_layer(NULL, layer);
2205 uifw_trace("uifw_set_layer_visible: Leave(No Memory)");
2208 new_el->visible = (visible != 0) ? TRUE : FALSE;
2209 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2210 layer, new_el->visible, 0,0,0);
2211 uifw_trace("uifw_set_layer_visible: Leave(new layer)");
2215 /* control all surface in layer */
2216 if ((el->visible != FALSE) && (visible == 0)) {
2217 /* layer change to NOT visible */
2218 uifw_trace("uifw_set_layer_visible: change to not visible");
2219 el->visible = FALSE;
2221 else if ((el->visible == FALSE) && (visible != 0)) {
2222 /* layer change to visible */
2223 uifw_trace("uifw_set_layer_visible: change to visible");
2228 uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)",
2229 el->visible, visible);
2233 /* set damege area */
2234 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2235 if ((usurf->visible != FALSE) && (usurf->surface != NULL) &&
2236 (usurf->surface->output != NULL)) {
2237 /* Damage(redraw) target surface */
2238 weston_surface_damage_below(usurf->surface);
2242 /* rebild compositor surface list */
2243 ico_window_mgr_restack_layer(NULL, 0);
2245 /* send layer visible event to manager */
2246 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL,
2247 layer, el->visible, 0,0,0);
2249 uifw_trace("uifw_set_layer_visible: Leave");
2252 /*--------------------------------------------------------------------------*/
2254 * @brief uifw_get_surfaces: get application surfaces
2256 * @param[in] client Weyland client
2257 * @param[in] resource resource of request
2258 * @param[in] appid application id
2261 /*--------------------------------------------------------------------------*/
2263 uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, const char *appid)
2265 struct uifw_client *uclient;
2266 struct uifw_win_layer *el;
2267 struct uifw_win_surface *usurf;
2268 struct wl_array reply;
2271 uifw_trace("uifw_get_surfaces: Enter(appid=%s)", appid);
2273 wl_array_init(&reply);
2275 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
2276 if (strcmp(uclient->appid, appid) == 0) break;
2278 if (&uclient->link == &_ico_win_mgr->client_list) {
2279 uifw_trace("uifw_get_surfaces: appid=%s dose not exist", appid);
2282 wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) {
2283 wl_list_for_each (usurf, &el->surface_list, ivi_layer) {
2284 if (usurf->uclient == uclient) {
2285 uifw_trace("uifw_get_surfaces: %s surf=%08x", appid, usurf->surfaceid);
2286 up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t));
2288 *up = usurf->surfaceid;
2294 ico_window_mgr_send_app_surfaces(resource, appid, &reply);
2296 wl_array_release(&reply);
2297 uifw_trace("uifw_get_surfaces: Leave");
2300 /*--------------------------------------------------------------------------*/
2302 * @brief win_mgr_check_surfacemap: check and change all surface
2304 * @param[in] animation weston animation table(unused)
2305 * @param[in] outout weston output table
2306 * @param[in] mseces current time(unused)
2309 /*--------------------------------------------------------------------------*/
2311 win_mgr_check_surfacemap(struct weston_animation *animation,
2312 struct weston_output *output, uint32_t msecs)
2314 struct uifw_surface_map *sm;
2316 wl_list_for_each(sm, &_ico_win_mgr->map_list, map_link) {
2317 if (sm->usurf->surface->output == output) {
2318 win_mgr_change_mapsurface(sm, 0);
2323 /*--------------------------------------------------------------------------*/
2325 * @brief win_mgr_change_mapsurface: check and change mapped surface
2327 * @param[in] sm map surface table
2328 * @param[in] event send event (if 0, send if changed)
2331 /*--------------------------------------------------------------------------*/
2333 win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event)
2335 struct uifw_drm_buffer *drm_buffer;
2336 struct uifw_dri_image *dri_image;
2337 struct uifw_intel_region *dri_region;
2338 struct uifw_gl_surface_state *gl_state;
2339 struct weston_surface *es;
2340 uint32_t eglname = 0;
2346 /* check if buffered */
2347 es = sm->usurf->surface;
2348 if ((es == NULL) || (es->buffer_ref.buffer == NULL) ||
2349 (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0) ||
2350 (es->buffer_ref.buffer->legacy_buffer == NULL) || (es->renderer_state == NULL) ||
2351 (((struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer)->driver_buffer
2353 /* surface has no buffer, error */
2354 uifw_trace("win_mgr_change_mapsurface: surface(%08x) has no buffer",
2355 sm->usurf->surfaceid);
2362 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP;
2369 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2370 if (gl_state->buffer_type == BUFFER_TYPE_SHM) {
2371 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR;
2373 else if (gl_state->buffer_type != BUFFER_TYPE_EGL) {
2377 drm_buffer = (struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer;
2378 dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer;
2379 dri_region = dri_image->region;
2380 width = es->buffer_ref.buffer->width;
2381 height = es->buffer_ref.buffer->height;
2382 stride = drm_buffer->stride[0];
2383 if (drm_buffer->format == 0x34325258) {
2384 format = EGL_TEXTURE_RGB;
2386 else if (drm_buffer->format == 0x34325241) {
2387 format = EGL_TEXTURE_RGBA;
2390 /* unknown format, error */
2391 format = EGL_NO_TEXTURE;
2393 eglname = dri_region->name;
2395 if ((sm->initflag == 0) && (width > 0) && (height > 0) && (stride > 0)) {
2397 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP;
2400 if ((width <= 0) || (height <= 0) || (stride <= 0)) {
2403 else if (event == 0) {
2404 if ((sm->width != width) || (sm->height != height) ||
2405 (sm->stride != stride)) {
2406 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE;
2408 else if ((eglname != sm->eglname) || (format != sm->format)) {
2409 event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS;
2414 sm->height = height;
2415 sm->stride = stride;
2416 sm->eglname = eglname;
2417 sm->format = format;
2418 sm->eglname = eglname;
2423 #if 0 /* too many log */
2424 uifw_trace("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x name=%08x "
2425 "w/h/s=%d/%d/%d format=%x",
2426 event, sm->usurf->surfaceid, sm->eglname, sm->width, sm->height,
2427 sm->stride, sm->format);
2429 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event,
2430 sm->usurf->surfaceid, sm->type, sm->eglname,
2431 sm->width, sm->height, sm->stride, sm->format);
2432 if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) {
2433 /* free map table if error */
2434 wl_list_remove(&sm->surf_link);
2435 wl_list_remove(&sm->map_link);
2436 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2437 _ico_win_mgr->free_maptable = sm;
2442 /*--------------------------------------------------------------------------*/
2444 * @brief uifw_map_surface: mapped surface buffer to system application
2446 * @param[in] client Weyland client
2447 * @param[in] resource resource of request
2448 * @param[in] surfaceid surface id
2449 * @param[in] framerate frame rate of surface update(frame/sec)
2452 /*--------------------------------------------------------------------------*/
2454 uifw_map_surface(struct wl_client *client, struct wl_resource *resource,
2455 uint32_t surfaceid, int32_t framerate)
2457 struct uifw_win_surface *usurf;
2458 struct weston_surface *es;
2459 struct uifw_surface_map *sm;
2460 struct weston_buffer *buffer;
2461 struct uifw_client *uclient;
2462 struct uifw_drm_buffer *drm_buffer;
2463 struct uifw_gl_surface_state *gl_state;
2465 uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate);
2467 usurf = ico_window_mgr_get_usurf(surfaceid);
2469 /* surface dose not exist, error */
2470 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2471 surfaceid, 1, 0, 0, 0, 0, 0);
2472 uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid);
2475 uclient = find_client_from_client(client);
2476 if ((! uclient) || (! uclient->mgr)) {
2477 /* client dose not exist, error */
2478 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2479 surfaceid, 2, 0, 0, 0, 0, 0);
2480 uifw_trace("uifw_map_surface: Leave(client=%08x dose not exist)", (int)client);
2484 es = usurf->surface;
2486 /* check if buffered */
2487 if ((es == NULL) || (es->buffer_ref.buffer == NULL)) {
2488 /* surface has no buffer, error */
2489 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2490 surfaceid, 3, 0, 0, 0, 0, 0);
2491 uifw_trace("uifw_map_surface: Leave(surface(%08x) has no buffer)", surfaceid);
2495 /* check buffer type */
2496 gl_state = (struct uifw_gl_surface_state *)es->renderer_state;
2497 if ((gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) {
2498 /* wl_shm_buffer not support */
2499 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2500 surfaceid, 4, 0, 0, 0, 0, 0);
2501 uifw_trace("uifw_map_surface: Leave(surface(%08x) is wl_shm_buffer, "
2502 "not support)", surfaceid);
2506 /* create map table */
2507 sm = _ico_win_mgr->free_maptable;
2509 _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf;
2512 sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map));
2514 ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR,
2515 surfaceid, 5, 0, 0, 0, 0, 0);
2516 uifw_trace("uifw_map_surface: Leave(malloc error)");
2520 memset(sm, 0, sizeof(struct uifw_surface_map));
2522 wl_list_init(&sm->map_link);
2523 wl_list_init(&sm->surf_link);
2525 sm->uclient = uclient;
2526 sm->type = ICO_WINDOW_MGR_MAP_TYPE_EGL;
2528 sm->framerate = framerate;
2529 wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link);
2530 wl_list_insert(usurf->surf_map.prev, &sm->surf_link);
2532 buffer = es->buffer_ref.buffer;
2533 if (gl_state->buffer_type == BUFFER_TYPE_EGL) {
2534 sm->width = buffer->width;
2535 sm->height = buffer->height;
2536 drm_buffer = (struct uifw_drm_buffer *)buffer->legacy_buffer;
2537 if (drm_buffer != NULL) {
2538 sm->stride = drm_buffer->stride[0];
2539 if (drm_buffer->format == 0x34325258) {
2540 sm->format = EGL_TEXTURE_RGB;
2542 else if (drm_buffer->format == 0x34325241) {
2543 sm->format = EGL_TEXTURE_RGBA;
2546 /* unknown format, error */
2547 sm->format = EGL_NO_TEXTURE;
2549 if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) &&
2550 (gl_state != NULL)) {
2556 /* send map event */
2558 win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP);
2560 uifw_trace("uifw_map_surface: Leave");
2563 /*--------------------------------------------------------------------------*/
2565 * @brief uifw_unmap_surface: unmap surface buffer
2567 * @param[in] client Weyland client
2568 * @param[in] resource resource of request
2569 * @param[in] surfaceid surface id
2572 /*--------------------------------------------------------------------------*/
2574 uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource,
2577 struct uifw_win_surface *usurf;
2578 struct uifw_surface_map *sm, *sm_tmp;
2579 struct uifw_client *uclient;
2581 uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid);
2583 usurf = ico_window_mgr_get_usurf(surfaceid);
2585 /* surface dose not exist, error */
2586 uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid);
2590 uclient = find_client_from_client(client);
2591 if ((! uclient) || (! uclient->mgr)) {
2592 /* client dose not exist, error */
2593 uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client);
2599 wl_list_for_each(sm, &usurf->surf_map, surf_link) {
2600 if (sm->uclient->mgr != NULL) {
2601 uifw_trace("uifw_unmap_surface: send MAP event(ev=%d surf=%08x name=%08x "
2602 "w/h/s=%d/%d/%d format=%x",
2603 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2604 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
2605 ico_window_mgr_send_map_surface(sm->uclient->mgr->resource,
2606 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2607 surfaceid, sm->type, sm->eglname, sm->width,
2608 sm->height, sm->stride, sm->format);
2613 wl_list_for_each_safe(sm, sm_tmp, &usurf->surf_map, surf_link) {
2614 if (((uclient != NULL) && (sm->uclient != uclient))) continue;
2615 /* send unmap event */
2616 if ((uclient != NULL) && (uclient->mgr != NULL)) {
2617 uifw_trace("uifw_unmap_surface: send MAP event(ev=%d surf=%08x name=%08x "
2618 "w/h/s=%d/%d/%d format=%x",
2619 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid,
2620 sm->eglname, sm->width, sm->height, sm->stride, sm->format);
2621 ico_window_mgr_send_map_surface(uclient->mgr->resource,
2622 ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP,
2623 surfaceid, sm->type, sm->eglname, sm->width,
2624 sm->height, sm->stride, sm->format);
2626 wl_list_remove(&sm->surf_link);
2627 wl_list_remove(&sm->map_link);
2628 sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable;
2629 _ico_win_mgr->free_maptable = sm;
2631 uifw_trace("uifw_unmap_surface: Leave");
2634 /*--------------------------------------------------------------------------*/
2636 * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen)
2638 * @param[in] surface Weston surface
2639 * @param[in] x X coordinate on screen
2640 * @param[in] y Y coordinate on screen
2641 * @param[in] width surface width
2642 * @param[in] height surface height
2643 * @return number of managers
2644 * @retval > 0 number of managers
2645 * @retval 0 manager not exist
2647 /*--------------------------------------------------------------------------*/
2649 win_mgr_surface_change_mgr(struct weston_surface *surface,
2650 const int x, const int y, const int width, const int height)
2653 struct uifw_win_surface *usurf;
2655 uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)",
2656 (int)surface, x, y, width, height);
2658 usurf = find_uifw_win_surface_by_ws(surface);
2660 uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)");
2664 num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2665 usurf, x, y, width, height, 1);
2667 uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr);
2671 /*--------------------------------------------------------------------------*/
2673 * @brief win_mgr_change_surface: surface change
2675 * @param[in] surface Weston surface
2676 * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager)
2677 * @param[in] manager request from manager(0=Client,1=Manager)
2680 /*--------------------------------------------------------------------------*/
2682 win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager)
2684 struct uifw_win_surface *usurf;
2685 struct weston_surface *es;
2690 uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager);
2693 usurf = find_uifw_win_surface_by_ws(surface);
2695 uifw_trace("win_mgr_change_surface: Leave(Not Exist)");
2698 es = usurf->surface;
2700 uifw_trace("win_mgr_change_surface: Leave(No weston surface)");
2704 /* set surface size */
2705 uifw_debug("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d",
2706 (int)es->geometry.x, (int)es->geometry.y, usurf->x, usurf->y,
2707 usurf->width, usurf->height, es->geometry.width, es->geometry.height);
2708 if ((usurf->width <= 0) || (usurf->height <= 0)) {
2709 usurf->width = es->geometry.width;
2710 usurf->height = es->geometry.height;
2712 win_mgr_set_scale(usurf);
2713 if (usurf->visible) {
2714 weston_surface_set_position(usurf->surface,
2715 (float)(usurf->node_tbl->disp_x +
2716 usurf->x + usurf->xadd),
2717 (float)(usurf->node_tbl->disp_y +
2718 usurf->y + usurf->yadd));
2719 ico_window_mgr_restack_layer(usurf, 0);
2722 weston_surface_set_position(usurf->surface, (float)(ICO_IVI_MAX_COORDINATE+1),
2723 (float)(ICO_IVI_MAX_COORDINATE+1));
2726 /* send wayland event to client */
2727 if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) &&
2728 (usurf->width > 0) && (usurf->height > 0)) {
2729 if ((usurf->width != usurf->conf_width) ||
2730 (usurf->height != usurf->conf_height)) {
2731 usurf->conf_width = usurf->width;
2732 usurf->conf_height = usurf->height;
2733 uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ",
2734 usurf->surfaceid, (int)es, usurf->width, usurf->height);
2735 ico_ivi_shell_send_configure(es,
2736 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
2737 usurf->width, usurf->height);
2741 if (usurf->visible) {
2742 x = usurf->node_tbl->disp_x + usurf->x;
2743 y = usurf->node_tbl->disp_y + usurf->y;
2746 x = ICO_IVI_MAX_COORDINATE+1;
2747 y = ICO_IVI_MAX_COORDINATE+1;
2749 /* change geometry if request from manager */
2751 if ((usurf->width != es->geometry.width) ||
2752 (usurf->height != es->geometry.height) ||
2753 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
2754 win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height);
2759 /* send manager event to HomeScreen */
2762 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2763 usurf, usurf->x, usurf->y,
2764 usurf->width, usurf->height, 0);
2767 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
2768 usurf, (int)es->geometry.x, (int)es->geometry.y,
2769 es->geometry.width, es->geometry.height, 1);
2773 /* change geometry if request from client */
2775 if ((usurf->width != es->geometry.width) || (usurf->height != es->geometry.height) ||
2776 (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) {
2777 win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height);
2783 uifw_trace("win_mgr_change_surface: repaint");
2784 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
2786 uifw_trace("win_mgr_change_surface: Leave(OK)");
2789 /*--------------------------------------------------------------------------*/
2791 * @brief win_mgr_surface_configure: UIFW surface configure
2793 * @param[in] usurf UIFW surface
2794 * @param[in] x X coordinate on screen
2795 * @param[in] y Y coordinate on screen
2796 * @param[in] width surface width
2797 * @param[in] height surface height
2800 /*--------------------------------------------------------------------------*/
2802 win_mgr_surface_configure(struct uifw_win_surface *usurf,
2803 int x, int y, int width, int height)
2805 struct weston_surface *es;
2807 es = usurf->surface;
2808 if ((es != NULL) && (es->buffer_ref.buffer)) {
2809 if (usurf->client_width == 0) {
2810 usurf->client_width = es->geometry.width;
2811 if (usurf->client_width == 0)
2812 usurf->client_width = weston_surface_buffer_width(es);
2814 if (usurf->client_height == 0) {
2815 usurf->client_height = es->geometry.height;
2816 if (usurf->client_height == 0)
2817 usurf->client_height = weston_surface_buffer_height(es);
2820 /* not set geometry width/height */
2821 win_mgr_set_scale(usurf);
2822 weston_surface_set_position(es, x + usurf->xadd, y + usurf->yadd);
2826 /*--------------------------------------------------------------------------*/
2828 * @brief win_mgr_shell_configure: shell surface configure
2830 * @param[in] surface Weston surface
2833 /*--------------------------------------------------------------------------*/
2835 win_mgr_shell_configure(struct weston_surface *surface)
2837 struct uifw_win_surface *usurf;
2841 uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface);
2843 /* Find UIFW surface */
2844 usurf = find_uifw_win_surface_by_ws(surface);
2846 uifw_trace("win_mgr_shell_configure: Leave(Not Exist)");
2850 usurf->client_width = surface->geometry.width;
2851 usurf->client_height = surface->geometry.height;
2852 buf_width = weston_surface_buffer_width(surface);
2853 buf_height = weston_surface_buffer_height(surface);
2854 uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d",
2856 usurf->client_width, usurf->client_height, buf_width, buf_height);
2857 if (usurf->client_width > buf_width) usurf->client_width = buf_width;
2858 if (usurf->client_height > buf_height) usurf->client_height = buf_height;
2860 /* send event to manager */
2861 win_mgr_change_surface(surface, -1, 0);
2863 uifw_trace("win_mgr_shell_configure: Leave");
2866 /*--------------------------------------------------------------------------*/
2868 * @brief win_mgr_select_surface: select surface by Bottun/Touch
2870 * @param[in] surface Weston surface
2873 /*--------------------------------------------------------------------------*/
2875 win_mgr_select_surface(struct weston_surface *surface)
2877 struct uifw_win_surface *usurf;
2879 uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface);
2882 usurf = find_uifw_win_surface_by_ws(surface);
2884 uifw_trace("win_mgr_select_surface: Leave(Not Exist)");
2887 if (usurf != _ico_win_mgr->active_pointer_usurf) {
2889 /* send active event to manager */
2890 if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
2891 usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) {
2892 uifw_trace("win_mgr_select_surface: not found manager, set active");
2893 win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER |
2894 ICO_WINDOW_MGR_ACTIVE_KEYBOARD);
2897 uifw_trace("win_mgr_select_surface: Leave(OK)");
2900 /*--------------------------------------------------------------------------*/
2902 * @brief win_mgr_set_title: set tile name to surface
2904 * @param[in] surface weston surface
2905 * @param[in] title title name
2908 /*--------------------------------------------------------------------------*/
2910 win_mgr_set_title(struct weston_surface *surface, const char *title)
2912 struct uifw_win_surface *usurf;
2914 uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title);
2916 usurf = find_uifw_win_surface_by_ws(surface);
2918 uifw_trace("win_mgr_set_title: Leave(Not Exist)");
2921 if (((usurf->width > 0) && (usurf->height > 0)) &&
2922 ((usurf->created == 0) ||
2923 (strncmp(title, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) {
2924 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
2925 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
2926 if (usurf->created == 0) {
2927 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0);
2931 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0);
2935 strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1);
2936 usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0;
2938 uifw_trace("win_mgr_set_title: Leave");
2941 /*--------------------------------------------------------------------------*/
2943 * @brief win_mgr_surface_move: set tile name to surface
2945 * @param[in] surface weston surface
2946 * @param[in] title title name
2949 /*--------------------------------------------------------------------------*/
2951 win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy)
2953 struct uifw_win_surface *usurf;
2955 uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy);
2957 usurf = find_uifw_win_surface_by_ws(surface);
2959 uifw_trace("win_mgr_surface_move: Leave(Not Exist)");
2962 if (usurf->visible) {
2963 *dx = usurf->node_tbl->disp_x + usurf->x;
2964 *dy = usurf->node_tbl->disp_y + usurf->y;
2967 *dx = ICO_IVI_MAX_COORDINATE+1;
2968 *dy = ICO_IVI_MAX_COORDINATE+1;
2970 uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy);
2973 /*--------------------------------------------------------------------------*/
2975 * @brief ico_window_mgr_set_visible: change surface visibility
2977 * @param[in] usurf UIFW surface
2978 * @param[in] visible visible(=1)/unvisible(0)
2981 /*--------------------------------------------------------------------------*/
2983 ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible)
2986 if (usurf->visible == 0) {
2987 uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x)", (int)usurf);
2989 /* change unvisible to visible, restack surface list */
2990 ico_window_mgr_restack_layer(usurf, 0);
2994 if (usurf->visible != 0) {
2995 uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)", (int)usurf);
2997 /* change visible to unvisible, restack surface list */
2998 ico_window_mgr_restack_layer(usurf, 0);
3001 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3002 usurf, usurf->visible, usurf->raise, 0, 0,0);
3005 /*--------------------------------------------------------------------------*/
3007 * @brief win_mgr_set_raise: change surface raise/lower
3009 * @param[in] usurf UIFW surface
3010 * @param[in] raise raise(=1)/lower(0)
3013 /*--------------------------------------------------------------------------*/
3015 win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise)
3017 uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%x",
3018 (int)usurf, raise, (int)usurf->win_layer->layer);
3020 wl_list_remove(&usurf->ivi_layer);
3022 /* raise ... surface stack to top of layer */
3023 wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer);
3025 uifw_trace("win_mgr_set_raise: Raise Link to Top");
3028 /* Lower ... surface stack to bottom of layer */
3029 wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer);
3031 uifw_trace("win_mgr_set_raise: Lower Link to Bottom");
3034 /* rebild compositor surface list */
3035 if (usurf->visible) {
3036 ico_window_mgr_restack_layer(usurf, 0);
3038 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
3039 usurf, usurf->visible, usurf->raise, 0, 0,0);
3041 uifw_trace("win_mgr_set_raise: Leave");
3044 /*--------------------------------------------------------------------------*/
3046 * @brief win_mgr_destroy_surface: surface destroy
3048 * @param[in] surface Weston surface
3051 /*--------------------------------------------------------------------------*/
3053 win_mgr_destroy_surface(struct weston_surface *surface)
3055 struct uifw_win_surface *usurf;
3056 struct uifw_win_surface *phash;
3057 struct uifw_win_surface *bhash;
3060 usurf = find_uifw_win_surface_by_ws(surface);
3062 uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist");
3065 uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid);
3068 if (&usurf->surf_map != usurf->surf_map.next) {
3069 uifw_unmap_surface(NULL, NULL, usurf->surfaceid);
3072 /* destroy active surface */
3073 if (usurf == _ico_win_mgr->active_pointer_usurf) {
3074 _ico_win_mgr->active_pointer_usurf = NULL;
3076 if (usurf == _ico_win_mgr->active_keyboard_usurf) {
3077 _ico_win_mgr->active_keyboard_usurf = NULL;
3080 /* destroy animation extenson */
3081 if (win_mgr_hook_animation) {
3082 (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf);
3085 /* delete from layer list */
3086 wl_list_remove(&usurf->ivi_layer);
3087 ico_window_mgr_restack_layer(NULL, 0);
3089 /* delete from cleint list */
3090 wl_list_remove(&usurf->client_link);
3092 /* delete from hash table */
3093 hash = MAKE_IDHASH(usurf->surfaceid);
3094 phash = _ico_win_mgr->idhash[hash];
3096 while ((phash) && (phash != usurf)) {
3098 phash = phash->next_idhash;
3101 bhash->next_idhash = usurf->next_idhash;
3104 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
3107 hash = MAKE_WSHASH(usurf->surface);
3108 phash = _ico_win_mgr->wshash[hash];
3110 while ((phash) && (phash != usurf)) {
3112 phash = phash->next_wshash;
3115 bhash->next_wshash = usurf->next_wshash;
3118 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
3121 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED,
3124 hash = usurf->surfaceid & SURCAFE_ID_MASK;
3125 _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16));
3128 uifw_trace("win_mgr_destroy_surface: Leave(OK)");
3131 /*--------------------------------------------------------------------------*/
3133 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
3135 * @param[in] client client
3136 * @param[in] data user data(unused)
3137 * @param[in] version protocol version(unused)
3138 * @param[in] id client object id
3141 /*--------------------------------------------------------------------------*/
3143 bind_ico_win_mgr(struct wl_client *client,
3144 void *data, uint32_t version, uint32_t id)
3146 struct wl_resource *add_resource;
3147 struct uifw_manager *mgr;
3148 struct uifw_client *uclient;
3150 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
3152 add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id);
3154 wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation,
3155 _ico_win_mgr, unbind_ico_win_mgr);
3158 /* Create client management tabel */
3159 uclient = find_client_from_client(client);
3161 win_mgr_bind_client(client, NULL);
3162 uclient = find_client_from_client(client);
3166 mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
3168 uifw_error("bind_ico_win_mgr: Error, No Memory");
3171 memset(mgr, 0, sizeof(struct uifw_manager));
3172 mgr->resource = add_resource;
3176 wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link);
3178 uifw_trace("bind_ico_win_mgr: Leave");
3181 /*--------------------------------------------------------------------------*/
3183 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
3185 * @param[in] resource client resource
3188 /*--------------------------------------------------------------------------*/
3190 unbind_ico_win_mgr(struct wl_resource *resource)
3192 struct uifw_manager *mgr, *itmp;
3194 uifw_trace("unbind_ico_win_mgr: Enter");
3196 /* Remove manager from manager list */
3197 _ico_win_mgr->num_manager = 0;
3198 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
3199 if (mgr->resource == resource) {
3200 wl_list_remove(&mgr->link);
3205 _ico_win_mgr->num_manager++;
3209 uifw_trace("unbind_ico_win_mgr: Leave");
3212 /*--------------------------------------------------------------------------*/
3214 * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen)
3216 * @param[in] event event code(if -1, not send event)
3217 * @param[in] usurf UIFW surface table
3218 * @param[in] param1 parameter 1
3220 * @param[in] param5 parameter 5
3221 * @return number of managers
3222 * @retval > 0 number of managers
3223 * @retval 0 manager not exist
3225 /*--------------------------------------------------------------------------*/
3227 ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf,
3228 const int param1, const int param2, const int param3,
3229 const int param4, const int param5)
3232 struct uifw_manager* mgr;
3234 /* if appid not fix, check and fix appid */
3235 if ((usurf != NULL) &&
3236 (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) {
3237 win_mgr_get_client_appid(usurf->uclient);
3240 /* send created if not send created event */
3241 if ((usurf != NULL) && (usurf->created == 0) &&
3242 (((usurf->width > 0) && (usurf->height > 0)) ||
3243 ((event != ICO_WINDOW_MGR_WINDOW_CREATED) &&
3244 (event != ICO_WINDOW_MGR_WINDOW_NAME)))) {
3245 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
3247 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED"
3248 "(surf=%08x,name=%s,pid=%d,appid=%s)", (int)mgr->resource,
3249 usurf->surfaceid, usurf->winname, usurf->uclient->pid,
3250 usurf->uclient->appid);
3251 ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid,
3252 usurf->winname, usurf->uclient->pid,
3253 usurf->uclient->appid);
3259 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
3264 case ICO_WINDOW_MGR_WINDOW_CREATED:
3265 /* Do nothing anymore because sended window create event */
3268 case ICO_WINDOW_MGR_WINDOW_NAME:
3269 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME"
3270 "(surf=%08x,name=%s)", (int)mgr->resource,
3271 usurf->surfaceid, usurf->winname);
3272 ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid,
3276 case ICO_WINDOW_MGR_WINDOW_DESTROYED:
3277 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED"
3278 "(surf=%08x)", (int)mgr->resource, usurf->surfaceid);
3279 ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid);
3282 case ICO_WINDOW_MGR_WINDOW_VISIBLE:
3283 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE"
3284 "(surf=%08x,vis=%d,raise=%d,hint=%d)",
3285 (int)mgr->resource, usurf->surfaceid, param1, param2, param3);
3286 ico_window_mgr_send_window_visible(mgr->resource,
3287 usurf->surfaceid, param1, param2, param3);
3290 case ICO_WINDOW_MGR_WINDOW_CONFIGURE:
3291 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE"
3292 "(surf=%08x,app=%s,node=%x,layer=%x,x/y=%d/%d,w/h=%d/%d,hint=%d)",
3293 (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid,
3294 usurf->node_tbl->node, usurf->win_layer->layer,
3295 param1, param2, param3, param4, param5);
3296 ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid,
3297 usurf->node_tbl->node,
3298 usurf->win_layer->layer,
3299 param1, param2, param3, param4, param5);
3302 case ICO_WINDOW_MGR_WINDOW_ACTIVE:
3303 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE"
3304 "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid,
3306 ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid,
3310 case ICO_WINDOW_MGR_LAYER_VISIBLE:
3311 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE"
3312 "(layer=%x,visivle=%d)", (int)mgr->resource, param1, param2);
3313 ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2);
3317 uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event);
3325 /*--------------------------------------------------------------------------*/
3327 * @brief win_mgr_set_scale: set surface transform scale
3329 * @param[in] usurf UIFW surface
3330 * @return chagne display
3331 * @retval =1 change display
3332 * @retval =0 no change
3334 /*--------------------------------------------------------------------------*/
3336 win_mgr_set_scale(struct uifw_win_surface *usurf)
3338 struct weston_surface *es;
3343 es = usurf->surface;
3344 if ((es != NULL) && (es->buffer_ref.buffer)) {
3345 if (usurf->client_width == 0) usurf->client_width = es->geometry.width;
3346 if (usurf->client_height == 0) usurf->client_height = es->geometry.height;
3347 scalex = (float)usurf->width / (float)usurf->client_width;
3348 scaley = (float)usurf->height / (float)usurf->client_height;
3349 uifw_debug("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)",
3350 usurf->surfaceid, scalex, usurf->width, usurf->client_width,
3351 scaley, usurf->height, usurf->client_height);
3354 if (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT) {
3355 if (scalex > scaley) {
3357 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) {
3358 usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex);
3359 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) {
3364 else if (scalex < scaley) {
3366 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) {
3367 usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley);
3368 if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) {
3373 uifw_trace("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d",
3374 usurf->surfaceid, usurf->xadd, usurf->yadd);
3376 if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) {
3377 usurf->scalex = scalex;
3378 usurf->scaley = scaley;
3379 if ((scalex != 1.0f) || (scaley != 1.0f)) {
3380 weston_matrix_init(&usurf->transform.matrix);
3381 weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f);
3382 uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform);
3383 if (usurf->set_transform == 0) {
3384 usurf->set_transform = 1;
3385 wl_list_init(&usurf->transform.link);
3386 wl_list_insert(&es->geometry.transformation_list, &usurf->transform.link);
3389 else if (usurf->set_transform != 0) {
3390 uifw_trace("win_mgr_set_scale: reset transform");
3391 usurf->set_transform = 0;
3392 wl_list_remove(&usurf->transform.link);
3394 weston_surface_geometry_dirty(es);
3395 weston_surface_update_transform(es);
3396 weston_surface_damage_below(es);
3397 weston_surface_damage(es);
3404 /*--------------------------------------------------------------------------*/
3406 * @brief ico_window_mgr_get_uclient: get UIFW client table
3408 * @param[in] appid application Id
3409 * @return UIFW client table
3410 * @retval !=NULL success(UIFW client table address)
3411 * @retval = NULL error(appid not exist)
3413 /*--------------------------------------------------------------------------*/
3414 WL_EXPORT struct uifw_client *
3415 ico_window_mgr_get_uclient(const char *appid)
3417 struct uifw_client *uclient;
3419 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3420 if (strcmp(uclient->appid, appid) == 0) {
3427 /*--------------------------------------------------------------------------*/
3429 * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table
3431 * @param[in] target surface window name and application Id(winname@appid)
3432 * @return UIFW surface table
3433 * @retval !=NULL success(UIFW surface table address)
3434 * @retval = NULL error(appid or winname not exist)
3436 /*--------------------------------------------------------------------------*/
3437 WL_EXPORT struct uifw_win_surface *
3438 ico_window_mgr_get_client_usurf(const char *target)
3440 struct uifw_client *uclient;
3441 struct uifw_win_surface *usurf;
3443 char winname[ICO_IVI_WINNAME_LENGTH];
3444 char appid[ICO_IVI_APPID_LENGTH];
3446 /* get window name and application id */
3448 for (i = 0; target[i]; i++) {
3449 if (target[i] == '@') {
3450 if (target[i+1] != '@') break;
3453 if (j < (ICO_IVI_WINNAME_LENGTH-1)) {
3454 winname[j++] = target[i];
3458 if (target[i] == '@') {
3466 for ( ; target[i]; i++) {
3467 if ((target[i] == '@') && (target[i+1] == '@')) i ++;
3468 if (j < (ICO_IVI_APPID_LENGTH-1)) {
3469 appid[j++] = target[i];
3473 #if 0 /* too many debug log */
3474 uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>",
3475 target, appid, winname);
3478 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
3479 if (strcmp(uclient->appid, appid) == 0) {
3480 wl_list_for_each (usurf, &uclient->surface_link, client_link) {
3481 if ((winname[0] == 0) ||
3482 (strcmp(winname, usurf->winname) == 0)) {
3491 /*--------------------------------------------------------------------------*/
3493 * @brief ico_window_mgr_set_hook_animation: set animation hook routine
3495 * @param[in] hook_animation hook routine
3498 /*--------------------------------------------------------------------------*/
3500 ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data))
3502 win_mgr_hook_animation = hook_animation;
3505 /*--------------------------------------------------------------------------*/
3507 * @brief module_init: initialize ico_window_mgr
3508 * this function called from ico_pluign_loader
3510 * @param[in] es weston compositor
3511 * @param[in] argc number of arguments(unused)
3512 * @param[in] argv argument list(unused)
3517 /*--------------------------------------------------------------------------*/
3519 module_init(struct weston_compositor *ec, int *argc, char *argv[])
3525 struct weston_output *output;
3526 struct weston_config_section *section;
3527 char *displayno = NULL;
3529 uifw_info("ico_window_mgr: Enter(module_init)");
3531 /* get ivi debug level */
3532 section = weston_config_get_section(ec->config, "ivi-debug", NULL, NULL);
3534 weston_config_section_get_int(section, "flag", &_ico_ivi_debug_flag, 0);
3535 weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3);
3538 /* get display number list */
3539 section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL);
3541 weston_config_section_get_string(section, "displayno", &displayno, NULL);
3545 section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL);
3547 weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1);
3548 weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 109);
3549 weston_config_section_get_int(section, "input", &_ico_ivi_input_layer, 101);
3550 weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102);
3551 weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0);
3554 /* get animation default */
3555 section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL);
3557 weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL);
3558 weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 600);
3559 weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 15);
3561 if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 600;
3562 if (_ico_ivi_animation_fps < 2) _ico_ivi_animation_fps = 15;
3564 /* create ico_window_mgr management table */
3565 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
3566 if (_ico_win_mgr == NULL) {
3567 uifw_error("ico_window_mgr: malloc failed");
3571 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
3572 _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8);
3573 if (! _ico_win_mgr->surfaceid_map) {
3574 uifw_error("ico_window_mgr: malloc failed");
3577 uifw_debug("ico_window_mgr: table=%08x", (int)_ico_win_mgr);
3578 memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8);
3580 _ico_win_mgr->compositor = ec;
3582 _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS;
3583 _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS;
3585 uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)");
3586 if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1,
3587 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
3588 uifw_error("ico_window_mgr: Error(wl_global_create)");
3592 wl_list_init(&_ico_win_mgr->client_list);
3593 wl_list_init(&_ico_win_mgr->manager_list);
3594 wl_list_init(&_ico_win_mgr->ivi_layer_list);
3595 wl_list_init(&_ico_win_mgr->map_list);
3597 _ico_win_mgr->free_maptable = NULL;
3599 /* create display list */
3600 if (displayno != NULL) {
3607 wl_list_for_each(output, &ec->output_list, link) {
3608 wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link);
3609 _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_surfacemap;
3610 wl_list_insert(output->animation_list.prev,
3611 &_ico_win_mgr->map_animation[_ico_num_nodes].link);
3613 if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break;
3615 memset(&_ico_node_table[0], 0, sizeof(_ico_node_table));
3617 wl_list_for_each(output, &ec->output_list, link) {
3620 idx = strtol(p, (char **)0, 0);
3621 uifw_trace("ico_window_mgr: config Display.%d is %d", i, idx);
3623 if ((idx < 0) || (idx >= _ico_num_nodes)) {
3630 if (_ico_node_table[idx].node) {
3631 for (idx = 0; idx < _ico_num_nodes; idx++) {
3632 if (_ico_node_table[idx].node == 0) break;
3634 if (idx >= _ico_num_nodes) {
3635 uifw_error("ico_window_mgr: number of display overflow");
3639 _ico_node_table[idx].node = idx + 0x100;
3640 _ico_node_table[idx].displayno = i;
3641 _ico_node_table[idx].disp_x = output->x;
3642 _ico_node_table[idx].disp_y = output->y;
3643 _ico_node_table[idx].disp_width = output->width;
3644 _ico_node_table[idx].disp_height = output->height;
3646 if (i >= _ico_num_nodes) break;
3649 for (i = 0; i < _ico_num_nodes; i++) {
3650 _ico_node_table[i].node &= 0x0ff;
3651 uifw_trace("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d",
3652 i, _ico_node_table[i].displayno,
3653 _ico_node_table[i].disp_x, _ico_node_table[i].disp_y,
3654 _ico_node_table[i].disp_width, _ico_node_table[i].disp_height);
3656 if (displayno) free(displayno);
3658 /* my node Id ... this version fixed 0 */
3659 nodeId = ico_ivi_get_mynode();
3661 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
3662 uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x",
3663 nodeId, _ico_win_mgr->surface_head);
3665 /* Hook to IVI-Shell */
3666 ico_ivi_shell_hook_bind(win_mgr_bind_client);
3667 ico_ivi_shell_hook_unbind(win_mgr_unbind_client);
3668 ico_ivi_shell_hook_create(win_mgr_register_surface);
3669 ico_ivi_shell_hook_destroy(win_mgr_destroy_surface);
3670 ico_ivi_shell_hook_map(win_mgr_map_surface);
3671 ico_ivi_shell_hook_configure(win_mgr_shell_configure);
3672 ico_ivi_shell_hook_select(win_mgr_select_surface);
3673 ico_ivi_shell_hook_title(win_mgr_set_title);
3674 ico_ivi_shell_hook_move(win_mgr_surface_move);
3676 uifw_info("ico_window_mgr: animation name=%s time=%d fps=%d",
3677 _ico_ivi_animation_name, _ico_ivi_animation_time, _ico_ivi_animation_fps);
3678 uifw_info("ico_window_mgr: layer default=%d startup=%d background=%d",
3679 _ico_ivi_default_layer, _ico_ivi_startup_layer, _ico_ivi_background_layer);
3680 uifw_info("ico_window_mgr: layer input=%d cursor=%d",
3681 _ico_ivi_input_layer, _ico_ivi_cursor_layer);
3682 uifw_info("ico_window_mgr: debug flag=%x log level=%d",
3683 _ico_ivi_debug_flag, _ico_ivi_debug_level);
3685 uifw_info("ico_window_mgr: Leave(module_init)");