Fixed some RPMlint errors - group name, duplicate files, etc.
[profile/ivi/ico-uxf-homescreen.git] / ico-app-framework / ico_uxf_init.c
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   user experiance library(initialize/terminate/event)
11  *
12  * @date    Feb-28-2013
13  */
14
15 #include    <stdio.h>
16 #include    <stdlib.h>
17 #include    <unistd.h>
18 #include    <string.h>
19 #include    <errno.h>
20 #include    <pthread.h>
21 #include    <sys/ioctl.h>
22 #include    <sys/time.h>
23 #include    <fcntl.h>
24
25 #include    "wayland-client.h"
26 #include    "ico_window_mgr-client-protocol.h"
27 #include    "ico_uxf.h"
28 #include    "ico_uxf_conf.h"
29 #include    "ico_uxf_private.h"
30
31 /* static functions             */
32 /* wayland standard callback functions      */
33 static void ico_uxf_wayland_globalcb(void *data, struct wl_registry *registry,
34                                      uint32_t name, const char *interface,
35                                      uint32_t version);
36 static void ico_uxf_output_geometrycb(void *data, struct wl_output *wl_output,
37                                       int32_t x, int32_t y, int32_t physical_width,
38                                       int32_t physical_height, int32_t subpixel,
39                                       const char *make, const char *model,
40                                       int32_t transform);
41 static void ico_uxf_output_modecb(void *data, struct wl_output *wl_output,
42                                   uint32_t flags, int32_t width, int32_t height,
43                                   int32_t refresh);
44 static void ico_uxf_create_window(uint32_t surfaceid, const char *appid, uint32_t node,
45                                   uint32_t layer, int32_t x, int32_t y,
46                                   int32_t width, int32_t height);
47
48 /* ico_window_mgr(Multi Window Manager) callback functions  */
49 struct ico_window;
50 static void ico_uxf_window_createdcb(void *data, struct ico_window_mgr *ico_window_mgr,
51                                      uint32_t surfaceid, const char *winname, int32_t pid,
52                                      const char *appid);
53 static void ico_uxf_window_namecb(void *data, struct ico_window_mgr *ico_window_mgr,
54                                   uint32_t surfaceid, const char *winname);
55 static void ico_uxf_window_destroyedcb(void *data, struct ico_window_mgr *ico_window_mgr,
56                                        uint32_t surfaceid);
57 static void ico_uxf_window_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
58                                      uint32_t surfaceid, int32_t visible, int32_t raise,
59                                      int32_t hint);
60 static void ico_uxf_window_configurecb(void *data, struct ico_window_mgr *ico_window_mgr,
61                                        uint32_t surfaceid, uint32_t node,
62                                        uint32_t layer, int32_t x, int32_t y,
63                                        int32_t width, int32_t height, int32_t hint);
64 static void ico_uxf_window_activecb(void *data, struct ico_window_mgr *ico_window_mgr,
65                                     uint32_t surfaceid, int32_t active);
66 static void ico_uxf_window_layer_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
67                                            uint32_t layer, int32_t visible);
68 static void ico_uxf_window_surfacecb(void *data, struct ico_window_mgr *ico_window_mgr,
69                                      const char *appid, struct wl_array *surfaces);
70 static void ico_uxf_window_mapcb(void *data, struct ico_window_mgr *ico_window_mgr,
71                                  int32_t event, uint32_t surfaceid, int32_t width,
72                                  int32_t height, int32_t stride, int32_t format);
73
74 /* ico_input_mgr(Multi Input Manager) callback functions    */
75 static void ico_uxf_input_capabilitiescb(void *data, struct ico_exinput *ico_exinput,
76                                          const char *device, int32_t type,
77                                          const char *swname, int32_t input,
78                                          const char *codename, int32_t code);
79 static void ico_uxf_input_codecb(void *data, struct ico_exinput *ico_exinput,
80                                  const char *device, int32_t input, const char *codename,
81                                  int32_t code);
82 static void ico_uxf_input_inputcb(void *data, struct ico_exinput *ico_exinput,
83                                   uint32_t time, const char *device, int32_t input,
84                                   int32_t code, int32_t state);
85
86 /* AppCore(AUL) callback function   */
87 static int ico_uxf_aul_aulcb(int pid, void *data);
88
89 /* Variables & Tables               */
90 Ico_Uxf_Api_Mng         gIco_Uxf_Api_Mng = { 0 };
91
92 static pthread_mutex_t  sMutex;
93
94 /* Wayland Registry Listener */
95 static const struct wl_registry_listener ico_uxf_registry_listener = {
96     ico_uxf_wayland_globalcb
97 };
98
99 /* Window Manger Interface */
100 static const struct ico_window_mgr_listener     windowlistener = {
101     ico_uxf_window_createdcb,
102     ico_uxf_window_namecb,
103     ico_uxf_window_destroyedcb,
104     ico_uxf_window_visiblecb,
105     ico_uxf_window_configurecb,
106     ico_uxf_window_activecb,
107     ico_uxf_window_layer_visiblecb,
108     ico_uxf_window_surfacecb,
109     ico_uxf_window_mapcb
110 };
111
112 /* Input Manger Interface */
113 static const struct ico_exinput_listener      exinputlistener = {
114     ico_uxf_input_capabilitiescb,
115     ico_uxf_input_codecb,
116     ico_uxf_input_inputcb
117 };
118
119 /* Wayland Output interface */
120 static const struct wl_output_listener outputlistener = {
121     ico_uxf_output_geometrycb,
122     ico_uxf_output_modecb
123 };
124
125
126 /*--------------------------------------------------------------------------*/
127 /**
128  * @brief   ico_uxf_init: initialize user interface library hor HomeScreen
129  *
130  * @param[in]   name            application id
131  * @return      result
132  * @retval      ICO_UXF_EOK     success
133  * @retval      ICO_UXF_EBUSY   error(cullentry terminating)
134  * @retval      ICO_UXF_ESRCH   error(configuration error)
135  * @retval      ICO_UXF_ENOSYS  error(system error)
136  */
137 /*--------------------------------------------------------------------------*/
138 ICO_APF_API int
139 ico_uxf_init(const char *name)
140 {
141     Ico_Uxf_Mng_Display *dsp;
142     Ico_Uxf_Mng_Layer   *lay;
143     Ico_Uxf_Mng_Process *prc;
144     pthread_mutexattr_t sMutexAttr;
145     Ico_Uxf_Sys_Config *sysconf;
146     Ico_Uxf_App_Config *appconf;
147     Ico_Uxf_conf_appdisplay *appdsp;
148     Ico_Uxf_Mng_Callback    *freecb;
149     Ico_Uxf_Mng_EventQue    *freeeq;
150     int         dn, tn;
151     int         ret;
152
153     ico_uxf_log_open(name);
154
155     if (gIco_Uxf_Api_Mng.Initialized)  {
156         if (gIco_Uxf_Api_Mng.Initialized < 0)  {
157             uifw_trace("ico_uxf_init: Enter");
158             uifw_warn("ico_uxf_init: Leave(EBUSY)");
159             return ICO_UXF_EBUSY;
160         }
161         uifw_trace("ico_uxf_init: Enter");
162         uifw_trace("ico_uxf_init: Leave(EOK)");
163         return ICO_UXF_EOK;
164     }
165     uifw_trace("ico_uxf_init: Enter");
166
167     gIco_Uxf_Api_Mng.Initialized = -1;
168     memset(gIco_Uxf_Api_Mng.MyProcess, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
169     strncpy(gIco_Uxf_Api_Mng.MyProcess, name, ICO_UXF_MAX_PROCESS_NAME);
170     gIco_Uxf_Api_Mng.EventMask = 0;
171     gIco_Uxf_Api_Mng.WaylandFd = -1;
172     gIco_Uxf_Api_Mng.Wayland_Display = NULL;
173     gIco_Uxf_Api_Mng.InitTimer = ICO_UXF_SUSP_INITTIME;
174     gIco_Uxf_Api_Mng.Win_Show_Anima = 1;
175     gIco_Uxf_Api_Mng.Win_Hide_Anima = 1;
176
177     /* read configurations */
178     sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
179     appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
180     if ((sysconf == NULL) || (appconf == NULL)) {
181         uifw_error("ico_uxf_init: Leave(ESRCH), Configuration Read Error");
182         return ICO_UXF_ESRCH;
183     }
184
185     uifw_trace("ico_uxf_init: set display configurations");
186     /* set display configurations */
187     for (dn = 0; dn < sysconf->displayNum; dn++) {
188         dsp = ico_uxf_mng_display(sysconf->display[dn].id, 1);
189         dsp->attr.type = sysconf->display[dn].type;
190         dsp->attr.num_layers = sysconf->display[dn].layerNum;
191         dsp->attr.hostId = sysconf->display[dn].hostId;
192         dsp->attr.displayNo = sysconf->display[dn].displayno;
193         dsp->attr.w = sysconf->display[dn].width;
194         dsp->attr.h = sysconf->display[dn].height;
195         dsp->attr.pWidth = -1;
196         dsp->attr.pHeight = -1;
197         dsp->attr.orientation = ICO_UXF_ORIENTATION_HORIZONTAL;
198         dsp->attr.inch = sysconf->display[dn].inch;
199         strncpy(dsp->attr.name, sysconf->display[dn].name, ICO_UXF_MAX_WIN_NAME);
200         dsp->attr.name[ICO_UXF_MAX_WIN_NAME] = 0;
201
202         for (tn = 0; tn < sysconf->display[dn].layerNum; tn++) {
203             lay = ico_uxf_mng_layer(sysconf->display[dn].id,
204                                     sysconf->display[dn].layer[tn].id, 1);
205             lay->attr.display = sysconf->display[dn].id;
206             lay->attr.w = sysconf->display[dn].width;
207             lay->attr.h = sysconf->display[dn].height;
208             lay->attr.menuoverlap = sysconf->display[dn].layer[tn].menuoverlap;
209             lay->mng_display = dsp;
210         }
211     }
212
213     uifw_trace("ico_uxf_init: set application configurations(num=%d)",
214                appconf->applicationNum);
215     /* set application configurations */
216     for(dn = 0; dn < appconf->applicationNum; dn++)  {
217         prc = ico_uxf_mng_process(appconf->application[dn].appid, 1);
218         prc->attr.internalid = 0;
219         prc->appconf = (void *)&appconf->application[dn];
220         prc->attr.status = ICO_UXF_PROCSTATUS_STOP;
221         prc->attr.type = appconf->application[dn].categoryId;
222         prc->attr.hostId = appconf->application[dn].hostId;
223         prc->attr.myHost = (prc->attr.hostId == sysconf->misc.myhostId) ? 1 : 0;
224         prc->attr.noicon = appconf->application[dn].noicon;
225         prc->attr.autostart = appconf->application[dn].autostart;
226         prc->attr.invisiblecpu = appconf->application[dn].invisiblecpu;
227
228         appdsp = &appconf->application[dn].display[0];
229         prc->attr.mainwin.window = 0;
230         prc->attr.mainwin.windowtype = appconf->application[dn].categoryId;
231         prc->attr.mainwin.display = appdsp->displayId;
232         prc->attr.mainwin.layer = appdsp->layerId;
233         prc->attr.mainwin.x =
234                 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
235         prc->attr.mainwin.y =
236                 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
237         prc->attr.mainwin.w =
238                 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
239         prc->attr.mainwin.h =
240                 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
241         prc->attr.mainwin.name[ICO_UXF_MAX_WIN_NAME] = 0;
242         prc->attr.numwindows = appconf->application[dn].displayzoneNum;
243         /* get sub windows                          */
244         if (prc->attr.numwindows > 1)   {
245             prc->attr.subwin = malloc(sizeof(Ico_Uxf_ProcessWin) *
246                                       (prc->attr.numwindows - 1));
247             if (! prc->attr.subwin) {
248                 uifw_error("ico_uxf_init: No Memory");
249                 appconf->application[dn].displayzoneNum = 1;
250                 prc->attr.numwindows = 1;
251             }
252             else    {
253                 memset(prc->attr.subwin, 0, (prc->attr.numwindows - 1));
254                 for (tn = 0; tn < (prc->attr.numwindows - 1); tn++) {
255                     appdsp ++;
256                     prc->attr.subwin[tn].windowtype = prc->attr.mainwin.windowtype;
257                     prc->attr.subwin[tn].display = appdsp->displayId;
258                     prc->attr.subwin[tn].layer = appdsp->layerId;
259                     prc->attr.subwin[tn].x =
260                         sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
261                     prc->attr.subwin[tn].y =
262                         sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
263                     prc->attr.subwin[tn].w =
264                         sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
265                     prc->attr.subwin[tn].h =
266                         sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
267                 }
268             }
269         }
270     }
271
272     gIco_Uxf_Api_Mng.Mng_MyProcess
273         = ico_uxf_mng_process(gIco_Uxf_Api_Mng.MyProcess, 0);
274     if (!gIco_Uxf_Api_Mng.Mng_MyProcess) {
275         uifw_error("ico_uxf_init: Leave(ESRCH), Unknown Apprication(%s)",
276                    gIco_Uxf_Api_Mng.MyProcess);
277         return ICO_UXF_ESRCH;
278     }
279     gIco_Uxf_Api_Mng.Mng_MyProcess->attr.internalid = getpid();
280     gIco_Uxf_Api_Mng.Mng_MyProcess->attr.status = ICO_UXF_PROCSTATUS_RUN;
281
282     dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
283
284     uifw_trace("ico_uxf_init: App.%s MainDisplay.%d %08x",
285                gIco_Uxf_Api_Mng.Mng_MyProcess->attr.process,
286                gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, dsp);
287
288     for (ret = 0; ret < (2000/50); ret++)  {
289         gIco_Uxf_Api_Mng.Wayland_Display = wl_display_connect(NULL);
290         if (gIco_Uxf_Api_Mng.Wayland_Display)  break;
291         usleep(50*1000);
292     }
293     if (! gIco_Uxf_Api_Mng.Wayland_Display) {
294         uifw_error("ico_uxf_init:Can not connect to wayland, Abort!!");
295         fprintf(stderr, "ico_uxf_init:Can not connect to wayland, Abort!!\n");
296         exit(1);
297     }
298
299     gIco_Uxf_Api_Mng.Wayland_Registry
300         = wl_display_get_registry(gIco_Uxf_Api_Mng.Wayland_Display);
301     wl_registry_add_listener(gIco_Uxf_Api_Mng.Wayland_Registry,
302                              &ico_uxf_registry_listener, (void *)0);
303
304     for (ret = 0; ret < (500/20); ret++) {
305         if ((gIco_Uxf_Api_Mng.Wayland_WindowMgr != NULL) &&
306             (gIco_Uxf_Api_Mng.Wayland_exInput != NULL) &&
307             (gIco_Uxf_Api_Mng.Wayland_InputMgr != NULL))    break;
308         uifw_trace("ico_uxf_init: call wl_display_dispatch(%08x)",
309                    (int)gIco_Uxf_Api_Mng.Wayland_Display);
310         wl_display_dispatch(gIco_Uxf_Api_Mng.Wayland_Display);
311         usleep(20*1000);
312     }
313     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
314     uifw_trace("ico_uxf_init: Wayland/Weston connect OK");
315
316     gIco_Uxf_Api_Mng.WaylandFd
317         = wl_display_get_fd(gIco_Uxf_Api_Mng.Wayland_Display);
318
319     /* initialize mutex */
320     (void) pthread_mutexattr_init(&sMutexAttr);
321     if (pthread_mutex_init(&sMutex, &sMutexAttr) != 0) {
322         uifw_error("ico_uxf_init: Leave(ENOSYS), Mutex Create Error %d", errno);
323         wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
324         gIco_Uxf_Api_Mng.Wayland_Display = NULL;
325         gIco_Uxf_Api_Mng.Initialized = 0;
326         return ICO_UXF_ENOSYS;
327     }
328
329     /* allocate free control blocks         */
330     freecb = ico_uxf_alloc_callback();
331     ico_uxf_free_callback(freecb);
332     freeeq = ico_uxf_alloc_eventque();
333     ico_uxf_free_eventque(freeeq);
334
335     /* flush wayland connection             */
336     ico_window_mgr_declare_manager(gIco_Uxf_Api_Mng.Wayland_WindowMgr, 1);
337     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
338
339     /* application launch/dead callback from AppCore(aul)   */
340     aul_listen_app_launch_signal(ico_uxf_aul_aulcb, (void *)0);
341     aul_listen_app_dead_signal(ico_uxf_aul_aulcb, (void *)1);
342
343     gIco_Uxf_Api_Mng.Initialized = 1;
344
345     uifw_trace("ico_uxf_init: Leave(EOK)");
346     uifw_logflush();
347
348     return ICO_UXF_EOK;
349 }
350
351 /*--------------------------------------------------------------------------*/
352 /**
353  * @brief   ico_uxf_wl_display_fd: get wayland file discriptor
354  *
355  * @param       none
356  * @return      wayland connect socket file descriptor
357  * @retval      >=0         success(file descriptor)
358  * @retval      < 0         error(wayland not connect)
359  */
360 /*--------------------------------------------------------------------------*/
361 ICO_APF_API int
362 ico_uxf_wl_display_fd(void)
363 {
364     uifw_trace("ico_uxf_wl_display_fd: fd=%d", gIco_Uxf_Api_Mng.WaylandFd);
365
366     return gIco_Uxf_Api_Mng.WaylandFd;
367 }
368
369 /*--------------------------------------------------------------------------*/
370 /**
371  * @brief   ico_uxf_shutdown: terminate user interface library hor HomeScreen
372  *
373  * @param       none
374  * @return      result
375  * @retval      ICO_UXF_EOK     success
376  * @retval      ICO_UXF_EBUSY   error(cullentry terminating)
377  */
378 /*--------------------------------------------------------------------------*/
379 ICO_APF_API int
380 ico_uxf_shutdown(void)
381 {
382     uifw_trace("ico_uxf_shutdown: Enter");
383
384     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
385         if (gIco_Uxf_Api_Mng.Initialized < 0)  {
386             uifw_warn("ico_uxf_shutdown: Leave(EBUSY)");
387             return ICO_UXF_EBUSY;
388         }
389         uifw_trace("ico_uxf_shutdown: Leave(EOK)");
390         return ICO_UXF_EOK;
391     }
392     gIco_Uxf_Api_Mng.Initialized = -1;
393     gIco_Uxf_Api_Mng.LastEvent = 0;
394
395     (void) pthread_mutex_destroy(&sMutex);
396
397     if (gIco_Uxf_Api_Mng.Wayland_Seat) {
398         wl_seat_destroy(gIco_Uxf_Api_Mng.Wayland_Seat);
399         gIco_Uxf_Api_Mng.Wayland_Seat = NULL;
400     }
401     if (gIco_Uxf_Api_Mng.Wayland_exInput) {
402         ico_exinput_destroy(gIco_Uxf_Api_Mng.Wayland_exInput);
403         gIco_Uxf_Api_Mng.Wayland_exInput = NULL;
404     }
405     if (gIco_Uxf_Api_Mng.Wayland_InputMgr) {
406         ico_input_mgr_control_destroy(gIco_Uxf_Api_Mng.Wayland_InputMgr);
407         gIco_Uxf_Api_Mng.Wayland_InputMgr = NULL;
408     }
409     if (gIco_Uxf_Api_Mng.Wayland_Compositor)   {
410         wl_compositor_destroy(gIco_Uxf_Api_Mng.Wayland_Compositor);
411         gIco_Uxf_Api_Mng.Wayland_Compositor = NULL;
412     }
413     if (gIco_Uxf_Api_Mng.Wayland_Display)  {
414         wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
415         wl_display_disconnect(gIco_Uxf_Api_Mng.Wayland_Display);
416         gIco_Uxf_Api_Mng.Wayland_Display = NULL;
417     }
418
419     gIco_Uxf_Api_Mng.Initialized = 0;
420
421     uifw_trace("ico_uxf_shutdown: Leave(EOK)");
422     return ICO_UXF_EOK;
423 }
424
425 /*--------------------------------------------------------------------------*/
426 /**
427  * @brief   ico_uxf_main_loop_iterate: process user interface library events
428  *
429  * @param       none
430  * @return      none
431  */
432 /*--------------------------------------------------------------------------*/
433 ICO_APF_API void
434 ico_uxf_main_loop_iterate(void)
435 {
436     int                     arg;
437     Ico_Uxf_Mng_EventQue    *wkque;
438     Ico_Uxf_Mng_Callback    *callback;
439     Ico_Uxf_Event_Cb        func;
440
441     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
442
443     arg = 0;
444     if (ioctl(gIco_Uxf_Api_Mng.WaylandFd, FIONREAD, &arg) < 0)   {
445         uifw_warn("ico_uxf_main_loop_iterate: ioclt(FIONREAD,) Error %d", errno);
446         arg = 0;
447     }
448
449     if (arg > 0)   {
450         wl_display_dispatch(gIco_Uxf_Api_Mng.Wayland_Display);
451     }
452
453     ico_uxf_enter_critical();
454
455     /* notify event */
456     while (gIco_Uxf_Api_Mng.EventQue) {
457
458         wkque = gIco_Uxf_Api_Mng.EventQue;
459         gIco_Uxf_Api_Mng.EventQue = gIco_Uxf_Api_Mng.EventQue->next;
460
461         gIco_Uxf_Api_Mng.LastEvent = wkque->detail.event;
462         callback = gIco_Uxf_Api_Mng.Callback;
463         while (callback) {
464             if (callback->eventmask & gIco_Uxf_Api_Mng.LastEvent) {
465                 func = callback->func;
466                 arg = callback->arg;
467                 ico_uxf_leave_critical();
468
469                 uifw_trace("ico_uxf_main_loop: Call Event Callback(%08x,,%08x)",
470                            gIco_Uxf_Api_Mng.LastEvent, arg);
471                 (*func)(gIco_Uxf_Api_Mng.LastEvent, wkque->detail, arg);
472
473                 ico_uxf_enter_critical();
474             }
475             callback = callback->next;
476         }
477         ico_uxf_free_eventque(wkque);
478     }
479
480     ico_uxf_leave_critical();
481
482     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
483 }
484
485 /*--------------------------------------------------------------------------*/
486 /**
487  * @brief   ico_uxf_callback_set: set event calback function
488  *
489  * @param[in]   mask            event mask
490  * @param[in]   func            callback function
491  * @param[in]   arg             user argument
492  * @return      result
493  * @retval      ICO_UXF_EOK     success
494  * @retval      ICO_UXF_ESRCH   error(user interface library not initialized)
495  * @retval      ICO_UXF_EINVAL  error(illegal event mask)
496  * @retval      ICO_UXF_EBUSY   error(already set same event)
497  */
498 /*--------------------------------------------------------------------------*/
499 ICO_APF_API int
500 ico_uxf_callback_set(const unsigned int mask, Ico_Uxf_Event_Cb func, const int arg)
501 {
502     Ico_Uxf_Mng_Callback    *callback;
503     unsigned int            wkmask;
504
505     uifw_trace("ico_uxf_callback_set: Enter(%08x,%08x,%08x)", mask, (int)func, arg);
506
507     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
508         uifw_warn("ico_uxf_callback_set: Leave(ESRCH)");
509         return ICO_UXF_ESRCH;
510     }
511
512     if (mask)  {
513         wkmask = mask;
514     }
515     else    {
516         wkmask = ICO_UXF_EVENT_ALL;
517     }
518     if ((wkmask & ICO_UXF_EVENT_VALIDALL) == 0) {
519         uifw_warn("ico_uxf_callback_set: Leave(EINVAL)");
520         return ICO_UXF_EINVAL;
521     }
522
523     ico_uxf_enter_critical();
524
525     callback = gIco_Uxf_Api_Mng.Callback;
526     while (callback)   {
527         if ((callback->eventmask == wkmask) && (callback->func == func) &&
528             (callback->arg == arg))    {
529
530             ico_uxf_leave_critical();
531             uifw_warn("ico_uxf_callback_set: Leave(EBUSY)");
532             return ICO_UXF_EBUSY;
533         }
534     }
535
536     callback = ico_uxf_alloc_callback();
537
538     callback->eventmask = wkmask;
539     callback->func = func;
540     callback->arg = arg;
541
542     ico_uxf_regist_callback(callback);
543
544     gIco_Uxf_Api_Mng.EventMask |= wkmask;
545
546     ico_uxf_leave_critical();
547
548     uifw_trace("ico_uxf_callback_set: Leave(EOK)");
549     return ICO_UXF_EOK;
550 }
551
552 /*--------------------------------------------------------------------------*/
553 /**
554  * @brief   ico_uxf_callback_remove: remove event calback function
555  *
556  * @param[in]   mask            event mask
557  * @param[in]   func            callback function
558  * @param[in]   arg             user argument
559  * @return      result
560  * @retval      ICO_UXF_EOK     success
561  * @retval      ICO_UXF_ESRCH   error(user interface library not initialized)
562  */
563 /*--------------------------------------------------------------------------*/
564 ICO_APF_API int
565 ico_uxf_callback_remove(const unsigned int mask, Ico_Uxf_Event_Cb func, const int arg)
566 {
567     Ico_Uxf_Mng_Callback    *callback;
568     unsigned int            wkmask;
569
570     uifw_trace("ico_uxf_callback_remove: Enter(%08x,%08x,%08x)", mask, (int)func, arg);
571
572     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
573         uifw_warn("ico_uxf_callback_remove: Leave(ESRCH)");
574         return ICO_UXF_ESRCH;
575     }
576
577     if (mask)  {
578         wkmask = mask;
579     }
580     else    {
581         wkmask = ICO_UXF_EVENT_ALL;
582     }
583
584     ico_uxf_enter_critical();
585
586     gIco_Uxf_Api_Mng.EventMask = 0;
587
588     callback = gIco_Uxf_Api_Mng.Callback;
589
590     while (callback)   {
591         if ((callback->eventmask == wkmask) && (callback->func == func) &&
592             (callback->arg == arg))    {
593             ico_uxf_remove_callback(callback);
594         }
595         else    {
596             gIco_Uxf_Api_Mng.EventMask |= callback->eventmask;
597         }
598         callback = callback->next;
599     }
600
601     ico_uxf_leave_critical();
602
603     uifw_trace("ico_uxf_callback_remove: Leave(EOK)");
604     return ICO_UXF_EOK;
605 }
606
607 /*--------------------------------------------------------------------------*/
608 /**
609  * @brief   ico_uxf_free_procwin: free active window management table(internal function)
610  *
611  * @param[in]   prc             application management table address
612  * @return      none
613  */
614 /*--------------------------------------------------------------------------*/
615 void
616 ico_uxf_free_procwin(Ico_Uxf_Mng_Process *prc)
617 {
618     Ico_Uxf_Mng_Window  *p;
619     Ico_Uxf_Mng_Window  *pp;
620     Ico_Uxf_Mng_Window  *freep;
621     int                 hash;
622
623     uifw_trace("ico_uxf_free_procwin: Enter(%d)", prc->attr.process);
624
625     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)   {
626         p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
627         pp = (Ico_Uxf_Mng_Window *)0;
628         while (p)  {
629             if (p->attr.process == prc->attr.process)  {
630                 freep = p;
631                 p = p->nextidhash;
632                 if (! pp)  {
633                     gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
634                 }
635                 else    {
636                     pp->nextidhash = p;
637                 }
638                 uifw_trace("ico_uxf_free_procwin: Free Window(%08x)", freep->attr.window);
639                 free(freep);
640             }
641             else    {
642                 pp = p;
643                 p = p->nextidhash;
644             }
645         }
646     }
647     uifw_trace("ico_uxf_free_procwin: Leave");
648 }
649
650 /*--------------------------------------------------------------------------*/
651 /**
652  * @brief   ico_uxf_wayland_globalcb: wayland global callback(static function)
653  *
654  * @param[in]   data            user data(unused)
655  * @param[in]   registry        wayland registry
656  * @param[in]   name            wayland display Id(unused)
657  * @param[in]   interface       wayland interface name
658  * @param[in]   version         wayland interface version number(unused)
659  * @return      none
660  */
661 /*--------------------------------------------------------------------------*/
662 static void
663 ico_uxf_wayland_globalcb(void *data, struct wl_registry *registry,
664                          uint32_t name, const char *interface, uint32_t version)
665 {
666     uifw_trace("ico_uxf_wayland_globalcb: Enter(Event=%s DispId=%08x)", interface, name);
667
668     if (strcmp(interface, "ico_window_mgr") == 0)    {
669         gIco_Uxf_Api_Mng.Wayland_WindowMgr = (struct ico_window_mgr *)
670                 wl_registry_bind(registry, name, &ico_window_mgr_interface, 1);
671         ico_window_mgr_add_listener(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
672                                     &windowlistener, NULL);
673     }
674     else if (strcmp(interface, "ico_exinput") == 0) {
675         /* regist exinput */
676         gIco_Uxf_Api_Mng.Wayland_exInput = (struct ico_exinput *)
677                 wl_registry_bind(registry, name, &ico_exinput_interface, 1);
678         ico_exinput_add_listener(gIco_Uxf_Api_Mng.Wayland_exInput, &exinputlistener, NULL);
679     }
680     else if (strcmp(interface, "ico_input_mgr_control") == 0) {
681         /* regist Multi Input Manager interface */
682         gIco_Uxf_Api_Mng.Wayland_InputMgr = (struct ico_input_mgr_control *)
683                 wl_registry_bind(registry, name, &ico_input_mgr_control_interface, 1);
684     }
685     else if (strcmp(interface, "wl_output") == 0) {
686         /* regist wl_output listener to get display info */
687         gIco_Uxf_Api_Mng.Wayland_Output = (struct wl_output *)
688                 wl_registry_bind(registry, name, &wl_output_interface, 1);
689         wl_output_add_listener(gIco_Uxf_Api_Mng.Wayland_Output, &outputlistener, NULL);
690     }
691     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
692     uifw_trace("ico_uxf_wayland_globalcb: Leave");
693 }
694
695 /*--------------------------------------------------------------------------*/
696 /**
697  * @brief   ico_uxf_output_geometrycb: wayland display attribute callback(static function)
698  *
699  * @param[in]   data            user data(unused)
700  * @param[in]   wl_output       wayland wl_output interface
701  * @param[in]   x               display upper-left X coodinate
702  * @param[in]   y               display upper-left Y coodinate
703  * @param[in]   physical_width  display physical width
704  * @param[in]   physical_height display physical height
705  * @param[in]   subpixel        display sub pixcel
706  * @param[in]   make            display maker
707  * @param[in]   model           diaplay model
708  * @param[in]   transform       transform
709  * @return      none
710  */
711 /*--------------------------------------------------------------------------*/
712 static void
713 ico_uxf_output_geometrycb(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
714                           int32_t physical_width, int32_t physical_height, int32_t subpixel,
715                           const char *make, const char *model, int32_t transform)
716 {
717     Ico_Uxf_Mng_Display *dsp;
718
719     uifw_trace("ico_uxf_output_geometrycb: Enter(x/y=%d/%d, pwidth/height=%d/%d, trans=%d)",
720                x, y, physical_width, physical_height, transform);
721
722     dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
723
724     if (dsp) {
725         if ((transform == WL_OUTPUT_TRANSFORM_90)
726             || (transform == WL_OUTPUT_TRANSFORM_270)
727             || (transform == WL_OUTPUT_TRANSFORM_FLIPPED_90)
728             || (transform == WL_OUTPUT_TRANSFORM_FLIPPED_270))  {
729             dsp->attr.pWidth = physical_height;
730             dsp->attr.pHeight = physical_width;
731             dsp->attr.orientation = ICO_UXF_ORIENTATION_VERTICAL;
732         }
733         else {
734             dsp->attr.pWidth = physical_width;
735             dsp->attr.pHeight = physical_height;
736             dsp->attr.orientation = ICO_UXF_ORIENTATION_HORIZONTAL;
737         }
738     }
739     uifw_trace("ico_uxf_output_geometrycb: Leave");
740 }
741
742 /*--------------------------------------------------------------------------*/
743 /**
744  * @brief   ico_uxf_output_modecb: wayland display mode callback(static function)
745  *
746  * @param[in]   data            user data(unused)
747  * @param[in]   wl_output       wayland wl_output interface
748  * @param[in]   flags           flags
749  * @param[in]   width           display width
750  * @param[in]   height          display height
751  * @param[in]   refresh         display refresh rate
752  * @return      none
753  */
754 /*--------------------------------------------------------------------------*/
755 static void
756 ico_uxf_output_modecb(void *data, struct wl_output *wl_output, uint32_t flags,
757                       int32_t width, int32_t height, int32_t refresh)
758 {
759     Ico_Uxf_Mng_Display *dsp;
760
761     uifw_trace("ico_uxf_output_modecb: Enter(flg=%d, width=%d, height=%d, ref=%d)",
762                flags, width, height, refresh);
763
764     dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
765
766     if (dsp && (flags & WL_OUTPUT_MODE_CURRENT)) {
767         if (dsp->attr.orientation == ICO_UXF_ORIENTATION_VERTICAL) {
768             dsp->attr.pWidth = height;
769             dsp->attr.pHeight = width;
770         }
771         else {
772             dsp->attr.pWidth = width;
773             dsp->attr.pHeight = height;
774         }
775     }
776     uifw_trace("ico_uxf_output_modecb: Leave");
777 }
778
779 /*--------------------------------------------------------------------------*/
780 /**
781  * @brief   ico_uxf_create_window: Create/Set Window management table(static function)
782  *
783  * @param[in]   surfaceid       ico_window_mgr surface Id
784  * @param[in]   appid           client application Id
785  * @param[in]   node            surface node Id
786  * @param[in]   layer           surface layer
787  * @param[in]   x               surface upper-left X coodinate
788  * @param[in]   y               surface upper-left Y coodinate
789  * @param[in]   width           surface width
790  * @param[in]   height          surface height
791  * @return      none
792  */
793 /*--------------------------------------------------------------------------*/
794 static void
795 ico_uxf_create_window(uint32_t surfaceid, const char *appid, uint32_t node, uint32_t layer,
796                       int32_t x, int32_t y, int32_t width, int32_t height)
797 {
798     Ico_Uxf_Mng_Window  *win;
799     Ico_Uxf_Mng_EventQue *que;
800     int                 display;
801     Ico_Uxf_Mng_Process *prc;
802
803     ico_uxf_enter_critical();
804
805     win = ico_uxf_mng_window(surfaceid, 0);
806
807     if (! win)  {
808         win = ico_uxf_mng_window(surfaceid, 1);
809         win->attr.eventmask = ICO_UXF_EVENT_NEWWINDOW;
810     }
811     display = ICO_UXF_SURFACEID_2_NODEID(surfaceid);
812     win->mng_display = ico_uxf_mng_display(display, 0);
813     win->mng_layer = ico_uxf_mng_layer(display, layer, 0);
814     win->attr.display = display;
815     win->attr.layer = layer;
816     memset(win->attr.process, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
817     strncpy(win->attr.process, appid, ICO_UXF_MAX_PROCESS_NAME);
818     win->attr.node = node;
819     win->attr.x = x;
820     win->attr.y = y;
821     win->attr.w = width;
822     win->attr.h = height;
823
824     prc = ico_uxf_mng_process(appid, 0);
825     win->mng_process = prc;
826     if ((prc != NULL) && (prc->attr.mainwin.window != (int)surfaceid)) {
827         /* sub-window */
828         win->attr.subwindow = 1;
829     }
830
831     if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_NEWWINDOW)    {
832
833         que = ico_uxf_alloc_eventque();
834
835         que->detail.event = ICO_UXF_EVENT_NEWWINDOW;
836         que->detail.window.display = display;
837         que->detail.window.window = surfaceid;
838         que->detail.window.layer = layer;
839         que->detail.window.x = win->attr.x;
840         que->detail.window.y = win->attr.y;
841         que->detail.window.w = win->attr.w;
842         que->detail.window.h = win->attr.h;
843         que->detail.window.visible = win->attr.visible;
844         que->detail.window.raise = win->attr.raise;
845         que->detail.window.active = win->attr.active;
846
847         ico_uxf_regist_eventque(que);
848     }
849     ico_uxf_leave_critical();
850 }
851
852 /*--------------------------------------------------------------------------*/
853 /**
854  * @brief   ico_uxf_window_createdcb: wayland surface create callback(static function)
855  *
856  * @param[in]   data            user data(unused)
857  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
858  * @param[in]   surfaceid       ico_window_mgr surface Id
859  * @param[in]   winname         surface window name(title)
860  * @param[in]   pid             wayland client process Id
861  * @param[in]   appid           wayland client application Id
862  * @return      none
863  */
864 /*--------------------------------------------------------------------------*/
865 static void
866 ico_uxf_window_createdcb(void *data, struct ico_window_mgr *ico_window_mgr,
867                          uint32_t surfaceid, const char *winname, int32_t pid,
868                          const char *appid)
869 {
870     Ico_Uxf_Mng_Process *prc;
871     Ico_Uxf_Mng_ProcWin *ppwin;
872     Ico_Uxf_Mng_ProcWin *ppw;
873
874     uifw_trace("ico_uxf_window_createdcb: Enter(surf=%08x name=%s pid=%d appid=%s myapp=%s)",
875                (int)surfaceid, winname, pid, appid, gIco_Uxf_Api_Mng.MyProcess);
876
877     prc = ico_uxf_mng_process(appid, 0);
878     if (prc)    {
879         /* set window animation     */
880         if (prc->appconf != NULL)   {
881             if (((Ico_Uxf_conf_application *)prc->appconf)->animation)  {
882                 ico_window_mgr_set_animation(
883                     gIco_Uxf_Api_Mng.Wayland_WindowMgr, surfaceid,
884                     ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE|ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW|
885                     ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
886                     ((Ico_Uxf_conf_application *)prc->appconf)->animation,
887                     ((Ico_Uxf_conf_application *)prc->appconf)->animation_time);
888             }
889             else if (((Ico_Uxf_conf_application *)prc->appconf)->animation_time > 0)    {
890                 ico_window_mgr_set_animation(
891                     gIco_Uxf_Api_Mng.Wayland_WindowMgr, surfaceid,
892                     ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE|ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW|
893                     ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
894                     " ", ((Ico_Uxf_conf_application *)prc->appconf)->animation_time);
895             }
896         }
897         if (prc->attr.mainwin.window <= 0)  {
898             uifw_trace("ico_uxf_window_createdcb: Set Main Window, Config Data");
899             prc->attr.mainwin.window = surfaceid;
900             ico_uxf_create_window(surfaceid, appid, prc->attr.mainwin.node,
901                                   prc->attr.mainwin.layer, prc->attr.mainwin.x,
902                                   prc->attr.mainwin.y, prc->attr.mainwin.w,
903                                   prc->attr.mainwin.h);
904             if (gIco_Uxf_Api_Mng.Hook_Window)   {
905                 (*gIco_Uxf_Api_Mng.Hook_Window)(prc->attr.process, surfaceid,
906                                                 ICO_UXF_HOOK_WINDOW_CREATE_MAIN);
907             }
908         }
909         else    {
910             uifw_trace("ico_uxf_window_createdcb: Sub Window, Dummy Data");
911             ico_uxf_create_window(surfaceid, appid, prc->attr.mainwin.node,
912                                   prc->attr.mainwin.layer, ICO_UXF_MAX_COORDINATE,
913                                   ICO_UXF_MAX_COORDINATE, 1, 1);
914             ppwin = (Ico_Uxf_Mng_ProcWin *)malloc(sizeof(Ico_Uxf_Mng_ProcWin));
915             if (ppwin) {
916                 memset(ppwin, 0, sizeof(Ico_Uxf_Mng_ProcWin));
917                 ppwin->attr.window = surfaceid;
918                 ppwin->attr.display = prc->attr.mainwin.display;
919                 if (!prc->procwin) {
920                     prc->procwin = ppwin;
921                 }
922                 else {
923                     ppw = prc->procwin;
924                     while (ppw->next) {
925                         ppw = ppw->next;
926                     }
927                     ppw->next = ppwin;
928                 }
929             }
930             if (gIco_Uxf_Api_Mng.Hook_Window)   {
931                 (*gIco_Uxf_Api_Mng.Hook_Window)(prc->attr.process, surfaceid,
932                                                 ICO_UXF_HOOK_WINDOW_CREATE_SUB);
933             }
934         }
935     }
936     else    {
937         uifw_warn("ico_uxf_window_createdcb: Application.%s dose not exist", appid);
938     }
939     uifw_trace("ico_uxf_window_createdcb: Leave");
940 }
941
942 /*--------------------------------------------------------------------------*/
943 /**
944  * @brief   ico_uxf_window_namecb: wayland change surface name callback(static function)
945  *
946  * @param[in]   data            user data(unused)
947  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
948  * @param[in]   surfaceid       ico_window_mgr surface Id
949  * @param[in]   winname         surface window name(title)
950  * @return      none
951  */
952 /*--------------------------------------------------------------------------*/
953 static void
954 ico_uxf_window_namecb(void *data, struct ico_window_mgr *ico_window_mgr,
955                       uint32_t surfaceid, const char *winname)
956 {
957     uifw_trace("ico_uxf_window_namecb: surf=%08x name=%s, NOP", (int)surfaceid, winname);
958 }
959
960 /*--------------------------------------------------------------------------*/
961 /**
962  * @brief   ico_uxf_window_destroyedcb: wayland surface destroy callback(static function)
963  *
964  * @param[in]   data            user data(unused)
965  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
966  * @param[in]   surfaceid       ico_window_mgr surface Id
967  * @return      none
968  */
969 /*--------------------------------------------------------------------------*/
970 static void
971 ico_uxf_window_destroyedcb(void *data, struct ico_window_mgr *ico_window_mgr,
972                            uint32_t surfaceid)
973 {
974     Ico_Uxf_Mng_Window  *p;
975     Ico_Uxf_Mng_Window  *pp;
976     Ico_Uxf_Mng_Window  *freep;
977     Ico_Uxf_Mng_Process *prc;
978     Ico_Uxf_Mng_EventQue *que;
979     int                 hash;
980     char                wkappid[ICO_UXF_MAX_PROCESS_NAME+1];
981     int                 wksubwindow;
982
983     uifw_trace("ico_uxf_window_destroyedcb: Enter(surf=%08x)", (int)surfaceid);
984
985     ico_uxf_enter_critical();
986
987     p = ico_uxf_mng_window(surfaceid, 0);
988
989     if (! p)    {
990         ico_uxf_leave_critical();
991         uifw_trace("ico_uxf_window_destroyedcb: Leave(Surface=%08x dose not exist)",
992                    (int)surfaceid);
993         return;
994     }
995     prc = p->mng_process;
996     if ((prc != NULL) && (prc->attr.mainwin.window == (int)surfaceid))  {
997         prc->attr.mainwin.window = 0;
998     }
999
1000     strcpy(wkappid, p->attr.process);
1001     wksubwindow = p->attr.subwindow;
1002
1003     if ((gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_DESTORYWINDOW) &&
1004         (p->attr.eventmask & ICO_UXF_EVENT_DESTORYWINDOW)) {
1005
1006         que = ico_uxf_alloc_eventque();
1007         que->detail.event = ICO_UXF_EVENT_DESTORYWINDOW;
1008         que->detail.window.display = p->attr.display;
1009         que->detail.window.window = surfaceid;
1010         que->detail.window.layer = p->attr.layer;
1011         que->detail.window.x = p->attr.x;
1012         que->detail.window.y = p->attr.y;
1013         que->detail.window.w = p->attr.w;
1014         que->detail.window.h = p->attr.h;
1015         que->detail.window.visible = p->attr.visible;
1016         que->detail.window.raise = p->attr.raise;
1017         que->detail.window.active = p->attr.active;
1018         ico_uxf_regist_eventque(que);
1019     }
1020
1021     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)   {
1022         p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
1023         pp = (Ico_Uxf_Mng_Window *)0;
1024         while (p)  {
1025             if (p->attr.window == (int)surfaceid)  {
1026                 freep = p;
1027                 p = p->nextidhash;
1028                 if (! pp)  {
1029                     gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
1030                 }
1031                 else    {
1032                     pp->nextidhash = p;
1033                 }
1034                 uifw_trace("ico_uxf_window_destroyedcb: Free Window.%08x(%08x)",
1035                            (int)freep, freep->attr.window);
1036                 free(freep);
1037                 hash = ICO_UXF_MISC_HASHSIZE;
1038                 break;
1039             }
1040             pp = p;
1041             p = p->nextidhash;
1042         }
1043     }
1044     ico_uxf_leave_critical();
1045
1046     if (gIco_Uxf_Api_Mng.Hook_Window)   {
1047         (*gIco_Uxf_Api_Mng.Hook_Window)(wkappid, surfaceid,
1048                                         wksubwindow ? ICO_UXF_HOOK_WINDOW_DESTORY_SUB :
1049                                                       ICO_UXF_HOOK_WINDOW_DESTORY_MAIN);
1050     }
1051     uifw_trace("ico_uxf_window_destroyedcb: Leave");
1052 }
1053
1054 /*--------------------------------------------------------------------------*/
1055 /**
1056  * @brief   ico_uxf_window_visiblecb: wayland surface visible callback(static function)
1057  *
1058  * @param[in]   data            user data(unused)
1059  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
1060  * @param[in]   surfaceid       ico_window_mgr surface Id
1061  * @param[in]   visible         surface visible(1=visible/0=unvisible/other=nochange)
1062  * @param[in]   raise           surface raise(1=raise/0=lower/other=nochange)
1063  * @param[in]   hint            client request(1=client request(not changed)/0=changed)
1064  * @return      none
1065  */
1066 /*--------------------------------------------------------------------------*/
1067 static void
1068 ico_uxf_window_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
1069                          uint32_t surfaceid, int32_t visible, int32_t raise, int32_t hint)
1070 {
1071     Ico_Uxf_Mng_Window  *win;
1072     Ico_Uxf_Mng_EventQue *que;
1073     int                 ovisible;
1074     int                 oraise;
1075
1076     ico_uxf_enter_critical();
1077
1078     win = ico_uxf_mng_window(surfaceid, 0);
1079
1080     if (!win)  {
1081         ico_uxf_leave_critical();
1082         uifw_trace("ico_uxf_window_visiblecb: Surface=%08x dose not exist",
1083                    (int)surfaceid);
1084         return;
1085     }
1086
1087     ovisible = visible;
1088     oraise = raise;
1089     if (ovisible == 9) {
1090         ovisible = win->attr.visible;
1091     }
1092     if (oraise == 9)   {
1093         oraise = win->attr.raise;
1094     }
1095
1096     if ((win->attr.visible != ovisible) ||
1097         (win->attr.raise != oraise))   {
1098
1099         if (((hint == 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_VISIBLE) &&
1100              (win->attr.eventmask & ICO_UXF_EVENT_VISIBLE)) ||
1101             ((hint != 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_VISIBLE_REQ) &&
1102              (win->attr.eventmask & ICO_UXF_EVENT_VISIBLE_REQ)))   {
1103
1104             que = ico_uxf_alloc_eventque();
1105             que->detail.event =
1106                     (hint == 0) ? ICO_UXF_EVENT_VISIBLE : ICO_UXF_EVENT_VISIBLE_REQ;
1107             que->detail.window.display = win->attr.display;
1108             que->detail.window.window = win->attr.window;
1109             que->detail.window.layer = win->attr.layer;
1110             que->detail.window.x = win->attr.x;
1111             que->detail.window.y = win->attr.y;
1112             que->detail.window.w = win->attr.w;
1113             que->detail.window.h = win->attr.h;
1114             que->detail.window.visible = ovisible;
1115             que->detail.window.raise = oraise;
1116             que->detail.window.active = win->attr.active;
1117
1118             ico_uxf_regist_eventque(que);
1119         }
1120     }
1121     ico_uxf_leave_critical();
1122 }
1123
1124 /*--------------------------------------------------------------------------*/
1125 /**
1126  * @brief   ico_uxf_window_configurecb: wayland surface configure callback(static function)
1127  *
1128  * @param[in]   data            user data(unused)
1129  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
1130  * @param[in]   surfaceid       ico_window_mgr surface Id
1131  * @param[in]   node            surface node Id
1132  * @param[in]   x               surface upper-left X coodinate
1133  * @param[in]   y               surface upper-left Y coodinate
1134  * @param[in]   width           surface width
1135  * @param[in]   height          surface height
1136  * @param[in]   hint            client request(1=client request(not changed)/0=changed)
1137  * @return      none
1138  */
1139 /*--------------------------------------------------------------------------*/
1140 static void
1141 ico_uxf_window_configurecb(void *data, struct ico_window_mgr *ico_window_mgr,
1142                            uint32_t surfaceid, uint32_t node,
1143                            uint32_t layer, int32_t x, int32_t y,
1144                            int32_t width, int32_t height, int32_t hint)
1145 {
1146     Ico_Uxf_Mng_Window  *win;
1147     Ico_Uxf_Mng_EventQue *que;
1148
1149 #if 0               /* too many logout, change to comment out   */
1150     uifw_trace("ico_uxf_window_configurecb: surf=%08x node=%x layer=%x "
1151                "x/y=%d/%d w/h=%d/%d hint=%d",
1152                (int)surfaceid, node, layer, x, y, width, height, hint);
1153 #endif              /* too many logout, change to comment out   */
1154
1155     ico_uxf_enter_critical();
1156
1157     win = ico_uxf_mng_window(surfaceid, 0);
1158
1159     if (!win)  {
1160         uifw_error("ico_uxf_window_configurecb: Unknown surface Id(%08x)", (int)surfaceid);
1161     }
1162     else    {
1163         if ((win->attr.layer != (int)layer) ||
1164             (win->attr.x != x) || (win->attr.y != y) ||
1165             (win->attr.w != width) || (win->attr.h != height)) {
1166
1167             if (((hint == 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_RESIZE) &&
1168                  (win->attr.eventmask & ICO_UXF_EVENT_RESIZE)) ||
1169                 ((hint != 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_RESIZE_REQ) &&
1170                  (win->attr.eventmask & ICO_UXF_EVENT_RESIZE_REQ)))    {
1171
1172                 que = ico_uxf_alloc_eventque();
1173
1174                 que->detail.event =
1175                         (hint == 0) ? ICO_UXF_EVENT_RESIZE : ICO_UXF_EVENT_RESIZE_REQ;
1176                 que->detail.window.display = win->mng_display->attr.display;
1177                 que->detail.window.window = win->attr.window;
1178                 que->detail.window.layer = layer;
1179                 que->detail.window.x = x;
1180                 que->detail.window.y = y;
1181                 que->detail.window.w = width;
1182                 que->detail.window.h = height;
1183                 que->detail.window.visible = win->attr.visible;
1184                 que->detail.window.raise = win->attr.raise;
1185                 que->detail.window.active = win->attr.active;
1186
1187                 ico_uxf_regist_eventque(que);
1188             }
1189             if (hint == 0)  {
1190                 win->attr.x = x;
1191                 win->attr.y = y;
1192                 win->attr.w = width;
1193                 win->attr.h = height;
1194                 if (win->attr.layer != (int)layer)  {
1195                     win->attr.layer = layer;
1196                     win->mng_layer = ico_uxf_mng_layer(win->mng_display->attr.display,
1197                                                        layer, 0);
1198                 }
1199             }
1200         }
1201     }
1202     ico_uxf_leave_critical();
1203 }
1204
1205 /*--------------------------------------------------------------------------*/
1206 /**
1207  * @brief   ico_uxf_window_activecb: wayland surface active callback(static function)
1208  *
1209  * @param[in]   data            user data(unused)
1210  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
1211  * @param[in]   surfaceid       ico_window_mgr surface Id
1212  * @param[in]   active          surface active(1=active/0=not active)
1213  * @return      none
1214  */
1215 /*--------------------------------------------------------------------------*/
1216 static void
1217 ico_uxf_window_activecb(void *data, struct ico_window_mgr *ico_window_mgr,
1218                         uint32_t surfaceid, int32_t active)
1219 {
1220     Ico_Uxf_Mng_Window  *win;
1221     Ico_Uxf_Mng_EventQue *que;
1222
1223     uifw_trace("ico_uxf_window_activecb: Enter(surf=%08x active=%d)", surfaceid, active);
1224
1225     ico_uxf_enter_critical();
1226
1227     win = ico_uxf_mng_window(surfaceid, 0);
1228
1229     if (win)  {
1230         if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_ACTIVEWINDOW)    {
1231
1232             que = ico_uxf_alloc_eventque();
1233
1234             que->detail.event = ICO_UXF_EVENT_ACTIVEWINDOW;
1235             que->detail.window.display = ICO_UXF_SURFACEID_2_NODEID(surfaceid);
1236             que->detail.window.window = surfaceid;
1237             if (active == ICO_WINDOW_MGR_ACTIVE_SELECTED)   {
1238                 que->detail.window.active = ICO_UXF_WINDOW_SELECT;
1239                 win->attr.active = ICO_UXF_WINDOW_POINTER_ACTIVE |
1240                                    ICO_UXF_WINDOW_KEYBOARD_ACTIVE;
1241             }
1242             else    {
1243                 que->detail.window.active = 0;
1244                 if (active & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1245                     que->detail.window.active |= ICO_UXF_WINDOW_POINTER_ACTIVE;
1246                 }
1247                 if (active & ICO_WINDOW_MGR_ACTIVE_KEYBOARD)    {
1248                     que->detail.window.active |= ICO_UXF_WINDOW_KEYBOARD_ACTIVE;
1249                 }
1250                 win->attr.active = que->detail.window.active;
1251             }
1252             ico_uxf_regist_eventque(que);
1253         }
1254     }
1255     ico_uxf_leave_critical();
1256     uifw_trace("ico_uxf_window_activecb: Leave");
1257 }
1258
1259 /*--------------------------------------------------------------------------*/
1260 /**
1261  * @brief   ico_uxf_window_layer_visiblecb: wayland layer visible callback(static function)
1262  *
1263  * @param[in]   data            user data(unused)
1264  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
1265  * @param[in]   layer           layer Id
1266  * @param[in]   visible         layer visible(1=visible/0=unvisible/other=nochange)
1267  * @return      none
1268  */
1269 /*--------------------------------------------------------------------------*/
1270 static void
1271 ico_uxf_window_layer_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
1272                                uint32_t layer, int32_t visible)
1273 {
1274     uifw_trace("ico_uxf_window_layer_visiblecb: layer=%x visible=%d, NOP", layer, visible);
1275 }
1276
1277 /*--------------------------------------------------------------------------*/
1278 /**
1279  * @brief   ico_uxf_window_surfacecb: query applicationsurface callback(static function)
1280  *
1281  * @param[in]   data            user data(unused)
1282  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
1283  * @param[in]   appid           application Id
1284  * @param[in]   suface          surface Id array
1285  * @return      none
1286  */
1287 /*--------------------------------------------------------------------------*/
1288 static void
1289 ico_uxf_window_surfacecb(void *data, struct ico_window_mgr *ico_window_mgr,
1290                          const char *appid, struct wl_array *surfaces)
1291 {
1292     uifw_trace("ico_uxf_window_surfacecb: appid=%s, NOP", appid);
1293 }
1294
1295 /*--------------------------------------------------------------------------*/
1296 /**
1297  * @brief   ico_uxf_window_mapcb: surface map event callback(static function)
1298  *
1299  * @param[in]   data            user data(unused)
1300  * @param[in]   ico_window_mgr  wayland ico_window_mgr plugin interface
1301  * @param[in]   event           event
1302  * @param[in]   surfaceid       surface Id
1303  * @param[in]   width           surface width
1304  * @param[in]   height          surface height
1305  * @param[in]   stride          surface buffer(frame buffer) stride
1306  * @param[in]   format          surface buffer format
1307  * @return      none
1308  */
1309 /*--------------------------------------------------------------------------*/
1310 static void
1311 ico_uxf_window_mapcb(void *data, struct ico_window_mgr *ico_window_mgr,
1312                      int32_t event, uint32_t surfaceid, int32_t width,
1313                      int32_t height, int32_t stride, int32_t format)
1314 {
1315     uifw_trace("ico_uxf_window_mapcb: surf=%08x event=%d w/h/s/f=%d/%d/%d/%d",
1316                (int)surfaceid, event, width, height, stride, format);
1317 }
1318
1319 /*--------------------------------------------------------------------------*/
1320 /**
1321  * @brief   ico_uxf_input_capabilitiescb: wayland extended input
1322  *                                        input capabilities callback(static function)
1323  *
1324  * @param[in]   data            user data(unused)
1325  * @param[in]   ico_exinput     wayland ico_input_mgr plugin interface
1326  * @param[in]   device          input device name
1327  * @param[in]   type            input device type
1328  * @param[in]   swname          input switch name
1329  * @param[in]   input           input switch number
1330  * @param[in]   codename        input code name
1331  * @param[in]   code            input code value
1332  * @return      none
1333  */
1334 /*--------------------------------------------------------------------------*/
1335 static void
1336 ico_uxf_input_capabilitiescb(void *data, struct ico_exinput *ico_exinput,
1337                              const char *device, int32_t type, const char *swname,
1338                              int32_t input, const char *codename, int32_t code)
1339 {
1340     int     i, j;
1341     Ico_Uxf_Sys_Config  *sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
1342     Ico_Uxf_InputDev    *inputdev;
1343     Ico_Uxf_InputDev    *bpdev;
1344     Ico_Uxf_InputSw     *inputsw;
1345     Ico_Uxf_InputSw     *bpsw;
1346
1347     uifw_trace("ico_uxf_input_capabilitiescb: "
1348                "Enter(device=%s type=%d sw=%s input=%d code=%s[%d])",
1349                device, type, swname, input, codename, code);
1350
1351     if (! sysconf)  return;
1352
1353     /* search and create input device table     */
1354     bpdev = NULL;
1355     inputdev = gIco_Uxf_Api_Mng.InputDev;
1356     while (inputdev)    {
1357         if (strcasecmp(inputdev->device, device) == 0)  break;
1358         bpdev = inputdev;
1359         inputdev = inputdev->next;
1360     }
1361     if (! inputdev) {
1362         inputdev = malloc(sizeof(Ico_Uxf_InputDev));
1363         if (! inputdev) {
1364             uifw_error("ico_uxf_input_capabilitiescb: Leave(No Memory)");
1365             return;
1366         }
1367         memset(inputdev, 0, sizeof(Ico_Uxf_InputDev));
1368
1369         if (bpdev)  {
1370             bpdev->next = inputdev;
1371         }
1372         else    {
1373             gIco_Uxf_Api_Mng.InputDev = inputdev;
1374         }
1375     }
1376     strncpy(inputdev->device, device, sizeof(inputdev->device)-1);
1377     inputdev->type = type;
1378
1379     bpsw = NULL;
1380     inputsw = inputdev->inputSw;
1381     while (inputsw) {
1382         if (strcasecmp(inputsw->swname, swname) == 0)   break;
1383         bpsw = inputsw;
1384         inputsw = inputsw->next;
1385     }
1386     if (! inputsw)  {
1387         inputsw = malloc(sizeof(Ico_Uxf_InputSw));
1388         if (! inputsw)  {
1389             uifw_error("ico_uxf_input_capabilitiescb: Leave(No Memory)");
1390             return;
1391         }
1392         if (bpsw)   {
1393             bpsw->next = inputsw;
1394         }
1395         else    {
1396             inputdev->inputSw = inputsw;
1397         }
1398         inputdev->numInputSw ++;
1399     }
1400     memset(inputsw, 0, sizeof(Ico_Uxf_InputSw));
1401     strncpy(inputsw->swname, swname, sizeof(inputsw->swname)-1);
1402     inputsw->input = input;
1403     inputsw->numCode = 1;
1404     inputsw->inputCode[0].code = code;
1405     strncpy(inputsw->inputCode[0].codename, codename,
1406             sizeof(inputsw->inputCode[0].codename)-1);
1407     uifw_trace("ico_uxf_input_capabilitiescb: create new inputsw");
1408
1409     /* send fixed application if fixed switch   */
1410     for (i = 0; i < sysconf->inputdevNum; i++)  {
1411         if (strcasecmp(sysconf->inputdev[i].name, inputdev->device) != 0)   continue;
1412
1413         for (j = 0; j < sysconf->inputdev[i].inputswNum; j++)   {
1414             if (! sysconf->inputdev[i].inputsw[j].appid)    continue;
1415             if (strcasecmp(sysconf->inputdev[i].inputsw[j].name,
1416                 inputsw->swname) != 0)  continue;
1417
1418             uifw_trace("ico_uxf_input_capabilitiescb: input %s.%s = %s",
1419                        inputdev->device, inputsw->swname,
1420                        sysconf->inputdev[i].inputsw[j].appid);
1421             ico_input_mgr_control_add_input_app(gIco_Uxf_Api_Mng.Wayland_InputMgr,
1422                                                 sysconf->inputdev[i].inputsw[j].appid,
1423                                                 inputdev->device, inputsw->input, 1,
1424                                                 sysconf->inputdev[i].inputsw[j].keycode);
1425             inputsw->fix = 1;
1426             break;
1427         }
1428     }
1429     uifw_trace("ico_uxf_input_capabilitiescb: Leave");
1430 }
1431
1432 /*--------------------------------------------------------------------------*/
1433 /**
1434  * @brief   ico_uxf_input_codecb: wayland extended input
1435  *                                input code callback(static function)
1436  *
1437  * @param[in]   data            user data(unused)
1438  * @param[in]   ico_exinput     wayland ico_input_mgr plugin interface
1439  * @param[in]   device          input device name
1440  * @param[in]   input           input switch number
1441  * @param[in]   codename        input code name
1442  * @param[in]   code            input code value
1443  * @return      none
1444  */
1445 /*--------------------------------------------------------------------------*/
1446 static void
1447 ico_uxf_input_codecb(void *data, struct ico_exinput *ico_exinput, const char *device,
1448                      int32_t input, const char *codename, int32_t code)
1449 {
1450     int     i;
1451     Ico_Uxf_InputDev    *inputdev;
1452     Ico_Uxf_InputSw     *inputsw;
1453
1454     uifw_trace("ico_uxf_input_codecb: device=%s input=%d code=%s[%d]",
1455                device, input, codename, code);
1456
1457     /* search input device table                */
1458     inputdev = gIco_Uxf_Api_Mng.InputDev;
1459     while (inputdev)    {
1460         if (strcasecmp(inputdev->device, device) == 0)  break;
1461         inputdev = inputdev->next;
1462     }
1463     if (! inputdev) {
1464         uifw_error("ico_uxf_input_codecb: device.%s dose not exist", device);
1465         return;
1466     }
1467
1468     /* search input switch                      */
1469     inputsw = inputdev->inputSw;
1470     while (inputsw) {
1471         if (inputsw->input == input)    break;
1472         inputsw = inputsw->next;
1473     }
1474     if (! inputsw)  {
1475         uifw_error("ico_uxf_input_codecb: device.%s input=%d dose not exist",
1476                    device, input);
1477         return;
1478     }
1479     for (i = 0; i < inputsw->numCode; i++)  {
1480         if (inputsw->inputCode[i].code == code) break;
1481     }
1482     if (i >= inputsw->numCode)  {
1483         if (i >= 8) {
1484             uifw_error("ico_uxf_input_codecb: device.%s input=%d number of codes overflow",
1485                        device, input);
1486             return;
1487         }
1488         inputsw->numCode ++;
1489         i = inputsw->numCode - 1;
1490     }
1491     memset(inputsw->inputCode[i].codename, 0, sizeof(inputsw->inputCode[i].codename));
1492     strncpy(inputsw->inputCode[i].codename, codename,
1493             sizeof(inputsw->inputCode[i].codename)-1);
1494     inputsw->inputCode[i].code = code;
1495 }
1496
1497 /*--------------------------------------------------------------------------*/
1498 /**
1499  * @brief   ico_uxf_input_inputcb: wayland extended input
1500  *                                 input switch callback(static function)
1501  *
1502  * @param[in]   data            user data(unused)
1503  * @param[in]   ico_exinput     wayland ico_input_mgr plugin interface
1504  * @param[in]   time            input time(miri-sec)
1505  * @param[in]   device          input device name
1506  * @param[in]   input           input switch number
1507  * @param[in]   code            input code value
1508  * @param[in]   state           input state(1=switch On/0=switch Off)
1509  * @return      none
1510  */
1511 /*--------------------------------------------------------------------------*/
1512 static void
1513 ico_uxf_input_inputcb(void *data, struct ico_exinput *ico_exinput, uint32_t time,
1514                       const char *device, int32_t input, int32_t code, int32_t state)
1515 {
1516     Ico_Uxf_Mng_EventQue *que;
1517     uifw_trace("ico_uxf_input_inputcb: device=%s input=%d code=%d state=%d",
1518                device, input, code, state);
1519
1520     if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_EXINPUT)    {
1521
1522         ico_uxf_enter_critical();
1523         que = ico_uxf_alloc_eventque();
1524
1525         strncpy(que->detail.exinput.device, device,
1526                 sizeof(que->detail.exinput.device)-1);
1527         que->detail.exinput.input = input;
1528         que->detail.exinput.code = code;
1529         que->detail.exinput.state = state;
1530
1531         ico_uxf_regist_eventque(que);
1532         ico_uxf_leave_critical();
1533     }
1534 }
1535
1536 /*--------------------------------------------------------------------------*/
1537 /**
1538  * @brief   ico_uxf_aul_aulcb: AppCore(AUL) application launch/dead callback(static function)
1539  *
1540  * @param[in]   pid             target application process Id
1541  * @param[in]   data            user data(0=launch, 1=dead)
1542  * @return      result(always 0, means success)
1543  */
1544 /*--------------------------------------------------------------------------*/
1545 static int
1546 ico_uxf_aul_aulcb(int pid, void *data)
1547 {
1548     Ico_Uxf_Mng_Process     *proc;
1549     int                     hash;
1550     Ico_Uxf_Mng_EventQue    *que;
1551     int                     dead;
1552     char                    appid[ICO_UXF_MAX_PROCESS_NAME+1];
1553
1554     dead = (int)data;
1555     memset(appid, 0, sizeof(appid));
1556     if (dead == 0)  {
1557         (void) aul_app_get_appid_bypid(pid, appid, sizeof(appid));
1558         uifw_trace("ico_uxf_aul_aulcb: Enter(pid=%d, dead=No, appid=%s)", pid, appid);
1559     }
1560     else    {
1561         uifw_trace("ico_uxf_aul_aulcb: Enter(pid=%d, dead=Yes)", pid);
1562     }
1563     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
1564         proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
1565         while (proc)   {
1566             if (proc->attr.internalid == pid) break;
1567             if (strcmp(proc->attr.process, appid) == 0) break;
1568             proc = proc->nextidhash;
1569         }
1570         if (proc) break;
1571     }
1572     if (! proc) {
1573         /* not handle process,  */
1574         /* or the process is correctly terminated by ico_uxf_process_terminate */
1575         uifw_trace("ico_uxf_aul_aulcb: Leave(not find)");
1576         return 0;
1577     }
1578     uifw_trace("ico_uxf_aul_aulcb: find(appid=%s)", proc->attr.process);
1579
1580     ico_uxf_enter_critical();
1581     /* set event */
1582     que = ico_uxf_alloc_eventque();
1583     strncpy(que->detail.process.process, proc->attr.process, ICO_UXF_MAX_PROCESS_NAME);
1584     if (dead)   {
1585         que->detail.event = ICO_UXF_EVENT_TERMPROCESS;
1586         que->detail.process.status = ICO_UXF_PROCSTATUS_STOP;
1587
1588         /* delete process info */
1589         proc->attr.status = ICO_UXF_PROCSTATUS_STOP;
1590         proc->attr.internalid = -1;
1591         proc->attr.mainwin.window = 0;
1592         ico_uxf_free_procwin(proc);
1593     }
1594     else    {
1595         que->detail.event = ICO_UXF_EVENT_EXECPROCESS;
1596         que->detail.process.status = ICO_UXF_PROCSTATUS_RUN;
1597
1598         /* setup process info */
1599         if (proc->attr.status != ICO_UXF_PROCSTATUS_RUN)    {
1600             proc->attr.internalid = pid;
1601             if (proc->attr.status != ICO_UXF_PROCSTATUS_INIT)   {
1602                 /* child process, search parent process */
1603                 uifw_trace("ico_uxf_aul_aulcb: fork&exec %s", proc->attr.process);
1604                 proc->attr.child = 1;
1605                 /* save parent application if exist     */
1606                 if (gIco_Uxf_Api_Mng.Mng_LastProcess != proc)   {
1607                     proc->parent = gIco_Uxf_Api_Mng.Mng_LastProcess;
1608                 }
1609                 else    {
1610                     uifw_trace("ico_uxf_aul_aulcb: same process %s real %s", proc->attr.process,
1611                                proc->parent ? proc->parent->attr.process : "(None)");
1612                 }
1613             }
1614             else    {
1615                 proc->attr.child = 0;
1616             }
1617             proc->attr.status = ICO_UXF_PROCSTATUS_RUN;
1618         }
1619     }
1620
1621     /* notify event */
1622     ico_uxf_regist_eventque(que);
1623
1624     ico_uxf_leave_critical();
1625
1626     uifw_trace("ico_uxf_aul_aulcb: Leave");
1627     return 0;
1628 }
1629
1630 /*--------------------------------------------------------------------------*/
1631 /**
1632  * @brief   ico_uxf_set_lastapp: save last application
1633  *
1634  * @param[in]   appid   applicationId (if NULL, no last application)
1635  * @return      none
1636  */
1637 /*--------------------------------------------------------------------------*/
1638 ICO_APF_API void
1639 ico_uxf_set_lastapp(const char *appid)
1640 {
1641     if (appid)  {
1642         gIco_Uxf_Api_Mng.Mng_LastProcess = ico_uxf_mng_process(appid, 0);
1643     }
1644     else    {
1645         gIco_Uxf_Api_Mng.Mng_LastProcess = NULL;
1646     }
1647 }
1648
1649 /*--------------------------------------------------------------------------*/
1650 /**
1651  * @brief   ico_uxf_getchild_appid: get child applicationId
1652  *
1653  * @param[in]   appid   parent applicationId
1654  * @return      last child applicationId
1655  * @retval      !=NULL      success(applicationId)
1656  * @retval      ==NULL      no child application
1657  */
1658 /*--------------------------------------------------------------------------*/
1659 ICO_APF_API char *
1660 ico_uxf_getchild_appid(const char *appid)
1661 {
1662     Ico_Uxf_Mng_Process *pproc;
1663     Ico_Uxf_Mng_Process *proc;
1664     int     hash;
1665
1666     pproc = ico_uxf_mng_process(appid, 0);
1667     if (! pproc)    {
1668         /* unknown parent application, no child     */
1669         uifw_trace("ico_uxf_getchild_appid: Unknown parent(%s)", appid);
1670         return NULL;
1671     }
1672
1673     /* search parent        */
1674     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)    {
1675         proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
1676         while (proc)    {
1677             if (proc->parent == pproc)  {
1678                 uifw_trace("ico_uxf_getchild_appid: child(%s) parent(%s)",
1679                            proc->attr.process, appid);
1680                 return proc->attr.process;
1681             }
1682             proc = proc->nextidhash;
1683         }
1684     }
1685     uifw_trace("ico_uxf_getchild_appid: parent(%s) has no child", appid);
1686     return NULL;
1687 }
1688
1689 /*--------------------------------------------------------------------------*/
1690 /**
1691  * @brief   ico_uxf_set_lastapp: save last application
1692  *
1693  * @param[in]   appid   applicationId (if NULL, no last application)
1694  * @return      none
1695  */
1696 /*--------------------------------------------------------------------------*/
1697 ICO_APF_API void
1698 ico_uxf_timer_wake(const int msec)
1699 {
1700     Ico_Uxf_Mng_Process *proc;
1701     int     hash;
1702
1703     if (gIco_Uxf_Api_Mng.InitTimer > 0) {
1704         gIco_Uxf_Api_Mng.InitTimer -= msec;
1705         if (gIco_Uxf_Api_Mng.InitTimer > 0) {
1706             return;
1707         }
1708         gIco_Uxf_Api_Mng.InitTimer = 0;
1709     }
1710
1711     if (gIco_Uxf_Api_Mng.NeedTimer == 0)    {
1712         return;
1713     }
1714     gIco_Uxf_Api_Mng.NeedTimer = 0;
1715     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)    {
1716         proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
1717         while (proc)    {
1718             if (proc->susptimer > 0)    {
1719                 if (msec >= proc->susptimer)    {
1720                     proc->susptimer = 0;
1721                     if (proc->attr.suspend) {
1722                         if (proc->susp == 0)    {
1723                             proc->susp = 1;
1724                             uifw_trace("ico_uxf_timer_wake: CPU suspend pid=%d",
1725                                        proc->attr.internalid);
1726                             kill(proc->attr.internalid, SIGSTOP);
1727                         }
1728                     }
1729                     else if (proc->susp == 0)    {
1730                         uifw_trace("ico_uxf_timer_wake: CPU resume pid=%d(show=%d)",
1731                                    proc->attr.internalid, proc->showmode);
1732                         ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
1733                                                    proc->attr.mainwin.window,
1734                                                    ICO_WINDOW_MGR_VISIBLE_SHOW,
1735                                                    ICO_WINDOW_MGR_V_NOCHANGE,
1736                                                    (proc->showmode != 0) ?
1737                                                      ICO_WINDOW_MGR_ANIMATION_ANIMATION :
1738                                                      ICO_WINDOW_MGR_ANIMATION_NOANIMATION);
1739                         wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
1740                     }
1741                 }
1742                 else    {
1743                     proc->susptimer -= msec;
1744                     gIco_Uxf_Api_Mng.NeedTimer ++;
1745                 }
1746             }
1747             proc = proc->nextidhash;
1748         }
1749     }
1750 }
1751
1752 /*--------------------------------------------------------------------------*/
1753 /**
1754  * @brief   ico_uxf_enter_critical: enter critical section(internal function)
1755  *
1756  * @param       none
1757  * @return      none
1758  */
1759 /*--------------------------------------------------------------------------*/
1760 void
1761 ico_uxf_enter_critical(void)
1762 {
1763     if (pthread_mutex_lock(&sMutex)) {
1764         uifw_error("ico_uxf_enter_critical: Error<%d>", errno);
1765     }
1766 }
1767
1768 /*--------------------------------------------------------------------------*/
1769 /**
1770  * @brief   ico_uxf_leave_critical: leave critical section(internal function)
1771  *
1772  * @param       none
1773  * @return      none
1774  */
1775 /*--------------------------------------------------------------------------*/
1776 void
1777 ico_uxf_leave_critical(void)
1778 {
1779     if (pthread_mutex_unlock(&sMutex))   {
1780         uifw_error("ico_uxf_leave_critical: Error<%d>", errno);
1781     }
1782 }
1783
1784 /*--------------------------------------------------------------------------*/
1785 /**
1786  * @brief   ico_uxf_alloc_callback: allocate callback management table(internal function)
1787  *
1788  * @param       none
1789  * @return      allocated callback management table address
1790  */
1791 /*--------------------------------------------------------------------------*/
1792 Ico_Uxf_Mng_Callback *
1793 ico_uxf_alloc_callback(void)
1794 {
1795     Ico_Uxf_Mng_Callback    *p;
1796     int                     idx;
1797
1798     p = gIco_Uxf_Api_Mng.CallbackFree;
1799     if (! p)   {
1800         p = (Ico_Uxf_Mng_Callback *)malloc(sizeof(Ico_Uxf_Mng_Callback) *
1801                                            ICO_UXF_MNG_BLOCK_ALLOCS);
1802         if (! p)   {
1803             uifw_error("ico_uxf_alloc_callback: NO Memory (malloc Error)");
1804             exit(1);
1805         }
1806         gIco_Uxf_Api_Mng.CallbackFree = p;
1807
1808         for (idx = 0; idx < ICO_UXF_MNG_BLOCK_ALLOCS; idx++, p++)  {
1809             if (idx != (ICO_UXF_MNG_BLOCK_ALLOCS-1))   {
1810                 p->next = (p+1);
1811             }
1812             else    {
1813                 p->next = (struct _Ico_Uxf_Mng_Callback *)0;
1814             }
1815         }
1816         p = gIco_Uxf_Api_Mng.CallbackFree;
1817     }
1818     gIco_Uxf_Api_Mng.CallbackFree = p->next;
1819     return p;
1820 }
1821
1822 /*--------------------------------------------------------------------------*/
1823 /**
1824  * @brief   ico_uxf_free_callback: release callback management table(internal function)
1825  *
1826  * @param[in]   p           callback management table address
1827  * @return      none
1828  */
1829 /*--------------------------------------------------------------------------*/
1830 void
1831 ico_uxf_free_callback(Ico_Uxf_Mng_Callback *p)
1832 {
1833     p->next = gIco_Uxf_Api_Mng.CallbackFree;
1834     gIco_Uxf_Api_Mng.CallbackFree = p;
1835 }
1836
1837 /*--------------------------------------------------------------------------*/
1838 /**
1839  * @brief   ico_uxf_regist_callback: register a callback management table(internal function)
1840  *
1841  * @param[in]   p           callback management table address
1842  * @return      none
1843  */
1844 /*--------------------------------------------------------------------------*/
1845 void
1846 ico_uxf_regist_callback(Ico_Uxf_Mng_Callback *p)
1847 {
1848     p->next = (struct _Ico_Uxf_Mng_Callback *)0;
1849
1850     if (gIco_Uxf_Api_Mng.Callback) {
1851         gIco_Uxf_Api_Mng.CallbackLast->next = p;
1852         gIco_Uxf_Api_Mng.CallbackLast = p;
1853     }
1854     else    {
1855         gIco_Uxf_Api_Mng.Callback = p;
1856         gIco_Uxf_Api_Mng.CallbackLast = gIco_Uxf_Api_Mng.Callback;
1857     }
1858 }
1859
1860 /*--------------------------------------------------------------------------*/
1861 /**
1862  * @brief   ico_uxf_remove_callback: remove a callback management table(internal function)
1863  *
1864  * @param[in]   p           callback management table address
1865  * @return      none
1866  */
1867 /*--------------------------------------------------------------------------*/
1868 void
1869 ico_uxf_remove_callback(Ico_Uxf_Mng_Callback *p)
1870 {
1871     Ico_Uxf_Mng_Callback    *pp;
1872     Ico_Uxf_Mng_Callback    *before;
1873
1874     pp = gIco_Uxf_Api_Mng.Callback;
1875     before = (Ico_Uxf_Mng_Callback *)0;
1876
1877     while (pp) {
1878         if (pp == p)   break;
1879         before = pp;
1880         pp = pp->next;
1881     }
1882     if (pp)    {
1883         if (before)    {
1884             before->next = p->next;
1885             if (! p->next) {
1886                 gIco_Uxf_Api_Mng.CallbackLast = before;
1887             }
1888         }
1889         else    {
1890             gIco_Uxf_Api_Mng.Callback = p->next;
1891         }
1892     }
1893 }
1894
1895 /*--------------------------------------------------------------------------*/
1896 /**
1897  * @brief   ico_uxf_alloc_eventque: allocate event queue block(internal function)
1898  *
1899  * @param       none
1900  * @return      allocated event queue control block address
1901  */
1902 /*--------------------------------------------------------------------------*/
1903 Ico_Uxf_Mng_EventQue
1904 *ico_uxf_alloc_eventque(void)
1905 {
1906     Ico_Uxf_Mng_EventQue    *p;
1907     int                 idx;
1908
1909     p = gIco_Uxf_Api_Mng.EventQueFree;
1910     if (! p)   {
1911         p = (Ico_Uxf_Mng_EventQue *)
1912                 malloc(sizeof(Ico_Uxf_Mng_EventQue) * ICO_UXF_MNG_BLOCK_ALLOCS);
1913         if (! p)   {
1914             uifw_error("ico_uxf_alloc_eventque: NO Memory (malloc Error)");
1915             exit(1);
1916         }
1917         gIco_Uxf_Api_Mng.EventQueFree = p;
1918
1919         for (idx = 0; idx < ICO_UXF_MNG_BLOCK_ALLOCS; idx++, p++)  {
1920             if (idx != (ICO_UXF_MNG_BLOCK_ALLOCS-1))   {
1921                 p->next = (p+1);
1922             }
1923             else    {
1924                 p->next = (struct _Ico_Uxf_Mng_EventQue *)0;
1925             }
1926         }
1927         p = gIco_Uxf_Api_Mng.EventQueFree;
1928     }
1929     gIco_Uxf_Api_Mng.EventQueFree = p->next;
1930
1931     return p;
1932 }
1933
1934 /*--------------------------------------------------------------------------*/
1935 /**
1936  * @brief   ico_uxf_free_eventque: release event queue block(internal function)
1937  *
1938  * @param[in]   p       event queue control block address
1939  * @return      none
1940  */
1941 /*--------------------------------------------------------------------------*/
1942 void
1943 ico_uxf_free_eventque(Ico_Uxf_Mng_EventQue *p)
1944 {
1945     p->next = gIco_Uxf_Api_Mng.EventQueFree;
1946     gIco_Uxf_Api_Mng.EventQueFree = p;
1947 }
1948
1949 /*--------------------------------------------------------------------------*/
1950 /**
1951  * @brief   ico_uxf_regist_eventque: register a event queue(internal function)
1952  *
1953  * @param[in]   p       event queue control block address
1954  * @return      none
1955  */
1956 /*--------------------------------------------------------------------------*/
1957 void
1958 ico_uxf_regist_eventque(Ico_Uxf_Mng_EventQue *p)
1959 {
1960     p->next = (struct _Ico_Uxf_Mng_EventQue *)0;
1961
1962     if (gIco_Uxf_Api_Mng.EventQue) {
1963         gIco_Uxf_Api_Mng.EventQueLast->next = p;
1964         gIco_Uxf_Api_Mng.EventQueLast = p;
1965     }
1966     else    {
1967         gIco_Uxf_Api_Mng.EventQue = p;
1968         gIco_Uxf_Api_Mng.EventQueLast = gIco_Uxf_Api_Mng.EventQue;
1969     }
1970 }
1971
1972 /*--------------------------------------------------------------------------*/
1973 /**
1974  * @brief   ico_uxf_mng_display: get display management table(internal function)
1975  *
1976  * @param[in]   display     display Id
1977  * @param[in]   create      create flag(1=create tabell if not exist/0=not create)
1978  * @return      display management table address
1979  * @retval      !=NULL      display management table address
1980  * @retval      ==NULL      display dose not exist(parameter 'create' only 0)
1981  */
1982 /*--------------------------------------------------------------------------*/
1983 Ico_Uxf_Mng_Display *
1984 ico_uxf_mng_display(const int display, const int create)
1985 {
1986     Ico_Uxf_Mng_Display *p;
1987     Ico_Uxf_Mng_Display *plast;
1988
1989     p = gIco_Uxf_Api_Mng.Mng_Display;
1990     plast = (Ico_Uxf_Mng_Display *)0;
1991     while (p)  {
1992         if (p->attr.display == display)    break;
1993         plast = p;
1994         p = p->next;
1995     }
1996
1997     if ((! p) && (create != 0))   {
1998
1999         p = (Ico_Uxf_Mng_Display *) malloc(sizeof(Ico_Uxf_Mng_Display));
2000         if (! p)   {
2001             uifw_error("ico_uxf_mng_display: NO Memory (malloc Error)");
2002             exit(1);
2003         }
2004         memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Display));
2005         p->attr.display = display;
2006         if (plast) {
2007             plast->next = p;
2008         }
2009         else    {
2010             gIco_Uxf_Api_Mng.Mng_Display = p;
2011         }
2012     }
2013     return p;
2014 }
2015
2016 /*--------------------------------------------------------------------------*/
2017 /**
2018  * @brief   ico_uxf_mng_layer: get layer management table(internal function)
2019  *
2020  * @param[in]   display     display Id
2021  * @param[in]   layer       layer Id
2022  * @param[in]   create      create flag(1=create tabell if not exist/0=not create)
2023  * @return      layer management table address
2024  * @retval      !=NULL      layer management table address
2025  * @retval      ==NULL      layer dose not exist(parameter 'create' only 0)
2026  */
2027 /*--------------------------------------------------------------------------*/
2028 Ico_Uxf_Mng_Layer *
2029 ico_uxf_mng_layer(const int display, const int layer, const int create)
2030 {
2031     Ico_Uxf_Mng_Layer   *p;
2032     Ico_Uxf_Mng_Layer   *plast;
2033
2034     p = gIco_Uxf_Api_Mng.Mng_Layer;
2035     plast = (Ico_Uxf_Mng_Layer *)0;
2036     while (p)  {
2037         if ((p->attr.display == display) &&
2038             (p->attr.layer == layer))  break;
2039         plast = p;
2040         p = p->next;
2041     }
2042
2043     if ((! p) && (create != 0))   {
2044
2045         p = (Ico_Uxf_Mng_Layer *) malloc(sizeof(Ico_Uxf_Mng_Layer));
2046         if (! p)   {
2047             uifw_error("ico_uxf_mng_layer: NO Memory (malloc Error)");
2048             exit(1);
2049         }
2050         memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Layer));
2051         p->attr.layer = layer;
2052         if (plast) {
2053             plast->next = p;
2054         }
2055         else    {
2056             gIco_Uxf_Api_Mng.Mng_Layer = p;
2057         }
2058     }
2059     return p;
2060 }
2061
2062 /*--------------------------------------------------------------------------*/
2063 /**
2064  * @brief   ico_uxf_mng_window: get window management table(internal function)
2065  *
2066  * @param[in]   window      window Id(same as ico_window_mgr surface Id)
2067  * @param[in]   create      create flag(1=create tabell if not exist/0=not create)
2068  * @return      window management table address
2069  * @retval      !=NULL      window management table address
2070  * @retval      ==NULL      window dose not exist(parameter 'create' only 0)
2071  */
2072 /*--------------------------------------------------------------------------*/
2073 Ico_Uxf_Mng_Window *
2074 ico_uxf_mng_window(const int window, const int create)
2075 {
2076     Ico_Uxf_Mng_Window  *p;
2077     Ico_Uxf_Mng_Window  *plast = (Ico_Uxf_Mng_Window *)0;
2078     int                 hash;
2079
2080     hash = ICO_UXF_MISC_HASHBYID(window);
2081     p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
2082     while (p)  {
2083         if (p->attr.window == window)  break;
2084         plast = p;
2085         p = p->nextidhash;
2086     }
2087
2088     if ((! p) && (create != 0))    {
2089
2090         p = (Ico_Uxf_Mng_Window *) malloc(sizeof(Ico_Uxf_Mng_Window));
2091         if (! p)   {
2092             uifw_error("ico_uxf_mng_window: NO Memory (malloc Error)");
2093             exit(1);
2094         }
2095         memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Window));
2096         p->attr.window = window;
2097         if (plast) {
2098             plast->nextidhash = p;
2099         }
2100         else    {
2101             gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
2102         }
2103         uifw_trace("ico_uxf_mng_window: Create New Table=%08x", (int)p);
2104     }
2105     return p;
2106 }
2107
2108 /*--------------------------------------------------------------------------*/
2109 /**
2110  * @brief   ico_uxf_mng_process: get process management table(internal function)
2111  *
2112  * @param[in]   process     application Id
2113  * @param[in]   create      create flag(1=create tabell if not exist/0=not create)
2114  * @return      process management table address
2115  * @retval      !=NULL      process management table address
2116  * @retval      ==NULL      process dose not exist(parameter 'create' only 0)
2117  */
2118 /*--------------------------------------------------------------------------*/
2119 Ico_Uxf_Mng_Process *
2120 ico_uxf_mng_process(const char *process, const int create)
2121 {
2122     Ico_Uxf_Mng_Process *p;
2123     Ico_Uxf_Mng_Process *plast = (Ico_Uxf_Mng_Process *)0;
2124     int                 hash;
2125
2126     hash = ICO_UXF_MISC_HASHBYNAME(process);
2127     p = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
2128     while (p)  {
2129         if(strncmp(p->attr.process, process, ICO_UXF_MAX_PROCESS_NAME) == 0) break;
2130         plast = p;
2131         p = p->nextidhash;
2132     }
2133
2134     if ((! p) && (create != 0))   {
2135
2136         p = (Ico_Uxf_Mng_Process *) malloc(sizeof(Ico_Uxf_Mng_Process));
2137         if (! p)   {
2138             uifw_error("ico_uxf_mng_process: NO Memory (malloc Error)");
2139             exit(1);
2140         }
2141         memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Process));
2142         strncpy(p->attr.process, process, ICO_UXF_MAX_PROCESS_NAME);
2143         if (plast) {
2144             plast->nextidhash = p;
2145         }
2146         else    {
2147             gIco_Uxf_Api_Mng.Hash_ProcessId[hash] = p;
2148         }
2149     }
2150     return p;
2151 }
2152
2153 /*--------------------------------------------------------------------------*/
2154 /**
2155  * @brief   ico_uxf_update_procwin: update a process management table
2156  *
2157  * @param[in]   appid       application id
2158  * @param[in]   type        type(install/uninstall)
2159  * @param[in]   func        window create/destroy hook function
2160  * @return      none
2161  */
2162 /*--------------------------------------------------------------------------*/
2163 ICO_APF_API void
2164 ico_uxf_update_procwin(const char *appid, int type)
2165 {
2166     Ico_Uxf_Mng_Process     *prc = NULL;
2167     Ico_Uxf_Sys_Config      *sysconf;
2168     Ico_Uxf_App_Config      *appconf;
2169     Ico_Uxf_conf_appdisplay *appdsp;
2170     int                     dn, tn;
2171     Ico_Uxf_conf_application *app = NULL;
2172
2173     uifw_trace("ico_uxf_update_procwin: Enter(appid=%s, type=%d)", appid, type);
2174
2175     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
2176         uifw_trace("ico_uxf_callback_remove: Leave(not initialized)");
2177         return;
2178     }
2179     prc = ico_uxf_mng_process(appid, 0);
2180
2181     if (type == ICO_UXF_CONF_EVENT_INSTALL) {
2182         if (!prc) {
2183             sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
2184             appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
2185             if ((sysconf == NULL) || (appconf == NULL)) {
2186                 uifw_trace("ico_uxf_update_procwin: Leave(cannot find tables)");
2187                 return;
2188             }
2189             for (dn = 0;  dn < appconf->applicationNum; dn++) {
2190                 app = &appconf->application[dn];
2191                 if (strncmp(app->appid, appid, ICO_UXF_MAX_PROCESS_NAME) == 0) {
2192                     uifw_trace("ico_uxf_update_procwin: Install(%s)", appid);
2193                     /* add process management table */
2194                     prc = ico_uxf_mng_process(appid, 1);
2195                     prc->attr.internalid = 0;
2196                     prc->attr.status = ICO_UXF_PROCSTATUS_STOP;
2197                     prc->attr.type = app->categoryId;
2198                     prc->attr.hostId = app->hostId;
2199                     prc->attr.myHost = (prc->attr.hostId == sysconf->misc.myhostId) ? 1 : 0;
2200
2201                     appdsp = &app->display[0];
2202                     prc->attr.mainwin.window = 0;
2203                     prc->attr.mainwin.windowtype = app->categoryId;
2204                     prc->attr.mainwin.display = appdsp->displayId;
2205                     prc->attr.mainwin.layer = appdsp->layerId;
2206                     prc->attr.mainwin.x =
2207                             sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
2208                     prc->attr.mainwin.y =
2209                             sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
2210                     prc->attr.mainwin.w =
2211                             sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
2212                     prc->attr.mainwin.h =
2213                             sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
2214                     prc->attr.mainwin.name[ICO_UXF_MAX_WIN_NAME] = 0;
2215                     prc->attr.numwindows = app->displayzoneNum;
2216                     /* get sub windows                          */
2217                     if (prc->attr.numwindows > 1)   {
2218                         prc->attr.subwin = malloc(sizeof(Ico_Uxf_ProcessWin) *
2219                                                   (prc->attr.numwindows - 1));
2220                         if (! prc->attr.subwin) {
2221                             uifw_trace("ico_uxf_update_procwin: Install(No memory)");
2222                             app->displayzoneNum = 1;
2223                             prc->attr.numwindows = 1;
2224                         }
2225                         else    {
2226                             memset(prc->attr.subwin, 0, (prc->attr.numwindows - 1));
2227                             for (tn = 0; tn < (prc->attr.numwindows - 1); tn++) {
2228                                 appdsp ++;
2229                                 prc->attr.subwin[tn].windowtype = prc->attr.mainwin.windowtype;
2230                                 prc->attr.subwin[tn].display = appdsp->displayId;
2231                                 prc->attr.subwin[tn].layer = appdsp->layerId;
2232                                 prc->attr.subwin[tn].x =
2233                                     sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
2234                                 prc->attr.subwin[tn].y =
2235                                     sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
2236                                 prc->attr.subwin[tn].w =
2237                                     sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
2238                                 prc->attr.subwin[tn].h =
2239                                     sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
2240                             }
2241                         }
2242                     }
2243                 }
2244             }
2245         }
2246     }
2247     else if (type == ICO_UXF_CONF_EVENT_UNINSTALL) {
2248         if (prc) {
2249             /* not delete process management table */
2250         }
2251     }
2252
2253     uifw_trace("ico_uxf_update_procwin: Leave");
2254
2255     return;
2256 }
2257
2258 /*--------------------------------------------------------------------------*/
2259 /**
2260  * @brief   ico_uxf_window_screen_size_get: get display physical size
2261  *
2262  * @param[out]  width       variable to receive the width of the display
2263  * @param[out]  height      variable to receive the height of the display
2264  * @return      none
2265  */
2266 /*--------------------------------------------------------------------------*/
2267 ICO_APF_API void
2268 ico_uxf_window_screen_size_get(int *width, int *height)
2269 {
2270     Ico_Uxf_Mng_Display *dsp;
2271     dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
2272
2273     uifw_trace("ico_uxf_window_screen_size_get: Enter(dsp=%d(%d))",
2274                dsp, gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display);
2275
2276     if ((dsp != NULL) && (width != NULL) && (height != NULL)) {
2277         uifw_trace("ico_uxf_window_screen_size_get: %dx%d",
2278                    dsp->attr.pWidth, dsp->attr.pHeight);
2279         *width = dsp->attr.pWidth;
2280         *height = dsp->attr.pHeight;
2281     }
2282 }
2283
2284 /*--------------------------------------------------------------------------*/
2285 /**
2286  * @brief   ico_uxf_window_hook: set window create/destroy hook function
2287  *
2288  * @param[in]   func        window create/destroy hook function
2289  * @return      none
2290  */
2291 /*--------------------------------------------------------------------------*/
2292 ICO_APF_API void
2293 ico_uxf_window_hook(Ico_Uxf_Hook func)
2294 {
2295     uifw_trace("ico_uxf_window_hook: Window Control Hook=%08x", (int)func);
2296
2297     gIco_Uxf_Api_Mng.Hook_Window = func;
2298 }
2299