Bug fix TIVI-839 ,change the design and permit operation of the music player while...
[profile/ivi/ico-uxf-homescreen.git] / ico-app-framework / ico_uxf_window.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   header file of Window control for HomeScreen
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    <signal.h>
20 #include    <errno.h>
21
22 #include    "ico_uxf.h"
23 #include    "ico_uxf_private.h"
24 #include    "ico_window_mgr-client-protocol.h"
25
26 extern Ico_Uxf_Api_Mng         gIco_Uxf_Api_Mng;
27
28 /*--------------------------------------------------------------------------*/
29 /**
30  * @brief   ico_uxf_window_visible_control: window visible control(internal function)
31  *
32  * @param[in]   winmng          process management table
33  * @param[in]   show            show(1)/hide(0)/nochange(9)
34  * @param[in]   raise           raise(1)/lower(0)/nochange(9)
35  * @return      none
36  */
37 /*--------------------------------------------------------------------------*/
38 void
39 ico_uxf_window_visible_control(Ico_Uxf_Mng_Window *winmng, const int show, const int raise)
40 {
41     uifw_trace("ico_uxf_window_visible_control: send visible to weston(%s,%08x,%d,%d)",
42                (winmng->mng_process)->attr.process, winmng->attr.window, show, raise);
43     if ((show == 1) && ((winmng->mng_process)->attr.invisiblecpu == 0) &&
44         ((winmng->mng_process)->attr.suspend != 0))   {
45         /* change to show, application resume   */
46         (winmng->mng_process)->attr.suspend = 0;
47         (winmng->mng_process)->susptimer = 0;
48         if ((winmng->mng_process)->susp)    {
49             (winmng->mng_process)->susp = 0;
50             uifw_trace("ico_uxf_window_visible_control: CPU resume(%s)",
51                        (winmng->mng_process)->attr.process);
52             kill((winmng->mng_process)->attr.internalid, SIGCONT);
53         }
54     }
55
56     /* send visible control to Weston(Multi Window Manager)     */
57     ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
58                                winmng->attr.window, show, raise);
59     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
60
61     if ((show == 0) && ((winmng->mng_process)->attr.invisiblecpu == 0) &&
62         ((winmng->mng_process)->attr.suspend == 0))   {
63         /* change to hide, application suspend  */
64         (winmng->mng_process)->attr.suspend = 1;
65         (winmng->mng_process)->susptimer = ICO_UXF_SUSP_DELAY;
66         gIco_Uxf_Api_Mng.NeedTimer = 1;
67         uifw_trace("ico_uxf_window_visible_control: set CPU suspend(%s)",
68                    (winmng->mng_process)->attr.process);
69     }
70 }
71
72 /*--------------------------------------------------------------------------*/
73 /**
74  * @brief   ico_uxf_window_layer: Set window layer
75  *
76  * @param[in]   window          window Id
77  * @param[in]   layer           layer Id
78  * @return      result
79  * @retval      ICO_UXF_EOK     success
80  * @retval      ICO_UXF_ESRCH   error(not initialized)
81  * @retval      ICO_UXF_ENOENT  error(window or layer dose not exist)
82  */
83 /*--------------------------------------------------------------------------*/
84 ICO_APF_API int
85 ico_uxf_window_layer(const int window, const int layer)
86 {
87     Ico_Uxf_Mng_Window  *winmng;
88     Ico_Uxf_Mng_Layer   *layermng;
89
90     uifw_trace("ico_uxf_window_layer: Enter(%08x,%d)", window, layer);
91
92     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
93         uifw_warn("ico_uxf_window_layer: Leave(ESRCH)");
94         return ICO_UXF_ESRCH;
95     }
96
97     winmng = ico_uxf_mng_window(window, 0);
98     if ((! winmng) || (! winmng->mng_display)) {
99         uifw_warn("ico_uxf_window_layer: Leave(ENOENT)");
100         return ICO_UXF_ENOENT;
101     }
102
103     layermng = ico_uxf_mng_layer(winmng->attr.display, layer, 0);
104     if ((! layermng) || (! layermng->mng_display)) {
105         uifw_warn("ico_uxf_window_layer: Leave(ENOENT)");
106         return ICO_UXF_ENOENT;
107     }
108
109     uifw_trace("ico_uxf_window_layer: ico_window_mgr_set_window_layer(%08x,%d)",
110                window, layer);
111     winmng->mng_layer = layermng;
112     ico_window_mgr_set_window_layer(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, layer);
113     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
114
115     uifw_trace("ico_uxf_window_layer: Leave(EOK)");
116     return ICO_UXF_EOK;
117 }
118
119 /*--------------------------------------------------------------------------*/
120 /**
121  * @brief   ico_uxf_layer_visible: Control layer visibility
122  *
123  * @param[in]   display         display Id
124  * @param[in]   layer           layer Id
125  * @param[in]   visible         layer show(1)/hide(0)
126  * @return      result
127  * @retval      ICO_UXF_EOK     success
128  * @retval      ICO_UXF_ESRCH   error(not initialized)
129  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
130  */
131 /*--------------------------------------------------------------------------*/
132 ICO_APF_API int
133 ico_uxf_layer_visible(const int display, const int layer, const int visible)
134 {
135     Ico_Uxf_Mng_Layer   *layermng;
136
137     uifw_trace("ico_uxf_layer_visible: Enter(%d,%d,%d)", display, layer, visible);
138
139     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
140         uifw_warn("ico_uxf_layer_visible: Leave(ESRCH)");
141         return ICO_UXF_ESRCH;
142     }
143
144     layermng = ico_uxf_mng_layer(display, layer, 0);
145     if ((! layermng) || (! layermng->mng_display)) {
146         uifw_warn("ico_uxf_layer_visible: Leave(ENOENT)");
147         return ICO_UXF_ENOENT;
148     }
149
150     uifw_trace("ico_uxf_layer_visible: ico_window_mgr_set_layer_visible(%d,%d)",
151                layer, visible);
152     ico_window_mgr_set_layer_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr, layer, visible);
153     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
154
155     uifw_trace("ico_uxf_layer_visible: Leave(EOK)");
156     return ICO_UXF_EOK;
157 }
158
159 /*--------------------------------------------------------------------------*/
160 /**
161  * @brief   ico_uxf_window_resize: resize window(surface) size
162  *
163  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
164  * @param[in]   w               window width
165  * @param[in]   h               window height
166  * @return      result
167  * @retval      ICO_UXF_EOK     success
168  * @retval      ICO_UXF_ESRCH   error(not initialized)
169  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
170  */
171 /*--------------------------------------------------------------------------*/
172 ICO_APF_API int
173 ico_uxf_window_resize(const int window, const int w, const int h)
174 {
175     Ico_Uxf_Mng_Window  *winmng;
176
177     uifw_trace("ico_uxf_window_resize: Enter(%08x,%d,%d)", window, w, h);
178
179     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
180         uifw_warn("ico_uxf_window_resize: Leave(ESRCH)");
181         return ICO_UXF_ESRCH;
182     }
183
184     winmng = ico_uxf_mng_window(window, 0);
185     if ((! winmng) || (! winmng->mng_layer))   {
186         uifw_warn("ico_uxf_window_resize: Leave(ENOENT)");
187         return ICO_UXF_ENOENT;
188     }
189
190     if ((w <= 0) || (w > winmng->mng_layer->attr.w) ||
191         (h <= 0) || (h > winmng->mng_layer->attr.h))   {
192         uifw_warn("ico_uxf_window_resize: Leave(EINVAL)");
193         return ICO_UXF_EINVAL;
194     }
195
196     winmng->attr.w = w;
197     winmng->attr.h = h;
198
199     ico_window_mgr_set_positionsize(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window,
200                                     winmng->attr.x, winmng->attr.y,
201                                     winmng->attr.w, winmng->attr.h);
202     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
203
204     uifw_trace("ico_uxf_window_resize: Leave(EOK)");
205     return ICO_UXF_EOK;
206 }
207
208 /*--------------------------------------------------------------------------*/
209 /**
210  * @brief   ico_uxf_window_move: move window(surface) geometry
211  *
212  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
213  * @param[in]   x               window upper-left X coodinate of display
214  * @param[in]   y               window upper-left Y coodinate of display
215  * @return      result
216  * @retval      ICO_UXF_EOK     success
217  * @retval      ICO_UXF_ESRCH   error(not initialized)
218  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
219  */
220 /*--------------------------------------------------------------------------*/
221 ICO_APF_API int
222 ico_uxf_window_move(const int window, const int x, const int y)
223 {
224     Ico_Uxf_Mng_Window  *winmng;
225
226     uifw_trace("ico_uxf_window_move: Enter(%08x,%d,%d)", window, x, y);
227
228     if(gIco_Uxf_Api_Mng.Initialized <= 0)   {
229         uifw_warn("ico_uxf_window_move: Leave(ESRCH)");
230         return ICO_UXF_ESRCH;
231     }
232
233     winmng = ico_uxf_mng_window(window, 0);
234     if ((! winmng) || (! winmng->mng_layer))   {
235         uifw_warn("ico_uxf_window_move: Leave(ENOENT)");
236         return ICO_UXF_ENOENT;
237     }
238
239     winmng->attr.x = x;
240     winmng->attr.y = y;
241
242     ico_window_mgr_set_positionsize(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window,
243                                     winmng->attr.x, winmng->attr.y,
244                                     winmng->attr.w, winmng->attr.h);
245     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
246
247     uifw_trace("ico_uxf_window_move: Leave(EOK)");
248     return ICO_UXF_EOK;
249 }
250
251 /*--------------------------------------------------------------------------*/
252 /**
253  * @brief   ico_uxf_window_raise: raise window(surface)
254  *
255  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
256  * @return      result
257  * @retval      ICO_UXF_EOK     success
258  * @retval      ICO_UXF_ESRCH   error(not initialized)
259  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
260  */
261 /*--------------------------------------------------------------------------*/
262 ICO_APF_API int
263 ico_uxf_window_raise(const int window)
264 {
265     Ico_Uxf_Mng_Window  *winmng;
266
267     uifw_trace("ico_uxf_window_raise: Enter(%08x)", window);
268
269     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
270         uifw_warn("ico_uxf_window_raise: Leave(ESRCH)");
271         return ICO_UXF_ESRCH;
272     }
273
274     winmng = ico_uxf_mng_window(window, 0);
275     if ((! winmng) || (! winmng->mng_display)) {
276         uifw_warn("ico_uxf_window_raise: Leave(ENOENT)");
277         return ICO_UXF_ENOENT;
278     }
279
280     ico_uxf_window_visible_control(winmng, 9, 1);
281
282     uifw_trace("ico_uxf_window_raise: Leave(EOK)");
283     return ICO_UXF_EOK;
284 }
285
286 /*--------------------------------------------------------------------------*/
287 /**
288  * @brief   ico_uxf_window_lower: lower window(surface)
289  *
290  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
291  * @return      result
292  * @retval      ICO_UXF_EOK     success
293  * @retval      ICO_UXF_ESRCH   error(not initialized)
294  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
295  */
296 /*--------------------------------------------------------------------------*/
297 ICO_APF_API int
298 ico_uxf_window_lower(const int window)
299 {
300     Ico_Uxf_Mng_Window  *winmng;
301
302     uifw_trace("ico_uxf_window_lower: Enter(%08x)", window);
303
304     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
305         uifw_warn("ico_uxf_window_lower: Leave(ESRCH)");
306         return ICO_UXF_ESRCH;
307     }
308
309     winmng = ico_uxf_mng_window(window, 0);
310     if ((! winmng) || (! winmng->mng_display)) {
311         uifw_warn("ico_uxf_window_lower: Leave(ENOENT)");
312         return ICO_UXF_ENOENT;
313     }
314
315     ico_uxf_window_visible_control(winmng, 9, 0);
316
317     uifw_trace("ico_uxf_window_lower: Leave(EOK)");
318     return ICO_UXF_EOK;
319 }
320
321 /*--------------------------------------------------------------------------*/
322 /**
323  * @brief   ico_uxf_window_active: active window(surface)
324  *
325  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
326  * @param[in]   target          target(pointer and/or keyboard)
327  * @return      result
328  * @retval      ICO_UXF_EOK     success
329  * @retval      ICO_UXF_ESRCH   error(not initialized)
330  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
331  */
332 /*--------------------------------------------------------------------------*/
333 ICO_APF_API int
334 ico_uxf_window_active(const int window, const int target)
335 {
336     Ico_Uxf_Mng_Window  *winmng;
337     Ico_Uxf_Mng_Process *proc;
338     Ico_Uxf_Mng_Process *aproc;
339     int                 hash;
340
341     uifw_trace("ico_uxf_window_active: Enter(%08x,%x)", window, target);
342
343     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
344         uifw_warn("ico_uxf_window_active: Leave(ESRCH)");
345         return ICO_UXF_ESRCH;
346     }
347
348     winmng = ico_uxf_mng_window(window, 0);
349     if ((! winmng) || (! winmng->mng_display)) {
350         uifw_warn("ico_uxf_window_active: Leave(ENOENT)");
351         return ICO_UXF_ENOENT;
352     }
353
354     uifw_trace("ico_uxf_window_active: ico_window_mgr_set_active(%08x)", window);
355     ico_window_mgr_set_active(gIco_Uxf_Api_Mng.Wayland_WindowMgr, window, target);
356     wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
357
358     /* reset all active window widthout target window   */
359     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)   {
360         winmng = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
361         while (winmng) {
362             if (winmng->attr.window == window)  {
363                 winmng->attr.active = target;
364             }
365             else    {
366                 if (target == 0)    {
367                     winmng->attr.active = 0;
368                 }
369                 else    {
370                     winmng->attr.active &= ~target;
371                 }
372             }
373             winmng = winmng->nextidhash;
374         }
375     }
376
377     /* reset all active application without this application    */
378     aproc = NULL;
379     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)    {
380         proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
381         while (proc)    {
382             if (proc->attr.mainwin.window == window)    {
383                 aproc = proc;
384             }
385             else    {
386                 if (target == 0)    {
387                     proc->attr.active = 0;
388                 }
389                 else    {
390                     proc->attr.active &= ~target;
391                 }
392             }
393             proc = proc->nextidhash;
394         }
395     }
396     aproc->attr.active = target;
397
398     uifw_trace("ico_uxf_window_active: Leave(EOK)");
399     return ICO_UXF_EOK;
400 }
401
402 /*--------------------------------------------------------------------------*/
403 /**
404  * @brief   ico_uxf_window_event_mask: set window(surface) event mask
405  *
406  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
407  * @param[in]   mask            event mask
408  * @return      result
409  * @retval      ICO_UXF_EOK     success
410  * @retval      ICO_UXF_ESRCH   error(not initialized)
411  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
412  */
413 /*--------------------------------------------------------------------------*/
414 ICO_APF_API int
415 ico_uxf_window_event_mask(const int window, const unsigned int mask)
416 {
417     Ico_Uxf_Mng_Window  *winmng;
418
419     uifw_trace("ico_uxf_window_event_mask: Enter(%08x,%08x)", window, mask);
420
421     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
422         uifw_warn("ico_uxf_window_event_mask: Leave(ESRCH)");
423         return ICO_UXF_ESRCH;
424     }
425
426     winmng = ico_uxf_mng_window(window, 0);
427     if (! winmng)  {
428         uifw_warn("ico_uxf_window_event_mask: Leave(ENOENT)");
429         return ICO_UXF_ENOENT;
430     }
431
432     winmng->attr.eventmask = mask;
433
434     uifw_trace("ico_uxf_window_event_mask: Leave(EOK)");
435     return ICO_UXF_EOK;
436 }
437
438 /*--------------------------------------------------------------------------*/
439 /**
440  * @brief   ico_uxf_window_attribute_get: get window(surface) attribute
441  *
442  * @param[in]   window          window Id(same as ico_window_mgr surface Id)
443  * @param[out]  attr            window attribute
444  * @return      result
445  * @retval      ICO_UXF_EOK     success
446  * @retval      ICO_UXF_ESRCH   error(not initialized)
447  * @retval      ICO_UXF_ENOENT  error(layer dose not exist)
448  */
449 /*--------------------------------------------------------------------------*/
450 ICO_APF_API int
451 ico_uxf_window_attribute_get(const int window, Ico_Uxf_WindowAttr *attr)
452 {
453     Ico_Uxf_Mng_Window  *winmng;
454
455     uifw_trace("ico_uxf_window_attribute_get: Enter(%08x)", window);
456
457     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
458         uifw_warn("ico_uxf_window_attribute_get: Leave(ESRCH)");
459         return ICO_UXF_ESRCH;
460     }
461
462     winmng = ico_uxf_mng_window(window, 0);
463     if (! winmng)  {
464         uifw_warn("ico_uxf_window_attribute_get: Leave(ENOENT)");
465         return ICO_UXF_ENOENT;
466     }
467
468     memcpy((char *)attr, (char *)&(winmng->attr), sizeof(Ico_Uxf_WindowAttr));
469
470     uifw_trace("ico_uxf_window_attribute_get: Leave(EOK)");
471     return ICO_UXF_EOK;
472 }
473
474 /*--------------------------------------------------------------------------*/
475 /**
476  * @brief   ico_uxf_window_query_windows: get all windows attribute
477  *
478  * @param[in]   display         target display Id
479  * @param[out]  attr            window attribute array
480  * @param[in]   num             number of window attribute area
481  * @return      result
482  * @retval      >= 0            success(number of windows)
483  * @retval      ICO_UXF_ESRCH   error(not initialized)
484  * @retval      ICO_UXF_EINVAL  error(illegal parameter 'num')
485  * @retval      ICO_UXF_E2BIG   error(number of windows over 'num')
486  */
487 /*--------------------------------------------------------------------------*/
488 ICO_APF_API int
489 ico_uxf_window_query_windows(const int display, Ico_Uxf_WindowAttr attr[], const int num)
490 {
491     int                 n;
492     Ico_Uxf_Mng_Window  *winmng;
493     int                 hash;
494
495     uifw_trace("ico_uxf_window_query_windows: Enter(%d,,%d)", display, num);
496
497     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
498         uifw_warn("ico_uxf_window_query_windows: Leave(ESRCH)");
499         return ICO_UXF_ESRCH;
500     }
501
502     if (num <= 0)  {
503         uifw_warn("ico_uxf_window_query_windows: Leave(EINVAL)");
504         return ICO_UXF_EINVAL;
505     }
506
507     n = 0;
508     for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)   {
509         winmng = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
510         while (winmng) {
511             if (n >= num)      break;
512             memcpy((char *)(&attr[n]), (char *)&(winmng->attr), sizeof(Ico_Uxf_WindowAttr));
513             n ++;
514             winmng = winmng->nextidhash;
515         }
516         if (winmng)    break;
517     }
518     if (winmng)    {
519         n = ICO_UXF_E2BIG;
520         uifw_trace("ico_uxf_window_query_windows: Leave(E2BIG)");
521     }
522     else    {
523         uifw_trace("ico_uxf_window_query_windows: Leave(%d)", n);
524     }
525     return n;
526 }
527
528 /*--------------------------------------------------------------------------*/
529 /**
530  * @brief   ico_uxf_window_control: target window control from AppsController
531  *
532  * @param[in]   appid       Application Id
533  * @param[in]   winidx      Window index
534  * @param[in]   control     Window control
535  *                            ICO_UXF_APPSCTL_INVISIBLE:   Invisible by low priority
536  *                            ICO_UXF_APPSCTL_REGULATION:  Invisible by regulation
537  *                            ICO_UXF_APPSCTL_TEMPVISIBLE: Visible as HomeScreen menu
538  * @param[in]   onoff       Flag On(1)/Off(0)
539  *                            ICO_UXF_APPSCTL_INVISIBLE:   On(1) is invisible
540  *                            ICO_UXF_APPSCTL_REGULATION:  On(1) is invisible
541  *                            ICO_UXF_APPSCTL_TEMPVISIBLE: On(1) is visible(menu)
542  * @return  result
543  * @retval  ICO_UXF_EOK         success
544  * @retval  ICO_UXF_ESRCH       error(not initialized)
545  * @retval  ICO_UXF_ENOENT      error(not exist)
546  */
547 /*--------------------------------------------------------------------------*/
548 ICO_APF_API int
549 ico_uxf_window_control(const char *appid, const int winidx,
550                        const int control, const int onoff)
551 {
552 #define MAX_APP_WINDOWS 20
553     Ico_Uxf_ProcessWin  procattr[MAX_APP_WINDOWS];
554     int         nwin;
555     Ico_Uxf_Mng_Window  *winmng;            /* window management table      */
556     int         hash;
557     int         newcontrol;
558     int         i;
559
560     uifw_trace("ico_uxf_window_control: Enter(%s,%d,%x,%d)",
561                appid, winidx, control, onoff);
562
563     if (gIco_Uxf_Api_Mng.Initialized <= 0)  {
564         uifw_warn("ico_uxf_window_control: Leave(ESRCH)");
565         return ICO_UXF_ESRCH;
566     }
567
568     if (control == ICO_UXF_APPSCTL_TEMPVISIBLE) {
569         if (onoff != gIco_Uxf_Api_Mng.AppsCtlVisible)   {
570             if (onoff > 0)  gIco_Uxf_Api_Mng.AppsCtlVisible = 1;
571             else            gIco_Uxf_Api_Mng.AppsCtlVisible = 0;
572
573             /* control all windows          */
574             for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++)    {
575                 winmng = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
576                 while (winmng)  {
577                     if ((winmng->attr.window > 0) && (winmng->attr.visible))    {
578                         if ((winmng->mng_process)->attr.noicon == 0)    {
579                             if ((gIco_Uxf_Api_Mng.AppsCtlVisible != 0) ||
580                                 (winmng->attr.control == 0))    {
581                                 i = 1;
582                             }
583                             else    {
584                                 i = 0;
585                             }
586                         }
587                         else    {
588                             if ((gIco_Uxf_Api_Mng.AppsCtlVisible == 0) &&
589                                 (winmng->attr.control == 0))    {
590                                 i = 1;
591                             }
592                             else    {
593                                 i = 0;
594                             }
595                         }
596                         ico_uxf_window_visible_control(winmng, i, 9);
597                     }
598                     winmng = winmng->nextidhash;
599                 }
600             }
601         }
602         uifw_trace("ico_uxf_window_control: Leave(EOK)");
603     }
604     else    {
605         /* get current application status       */
606         if (winidx >= 0)    {
607             nwin = ico_uxf_process_window_get_one(appid, procattr, winidx);
608             if (nwin == 0)  nwin = 1;
609         }
610         else    {
611             /* all window           */
612             nwin = ico_uxf_process_window_get(appid, procattr, MAX_APP_WINDOWS);
613         }
614         if (nwin == ICO_UXF_E2BIG)  nwin = MAX_APP_WINDOWS;
615         if (nwin < 0)  {
616             uifw_trace("ico_uxf_window_control: Leave(Unknown appid(%s))", appid);
617             return ICO_UXF_ENOENT;
618         }
619         for (i = 0; i < nwin; i++)  {
620             if (procattr[i].window == 0)    continue;
621             winmng = ico_uxf_mng_window(procattr[i].window, 0);
622             if (! winmng)   {
623                 uifw_trace("ico_uxf_window_control: winid=%08x not exist",
624                            procattr[i].window);
625                 continue;
626             }
627             newcontrol = winmng->attr.control;
628             if (onoff)  newcontrol |= control;
629             else        newcontrol &= (~control);
630
631             uifw_trace("ico_uxf_window_control: control %08x(%s) %02x=>%02x vis=%d icon=%d",
632                        procattr[i].window, (winmng->mng_process)->attr.process,
633                        winmng->attr.control, newcontrol, winmng->attr.visible,
634                        (winmng->mng_process)->attr.noicon);
635             if (winmng->attr.control != newcontrol) {
636                 winmng->attr.control = newcontrol;
637                 if (winmng->attr.visible != 0)  {
638                     if (gIco_Uxf_Api_Mng.AppsCtlVisible != 0)   {
639                         if ((winmng->mng_process)->attr.noicon == 0)    newcontrol = 0;
640                         else                                            newcontrol = 1;
641                     }
642                     /* request to Weston(Multi Window Manager)  */
643                     ico_uxf_window_visible_control(winmng,
644                                                    (newcontrol != 0) ? 0 : 1, 9);
645                 }
646             }
647             uifw_trace("ico_uxf_window_control: Leave(EOK) control=%x(%d) visible=%d",
648                        winmng->attr.control, gIco_Uxf_Api_Mng.AppsCtlVisible,
649                        winmng->attr.visible);
650         }
651     }
652     return ICO_UXF_EOK;
653 }
654
655 /*--------------------------------------------------------------------------*/
656 /**
657  * @brief   ico_uxf_window_show: show a target window
658  *          if target window's state is visible, do nothing and return success
659  *
660  * @param[in]   window      Window identity
661  * @return  result
662  * @retval  ICO_UXF_EOK         success
663  * @retval  ICO_UXF_ESRCH       error(not initialized)
664  * @retval  ICO_UXF_ENOENT      error(not exist)
665  */
666 /*--------------------------------------------------------------------------*/
667 ICO_APF_API int
668 ico_uxf_window_show(const int window)
669 {
670     Ico_Uxf_Mng_Window  *winmng;            /* window management table      */
671
672     uifw_trace("ico_uxf_window_show: Enter(%08x)", window);
673
674     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
675         uifw_warn("ico_uxf_window_show: Leave(ESRCH)");
676         return ICO_UXF_ESRCH;
677     }
678
679     winmng = ico_uxf_mng_window(window, 0);
680     if ((! winmng) || (! winmng->mng_display)) {
681         uifw_warn("ico_uxf_window_show: Leave(ENOENT)");
682         return ICO_UXF_ENOENT;
683     }
684     winmng->attr.visible = 1;
685
686     if (winmng->attr.control == 0)  {
687         /* request to display to Weston(Multi Window Manager)   */
688         ico_uxf_window_visible_control(winmng, 1, 9);
689     }
690     uifw_trace("ico_uxf_window_show: Leave(EOK) control=%x", winmng->attr.control);
691     return ICO_UXF_EOK;
692 }
693
694 /*--------------------------------------------------------------------------*/
695 /**
696  * @brief   ico_uxf_window_hide: hide a target window
697  *          if target window's state is unvisible, do nothing and return success
698  *
699  * @param[in]   window      target window identity
700  * @return  result
701  * @retval  ICO_UXF_EOK         success
702  * @retval  ICO_UXF_ESRCH       error(not initialized)
703  * @retval  ICO_UXF_ENOENT      error(not exist)
704  */
705 /*--------------------------------------------------------------------------*/
706 ICO_APF_API int
707 ico_uxf_window_hide(const int window)
708 {
709     Ico_Uxf_Mng_Window  *winmng;            /* window management table      */
710
711     uifw_trace("ico_uxf_window_hide: Enter(%08x)", window);
712
713     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
714         uifw_warn("ico_uxf_window_hide: Leave(ESRCH)");
715         return ICO_UXF_ESRCH;
716     }
717
718     winmng = ico_uxf_mng_window(window, 0);
719     if ((! winmng) || (! winmng->mng_display)) {
720         uifw_warn("ico_uxf_window_hide: Leave(ENOENT)");
721         return ICO_UXF_ENOENT;
722     }
723     winmng->attr.visible = 0;
724
725     /* request to hide to Weston(Multi Window Manager)  */
726     ico_uxf_window_visible_control(winmng, 0, 9);
727
728     uifw_trace("ico_uxf_window_hide: Leave(EOK)");
729     return ICO_UXF_EOK;
730 }
731
732 /*--------------------------------------------------------------------------*/
733 /**
734  * @brief   ico_uxf_window_visible_raise: control status of visible(show/hide)
735  *                                        and order(raise/lower)
736  *
737  * @param[in]   window      target window identity
738  * @param[in]   visible     visible(1)/unvisible(0)
739  * @param[in]   raise       forefront(1)/maximum back(0)
740  * @return  result
741  * @retval  ICO_UXF_EOK         success
742  * @retval  ICO_UXF_ESRCH       error(not initialized)
743  * @retval  ICO_UXF_ENOENT      error(not exist)
744  */
745 /*--------------------------------------------------------------------------*/
746 ICO_APF_API int
747 ico_uxf_window_visible_raise(const int window, const int visible, const int raise)
748 {
749     Ico_Uxf_Mng_Window  *winmng;            /* window management table      */
750     int                 vis = visible;
751
752     uifw_trace("ico_uxf_window_visible_raise: Enter(%08x,%d,%d)", window, visible, raise);
753
754     if (gIco_Uxf_Api_Mng.Initialized <= 0)  {
755         uifw_warn("ico_uxf_window_visible_raise: Leave(ESRCH)");
756         return ICO_UXF_ESRCH;
757     }
758
759     winmng = ico_uxf_mng_window(window, 0);
760     if ((! winmng) || (! winmng->mng_display))  {
761         uifw_warn("ico_uxf_window_visible_raise: Leave(ENOENT)");
762         return ICO_UXF_ENOENT;
763     }
764
765     if (vis == 0)   {
766         winmng->attr.visible = 0;
767     }
768     else if (vis == 1)  {
769         winmng->attr.visible = 1;
770         if (gIco_Uxf_Api_Mng.AppsCtlVisible == 0)   {
771             /* application screen       */
772             if (winmng->attr.control != 0)  {
773                 uifw_trace("ico_uxf_window_visible_raise: change to hide(ctrl=%x menu=0)",
774                            winmng->attr.control);
775                 vis = 0;
776             }
777         }
778         else    {
779             /* HomeScreen menu screen   */
780             if ((winmng->mng_process)->attr.noicon != 0)    {
781                 uifw_trace("ico_uxf_window_visible_raise: change to hide(ctrl=%x menu=1)",
782                            winmng->attr.control);
783                 vis = 0;
784             }
785         }
786     }
787
788     if ((vis != 9) || (raise != 9)) {
789         /* request to visible status and order status to Weston(Multi Window Manager)   */
790         ico_uxf_window_visible_control(winmng, vis, raise);
791     }
792     uifw_trace("ico_uxf_window_visible_raise: Leave(EOK)");
793     return ICO_UXF_EOK;
794 }
795
796 /*--------------------------------------------------------------------------*/
797 /**
798  * @brief   ico_uxf_window_animation: set window animation
799  *
800  * @param[in]   window      Window identity
801  * @param[in]   animation   Animation name
802  * @return  result
803  * @retval  ICO_UXF_EOK         success
804  * @retval  ICO_UXF_ESRCH       error(not initialized)
805  * @retval  ICO_UXF_ENOENT      error(not exist)
806  */
807 /*--------------------------------------------------------------------------*/
808 ICO_APF_API int
809 ico_uxf_window_animation(const int window, const char *animation)
810 {
811     Ico_Uxf_Mng_Window  *winmng;            /* window management table      */
812     char    nullname[4];
813
814     uifw_trace("ico_uxf_window_animation: Enter(%08x, %s)",
815                window, animation ? animation : "NULL");
816
817     if (gIco_Uxf_Api_Mng.Initialized <= 0) {
818         uifw_warn("ico_uxf_window_animation: Leave(ESRCH)");
819         return ICO_UXF_ESRCH;
820     }
821
822     winmng = ico_uxf_mng_window(window, 0);
823     if ((! winmng) || (! winmng->mng_display)) {
824         uifw_warn("ico_uxf_window_animation: Leave(ENOENT)");
825         return ICO_UXF_ENOENT;
826     }
827
828     if (animation)  {
829         ico_window_mgr_set_animation(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
830                                      winmng->attr.window, animation);
831     }
832     else    {
833         nullname[0] = ' ';
834         nullname[1] = 0;
835         ico_window_mgr_set_animation(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
836                                      winmng->attr.window, nullname);
837     }
838     uifw_trace("ico_uxf_window_animation: Leave(EOK)");
839     return ICO_UXF_EOK;
840 }
841