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>
49 #include <weston/compositor.h>
50 #include "ico_ivi_common.h"
51 #include "ico_ivi_shell.h"
52 #include "ico_window_mgr.h"
53 #include "ico_ivi_shell-server-protocol.h"
54 #include "ico_window_mgr-server-protocol.h"
57 #define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */
58 #define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */
59 #define SURCAFE_ID_MASK 0x0ffff /* SurfaceId bit mask pattern */
60 #define UIFW_HASH 64 /* Hash value (2's compliment) */
62 /* Cleint management table */
64 struct wl_client *client; /* Wayland client */
65 int pid; /* ProcessId (pid) */
66 char appid[ICO_IVI_APPID_LENGTH]; /* ApplicationId(from AppCore AUL) */
67 int manager; /* Manager flag (Need send event) */
68 struct wl_resource *resource;
74 struct uifw_win_surface {
75 uint32_t id; /* UIFW SurfaceId */
76 int layer; /* LayerId */
77 struct weston_surface *surface; /* Weston surface */
78 struct shell_surface *shsurf; /* Shell(IVI-Shell) surface */
79 struct uifw_client *uclient; /* Client */
82 int width; /* Width */
83 int height; /* Height */
84 int transition; /* Transition */
85 struct wl_list link; /* */
86 struct uifw_win_surface *next_idhash; /* UIFW SurfaceId hash list */
87 struct uifw_win_surface *next_wshash; /* Weston SurfaceId hash list */
92 struct wl_resource *resource; /* Manager resource */
93 int eventcb; /* Event send flag */
94 struct wl_list link; /* link to next manager */
97 /* Multi Windiw Manager */
99 struct weston_compositor *compositor; /* Weston compositor */
100 int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */
102 struct wl_list client_list; /* Clients */
103 struct wl_list manager_list; /* Manager(ex.HomeScreen) list */
104 int num_manager; /* Number of managers */
105 struct wl_list surface_list; /* Surface list */
106 struct uifw_win_surface *active_surface;/* Active Surface */
108 struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */
109 struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */
111 uint32_t surfaceid_count; /* Number of surface id */
112 uint32_t surfaceid_max; /* Maximum number of surface id */
113 uint16_t *surfaceid_map; /* SurfaceId assign bit map */
116 /* Internal macros */
118 #define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1))
120 #define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1))
122 /* function prototype */
123 /* weston compositor interface */
124 int module_init(struct weston_compositor *ec);
125 /* get surface table from surfece id */
126 static struct uifw_win_surface* find_uifw_win_surface_by_id(uint32_t surfaceid);
127 /* get surface table from weston surface*/
128 static struct uifw_win_surface* find_uifw_win_surface_by_ws(
129 struct weston_surface *wsurf);
130 /* get client table from weston client */
131 static struct uifw_client* find_client_from_client(struct wl_client* client);
132 /* assign new surface id */
133 static uint32_t generate_id(void);
134 /* bind shell client */
135 static void bind_shell_client(struct wl_client *client);
136 /* unind shell client */
137 static void unbind_shell_client(struct wl_client *client);
138 /* create new surface */
139 static void client_register_surface(
140 struct wl_client *client, struct wl_resource *resource,
141 struct weston_surface *surface, struct shell_surface *shsurf);
142 /* map new surface */
143 static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width,
144 int32_t *height, int32_t *sx, int32_t *sy);
145 /* set applicationId for RemoteUI */
146 static void uifw_set_user(struct wl_client *client, struct wl_resource *resource,
147 int pid, const char *appid);
148 /* set/reset event flag */
149 static void uifw_set_eventcb(struct wl_client *client, struct wl_resource *resource,
151 /* set window layer */
152 static void uifw_set_window_layer(struct wl_client *client,
153 struct wl_resource *resource,
154 uint32_t surfaceid, int layer);
155 /* set surface size and position */
156 static void uifw_set_positionsize(struct wl_client *client,
157 struct wl_resource *resource, uint32_t surfaceid,
158 int32_t x, int32_t y, int32_t width, int32_t height);
159 /* show/hide and raise/lower surface */
160 static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
161 uint32_t surfaceid, int32_t visible, int32_t raise);
162 /* set surface transition */
163 static void uifw_set_transition(struct wl_client *client, struct wl_resource *resource,
164 uint32_t surfaceid, int32_t transition);
165 /* set active surface (form HomeScreen) */
166 static void uifw_set_active(struct wl_client *client, struct wl_resource *resource,
168 /* layer visibility control */
169 static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
170 int32_t layer, int32_t visible);
171 /* send surface change event to manager */
172 static void win_mgr_surface_change(struct weston_surface *surface,
173 const int to, const int manager);
174 /* surface change from manager */
175 static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x,
176 const int y, const int width, const int height);
177 /* surface destory */
178 static void win_mgr_surface_destroy(struct weston_surface *surface);
180 static void bind_ico_win_mgr(struct wl_client *client,
181 void *data, uint32_t version, uint32_t id);
183 static void unbind_ico_win_mgr(struct wl_resource *resource);
184 /* convert surfaceId to nodeId */
185 static int ico_winmgr_usurf_2_node(const int surfaceid);
186 /* send event to manager */
187 static int ico_win_mgr_send_to_mgr(const int event, const int surfaceid,
188 const char *appid, const int param1,
189 const int param2, const int param3, const int param4,
190 const int param5, const int param6);
191 /* hook for set user */
192 static void (*win_mgr_hook_set_user)
193 (struct wl_client *client, const char *appid) = NULL;
194 /* hook for surface create */
195 static void (*win_mgr_hook_create)
196 (struct wl_client *client, struct weston_surface *surface,
197 int surfaceId, const char *appid) = NULL;
198 /* hook for surface destory */
199 static void (*win_mgr_hook_destroy)(struct weston_surface *surface) = NULL;
202 /* Multi Window Manager interface */
203 static const struct ico_window_mgr_interface ico_window_mgr_implementation = {
206 uifw_set_window_layer,
207 uifw_set_positionsize,
211 uifw_set_layer_visible
214 /* static management table */
215 static struct ico_win_mgr *_ico_win_mgr = NULL;
218 /*--------------------------------------------------------------------------*/
220 * @brief find_uifw_win_surface_by_id: find UIFW surface by surface id
222 * @param[in] surfaceid UIFW surface id
223 * @return UIFW surface table address
224 * @retval !=NULL success(surface table address)
225 * @retval NULL error(surface id dose not exist)
227 /*--------------------------------------------------------------------------*/
228 static struct uifw_win_surface*
229 find_uifw_win_surface_by_id(uint32_t surfaceid)
231 struct uifw_win_surface* usurf;
233 usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)];
236 if (usurf->id == surfaceid) {
239 usurf = usurf->next_idhash;
241 uifw_trace("find_uifw_win_surface_by_id: NULL");
246 /*--------------------------------------------------------------------------*/
248 * @brief find_uifw_win_surface_by_ws: find UIFW srurace by weston surface
250 * @param[in] wsurf Weston surface
251 * @return UIFW surface table address
252 * @retval !=NULL success(surface table address)
253 * @retval NULL error(surface dose not exist)
255 /*--------------------------------------------------------------------------*/
256 static struct uifw_win_surface*
257 find_uifw_win_surface_by_ws(struct weston_surface *wsurf)
259 struct uifw_win_surface* usurf;
261 usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)];
264 if (usurf->surface == wsurf) {
267 usurf = usurf->next_wshash;
269 uifw_trace("find_uifw_win_surface_by_ws: NULL");
273 /*--------------------------------------------------------------------------*/
275 * @brief find_client_from_client: find UIFW client by wayland client
277 * @param[in] client Wayland client
278 * @return UIFW client table address
279 * @retval !=NULL success(client table address)
280 * @retval NULL error(client dose not exist)
282 /*--------------------------------------------------------------------------*/
283 static struct uifw_client*
284 find_client_from_client(struct wl_client* client)
286 struct uifw_client *uclient;
288 wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) {
289 if (uclient->client == client) {
293 uifw_trace("find_client_from_client: NULL");
297 /*--------------------------------------------------------------------------*/
299 * @brief ico_window_mgr_appid: find application id by wayland client
301 * @param[in] client Wayland client
302 * @return application id
303 * @retval !=NULL success(application id)
304 * @retval NULL error(client dose not exist)
306 /*--------------------------------------------------------------------------*/
308 ico_window_mgr_appid(struct wl_client* client)
310 struct uifw_client *uclient;
312 uclient = find_client_from_client(client);
317 return uclient->appid;
320 /*--------------------------------------------------------------------------*/
322 * @brief generate_id: generate uniq id for UIFW surface id
325 * @return uniq id for UIFW surface id
327 /*--------------------------------------------------------------------------*/
338 _ico_win_mgr->surfaceid_count ++;
340 /* serach free id from bitmap */
341 for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) {
342 if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) {
343 _ico_win_mgr->surfaceid_count = 0;
345 if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) {
346 /* find free id from bitmap */
347 map = 1 << (_ico_win_mgr->surfaceid_count % 16);
348 for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) {
349 if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map)
351 _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map;
352 _ico_win_mgr->surfaceid_count
353 = (_ico_win_mgr->surfaceid_count/16)*16 + i;
355 surfaceId = (_ico_win_mgr->surfaceid_count + 1)
356 | _ico_win_mgr->surface_head;
357 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
363 _ico_win_mgr->surfaceid_count += 16;
366 /* no free id in bitmap, extend bitmap */
367 if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) {
368 /* too many surfaces, system error */
369 uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort",
370 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
371 fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n",
372 _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK);
376 new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8);
377 memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8);
378 memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8);
379 _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max;
380 new_map[_ico_win_mgr->surfaceid_count/16] |= 1;
381 _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS;
382 free(_ico_win_mgr->surfaceid_map);
383 _ico_win_mgr->surfaceid_map = new_map;
385 uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)",
386 _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max);
387 surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head;
389 uifw_trace("generate_id: SurfaceId=%08x", surfaceId);
393 /*--------------------------------------------------------------------------*/
395 * @brief bind_shell_client: ico_ivi_shell from client
397 * @param[in] client Wayland client
400 /*--------------------------------------------------------------------------*/
402 bind_shell_client(struct wl_client *client)
404 struct uifw_client *uclient;
414 uifw_trace("bind_shell_client: Enter(client=%08x)", (int)client);
417 uclient = find_client_from_client(client);
419 /* client not exist, create client management table */
420 uifw_trace("bind_shell_client: Create Client");
421 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
423 uifw_error("bind_shell_client: Error, No Memory");
426 memset(uclient, 0, sizeof(struct uifw_client));
427 uclient->client = client;
428 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
430 wl_client_get_credentials(client, &pid, &uid, &gid);
431 uifw_trace("bind_shell_client: client=%08x pid=%d uid=%d gid=%d",
432 (int)client, (int)pid, (int)uid, (int)gid);
434 uclient->pid = (int)pid;
435 /* get applicationId from AppCore(AUL) */
436 if (aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH)
438 uifw_trace("bind_shell_client: client=%08x pid=%d appid=<%s>",
439 (int)client, uclient->pid, uclient->appid);
442 /* client dose not exist in AppCore, search Linux process table */
443 uifw_trace("bind_shell_client: pid=%d dose not exist in AppCore(AUL)",
446 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
447 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid);
448 fd = open(procpath, O_RDONLY);
450 size = read(fd, procpath, sizeof(procpath));
451 for (; size > 0; size--) {
452 if (procpath[size-1]) break;
455 /* get program base name */
457 for (j = 0; j < size; j++) {
458 if (procpath[j] == 0) break;
459 if (procpath[j] == '/') i = j + 1;
462 for (; i < size; i++) {
463 uclient->appid[j] = procpath[i];
464 if ((uclient->appid[j] == 0) ||
465 (j >= (ICO_IVI_APPID_LENGTH-1))) break;
468 /* search application number in apprication start option */
469 if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) {
470 for (; i < size; i++) {
471 if ((procpath[i] == 0) &&
472 (procpath[i+1] == '@')) {
473 strncpy(&uclient->appid[j], &procpath[i+1],
474 ICO_IVI_APPID_LENGTH - j - 2);
481 if (uclient->appid[0]) {
482 uifw_trace("bind_shell_client: client=%08x pid=%d appid=<%s> from "
483 "Process table", (int)client, uclient->pid, uclient->appid);
486 uifw_trace("bind_shell_client: pid=%d dose not exist in Process table",
488 sprintf(uclient->appid, "?%d?", uclient->pid);
493 uifw_trace("bind_shell_client: client=%08x pid dose not exist", (int)client);
495 uifw_trace("bind_shell_client: Leave");
498 /*--------------------------------------------------------------------------*/
500 * @brief unbind_shell_client: unbind ico_ivi_shell from client
502 * @param[in] client Wayland client
505 /*--------------------------------------------------------------------------*/
507 unbind_shell_client(struct wl_client *client)
509 struct uifw_client *uclient;
511 uifw_trace("unbind_shell_client: Enter(client=%08x)", (int)client);
513 uclient = find_client_from_client(client);
515 /* Client exist, Destory client management table */
516 wl_list_remove(&uclient->link);
519 uifw_trace("unbind_shell_client: Leave");
522 /*--------------------------------------------------------------------------*/
524 * @brief client_register_surface: create UIFW surface
526 * @param[in] client Wayland client
527 * @param[in] resource client resource
528 * @param[in] surface Weston surface
529 * @param[in] shsurf shell surface
532 /*--------------------------------------------------------------------------*/
534 client_register_surface(struct wl_client *client, struct wl_resource *resource,
535 struct weston_surface *surface, struct shell_surface *shsurf)
537 struct uifw_win_surface *us;
538 struct uifw_win_surface *phash;
539 struct uifw_win_surface *bhash;
542 uifw_trace("client_register_surface: Enter(surf=%08x,client=%08x,res=%08x)",
543 (int)surface, (int)client, (int)resource);
545 /* check new surface */
546 if (find_uifw_win_surface_by_ws(surface)) {
547 /* surface exist, NOP */
548 uifw_trace("client_register_surface: Leave(Already Exist)");
552 /* create UIFW surface management table */
553 us = malloc(sizeof(struct uifw_win_surface));
555 uifw_error("client_register_surface: No Memory");
559 memset(us, 0, sizeof(struct uifw_win_surface));
561 us->id = generate_id();
562 us->surface = surface;
564 if (_ico_win_mgr->num_manager <= 0) {
565 uifw_trace("client_register_surface: No Manager, Force visible");
566 ivi_shell_set_visible(shsurf, 1); /* NOT exist HomeScreen */
569 uifw_trace("client_register_surface: Manager exist, Not visible");
570 ivi_shell_set_visible(shsurf, -1); /* Exist HomeScreen */
574 us->uclient = find_client_from_client(client);
576 /* client not exist, create client management table */
577 uifw_trace("client_register_surface: Create Client");
578 bind_shell_client(client);
579 us->uclient = find_client_from_client(client);
581 uifw_error("client_register_surface: No Memory");
585 wl_list_insert(&_ico_win_mgr->surface_list, &us->link);
587 /* make surface id hash table */
588 hash = MAKE_IDHASH(us->id);
589 phash = _ico_win_mgr->idhash[hash];
593 phash = phash->next_idhash;
596 bhash->next_idhash = us;
599 _ico_win_mgr->idhash[hash] = us;
602 /* make weston surface hash table */
603 hash = MAKE_WSHASH(us->surface);
604 phash = _ico_win_mgr->wshash[hash];
608 phash = phash->next_wshash;
611 bhash->next_wshash = us;
614 _ico_win_mgr->wshash[hash] = us;
616 /* set default layer id */
617 ivi_shell_set_layer(shsurf, 0);
619 /* send event to manager */
620 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED,
621 us->id, us->uclient->appid, us->uclient->pid, 0,0,0,0,0);
623 if (win_mgr_hook_create) {
624 /* call surface create hook for ico_window_mgr */
625 (void) (*win_mgr_hook_create)(client, surface, us->id, us->uclient->appid);
627 uifw_trace("client_register_surface: Leave(surfaceId=%08x)", us->id);
630 /*--------------------------------------------------------------------------*/
632 * @brief win_mgr_map_surface: map surface
634 * @param[in] surface Weston surface
635 * @param[in] width surface width
636 * @param[in] height surface height
637 * @param[in] sx X coordinate on screen
638 * @param[in] sy Y coordinate on screen
641 /*--------------------------------------------------------------------------*/
643 win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height,
644 int32_t *sx, int32_t *sy)
646 struct uifw_win_surface *usurf;
648 uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)",
649 (int)surface, *sx, *sy, *width, *height);
651 usurf = find_uifw_win_surface_by_ws(surface);
654 uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d",
655 usurf->id, usurf->width, usurf->height,
656 ivi_shell_is_visible(usurf->shsurf));
658 if ((usurf->width > 0) && (usurf->height > 0)) {
659 uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize"
660 "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d",
661 usurf->id, usurf->x, usurf->y, usurf->width, usurf->height,
662 ivi_shell_is_visible(usurf->shsurf));
663 *width = usurf->width;
664 *height = usurf->height;
665 surface->geometry.x = usurf->x;
666 surface->geometry.y = usurf->y;
669 uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, "
670 "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)",
671 usurf->id, *sx, *sy, *width, *height);
672 usurf->width = *width;
673 usurf->height = *height;
676 if (usurf->x < 0) usurf->x = 0;
677 if (usurf->y < 0) usurf->y = 0;
679 if (_ico_win_mgr->num_manager > 0) {
680 /* HomeScreen exist, coodinate set by HomeScreen */
681 surface->geometry.x = 0;
682 surface->geometry.y = 0;
684 /* change surface size, because HomeScreen change surface size */
687 uifw_trace("win_mgr_map_surface: Change size and position");
690 uifw_trace("win_mgr_map_surface: Np HomeScreen, chaneg to Visible");
691 ivi_shell_set_visible(usurf->shsurf, 1);
694 ivi_shell_set_positionsize(usurf->shsurf,
695 usurf->x, usurf->y, usurf->width, usurf->height);
696 uifw_trace("win_mgr_map_surface: Leave");
699 uifw_trace("win_mgr_map_surface: Leave(No Window Manager Surface)");
703 /*--------------------------------------------------------------------------*/
705 * @briefdwi uifw_set_user: set user id (for RemoteUI)
707 * @param[in] client Weyland client
708 * @param[in] resource resource of request
709 * @param[in] pid client process id
710 * @param[in] appid application id
713 /*--------------------------------------------------------------------------*/
715 uifw_set_user(struct wl_client *client, struct wl_resource *resource,
716 int pid, const char *appid)
718 struct uifw_client *uclient;
720 uifw_trace("uifw_set_user: Enter(client=%08x pid=%d appid=%s)",
721 (int)client, pid, appid);
723 uclient = find_client_from_client(client);
726 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
727 strncpy(uclient->appid, appid, ICO_IVI_APPID_LENGTH-1);
728 uclient->resource = resource;
729 uifw_trace("uifw_set_user: Leave(Client Exist, change PID/AppId)");
733 uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client));
735 uifw_trace("uifw_set_user: Leave(Error, No Memory)");
739 memset(uclient, 0, sizeof(struct uifw_client));
740 uclient->client = client;
742 memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH);
743 strncpy(uclient->appid, appid, ICO_IVI_APPID_LENGTH-1);
744 uclient->resource = resource;
746 wl_list_insert(&_ico_win_mgr->client_list, &uclient->link);
748 if (win_mgr_hook_set_user) {
749 (void) (*win_mgr_hook_set_user) (client, uclient->appid);
751 uifw_trace("uifw_set_user: Leave");
754 /*--------------------------------------------------------------------------*/
756 * @brief uifw_set_eventcb: set event callback flag for HomeScreen
758 * @param[in] client Weyland client
759 * @param[in] resource resource of request
760 * @param[in] eventcb event callback flag(1=callback, 0=no callback)
763 /*--------------------------------------------------------------------------*/
765 uifw_set_eventcb(struct wl_client *client, struct wl_resource *resource, int eventcb)
767 struct uifw_manager* mgr;
768 struct uifw_win_surface *usurf;
769 struct uifw_client *uclient;
771 uifw_trace("uifw_set_eventcb: Enter client=%08x eventcb=%d",
772 (int)client, eventcb);
774 uclient = find_client_from_client(client);
776 uclient->manager = eventcb;
779 /* client set to manager */
780 _ico_win_mgr->num_manager = 0;
781 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
782 if (mgr->resource == resource) {
783 if (mgr->eventcb != eventcb) {
784 uifw_trace("uifw_set_eventcb: Event Callback %d=>%d",
785 mgr->eventcb, eventcb);
786 mgr->eventcb = eventcb;
789 wl_list_for_each (usurf, &_ico_win_mgr->surface_list, link) {
790 /* send window create event to manager */
791 uifw_trace("uifw_set_eventcb: Send manager(%08x) WINDOW_CREATED"
792 "(surf=%08x,pid=%d,appid=%s)", (int)resource, usurf->id,
793 usurf->uclient->pid, usurf->uclient->appid);
794 ico_window_mgr_send_window_created(resource,
795 usurf->id, usurf->uclient->pid, usurf->uclient->appid);
801 _ico_win_mgr->num_manager++;
804 uifw_trace("uifw_set_eventcb: Leave(managers=%d)", _ico_win_mgr->num_manager);
807 /*--------------------------------------------------------------------------*/
809 * @brief uifw_set_window_layer: set layer id to surface
811 * @param[in] client Weyland client
812 * @param[in] resource resource of request
813 * @param[in] surfaceid UIFW surface id
814 * @param[in] layer layer id
817 /*--------------------------------------------------------------------------*/
819 uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource,
820 uint32_t surfaceid, int32_t layer)
822 uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d",
823 (int)resource, surfaceid, layer);
825 struct uifw_win_surface *usurf = find_uifw_win_surface_by_id(surfaceid);
828 uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x)", surfaceid);
831 else if (usurf->layer != layer) {
832 usurf->layer = layer;
833 uifw_trace("uifw_set_window_layer: Set Layer(%d) to Shell Surface", layer);
834 ivi_shell_set_layer(usurf->shsurf, layer);
836 win_mgr_surface_change(usurf->surface, 1, 1);
838 uifw_trace("uifw_set_window_layer: Leave");
841 /*--------------------------------------------------------------------------*/
843 * @brief uifw_set_weston_surface: set weston surface from UIFW surface
845 * @param[in] usurf UIFW surface
848 /*--------------------------------------------------------------------------*/
850 uifw_set_weston_surface(struct uifw_win_surface *usurf)
852 struct weston_surface *es = usurf->surface;
853 int width = usurf->width;
854 int height = usurf->height;
858 if ((es != NULL) && (es->buffer != NULL)) {
859 if (usurf->width > es->buffer->width) {
860 width = es->buffer->width;
861 x += (usurf->width - es->buffer->width)/2;
863 if (usurf->height > es->buffer->height) {
864 height = es->buffer->height;
865 y += (usurf->height - es->buffer->height)/2;
868 ivi_shell_set_positionsize(usurf->shsurf,
869 usurf->x, usurf->y, usurf->width, usurf->height);
870 uifw_trace("uifw_set_weston_surface: w/h=%d/%d->%d/%d x/y=%d/%d->%d/%d",
871 usurf->width, usurf->height, width, height, usurf->x, usurf->y, x, y);
872 ivi_shell_surface_configure(usurf->shsurf, x, y, width, height);
875 /*--------------------------------------------------------------------------*/
877 * @brief uifw_set_positionsize: set surface position and size
879 * @param[in] client Weyland client
880 * @param[in] resource resource of request
881 * @param[in] surfaceid UIFW surface id
882 * @param[in] x X coordinate on screen(if bigger than 16383, no change)
883 * @param[in] y Y coordinate on screen(if bigger than 16383, no change)
884 * @param[in] width surface width(if bigger than 16383, no change)
885 * @param[in] height surface height(if bigger than 16383, no change)
888 /*--------------------------------------------------------------------------*/
890 uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource,
892 int32_t x, int32_t y, int32_t width, int32_t height)
894 struct uifw_client *uclient;
896 uifw_trace("uifw_set_positionsize: Enter res=%08x surf=%08x x/y/w/h=%d/%d/%d/%d",
897 (int)resource, surfaceid, x, y, width, height);
899 struct uifw_win_surface* usurf = find_uifw_win_surface_by_id(surfaceid);
901 if (usurf && (usurf->surface)) {
902 /* weston surface exist */
903 struct weston_surface *es = usurf->surface;
905 /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */
906 if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x;
907 if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y;
908 if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width;
909 if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height;
911 uclient = find_client_from_client(client);
913 if (! uclient->manager) uclient = NULL;
916 if ((usurf->width > 0) && (usurf->height > 0)) {
917 win_mgr_surface_change_mgr(es, x, y, width, height);
918 uifw_trace("uifw_set_positionsize: Leave(Request from App)");
922 uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d",
923 ivi_shell_is_visible(usurf->shsurf));
924 /* Initiale position is (0,0) */
929 uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d",
930 (int)es->geometry.x, (int)es->geometry.y,
931 (int)es->geometry.width, (int)es->geometry.height);
935 usurf->width = width;
936 usurf->height = height;
937 ivi_shell_set_positionsize(usurf->shsurf, x, y, width, height);
938 if (_ico_win_mgr->num_manager <= 0) {
939 /* no manager(HomeScreen), set geometory */
943 if ((es->output) && (es->buffer) &&
944 (es->geometry.width > 0) && (es->geometry.height > 0)) {
945 uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)",
946 ivi_shell_is_visible(usurf->shsurf));
947 uifw_set_weston_surface(usurf);
948 weston_surface_damage_below(es);
949 weston_surface_damage(es);
950 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
952 win_mgr_surface_change(es, 0, 1);
954 uifw_trace("uifw_set_positionsize: Leave(OK,output=%x)", (int)es->output);
957 uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid);
961 /*--------------------------------------------------------------------------*/
963 * @brief uifw_set_visible: surface visible/raise control
965 * @param[in] client Weyland client
966 * @param[in] resource resource of request
967 * @param[in] surfaceid UIFW surface id
968 * @param[in] visible visible(1=show/0=hide/other=no change)
969 * @param[in] raise raise(1=raise/0=lower/other=no change)
972 /*--------------------------------------------------------------------------*/
974 uifw_set_visible(struct wl_client *client, struct wl_resource *resource,
975 uint32_t surfaceid, int32_t visible, int32_t raise)
977 struct uifw_win_surface* usurf;
978 struct uifw_client *uclient;
980 uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d)", surfaceid, visible, raise);
982 uclient = find_client_from_client(client);
984 if (! uclient->manager) {
985 uifw_trace("uifw_set_visible: Request from App(%s), not Manager",
990 uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid);
994 uifw_trace("uifw_set_visible: Request from Unknown App, not Manager");
997 usurf = find_uifw_win_surface_by_id(surfaceid);
999 if ((! usurf) || (! usurf->surface)) {
1000 uifw_trace("uifw_set_visible: Leave(Surface Not Exist)");
1005 if ((usurf->width <= 0) || (usurf->height <= 0)) {
1006 /* not declare surface geometry, initialize */
1007 usurf->width = usurf->surface->geometry.width;
1008 usurf->height = usurf->surface->geometry.height;
1009 uifw_trace("uifw_set_visible: Set w/h=%d/%d", usurf->width, usurf->height);
1011 if (! ivi_shell_is_visible(usurf->shsurf)) {
1013 /* manager exist, change to visible */
1014 ivi_shell_set_visible(usurf->shsurf, 1);
1016 uifw_trace("uifw_set_visible: Change to Visible");
1018 ivi_shell_set_toplevel(usurf->shsurf);
1020 /* Weston surface configure */
1021 uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d/%d/%d/%d",
1022 (int)usurf->surface, usurf->x, usurf->y,
1023 usurf->width, usurf->height);
1024 uifw_set_weston_surface(usurf);
1025 ivi_shell_set_surface_type(usurf->shsurf);
1027 else if ((raise != 0) && (raise != 1)) {
1028 uifw_trace("uifw_set_visible: Leave(No Change)");
1032 else if (visible == 0) {
1034 if (ivi_shell_is_visible(usurf->shsurf)) {
1035 ivi_shell_set_visible(usurf->shsurf, 0);
1036 uifw_trace("uifw_set_visible: Change to UnVisible");
1038 /* Weston surface configure */
1039 uifw_set_weston_surface(usurf);
1041 else if ((raise != 0) && (raise != 1)) {
1042 uifw_trace("uifw_set_visible: Leave(No Change)");
1046 else if ((raise != 0) && (raise != 1)) {
1047 uifw_trace("uifw_set_visible: Leave(No Change)");
1052 if ((raise == 1) || (raise == 0)) {
1053 ivi_shell_set_raise(usurf->shsurf, raise);
1056 if ((usurf->surface) && (usurf->surface->buffer) && (usurf->surface->output)) {
1057 weston_surface_damage_below(usurf->surface);
1058 weston_surface_damage(usurf->surface);
1059 weston_compositor_schedule_repaint(_ico_win_mgr->compositor);
1061 /* send event(VISIBLE) to manager */
1062 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE,
1063 surfaceid, NULL, visible, raise, uclient ? 0 : 1, 0,0,0);
1065 uifw_trace("uifw_set_visible: Leave(OK)");
1068 /*--------------------------------------------------------------------------*/
1070 * @brief uifw_set_transition: set transition of surface visible/unvisible
1072 * @param[in] client Weyland client
1073 * @param[in] resource resource of request
1074 * @param[in] surfaceid UIFW surface id
1075 * @param[in] transition transiton id
1078 /*--------------------------------------------------------------------------*/
1080 uifw_set_transition(struct wl_client *client, struct wl_resource *resource,
1081 uint32_t surfaceid, int32_t transition)
1083 struct uifw_win_surface* usurf = find_uifw_win_surface_by_id(surfaceid);
1085 uifw_trace("uifw_set_transition: Enter(surf=%08x, transition=%d)",
1086 surfaceid, transition);
1089 usurf->transition = transition;
1090 uifw_trace("uifw_set_transition: Leave(OK)");
1093 uifw_trace("uifw_set_transition: Leave(Surface(%08x) Not exist)", surfaceid);
1097 /*--------------------------------------------------------------------------*/
1099 * @brief uifw_set_active: set active surface
1101 * @param[in] client Weyland client
1102 * @param[in] resource resource of request
1103 * @param[in] surfaceid UIFW surface id
1106 /*--------------------------------------------------------------------------*/
1108 uifw_set_active(struct wl_client *client, struct wl_resource *resource, uint32_t surfaceid)
1110 struct uifw_win_surface* usurf = find_uifw_win_surface_by_id(surfaceid);
1112 uifw_trace("uifw_set_active: Enter(surf=%08x)", surfaceid);
1115 if (usurf != _ico_win_mgr->active_surface) {
1116 if (_ico_win_mgr->active_surface) {
1117 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
1118 surfaceid, NULL, ICO_WINDOW_MGR_ACTIVE_INACTIVE,
1121 _ico_win_mgr->active_surface = usurf;
1122 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
1123 surfaceid, NULL, ICO_WINDOW_MGR_ACTIVE_ACTIVE,
1126 uifw_trace("uifw_set_active: Leave(Change Active)");
1129 uifw_trace("uifw_set_active: Leave(Surface(%08x) Not exist)", surfaceid);
1133 /*--------------------------------------------------------------------------*/
1135 * @brief uifw_set_layer_visible: layer visible control
1137 * @param[in] client Weyland client
1138 * @param[in] resource resource of request
1139 * @param[in] layer layer id
1140 * @param[in] visible visible(1=show/0=hide)
1143 /*--------------------------------------------------------------------------*/
1145 uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource,
1146 int32_t layer, int32_t visible)
1148 uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible);
1150 ivi_shell_set_layer_visible(layer, visible);
1152 uifw_trace("uifw_set_layer_visible: Leave");
1155 /*--------------------------------------------------------------------------*/
1157 * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen)
1159 * @param[in] surface Weston surface
1160 * @param[in] x X coordinate on screen
1161 * @param[in] y Y coordinate on screen
1162 * @param[in] width surface width
1163 * @param[in] height surface height
1164 * @return number of managers
1165 * @retval > 0 number of managers
1166 * @retval 0 manager not exist
1168 /*--------------------------------------------------------------------------*/
1170 win_mgr_surface_change_mgr(struct weston_surface *surface,
1171 const int x, const int y, const int width, const int height)
1174 struct uifw_win_surface *usurf;
1176 uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)",
1177 (int)surface, x, y, width, height);
1179 usurf = find_uifw_win_surface_by_ws(surface);
1181 uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)");
1185 num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
1186 usurf->id, usurf->uclient->appid, usurf->layer,
1187 x, y, width, height, 1);
1189 uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr);
1193 /*--------------------------------------------------------------------------*/
1195 * @brief win_mgr_surface_change: surface change
1197 * @param[in] surface Weston surface
1198 * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager)
1199 * @param[in] manager request from manager(0=Client,1=Manager)
1202 /*--------------------------------------------------------------------------*/
1204 win_mgr_surface_change(struct weston_surface *surface, const int to, const int manager)
1206 struct uifw_win_surface *usurf;
1208 uifw_trace("win_mgr_surface_change: Enter(%08x,%d,%d)", (int)surface, to, manager);
1211 usurf = find_uifw_win_surface_by_ws(surface);
1213 uifw_trace("win_mgr_surface_change: Leave(Not Exist)");
1217 /* send wayland event to client */
1218 if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0)) {
1219 uifw_trace("win_mgr_surface_change: Send SHELL_SURFACE_CONFIGURE(%08x,w/h=%d/%d)",
1220 usurf->id, usurf->width, usurf->height);
1221 ivi_shell_send_configure(usurf->shsurf, usurf->id,
1222 (WL_SHELL_SURFACE_RESIZE_RIGHT |
1223 WL_SHELL_SURFACE_RESIZE_BOTTOM),
1224 usurf->width, usurf->height);
1227 /* send manager event to HomeScreen */
1229 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE,
1230 usurf->id, usurf->uclient->appid, usurf->layer,
1231 usurf->x, usurf->y, usurf->width, usurf->height,
1232 (manager != 0) ? 0 : 1);
1234 uifw_trace("win_mgr_surface_change: Leave(OK)");
1237 /*--------------------------------------------------------------------------*/
1239 * @brief win_mgr_surface_select: select surface by Bottun/Touch
1241 * @param[in] surface Weston surface
1244 /*--------------------------------------------------------------------------*/
1246 win_mgr_surface_select(struct weston_surface *surface)
1248 struct uifw_win_surface *usurf;
1250 uifw_trace("win_mgr_surface_select: Enter(%08x)", (int)surface);
1253 usurf = find_uifw_win_surface_by_ws(surface);
1255 uifw_trace("win_mgr_surface_select: Leave(Not Exist)");
1259 /* send active event to manager */
1260 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE,
1261 usurf->id, NULL, ICO_WINDOW_MGR_ACTIVE_SELECT, 0,0,0,0,0);
1263 uifw_trace("win_mgr_surface_select: Leave(OK)");
1266 /*--------------------------------------------------------------------------*/
1268 * @brief win_mgr_surface_destroy: surface destroy
1270 * @param[in] surface Weston surface
1273 /*--------------------------------------------------------------------------*/
1275 win_mgr_surface_destroy(struct weston_surface *surface)
1277 struct uifw_win_surface *usurf;
1278 struct uifw_win_surface *phash;
1279 struct uifw_win_surface *bhash;
1282 uifw_trace("win_mgr_surface_destroy: Enter(%08x)", (int)surface);
1284 usurf = find_uifw_win_surface_by_ws(surface);
1286 uifw_trace("win_mgr_surface_destroy: Leave(Not Exist)");
1290 hash = MAKE_IDHASH(usurf->id);
1291 phash = _ico_win_mgr->idhash[hash];
1293 while ((phash) && (phash != usurf)) {
1295 phash = phash->next_idhash;
1298 bhash->next_idhash = usurf->next_idhash;
1301 _ico_win_mgr->idhash[hash] = usurf->next_idhash;
1304 hash = MAKE_WSHASH(usurf->surface);
1305 phash = _ico_win_mgr->wshash[hash];
1307 while ((phash) && (phash != usurf)) {
1309 phash = phash->next_wshash;
1312 bhash->next_wshash = usurf->next_wshash;
1315 _ico_win_mgr->wshash[hash] = usurf->next_wshash;
1318 wl_list_remove(&usurf->link);
1319 wl_list_init(&usurf->link);
1321 ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED,
1322 usurf->id, NULL, 0,0,0,0,0,0);
1324 hash = usurf->id & SURCAFE_ID_MASK;
1325 _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16));
1329 if (win_mgr_hook_destroy) {
1330 (void) (*win_mgr_hook_destroy) (surface);
1332 uifw_trace("win_mgr_surface_destroy: Leave(OK)");
1335 /*--------------------------------------------------------------------------*/
1337 * @brief bind_ico_win_mgr: bind Multi Window Manager from client
1339 * @param[in] client client
1340 * @param[in] data user data(unused)
1341 * @param[in] version protocol version(unused)
1342 * @param[in] id client object id
1345 /*--------------------------------------------------------------------------*/
1347 bind_ico_win_mgr(struct wl_client *client,
1348 void *data, uint32_t version, uint32_t id)
1350 struct wl_resource *add_resource;
1351 struct uifw_manager *nm;
1353 uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id);
1355 add_resource = wl_client_add_object(client, &ico_window_mgr_interface,
1356 &ico_window_mgr_implementation, id, _ico_win_mgr);
1357 add_resource->destroy = unbind_ico_win_mgr;
1360 nm = (struct uifw_manager *)malloc(sizeof(struct uifw_manager));
1361 memset(nm, 0, sizeof(struct uifw_manager));
1362 nm->resource = add_resource;
1363 wl_list_insert(&_ico_win_mgr->manager_list, &nm->link);
1365 uifw_trace("bind_ico_win_mgr: Leave");
1368 /*--------------------------------------------------------------------------*/
1370 * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client
1372 * @param[in] resource client resource
1375 /*--------------------------------------------------------------------------*/
1377 unbind_ico_win_mgr(struct wl_resource *resource)
1379 struct uifw_manager *mgr, *itmp;
1381 uifw_trace("unbind_ico_win_mgr: Enter");
1383 /* Remove manager from manager list */
1384 _ico_win_mgr->num_manager = 0;
1385 wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) {
1386 if (mgr->resource == resource) {
1387 wl_list_remove(&mgr->link);
1392 _ico_win_mgr->num_manager++;
1398 uifw_trace("unbind_ico_win_mgr: Leave");
1401 /*--------------------------------------------------------------------------*/
1403 * @brief ico_winmgr_usurf_2_node: get surface nodeId
1405 * @param[in] surfaceid UIFW surface id
1407 * @retval >= 0 success(surface node id)
1408 * @retval < 0 error(surface id dose not exist)
1410 /*--------------------------------------------------------------------------*/
1412 ico_winmgr_usurf_2_node(const int surfaceid)
1414 /* currently support single ECU system */
1415 return(ICO_IVI_SURFACEID_2_NODEID(surfaceid));
1418 /*--------------------------------------------------------------------------*/
1420 * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen)
1422 * @param[in] event event code(if -1, not send event)
1423 * @param[in] surfaceid UIFW surface id
1424 * @param[in] appid applicationId
1425 * @param[in] param1 parameter 1
1427 * @param[in] param6 parameter 6
1428 * @return number of managers
1429 * @retval > 0 number of managers
1430 * @retval 0 manager not exist
1432 /*--------------------------------------------------------------------------*/
1434 ico_win_mgr_send_to_mgr(const int event, const int surfaceid, const char *appid,
1435 const int param1, const int param2, const int param3,
1436 const int param4, const int param5, const int param6)
1439 struct uifw_manager* mgr;
1441 wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) {
1445 case ICO_WINDOW_MGR_WINDOW_CREATED:
1446 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED"
1447 "(surf=%08x,pid=%d,appid=%s)",
1448 (int)mgr->resource, surfaceid, param1, appid);
1449 ico_window_mgr_send_window_created(mgr->resource, surfaceid, param1, appid);
1452 case ICO_WINDOW_MGR_WINDOW_VISIBLE:
1453 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE"
1454 "(surf=%08x,vis=%d,raise=%d,hint=%d)",
1455 (int)mgr->resource, surfaceid, param1, param2, param3);
1456 ico_window_mgr_send_window_visible(mgr->resource,
1457 surfaceid, param1, param2, param3);
1460 case ICO_WINDOW_MGR_WINDOW_CONFIGURE:
1461 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE"
1462 "(surf=%08x,app=%s,layer=%d,x/y=%d/%d,w/h=%d/%d,hint=%d)",
1463 (int)mgr->resource, surfaceid, appid,
1464 param1, param2, param3, param4, param5, param6);
1465 ico_window_mgr_send_window_configure(mgr->resource, surfaceid, appid,
1466 param1, param2, param3, param4,
1470 case ICO_WINDOW_MGR_WINDOW_DESTROYED:
1471 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED "
1472 "surf=%08x", (int)mgr->resource, surfaceid);
1473 ico_window_mgr_send_window_destroyed(mgr->resource, surfaceid);
1476 case ICO_WINDOW_MGR_WINDOW_ACTIVE:
1477 uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE surf=%08x "
1478 "active=%d", (int)mgr->resource, surfaceid, param1);
1479 ico_window_mgr_send_window_active(mgr->resource, surfaceid,
1491 /*--------------------------------------------------------------------------*/
1493 * @brief ico_win_mgr_hook_set_user: set hook function for set user
1495 * @param[in] hook_set_user hook function
1498 /*--------------------------------------------------------------------------*/
1500 ico_win_mgr_hook_set_user(void (*hook_set_user)(struct wl_client *client,
1503 uifw_trace("ico_win_mgr_hook_set_user: Hook %08x", (int)hook_set_user);
1504 win_mgr_hook_set_user = hook_set_user;
1507 /*--------------------------------------------------------------------------*/
1509 * @brief ico_win_mgr_hook_create: set hook function for create surface
1511 * @param[in] hook_create hook function
1514 /*--------------------------------------------------------------------------*/
1516 ico_win_mgr_hook_create(void (*hook_create)(struct wl_client *client,
1517 struct weston_surface *surface,
1518 int surfaceId, const char *appid))
1520 uifw_trace("ico_win_mgr_hook_create: Hook %08x", (int)hook_create);
1521 win_mgr_hook_create = hook_create;
1524 /*--------------------------------------------------------------------------*/
1526 * @brief ico_win_mgr_hook_destroy: set hook function for destroy surface
1528 * @param[in] hook_destroy hook function
1531 /*--------------------------------------------------------------------------*/
1533 ico_win_mgr_hook_destroy(void (*hook_destroy)(struct weston_surface *surface))
1535 uifw_trace("ico_win_mgr_hook_destroy: Hook %08x", (int)hook_destroy);
1536 win_mgr_hook_destroy = hook_destroy;
1540 /*--------------------------------------------------------------------------*/
1542 * @brief module_init: initialize ico_window_mgr
1543 * this function called from ico_pluign_loader
1545 * @param[in] es weston compositor
1550 /*--------------------------------------------------------------------------*/
1552 module_init(struct weston_compositor *ec)
1556 uifw_info("ico_window_mgr: Enter(module_init)");
1558 _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr));
1559 if (_ico_win_mgr == NULL) {
1560 uifw_error("ico_window_mgr: malloc failed");
1564 memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr));
1565 _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8);
1566 if (! _ico_win_mgr->surfaceid_map) {
1567 uifw_error("ico_window_mgr: malloc failed");
1570 uifw_trace("ico_window_mgr: sh=%08x", (int)_ico_win_mgr);
1571 memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8);
1573 _ico_win_mgr->compositor = ec;
1575 _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS;
1576 _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS;
1578 uifw_trace("ico_window_mgr: wl_display_add_global(bind_ico_win_mgr)");
1579 if (wl_display_add_global(ec->wl_display, &ico_window_mgr_interface,
1580 _ico_win_mgr, bind_ico_win_mgr) == NULL) {
1581 uifw_error("ico_window_mgr: Error(wl_display_add_global)");
1585 wl_list_init(&_ico_win_mgr->surface_list);
1586 wl_list_init(&_ico_win_mgr->client_list);
1587 wl_list_init(&_ico_win_mgr->manager_list);
1589 nodeId = ico_ivi_get_mynode();
1590 _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId);
1591 uifw_trace("ico_window_mgr: NoedId=%08x SurfaceIdBase=%08x",
1592 nodeId, _ico_win_mgr->surface_head);
1594 /* Regist usurf_2_node to ivi_common plugin */
1595 ico_ivi_set_usurf_2_node(ico_winmgr_usurf_2_node);
1597 /* Regist send_to_mgr to ivi_common plugin */
1598 ico_ivi_set_send_to_mgr(ico_win_mgr_send_to_mgr);
1599 ico_ivi_set_send_surface_change(win_mgr_surface_change_mgr);
1601 /* Hook to IVI-Shell */
1602 ivi_shell_hook_bind(bind_shell_client);
1603 ivi_shell_hook_unbind(unbind_shell_client);
1604 ivi_shell_hook_create(client_register_surface);
1605 ivi_shell_hook_destroy(win_mgr_surface_destroy);
1606 ivi_shell_hook_map(win_mgr_map_surface);
1607 ivi_shell_hook_change(win_mgr_surface_change);
1608 ivi_shell_hook_select(win_mgr_surface_select);
1610 uifw_info("ico_window_mgr: Leave(module_init)");