0e412421e70d2b62d30c369d38dc8a9c3b71204a
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCWindowController.cpp
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 //==========================================================================
11 /**
12  *  @file   CicoSCWindowController.cpp
13  *
14  *  @brief  This file implementation of CicoSCWindowController class
15  */
16 //==========================================================================
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <string.h>
22 #include <signal.h>
23 #include <errno.h>
24 #include <sys/types.h>
25 #include <sys/ioctl.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <Ecore.h>
29
30 #include <vector>
31 #include <algorithm>
32 using namespace std;
33
34 #include "CicoSCWindow.h"
35 #include "CicoSCWayland.h"
36 #include "CicoSCWindowController.h"
37 #include "CicoLog.h"
38
39 #include "CicoSystemConfig.h"
40 #include "CicoConf.h"
41 #include "CicoSCDisplay.h"
42 #include "CicoSCLayer.h"
43 #include "CicoSCDisplayZone.h"
44 #include "ico_syc_error.h"
45 #include "ico_syc_type.h"
46 #include "ico_syc_winctl.h"
47 #include "CicoSCCommand.h"
48 #include "ico_syc_msg_cmd_def.h"
49 #include "CicoSCServer.h"
50 #include "CicoSCMessage.h"
51 #include "CicoSCMessageRes.h"
52 #include "CicoSCLifeCycleController.h"
53 #include "CicoSCResourceManager.h"
54
55 //==========================================================================
56 //  private static variable
57 //==========================================================================
58 CicoSCWindowController* CicoSCWindowController::ms_myInstance = NULL;
59
60 struct ico_sc_win_check_t* CicoSCWindowController::win_check_timer = NULL;
61 struct ico_sc_win_check_t* CicoSCWindowController::win_check_free = NULL;
62
63 //==========================================================================
64 //  static function for Ecore timer
65 //==========================================================================
66 static Ecore_Timer* g_SCWindowChecker = 0;
67 static struct timeval   g_lasttime = { 0, 0 };
68 static int              g_hightimer = 0;
69
70 //--------------------------------------------------------------------------
71 /**
72  *  @brief  get instance of CicoSCWindowController
73  *
74  *  @return instance of CicoSCWindowController
75  */
76 //--------------------------------------------------------------------------
77 CicoSCWindowController*
78 CicoSCWindowController::getInstance(void)
79 {
80     if (NULL == ms_myInstance) {
81         ms_myInstance = new CicoSCWindowController();
82     }
83     return ms_myInstance;
84 }
85
86 //--------------------------------------------------------------------------
87 /**
88  *  @brief  default constructor
89  */
90 //--------------------------------------------------------------------------
91 CicoSCWindowController::CicoSCWindowController()
92     : m_resMgr(NULL), m_physicalDisplayTotal(0)
93 {
94     CicoSCWayland* wayland = CicoSCWayland::getInstance();
95     wayland->getInstance()->addWaylandIF(ICO_WL_IVI_CONTROLLER_IF, this);
96 #ifdef GENIVI_WL_SHELL_INFO         /* GENIVI-LM is supporting the wl_shell_info    */
97     wayland->getInstance()->addWaylandIF(ICO_WL_IVI_APPLICATION_IF, this);
98 #endif /*GENIVI_WL_SHELL_INFO*/     /* GENIVI-LM is supporting the wl_shell_info    */
99     wayland->getInstance()->addWaylandIF(ICO_WL_OUTPUT_IF, this);
100     initDB();
101
102     CicoSCWindowController::ms_myInstance = this;
103
104     g_SCWindowChecker = ecore_timer_add(((double)ICO_SC_WINCHK_TIMER_BASE_L)/1000.0,
105                                         ico_SCWindowChecker, this);
106 }
107
108 //--------------------------------------------------------------------------
109 /**
110  *  @brief  destructor
111  */
112 //--------------------------------------------------------------------------
113 CicoSCWindowController::~CicoSCWindowController()
114 {
115     CicoSCWindowController::ms_myInstance = NULL;
116 }
117
118 //--------------------------------------------------------------------------
119 /**
120  *  @brief  initialize display and window database
121  */
122 //--------------------------------------------------------------------------
123 int
124 CicoSCWindowController::initDB(void)
125 {
126     ICO_TRA("CicoSCWindowController::initDB: Enter");
127
128     const vector<CicoSCDisplayConf*>& displayList =
129             CicoSystemConfig::getInstance()->getDisplayConfList();
130     vector<CicoSCDisplayConf*>::const_iterator itr;
131     itr = displayList.begin();
132     for (; itr != displayList.end(); ++itr) {
133         CicoSCDisplay *display = new CicoSCDisplay();
134         display->displayid = (*itr)->id;
135         display->type      = (*itr)->type;
136         display->nodeid    = (*itr)->node;
137         display->displayno = (*itr)->no;
138         display->width     = (*itr)->width;
139         display->height    = (*itr)->height;
140         display->name      = (*itr)->name;
141
142         vector<CicoSCLayerConf*>::const_iterator itr2;
143         itr2 = (*itr)->layerConfList.begin();
144         for (; itr2 != (*itr)->layerConfList.end(); ++itr2) {
145             CicoSCLayer *layer = new CicoSCLayer();
146             layer->layerid     = (*itr2)->id;
147             layer->type        = (*itr2)->type;
148             layer->width       = display->width;
149             layer->height      = display->height;
150             layer->displayid   = display->displayid;
151             layer->menuoverlap = (*itr2)->menuoverlap;
152             display->layerList.push_back(layer);
153         }
154
155         vector<CicoSCDisplayZoneConf*>::const_iterator itr3;
156         itr3 = (*itr)->zoneConfList.begin();
157         for (; itr3 != (*itr)->zoneConfList.end(); ++itr3) {
158             CicoSCDisplayZone *zone = new CicoSCDisplayZone();
159             zone->zoneid   = (*itr3)->id;
160             zone->x        = (*itr3)->x;
161             zone->y        = (*itr3)->y;
162             zone->width    = (*itr3)->w;
163             zone->height   = (*itr3)->h;
164             zone->fullname = (*itr3)->fullname;
165             zone->aspectFixed       = (*itr3)->aspectFixed;
166             zone->aspectAlignLeft   = (*itr3)->aspectAlignLeft;
167             zone->aspectAlignRight  = (*itr3)->aspectAlignRight;
168             zone->aspectAlignTop    = (*itr3)->aspectAlignTop;
169             zone->aspectAlignBottom = (*itr3)->aspectAlignBottom;
170             display->zoneList[zone->zoneid] = zone;
171         }
172         display->dump();
173         m_displayList.push_back(display);
174     }
175
176     ICO_TRA("CicoSCWindowController::initDB: Leave");
177     return ICO_SYC_EOK;
178 }
179
180 //--------------------------------------------------------------------------
181 /**
182  *  @brief   set resource manager instance
183  *
184  *  @param [in] resMgr  resource manager instance
185  */
186 //--------------------------------------------------------------------------
187 void
188 CicoSCWindowController::setResourceManager(CicoSCResourceManager *resMgr)
189 {
190     m_resMgr = resMgr;
191 }
192
193 //--------------------------------------------------------------------------
194 /**
195  *  @brief   show a target window
196  *
197  *  @param [in] surfaceid       wayland surface id
198  *  @param [in] animation       animation name
199  *  @param [in] animationTime   animation time
200  *
201  *  @return ICO_SYC_EOK on success, other on error
202  *  @retval ICO_SYC_EOK         success
203  *  @retval ICO_SYC_ESRCH       error(not initialized)
204  *  @retval ICO_SYC_ENOENT      error(not exist)
205  */
206 //--------------------------------------------------------------------------
207 int
208 CicoSCWindowController::show(int        surfaceid,
209                              const char *animation,
210                              int        animationTime)
211 {
212     int     type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
213     animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
214
215     ICO_TRA("CicoSCWindowController::show Enter"
216             "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
217             surfaceid, animation, type, animationTime);
218
219     // find window information in window list
220     CicoSCWindow *window = findWindow(surfaceid);
221     if (NULL == window) {
222         ICO_WRN("not found window information");
223         ICO_TRA("CicoSCWindowController::show Leave(ENOENT)");
224         return ICO_SYC_ENOENT;
225     }
226
227     // update visible attr
228     window->visible = true;
229
230     // update current displayed window at display zone
231     CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
232     if (NULL != zone) {
233         CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
234         if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
235             ICO_DBG("Entry display zone[%d] current displayed window"
236                     "(%08x:\"%s\")",
237                     zone->zoneid, window->surfaceid, window->appid.c_str());
238             zone->displayedWindow = window;
239         }
240     }
241
242     // set animation request
243     int raiseFlag = ICO_SYC_WIN_RAISE_NOCHANGE;
244     if (type & ICO_SYC_WIN_SURF_RAISE)  {
245         raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
246     }
247     else if (type & ICO_SYC_WIN_SURF_LOWER) {
248         raiseFlag = ICO_SYC_WIN_RAISE_LOWER;
249     }
250     else if (((type & ICO_SYC_WIN_SURF_NOCHANGE) == 0) &&
251              (false == window->raise))   {
252         raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
253     }
254     if ((animationTime > 0) && (NULL != animation) &&
255         (animation[0] != '\0') && (strcasecmp(animation, "none") != 0)) {
256         // set animation
257         setWindowAnimation(window, ICO_SC_WINANIMA_SHOW, animation, animationTime);
258     }
259     else    {
260         // reset animation
261         resetWindowAnimation(window);
262     }
263
264     // set raise/lower request (if need)
265     if (raiseFlag != ICO_SYC_WIN_RAISE_NOCHANGE)    {
266         raiselower(window, (raiseFlag == ICO_SYC_WIN_RAISE_RAISE));
267     }
268
269     // set visible request
270     CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_WIN_VISIBLE_SHOW);
271
272     // flush display
273     CicoSCWayland::getInstance()->flushDisplay();
274
275     ICO_TRA("CicoSCWindowController::show Leave(EOK)");
276     return ICO_SYC_EOK;
277 }
278
279 //--------------------------------------------------------------------------
280 /**
281  *  @brief   raise/lower a target window
282  *
283  *  @param [in] window          target window
284  *  @param [in] raise           raise(true)/lower(false)
285  *
286  *  @return nothing
287  */
288 //--------------------------------------------------------------------------
289 void
290 CicoSCWindowController::raiselower(CicoSCWindow *window, bool raise)
291 {
292     ICO_TRA("CicoSCWindowController::raiselower(%08x,%d)", window->surfaceid, raise);
293
294     window->raise = raise;
295
296     CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
297     if (! layer)    {
298         ICO_ERR("CicoSCWindowController::raiselower: surface.%08x has no layer(%d)",
299                 window->surfaceid, window->layerid);
300         return;
301     }
302     if ((raise) && (layer->is_topSurface(window->surfaceid)))   {
303         ICO_DBG("CicoSCWindowController::raiselower %08x raise but top",
304                 window->surfaceid);
305     }
306     else if ((! raise) && (layer->is_buttomSurface(window->surfaceid))) {
307         ICO_DBG("CicoSCWindowController::raiselower %08x lower but buttom",
308                 window->surfaceid);
309     }
310     else    {
311         layer->addSurface(window->surfaceid, raise);
312
313         int nsurf;
314         const int *surfs = layer->getSurfaces(&nsurf);
315         ICO_TRA("CicoSCWindowControllerCicoSCWindowController layer.%d %d.%x %x %x %x",
316                 window->layerid, nsurf, surfs[0], surfs[1], surfs[2], surfs[3]);
317         if (nsurf > 4)  {
318             ICO_TRA("CicoSCWindowControllerCicoSCWindowController          .%x %x %x %x",
319                     surfs[4], surfs[5], surfs[6], surfs[7]);
320         }
321         if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
322             != ILM_SUCCESS) {
323             ICO_ERR("CicoSCWindowController::raiselower "
324                     "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
325         }
326     }
327 }
328
329 //--------------------------------------------------------------------------
330 /**
331  *  @brief   hide a target window
332  *
333  *  @param [in] surfaceid       wayland surface id
334  *  @param [in] animation       animation name
335  *  @param [in] animationTime   animation time
336  *
337  *  @return ICO_SYC_EOK on success, other on error
338  *  @retval ICO_SYC_EOK         success
339  *  @retval ICO_SYC_ESRCH       error(not initialized)
340  *  @retval ICO_SYC_ENOENT      error(not exist)
341  */
342 //--------------------------------------------------------------------------
343 int
344 CicoSCWindowController::hide(int        surfaceid,
345                              const char *animation,
346                              int        animationTime)
347 {
348     int     type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
349     animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
350
351     ICO_TRA("CicoSCWindowController::hide Enter"
352             "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
353             surfaceid, animation, type, animationTime);
354
355     // find window information in window list
356     CicoSCWindow *window = findWindow(surfaceid);
357     if (NULL == window) {
358         ICO_WRN("not found window information");
359         ICO_TRA("CicoSCWindowController::hide Leave(ENOENT)");
360         return ICO_SYC_ENOENT;
361     }
362
363     if (false == window->visible) {
364         ICO_DBG("already hide state");
365         ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
366         return ICO_SYC_EOK;
367     }
368
369     // update window attr
370     window->visible = false;
371
372     // update current displayed window at display zone
373     CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
374     if (NULL != zone) {
375         CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
376         if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
377             (getDisplayedWindow(zone->zoneid) == surfaceid)) {
378             ICO_DBG("Exit  display zone[%d] current displayed window"
379                     "(%08x:\"%s\")",
380                     zone->zoneid, window->surfaceid, window->appid.c_str());
381             zone->displayedWindow = NULL;
382         }
383     }
384
385     if ((animationTime > 0) && (NULL != animation) &&
386         (animation[0] != '\0') && (strcasecmp(animation, "none") != 0)) {
387         // set animation
388         setWindowAnimation(window, ICO_SC_WINANIMA_HIDE, animation, animationTime);
389     }
390     else    {
391         // reset animation
392         resetWindowAnimation(window);
393         CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_WIN_VISIBLE_HIDE);
394     }
395
396     // flush display
397     CicoSCWayland::getInstance()->flushDisplay();
398
399     ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
400     return ICO_SYC_EOK;
401 }
402
403 //--------------------------------------------------------------------------
404 /**
405  *  @brief   resize window(surface) size
406  *
407  *  @param [in] surfaceid       wayland surface id
408  *  @param [in] w               window width
409  *  @param [in] h               window height
410  *  @param [in] animation       animation name
411  *  @param [in] animationTime   animation time
412  *
413  *  @return ICO_SYC_EOK on success, other on error
414  *  @retval ICO_SYC_EOK         success
415  *  @retval ICO_SYC_ESRCH       error(not initialized)
416  *  @retval ICO_SYC_ENOENT      error(window dose not exist)
417  */
418 //--------------------------------------------------------------------------
419 int
420 CicoSCWindowController::resize(int        surfaceid,
421                                int        w,
422                                int        h,
423                                const char *animation,
424                                int        animationTime)
425 {
426     int     type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
427     animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
428
429     ICO_TRA("CicoSCWindowController::resize Enter"
430             "(surfaceid=%08x h=%d w=%d animation=%s type=%x animationTime=%d)",
431             surfaceid, w, h, animation, type, animationTime);
432
433     // find window information in window list
434     CicoSCWindow *window = findWindow(surfaceid);
435     if (NULL == window) {
436         ICO_WRN("not found window information");
437         ICO_TRA("CicoSCWindowController::resize Leave(ENOENT)");
438         return ICO_SYC_ENOENT;
439     }
440
441     // set visible request
442     window->width = w;
443     window->height = h;
444     CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, window->nodeid,
445                                       window->x, window->y, w, h);
446
447     // flush display
448     CicoSCWayland::getInstance()->flushDisplay();
449
450     ICO_TRA("CicoSCWindowController::resize Leave(EOK)");
451     return ICO_SYC_EOK;
452 }
453
454 //--------------------------------------------------------------------------
455 /**
456  *  @brief  move window(surface) position
457  *
458  *  @param [in] surfaceid       wayland surface id
459  *  @param [in] nodeid          node id
460  *  @param [in] x               window width
461  *  @param [in] y               window height
462  *  @param [in] animation       animation name
463  *  @param [in] animationTime   animation time
464  *
465  *  @return ICO_SYC_EOK on success, other on error
466  *  @retval ICO_SYC_EOK         success
467  *  @retval ICO_SYC_ESRCH       error(not initialized)
468  *  @retval ICO_SYC_ENOENT      error(window dose not exist)
469  */
470 //--------------------------------------------------------------------------
471 int
472 CicoSCWindowController::move(int        surfaceid,
473                              int        nodeid,
474                              int        x,
475                              int        y,
476                              const char *animation,
477                              int        animationTime)
478 {
479     int     type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
480     animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
481
482     ICO_TRA("CicoSCWindowController::move Enter"
483             "(surfaceid=%08x nodeid=%d x=%d y=%d "
484             "animation=%s type=%x animationTime=%d)",
485             surfaceid, nodeid, x, y, animation, type, animationTime);
486
487     // find window information in window list
488     CicoSCWindow *window = findWindow(surfaceid);
489     if (NULL == window) {
490         ICO_WRN("CicoSCWindowController::move not found window(%08x)", surfaceid);
491         ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
492         return ICO_SYC_ENOENT;
493     }
494     // check nodeid
495     if (nodeid >= (int)m_physicalDisplayTotal)  {
496         ICO_WRN("CicoSCWindowController::move not found node(%d)", nodeid);
497         ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
498         return ICO_SYC_ENOENT;
499     }
500
501     int moveNodeId = ICO_SYC_WIN_NOCHANGE;
502     if (nodeid >= 0) {
503         moveNodeId = nodeid;
504     }
505
506     // set visible request
507     window->x = x;
508     window->y = y;
509     CicoSCWlWinMgrIF::setPositionsize(window->surfaceid,
510                                       moveNodeId, x, y,
511                                       window->width, window->height);
512
513     // flush display
514     CicoSCWayland::getInstance()->flushDisplay();
515
516     ICO_TRA("CicoSCWindowController::move Leave(EOK)");
517     return ICO_SYC_EOK;
518 }
519
520 //--------------------------------------------------------------------------
521 /**
522  *  @brief  raise window(surface)
523  *
524  *  @param [in] surfaceid       wayland surface id
525  *  @param [in] animation       animation name
526  *  @param [in] animationTime   animation time
527  *
528  *  @return ICO_SYC_EOK on success, other on error
529  *  @retval ICO_SYC_EOK         success
530  *  @retval ICO_SYC_ESRCH       error(not initialized)
531  *  @retval ICO_SYC_ENOENT      error(layer dose not exist)
532  */
533 //--------------------------------------------------------------------------
534 int
535 CicoSCWindowController::raise(int        surfaceid,
536                               const char *animation,
537                               int        animationTime)
538 {
539     int     type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
540     animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
541
542     ICO_TRA("CicoSCWindowController::raise Enter"
543             "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
544             surfaceid, animation, type, animationTime);
545
546     // find window information in window list
547     CicoSCWindow *window = findWindow(surfaceid);
548     if (NULL == window) {
549         ICO_WRN("not found window information");
550         ICO_TRA("CicoSCWindowController::raise Leave(ENOENT)");
551         return ICO_SYC_ENOENT;
552     }
553
554     // set raise request
555     raiselower(window, true);
556     if (ilm_commitChanges() != ILM_SUCCESS)    {
557         ICO_ERR("CicoSCWindowController::raise ilm_commitChanges() Error");
558     }
559
560     // flush display
561     CicoSCWayland::getInstance()->flushDisplay();
562
563     ICO_TRA("CicoSCWindowController::raise Leave(EOK)");
564     return ICO_SYC_EOK;
565 }
566
567 //--------------------------------------------------------------------------
568 /**
569  *  @brief  set window(surface) geometry
570  *
571  *  @param [in] surfaceid           wayland surface id
572  *  @param [in] nodeid              node id
573  *  @param [in] layerid             layer id
574  *  @param [in] x                   window x position
575  *  @param [in] y                   window y position
576  *  @param [in] w                   window width
577  *  @param [in] h                   window height
578  *  @param [in] resizeAnimation     resize animation name
579  *  @param [in] resizeAnimationTime resize animation time
580  *  @param [in] moveAnimation       move animation name
581  *  @param [in] moveanimationTime   move animation time
582  *
583  *  @return ICO_SYC_EOK on success, other on error
584  *  @retval ICO_SYC_EOK         success
585  *  @retval ICO_SYC_ESRCH       error(not initialized)
586  *  @retval ICO_SYC_ENOENT      error(window dose not exist)
587  */
588 //--------------------------------------------------------------------------
589 int
590 CicoSCWindowController::setGeometry(int        surfaceid,
591                                     int        nodeid,
592                                     int        layerid,
593                                     int        x,
594                                     int        y,
595                                     int        w,
596                                     int        h,
597                                     const char *resizeAnimation,
598                                     int        resizeAnimationTime,
599                                     const char *moveAnimation,
600                                     int        moveAnimationTime)
601 {
602     ICO_TRA("CicoSCWindowController::setGeometry Enter"
603             "(surfaceid=%08x nodeid=%d layerid=%d x=%d y=%d w=%d h=%d "
604             "resizeAnimation=%s resizeAnimationTime=%d "
605             "moveAnimation=%s moveAnimationTime=%d)",
606             surfaceid, nodeid, layerid, x, y, w, h,
607             resizeAnimation, resizeAnimationTime,
608             moveAnimation, moveAnimationTime);
609
610     // find window information in window list
611     CicoSCWindow *window = findWindow(surfaceid);
612     if (NULL == window) {
613         ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
614         ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
615         return ICO_SYC_ENOENT;
616     }
617     // check nodeid
618     if (nodeid >= (int)m_physicalDisplayTotal)  {
619         ICO_WRN("CicoSCWindowController::setGeometry not found node(%d)", nodeid);
620         ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
621         return ICO_SYC_ENOENT;
622     }
623
624     int moveNodeId = ICO_SYC_WIN_NOCHANGE;
625     if (nodeid >= 0) {
626         moveNodeId = nodeid;
627     }
628     else {
629         moveNodeId = window->nodeid;
630     }
631
632     if (m_physicalDisplayTotal <= (unsigned int)moveNodeId) {
633         ICO_WRN("nodeid(%d) is over physical display total(%d)",
634                 m_physicalDisplayTotal, nodeid);
635         ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
636         return ICO_SYC_EINVAL;
637     }
638
639     int moveX = window->x;
640     if (0 <= x) {
641         moveX = x;
642         window->x = x;
643     }
644
645     int moveY = window->y;
646     if (0 <= y) {
647         moveY = y;
648         window->y = y;
649     }
650
651     int moveW = window->width;
652     if (0 <= w) {
653         moveW = w;
654         window->width = w;
655     }
656
657     int moveH = window->height;
658     if (0 <= h) {
659         moveH = h;
660         window->height = h;
661     }
662
663     // set window layer
664     if (0 <= layerid) {
665         setWindowLayer(window->surfaceid, layerid);
666     }
667
668     // update window attr
669     window->nodeid = moveNodeId;
670
671     // set visible request
672     CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, moveNodeId,
673                                       moveX, moveY, moveW, moveH);
674
675     // flush display
676     CicoSCWayland::getInstance()->flushDisplay();
677
678     ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
679     return ICO_SYC_EOK;
680 }
681
682 //--------------------------------------------------------------------------
683 /**
684  *  @brief  set window(surface) geometry
685  *
686  *  @param [in] surfaceid           wayland surface id
687  *  @param [in] layerid             layer id
688  *  @param [in] nodeid              node id
689  *  @param [in] zone                display zone name
690  *  @param [in] resizeAnimation     resize animation name
691  *  @param [in] resizeAnimationTime resize animation time
692  *  @param [in] moveAnimation       move animation name
693  *  @param [in] moveanimationTime   move animation time
694  *
695  *  @return ICO_SYC_EOK on success, other on error
696  *  @retval ICO_SYC_EOK         success
697  *  @retval ICO_SYC_ESRCH       error(not initialized)
698  *  @retval ICO_SYC_ENOENT      error(window dose not exist)
699  *  @retval ICO_SYC_EINVAL      error(zone is null, zone name is invalid)
700  */
701 //--------------------------------------------------------------------------
702 int
703 CicoSCWindowController::setGeometry(int        surfaceid,
704                                     const char *zone,
705                                     int        layerid,
706                                     const char *resizeAnimation,
707                                     int        resizeAnimationTime,
708                                     const char *moveAnimation,
709                                     int        moveAnimationTime)
710 {
711     ICO_TRA("CicoSCWindowController::setGeometry Enter"
712             "(surfaceid=%08x zone=%s layerid=%d "
713             "resizeAnimation=%s resizeAnimationTime=%d "
714             "moveAnimation=%s moveAnimationTime=%d)",
715             surfaceid, zone, layerid,
716             resizeAnimation, resizeAnimationTime,
717             moveAnimation, moveAnimationTime);
718
719     // find window information in window list
720     CicoSCWindow *window = findWindow(surfaceid);
721     if (NULL == window) {
722         ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
723         ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
724         return ICO_SYC_ENOENT;
725     }
726
727     // find zone information
728     if ((NULL == zone) || ('\0' == zone[0])) {
729         ICO_WRN("zone value is invalid");
730         ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
731         return ICO_SYC_EINVAL;
732     }
733
734     vector<CicoSCDisplay*>::iterator itr;
735     itr = m_displayList.begin();
736     CicoSCDisplayZone* dispzone = NULL;
737     int displayno = 0;
738     for (; itr != m_displayList.end(); ++itr) {
739         dispzone = (*itr)->findDisplayZonebyFullName(zone);
740         if (NULL != dispzone) {
741             displayno = (*itr)->displayno;
742             break;
743         }
744     }
745     if (NULL == dispzone) {
746         ICO_WRN("display zone name(%s) is invalid.", zone);
747         ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
748         return ICO_SYC_EINVAL;
749     }
750     if (m_physicalDisplayTotal <= (unsigned int)displayno) {
751         ICO_WRN("nodeid(%d) is over physical display total(%d)",
752                 m_physicalDisplayTotal, displayno);
753         ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
754         return ICO_SYC_EINVAL;
755     }
756
757     if (window->zoneid != dispzone->zoneid) {
758         // update current displayed window at display zone
759         CicoSCDisplayZone* olddispzone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
760         if (NULL != olddispzone) {
761             CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
762             if ((NULL != layer) &&
763                 (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
764                 (getDisplayedWindow(olddispzone->zoneid) == surfaceid)) {
765                 ICO_DBG("Exit display zone[%d] current displayed window"
766                         "(%08x:\"%s\")",
767                         olddispzone->zoneid, window->surfaceid,
768                         window->appid.c_str());
769                 olddispzone->displayedWindow = NULL;
770             }
771         }
772
773         CicoSCLayer *layer = findLayer(displayno, window->layerid);
774         if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
775             ICO_DBG("Entry display zone[%d] current displayed window"
776                     "(%08x:\"%s\")",
777                     dispzone->zoneid, window->surfaceid, window->appid.c_str());
778             dispzone->displayedWindow = window;
779         }
780     }
781
782     // update window attr
783     window->zoneid = dispzone->zoneid;
784     window->zone = dispzone->fullname;
785     setAttributes(window->surfaceid);
786
787     int ret = setGeometry(surfaceid, displayno, layerid,
788                           dispzone->x, dispzone->y,
789                           dispzone->width, dispzone->height,
790                           resizeAnimation, resizeAnimationTime,
791                           moveAnimation, moveAnimationTime);
792
793     ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
794     return ret;
795 }
796
797 //--------------------------------------------------------------------------
798 /**
799  *  @brief  lower window(surface)
800  *
801  *  @param [in] surfaceid       wayland surface id
802  *  @param [in] animation       animation name
803  *  @param [in] animationTime   animation time
804  *
805  *  @return ICO_SYC_EOK on success, other on error
806  *  @retval ICO_SYC_EOK         success
807  *  @retval ICO_SYC_ESRCH       error(not initialized)
808  *  @retval ICO_SYC_ENOENT      error(layer dose not exist)
809  */
810 //--------------------------------------------------------------------------
811 int
812 CicoSCWindowController::lower(int        surfaceid,
813                               const char *animation,
814                               int        animationTime)
815 {
816     int     type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
817     animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
818
819     ICO_TRA("CicoSCWindowController::lower Enter"
820             "(surfaceid=08x animation=%s type=%x animationTime=%d)",
821             surfaceid, animation, type, animationTime);
822
823     // find window information in window list
824     CicoSCWindow *window = findWindow(surfaceid);
825     if (NULL == window) {
826         ICO_WRN("not found window information");
827         ICO_TRA("CicoSCWindowController::lower Leave(ENOENT)");
828         return ICO_SYC_ENOENT;
829     }
830
831     // set lower request
832     raiselower(window, false);
833     if (ilm_commitChanges() != ILM_SUCCESS)    {
834         ICO_ERR("CicoSCWindowController::lower ilm_commitChanges() Error");
835     }
836
837     // flush display
838     CicoSCWayland::getInstance()->flushDisplay();
839
840     ICO_TRA("CicoSCWindowController::lower Leave(EOK)");
841     return ICO_SYC_EOK;
842 }
843
844 //--------------------------------------------------------------------------
845 /**
846  *  @brief  set window layer
847  *
848  *  @param [in] surfaceid       wayland surface id
849  *  @param [in] layer           layer id
850  *
851  *  @return ICO_SYC_EOK on success, other on error
852  *  @retval ICO_SYC_EOK         success
853  *  @retval ICO_SYC_ESRCH       error(not initialized)
854  *  @retval ICO_SYC_ENOENT      error(window or layer dose not exist)
855  */
856 //--------------------------------------------------------------------------
857 int
858 CicoSCWindowController::setWindowLayer(int surfaceid, int layerid)
859 {
860     ICO_TRA("CicoSCWindowController::setWindowLayer Enter"
861             "(surfaceid=%08x layerid=%x)", surfaceid, layerid);
862
863     // find window information in window list
864     CicoSCWindow* window = findWindow(surfaceid);
865     if (NULL == window) {
866         ICO_WRN("not found window information");
867         ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT)");
868         return ICO_SYC_ENOENT;
869     }
870     if (window->layerid == layerid) {
871         ICO_TRA("CicoSCWindowController::setWindowLayer Leave(same layer %d)", layerid);
872         return ICO_SYC_EOK;
873     }
874
875     // find new layer information in layer list
876     CicoSCLayer* layer = findLayer(window->displayid, layerid);
877     if (NULL == layer) {
878         ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT[disp=%d,layer=%d])",
879                 window->displayid, layerid);
880         return ICO_SYC_ENOENT;
881     }
882
883     // find old layer information and remove surface if need
884     CicoSCLayer* oldlayer = findLayer(window->displayid, window->layerid);
885     if (oldlayer)   {
886         if (ilm_layerRemoveSurface(window->layerid, window->surfaceid) != ILM_SUCCESS)  {
887             ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerRemoveSurface(%d,%08x)"
888                     " Error", window->layerid, window->surfaceid);
889         }
890         // must need ilm_commitChanges() after ilm_layerRemoveSurface()
891         if (ilm_commitChanges() != ILM_SUCCESS) {
892             ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
893         }
894
895         oldlayer->removeSurface(window->surfaceid);
896         int noldsurf;
897         const int *oldsurfs = oldlayer->getSurfaces(&noldsurf);
898         if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)oldsurfs, noldsurf)
899             != ILM_SUCCESS)   {
900             ICO_ERR("CicoSCWindowController::setWindowLayer "
901                 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, noldsurf);
902         }
903         if (ilm_commitChanges() != ILM_SUCCESS) {
904             ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
905         }
906     }
907
908     // update window attr
909     window->layerid = layerid;
910
911     // set window layer request
912     if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
913         ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerAddSurface(%d,%08x) Error",
914                 window->layerid, window->surfaceid);
915     }
916     if (ilm_commitChanges() != ILM_SUCCESS)    {
917         ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
918     }
919
920     // add surface to new layer
921     layer->addSurface(window->surfaceid, true);
922     int nsurf;
923     const int *surfs = layer->getSurfaces(&nsurf);
924     if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
925         != ILM_SUCCESS)   {
926         ICO_ERR("CicoSCWindowController::setWindowLayer "
927                 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
928     }
929     if (ilm_commitChanges() != ILM_SUCCESS)    {
930         ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
931     }
932
933     // flush display
934     CicoSCWayland::getInstance()->flushDisplay();
935
936     ICO_TRA("CicoSCWindowController::setWindowLayer Leave(EOK)");
937     return ICO_SYC_EOK;
938 }
939
940 //--------------------------------------------------------------------------
941 /**
942  *  @brief   show layer
943  *
944  *  @param [in] displayid   display id
945  *  @param [in] layerid     layer id
946  *
947  *  @return ICO_SYC_EOK on success, other on error
948  *  @retval ICO_SYC_EOK     success
949  *  @retval ICO_SYC_ESRCH   error(not initialized)
950  *  @retval ICO_SYC_ENOENT  error(layer dose not exist)
951  */
952 //--------------------------------------------------------------------------
953 int
954 CicoSCWindowController::showLayer(int displayid, int layerid)
955 {
956     ICO_TRA("CicoSCWindowController::showLayer Enter"
957             "(displayid=%d layerid=%d)", displayid, layerid);
958
959     // find layer information in layer list
960     CicoSCLayer* layer = findLayer(displayid, layerid);
961     if (NULL == layer) {
962         ICO_WRN("not found layer information");
963         ICO_TRA("CicoSCWindowController::showLayer Leave(ENOENT)");
964         return ICO_SYC_ENOENT;
965     }
966
967     CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_SHOW);
968
969     // flush display
970     CicoSCWayland::getInstance()->flushDisplay();
971
972     ICO_TRA("CicoSCWindowController::showLayer Leave(EOK)");
973     return ICO_SYC_EOK;
974 }
975
976 //--------------------------------------------------------------------------
977 /**
978  *  @brief   show layer
979  *
980  *  @param [in] displayid   display id
981  *  @param [in] layerid     layer id
982  *
983  *  @return ICO_SYC_EOK on success, other on error
984  *  @retval ICO_SYC_EOK     success
985  *  @retval ICO_SYC_ESRCH   error(not initialized)
986  *  @retval ICO_SYC_ENOENT  error(layer dose not exist)
987  */
988 //--------------------------------------------------------------------------
989 int
990 CicoSCWindowController::hideLayer(int displayid, int layerid)
991 {
992     ICO_TRA("CicoSCWindowController::hideLayer Enter(displayid=%d layerid=%d)",
993             displayid, layerid);
994
995     // find layer information in layer list
996     CicoSCLayer* layer = findLayer(displayid, layerid);
997     if (NULL == layer) {
998         ICO_WRN("not found layer information");
999         ICO_TRA("CicoSCWindowController::hideLayer Leave(ENOENT)");
1000         return ICO_SYC_ENOENT;
1001     }
1002
1003     CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_HIDE);
1004
1005     // flush display
1006     CicoSCWayland::getInstance()->flushDisplay();
1007
1008     ICO_TRA("CicoSCWindowController::hideLayer Leave(EOK)");
1009     return ICO_SYC_EOK;
1010 }
1011
1012 //--------------------------------------------------------------------------
1013 /**
1014  *  @brief   active window(surface)
1015  *
1016  *  @param [in] surfaceid   wayland surface id
1017  *  @param [in] target      target(pointer and/or keyboard)
1018  *
1019  *  @return ICO_SYC_EOK on success, other on error
1020  *  @retval ICO_SYC_EOK     success
1021  *  @retval ICO_SYC_ESRCH   error(not initialized)
1022  *  @retval ICO_SYC_ENOENT  error(layer dose not exist)
1023  */
1024 //--------------------------------------------------------------------------
1025 int
1026 CicoSCWindowController::active(int surfaceid, int target)
1027 {
1028     CicoSCWindow *window = NULL;
1029
1030     ICO_TRA("CicoSCWindowController::active Enter"
1031             "(surfaceid=%08x, target=%08x)", surfaceid, target);
1032
1033     // find window information in window list
1034     if (surfaceid) {
1035         window = findWindow(surfaceid);
1036         if (NULL == window) {
1037             ICO_WRN("not found window information");
1038             ICO_TRA("CicoSCWindowController::active Leave(ENOENT)");
1039             return ICO_SYC_ENOENT;
1040         }
1041     }
1042
1043     if (target < 0) {
1044         target = 0xffff;
1045     }
1046
1047     // set active request
1048     CicoSCWlWinMgrIF::setActive(surfaceid, target);
1049
1050     // flush display
1051     CicoSCWayland::getInstance()->flushDisplay();
1052
1053     // update visible attr
1054     if (window) {
1055         window->raise = true;
1056     }
1057
1058     // update active window
1059     map<unsigned int, CicoSCWindow*>::iterator itr;
1060     itr = m_windowList.begin();
1061     for (; itr != m_windowList.end(); ++itr) {
1062         CicoSCWindow* window = itr->second;
1063         if ((surfaceid != 0) && (window->surfaceid == surfaceid)) {
1064             window->active = target;
1065         }
1066         else {
1067             if (target == 0) {
1068                 window->active = 0;
1069             }
1070             else {
1071                 window->active &= ~target;
1072             }
1073         }
1074     }
1075
1076     ICO_TRA("CicoSCWindowController::active Leave(EOK)");
1077     return ICO_SYC_EOK;
1078 }
1079
1080 //--------------------------------------------------------------------------
1081 /**
1082  *  @brief   set surface map get
1083  *
1084  *  @param [in] surfaceid   wayland surface id
1085  *  @param [in] filepath    surface image pixel file path
1086  *
1087  *  @return ICO_SYC_EOK on success, other on error(currently EOK only)
1088  *  @retval ICO_SYC_EOK     success
1089  */
1090 //--------------------------------------------------------------------------
1091 int
1092 CicoSCWindowController::setmapGet(int surfaceid, const char *filepath)
1093 {
1094     ICO_TRA("CicoSCWindowController::setmapGet Enter");
1095
1096     CicoSCWlWinMgrIF::setmapGet(surfaceid, filepath);
1097     CicoSCWayland::getInstance()->flushDisplay();
1098
1099     ICO_TRA("CicoSCWindowController::setmapGet Leave(EOK)");
1100     return ICO_SYC_EOK;
1101 }
1102
1103 //--------------------------------------------------------------------------
1104 /**
1105  *  @brief   map surface
1106  *
1107  *  @param [in] surfaceid   wayland surface id
1108  *  @param [in] framerate   surface change frame rate(frames par sec)
1109  *  @param [in] filepath    surface image pixel file path
1110  *
1111  *  @return ICO_SYC_EOK on success, other on error
1112  *  @retval ICO_SYC_EOK     success
1113  *  @retval ICO_SYC_ESRCH   error(not initialized)
1114  *  @retval ICO_SYC_ENOENT  error(layer dose not exist)
1115  */
1116 //--------------------------------------------------------------------------
1117 int
1118 CicoSCWindowController::mapSurface(int surfaceid, int framerate, const char *filepath)
1119 {
1120     ICO_TRA("CicoSCWindowController::mapSurface Enter(%08x,%d,%s)",
1121             surfaceid, framerate, filepath ? filepath : "(null)");
1122
1123     // find window information in window list
1124     CicoSCWindow *window = findWindow(surfaceid);
1125     if (NULL == window) {
1126         ICO_WRN("not found window information");
1127         ICO_TRA("CicoSCWindowController::mapSurface Leave(ENOENT)");
1128         return ICO_SYC_ENOENT;
1129     }
1130
1131     setWindowMap(window, framerate, filepath);
1132
1133     ICO_TRA("CicoSCWindowController::mapSurface Leave(EOK)");
1134     return ICO_SYC_EOK;
1135 }
1136
1137 //--------------------------------------------------------------------------
1138 /**
1139  *  @brief   unmap surface
1140  *
1141  *  @param [in] surfaceid   wayland surface id
1142  *
1143  *  @return ICO_SYC_EOK on success, other on error
1144  *  @retval ICO_SYC_EOK     success
1145  *  @retval ICO_SYC_ESRCH   error(not initialized)
1146  *  @retval ICO_SYC_ENOENT  error(layer dose not exist)
1147  */
1148 //--------------------------------------------------------------------------
1149 int
1150 CicoSCWindowController::unmapSurface(int surfaceid)
1151 {
1152     ICO_TRA("CicoSCWindowController::unmapSurface Enter(%08x)", surfaceid);
1153
1154     // find window information in window list
1155     CicoSCWindow *window = findWindow(surfaceid);
1156     if (NULL == window) {
1157         ICO_WRN("not found window information");
1158         ICO_TRA("CicoSCWindowController::unmapSurface Leave(ENOENT)");
1159         return ICO_SYC_ENOENT;
1160     }
1161
1162     resetWindowMap(surfaceid);
1163
1164     ICO_TRA("CicoSCWindowController::unmapSurface Leave(EOK)");
1165     return ICO_SYC_EOK;
1166 }
1167
1168 //--------------------------------------------------------------------------
1169 /**
1170  *  @brief   get displayed window by display zone id
1171  *
1172  *  @param [in] zoneid  display zone id
1173  *
1174  *  @return surface id on success, -1 on not displayed
1175  */
1176 //--------------------------------------------------------------------------
1177 int
1178 CicoSCWindowController::getDisplayedWindow(int zoneid)
1179 {
1180     const CicoSCDisplayZone* zone = findDisplayZone(zoneid);
1181     if (NULL == zone) {
1182         return -1;
1183     }
1184
1185     if (NULL == zone->displayedWindow) {
1186         return -1;
1187     }
1188
1189     return zone->displayedWindow->surfaceid;
1190 }
1191
1192 //--------------------------------------------------------------------------
1193 /**
1194  *  @brief  set surface attributes
1195  *
1196  *  @param [in] surfaceid   surface id
1197  *
1198  *  @retval ICO_SYC_EOK     success
1199  *  @retval ICO_SYC_ESRCH   error(not initialized)
1200  *  @retval ICO_SYC_ENOENT  error(layer dose not exist)
1201  */
1202 //--------------------------------------------------------------------------
1203 int
1204 CicoSCWindowController::setAttributes(int surfaceid)
1205 {
1206     ICO_TRA("CicoSCWindowController::setAttributes Enter(surfaceid=%08x)", surfaceid);
1207
1208     // find window information in window list
1209     CicoSCWindow *window = findWindow(surfaceid);
1210     if (NULL == window) {
1211         ICO_WRN("not found window information");
1212         ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1213         return ICO_SYC_ENOENT;
1214     }
1215
1216     // find zone
1217     const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1218     if (NULL == zone) {
1219         ICO_WRN("not found zone information");
1220         ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1221         return ICO_SYC_ENOENT;
1222     }
1223
1224     uint32_t attributes = 0;
1225     if (true == zone->aspectFixed) {
1226         attributes |= ICO_SYC_WIN_ASPECT_FIXED;
1227         if (true == zone->aspectAlignLeft) {
1228             attributes |= ICO_SYC_WIN_ASPECT_ALIGN_LEFT;
1229         }
1230         if (true == zone->aspectAlignRight) {
1231             attributes |= ICO_SYC_WIN_ASPECT_ALIGN_RIGHT;
1232         }
1233         if (true == zone->aspectAlignTop) {
1234             attributes |= ICO_SYC_WIN_ASPECT_ALIGN_TOP;
1235         }
1236         if (true == zone->aspectAlignBottom) {
1237             attributes |= ICO_SYC_WIN_ASPECT_ALIGN_BOTTOM;
1238         }
1239     }
1240     ICO_TRA("CicoSCWindowController::setAttributes Leave(EOK)");
1241     return ICO_SYC_EOK;
1242 }
1243
1244 //--------------------------------------------------------------------------
1245 /**
1246  *  @brief  wayland surface active callback
1247  *
1248  *  @param [in] data            user data(unused)
1249  *  @param [in] surfaceid       surface Id
1250  *  @param [in] select          select device(unused)
1251  *                              (0=not active/1=pointer/2=touch)
1252  */
1253 //--------------------------------------------------------------------------
1254 void
1255 CicoSCWindowController::activeCB(void                  *data,
1256                                  uint32_t              surfaceid,
1257                                  int32_t               select)
1258 {
1259     ICO_TRA("CicoSCWindowController::activeCB Enter(surfaceid=%08x select=%d)",
1260             surfaceid, select);
1261
1262     CicoSCWindow *window = findWindow(surfaceid);
1263     if (NULL == window) {
1264         ICO_WRN("not found window information");
1265         ICO_TRA("CicoSCWindowController::activeCB Leave(not found window)");
1266         return;
1267     }
1268
1269     if (0 == select) {
1270         ICO_TRA("CicoSCWindowController::activeCB Leave(not active)");
1271         return;
1272     }
1273
1274     if (0 != window->active) {
1275         ICO_TRA("CicoSCWindowController::activeCB Leave(already active)");
1276         return;
1277     }
1278
1279     // send message
1280     CicoSCMessage *message = new CicoSCMessage();
1281     message->addRootObject("command", MSG_CMD_CHANGE_ACTIVE);
1282     message->addRootObject("appid", window->appid);
1283     message->addRootObject("pid", window->pid);
1284     message->addArgObject("surface", window->surfaceid);
1285     message->addArgObject("winname", window->name);
1286     CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1287
1288     ICO_TRA("CicoSCWindowController::activeCB Leave");
1289 }
1290
1291 //--------------------------------------------------------------------------
1292 /**
1293  *  @brief   surface map event callback
1294  *
1295  *  @param [in] event           event
1296  *  @param [in] surfaceid       surface Id
1297  *  @param [in] type            surface type (EGL buffer/Shared memory)
1298  *  @param [in] width           surface width
1299  *  @param [in] height          surface height
1300  *  @param [in] stride          surface buffer(frame buffer) stride
1301  *  @param [in] format          surface buffer format
1302  */
1303 //--------------------------------------------------------------------------
1304 void
1305 CicoSCWindowController::mapSurfaceCB(int32_t                event,
1306                                      uint32_t               surfaceid,
1307                                      uint32_t               type,
1308                                      int32_t                width,
1309                                      int32_t                height,
1310                                      int32_t                stride,
1311                                      uint32_t               format)
1312 {
1313     int     command;
1314
1315     ICO_TRA("CicoSCWindowController::mapSurfaceCB Enter(ev=%d surf=%d[%x] w/h=%d/%d)",
1316             event, surfaceid, surfaceid, width, height);
1317
1318     CicoSCWindow *window = findWindow(surfaceid);
1319     if (NULL == window) {
1320         ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave(NOENT)");
1321         return;
1322     }
1323
1324     // convert event to command
1325     switch (event)  {
1326     case ICO_SC_WINCHK_MAP_SURFACE_EVENT_MAP:
1327     case ICO_SC_WINCHK_MAP_SURFACE_EVENT_CONTENTS:
1328         command = MSG_CMD_MAP_THUMB;
1329         break;
1330     case ICO_SC_WINCHK_MAP_SURFACE_EVENT_UNMAP:
1331         command = MSG_CMD_UNMAP_THUMB;
1332         break;
1333     default:
1334         ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave(Unknown event(%d))", event);
1335         return;
1336     }
1337
1338     // send message
1339     CicoSCMessage *message = new CicoSCMessage();
1340     message->addRootObject("command", command);
1341     message->addRootObject("appid", window->appid);
1342     message->addArgObject("surface", window->surfaceid);
1343     message->addArgObject("attr", type);
1344     message->addArgObject("width", width);
1345     message->addArgObject("height", height);
1346     message->addArgObject("stride", stride);
1347     message->addArgObject("format", format);
1348     CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1349
1350     ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave");
1351 }
1352
1353 //--------------------------------------------------------------------------
1354 /**
1355  *  @brief   surface update event callback from GENIVI-LM
1356  *
1357  *  @param [in] surfaceid       surface Id
1358  *  @param [in] surfprop        surface Properties
1359  *  @param [in] maek            attribute change mask bits(unused)
1360  */
1361 //--------------------------------------------------------------------------
1362 void
1363 CicoSCWindowController::wlGeniviSurfaceNotification(t_ilm_surface               surfaceid,
1364                                                     struct ilmSurfaceProperties *surfprop,
1365                                                     t_ilm_notification_mask     mask)
1366 {
1367     ICO_TRA("CicoSCWindowController::wlGeniviSurfaceNotification(%d(%x),,%x)",
1368             surfaceid, surfaceid, mask);
1369
1370     if (mask & (ILM_NOTIFICATION_VISIBILITY | ILM_NOTIFICATION_SOURCE_RECT |
1371                 ILM_NOTIFICATION_DEST_RECT))    {
1372         CicoSCWindowController::getInstance()->
1373                 updateSurfaceCB((uint32_t)surfaceid, surfprop);
1374     }
1375     else if (mask & ILM_NOTIFICATION_CONTENT_REMOVED)   {
1376         CicoSCWindowController::getInstance()->
1377                 destroySurfaceCB((uint32_t)surfaceid);
1378     }
1379 }
1380
1381 //--------------------------------------------------------------------------
1382 /**
1383  *  @brief   surface update event callback
1384  *
1385  *  @param [in] surfaceid       surface Id
1386  *  @param [in] surfprop        surface Properties
1387  */
1388 //--------------------------------------------------------------------------
1389 void
1390 CicoSCWindowController::updateSurfaceCB(uint32_t                    surfaceid,
1391                                         struct ilmSurfaceProperties *surfprop)
1392 {
1393     ICO_TRA("CicoSCWindowController::updateSurfaceCB: Enter"
1394             "(%08x pid=%d v=%d,x/y=%d/%d,w/h=%d/%d->%d/%d)",
1395             surfaceid, surfprop->creatorPid, surfprop->visibility,
1396             surfprop->destX, surfprop->destY,
1397             surfprop->sourceWidth, surfprop->sourceHeight,
1398             surfprop->destWidth, surfprop->destHeight);
1399
1400     CicoSCWindow *window = findWindow(surfaceid);
1401     if (NULL == window) {
1402         ICO_WRN("CicoSCWindowController::updateSurfaceCB: not found window(%08x)",
1403                 surfaceid);
1404         ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
1405         return;
1406     }
1407
1408     // update attr
1409     window->visible = surfprop->visibility;
1410     window->srcwidth = surfprop->sourceWidth;
1411     window->srcheight = surfprop->sourceHeight;
1412     window->x = surfprop->destX;
1413     window->y = surfprop->destY;
1414     window->width = surfprop->destWidth;
1415     window->height = surfprop->destHeight;
1416     window->nodeid = window->layerid / ICO_SC_LAYERID_SCREENBASE;
1417
1418     // notify to homescreen
1419     CicoSCMessage *message = new CicoSCMessage();
1420     message->addRootObject("command", MSG_CMD_CHANGE_ATTR);
1421     message->addRootObject("appid", window->appid);
1422     const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1423     if (NULL != zone) {
1424         message->addArgObject("zone", zone->fullname);
1425     }
1426     else {
1427         message->addArgObject("zone", "");
1428     }
1429     message->addArgObject("surface", window->surfaceid);
1430     message->addArgObject("winname", window->name);
1431     message->addArgObject("node", window->nodeid);
1432     message->addArgObject("layer", window->layerid);
1433     message->addArgObject("pos_x", window->x);
1434     message->addArgObject("pos_y", window->y);
1435     message->addArgObject("width", window->width);
1436     message->addArgObject("height", window->height);
1437     message->addArgObject("raise", window->raise ? 1 : 0);
1438     message->addArgObject("visible", window->visible ? 1 : 0);
1439     message->addArgObject("active", window->active ? 1 : 0);
1440     CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1441
1442     ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
1443 }
1444
1445 //--------------------------------------------------------------------------
1446 /**
1447  *  @brief  wayland surface destroy callback
1448  *
1449  *  @param [in] surfaceid       surface Id
1450  */
1451 //--------------------------------------------------------------------------
1452 void
1453 CicoSCWindowController::destroySurfaceCB(uint32_t surfaceid)
1454 {
1455     ICO_TRA("CicoSCWindowController::destroySurfaceCB: Enter(%08x)", surfaceid);
1456
1457     CicoSCWindow *window = findWindow(surfaceid);
1458     if (NULL == window) {
1459         ICO_WRN("not found window(%08x)", surfaceid);
1460         ICO_TRA("CicoSCWindowController::destroySurfaceCB Leave");
1461         return;
1462     }
1463
1464     // remove window check
1465     CicoSCWindowController::windowCheckerRemove(surfaceid);
1466
1467     // delete surface from layer
1468     CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
1469     if (NULL == layer) {
1470         ICO_TRA("CicoSCWindowController::destroySurfaceCB: surf.%08x not exist in layer.%d",
1471                 surfaceid, window->layerid);
1472     }
1473     else    {
1474         layer->removeSurface(surfaceid);
1475     }
1476
1477     // send message
1478     CicoSCMessage *message = new CicoSCMessage();
1479     message->addRootObject("command", MSG_CMD_DESTROY);
1480     message->addRootObject("appid", window->appid);
1481     message->addRootObject("pid", window->pid);
1482     message->addArgObject("surface", window->surfaceid);
1483     message->addArgObject("winname", window->name);
1484     CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1485
1486     // TODO delete window in application
1487     if (NULL != m_resMgr) {
1488         CicoSCCommand cmd;
1489         CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1490
1491         cmd.cmdid = MSG_CMD_DESTORY_RES;
1492         cmd.appid = window->appid;
1493         cmd.pid   = window->pid;
1494         cmd.opt = opt;
1495
1496         opt->dispres   = true;
1497         opt->winname   = window->name;
1498         opt->surfaceid = window->surfaceid;
1499
1500         string fullname;
1501         const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1502         if (NULL != zone) {
1503             opt->dispzone = zone->fullname;
1504         }
1505
1506         opt->soundres  = true;
1507         opt->soundname = window->appid;
1508         opt->soundid   = 0;
1509         CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1510         const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1511         if (NULL != defconf) {
1512             const CicoSCSoundZoneConf *zoneconf =
1513                 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1514             if (NULL != zoneconf) {
1515                 opt->soundzone = zoneconf->fullname;
1516             }
1517         }
1518         m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1519     }
1520     // delete window in list
1521     m_windowList.erase(window->surfaceid);
1522     delete(window);
1523
1524     ICO_TRA("CicoSCWindowController::destroySurfaceCB: Leave");
1525 }
1526
1527 //--------------------------------------------------------------------------
1528 /**
1529  *  @brief  wayland update surface name callback
1530  *
1531  *  @param [in] surfaceid       surface Id
1532  *  @param [in] winname         surface name (title)
1533  */
1534 //--------------------------------------------------------------------------
1535 void
1536 CicoSCWindowController::updateWinnameCB(uint32_t surfaceid,
1537                                         const char *winname)
1538 {
1539     ICO_TRA("CicoSCWindowController::updateWinnameCB: Enter(%08x,<%s>)",
1540             surfaceid, winname ? winname : "(null)");
1541
1542     CicoSCWindow *window = findWindow(surfaceid);
1543     if (NULL == window) {
1544         ICO_WRN("CicoSCWindowController::updateWinnameCB: not found window(%08x)",
1545                 surfaceid);
1546         ICO_TRA("CicoSCWindowController::updateWinnameCB Leave");
1547         return;
1548     }
1549
1550     window->name = winname;
1551
1552     // send message
1553     CicoSCMessage *message = new CicoSCMessage();
1554     message->addRootObject("command", MSG_CMD_NAME);
1555     message->addRootObject("appid", window->appid);
1556     message->addRootObject("pid", window->pid);
1557     message->addArgObject("surface", window->surfaceid);
1558     message->addArgObject("winname", window->name);
1559     CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1560
1561     ICO_TRA("CicoSCWindowController::updateWinnameCB: Leave");
1562 }
1563
1564 //--------------------------------------------------------------------------
1565 /**
1566  *  @brief   wayland display attribute callback
1567  *
1568  *  @param [in] data            user data(unused)
1569  *  @param [in] wl_output       wayland wl_output interface
1570  *  @param [in] x               display upper-left X coordinate
1571  *  @param [in] y               display upper-left Y coordinate
1572  *  @param [in] physical_width  display physical width
1573  *  @param [in] physical_height display physical height
1574  *  @param [in] subpixel        display sub pixel
1575  *  @param [in] make            display maker
1576  *  @param [in] model           display model
1577  *  @param [in] transform       transform
1578  */
1579 //--------------------------------------------------------------------------
1580 void
1581 CicoSCWindowController::outputGeometryCB(void             *data,
1582                                          struct wl_output *wl_output,
1583                                          int32_t          x,
1584                                          int32_t          y,
1585                                          int32_t          physical_width,
1586                                          int32_t          physical_height,
1587                                          int32_t          subpixel,
1588                                          const char       *make,
1589                                          const char       *model,
1590                                          int32_t          transform)
1591 {
1592     ICO_TRA("CicoSCWindowController::outputGeometryCB Enter"
1593             "(x=%d y=%d physical_width=%d physical_height=%d "
1594             "subpixel=%d make=%s model=%s transform=%d)",
1595             x, y, physical_width, physical_height,
1596             subpixel, make, model, transform);
1597
1598     ++ m_physicalDisplayTotal;
1599     if (0 == m_displayList.size()) {
1600         ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1601                 "(display is zero)");
1602         return;
1603     }
1604
1605     if (m_displayList.size() < m_physicalDisplayTotal) {
1606         ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1607                 "(display total unmatch)");
1608         return;
1609     }
1610
1611     CicoSCDisplay* display = m_displayList.at(m_physicalDisplayTotal-1);
1612     switch (transform) {
1613     case WL_OUTPUT_TRANSFORM_90:
1614     case WL_OUTPUT_TRANSFORM_270:
1615     case WL_OUTPUT_TRANSFORM_FLIPPED_90:
1616     case WL_OUTPUT_TRANSFORM_FLIPPED_270:
1617         display->pWidth      = physical_height;
1618         display->pHeight     = physical_width;
1619         display->orientation = CicoSCDisplay::ORIENTATION_VERTICAL;
1620         break;
1621     case WL_OUTPUT_TRANSFORM_NORMAL:
1622     case WL_OUTPUT_TRANSFORM_180:
1623     case WL_OUTPUT_TRANSFORM_FLIPPED:
1624     case WL_OUTPUT_TRANSFORM_FLIPPED_180:
1625     default:
1626         display->pWidth      = physical_width;
1627         display->pHeight     = physical_height;
1628         display->orientation = CicoSCDisplay::ORIENTATION_HORIZONTAL;
1629         break;
1630     }
1631     display->dump();
1632
1633     ICO_TRA("CicoSCWindowController::outputGeometryCB Leave");
1634 }
1635
1636 //--------------------------------------------------------------------------
1637 /**
1638  *  @brief  wayland display mode callback
1639  *
1640  *  @param [in] data        user data(unused)
1641  *  @param [in] wl_output   wayland wl_output interface
1642  *  @param [in] flags       flags
1643  *  @param [in] width       display width
1644  *  @param [in] height      display height
1645  *  @param [in] refresh     display refresh rate
1646  */
1647 //--------------------------------------------------------------------------
1648 void
1649 CicoSCWindowController::outputModeCB(void             *data,
1650                                      struct wl_output *wl_output,
1651                                      uint32_t         flags,
1652                                      int32_t          width,
1653                                      int32_t          height,
1654                                      int32_t          refresh)
1655 {
1656     ICO_TRA("CicoSCWindowController::outputModeCB Enter"
1657             "(flags=%d width=%d height=%d refresh=%d)",
1658             flags, width, height, refresh);
1659
1660     if (0 == m_displayList.size()) {
1661         ICO_TRA("CicoSCWindowController::outputModeCB Leave(display is zero)");
1662         return;
1663     }
1664
1665     CicoSCDisplay* display = m_displayList.at(0);
1666     if (flags & WL_OUTPUT_MODE_CURRENT) {
1667         if (display->orientation == CicoSCDisplay::ORIENTATION_VERTICAL) {
1668             display->pWidth  = height;
1669             display->pHeight = width;
1670         }
1671         else {
1672             display->pWidth  = width;
1673             display->pHeight = height;
1674         }
1675         display->dump();
1676     }
1677
1678     ICO_TRA("CicoSCWindowController::outputModeCB Leave");
1679 }
1680
1681 //--------------------------------------------------------------------------
1682 /**
1683  *  @brief  wayland genivi ivi-shell surface create callback
1684  *
1685  *  @param [in] data        user data
1686  *  @param [in] ivi_controller  wayland ivi-controller plugin interface
1687  *  @param [in] id_surface      surface id
1688  */
1689 //--------------------------------------------------------------------------
1690 void
1691 CicoSCWindowController::createSurfaceCB(void *data,
1692                                         struct ivi_controller *ivi_controller,
1693                                         uint32_t id_surface)
1694 {
1695     struct ilmSurfaceProperties SurfaceProperties;
1696
1697     ICO_TRA("CicoSCWindowController::createSurfaceCB Enter"
1698             "(surfaceid=%08x)", id_surface);
1699
1700     if (ilm_getPropertiesOfSurface(id_surface, &SurfaceProperties) != ILM_SUCCESS)  {
1701         ICO_ERR("CicoSCWindowController::createSurfaceCB: ilm_getPropertiesOfSurface(%x) Error",
1702                 id_surface);
1703         return;
1704     }
1705     ICO_TRA("createSurfaceCB: surface=%d(0x%08x) pid=%d w/h=%d/%d(%d/%d)->%d/%d",
1706             id_surface, id_surface, SurfaceProperties.creatorPid,
1707             SurfaceProperties.sourceWidth, SurfaceProperties.sourceHeight,
1708             SurfaceProperties.origSourceWidth, SurfaceProperties.origSourceHeight,
1709             SurfaceProperties.destWidth, SurfaceProperties.destHeight);
1710
1711 #if 1       /* 2014/08/20 workaround, SurfaceProperties.creatorPid not set */
1712     if (SurfaceProperties.creatorPid == 0)  {
1713         SurfaceProperties.creatorPid = (id_surface - 6000) / 100;
1714         ICO_WRN("createSurfaceCB: surface=%d(0x%08x) pid is Zero, workaround to %d",
1715                 id_surface, id_surface, SurfaceProperties.creatorPid);
1716     }
1717 #endif
1718
1719     CicoSCWindow* window = new CicoSCWindow();
1720     window->surfaceid = id_surface;
1721     window->name = "";
1722     window->pid  = SurfaceProperties.creatorPid;
1723     window->displayid = 0;              // currently fixed 0
1724     window->raise = 1;                  // created surface is top of layer
1725     window->srcwidth = SurfaceProperties.sourceWidth;
1726     window->srcheight = SurfaceProperties.sourceHeight;
1727     window->width = SurfaceProperties.destWidth;
1728     window->height = SurfaceProperties.destHeight;
1729     window->layerid = 0;
1730
1731 #ifdef GENIVI_WL_SHELL_INFO         /* GENIVI-LM is supporting the wl_shell_info    */
1732     const char *title = CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(id_surface, &pid);
1733
1734     if (title) {
1735         window->name = title;
1736         window->pid  = pid;
1737     }
1738     else {
1739         ICO_WRN("Could not find window title!");
1740     }
1741 #endif /*GENIVI_WL_SHELL_INFO*/     /* GENIVI-LM is supporting the wl_shell_info    */
1742
1743     CicoSCLifeCycleController* appctrl;
1744     appctrl = CicoSCLifeCycleController::getInstance();
1745     const CicoAilItems* ailItem = NULL;
1746     const CicoAulItems* aulitem = appctrl->findAUL(window->pid);
1747     if (NULL == aulitem) {
1748         /* client does not exist in AppCore, search parent process  */
1749         ICO_DBG("application information not found. search parent process");
1750
1751         int     fd;
1752         int     cpid = window->pid;
1753         int     ppid;
1754         int     size;
1755         char    *ppid_line;
1756         char    procpath[PATH_MAX];
1757
1758         while ((cpid > 1) && (aulitem == NULL)) {
1759             snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", cpid);
1760
1761             fd = open(procpath, O_RDONLY);
1762             if (fd < 0)     break;
1763
1764             size = read(fd, procpath, sizeof(procpath));
1765             close(fd);
1766
1767             if (size <= 0)  break;
1768             ppid_line = strstr(procpath, "PPid");
1769
1770             if (ppid_line == NULL)  break;
1771             ppid = 0;
1772             sscanf(ppid_line, "PPid:    %d", &ppid);
1773             if (ppid <= 1)  break;
1774             ICO_DBG("application pid=%d parent=%d", cpid, ppid);
1775             cpid = ppid;
1776             aulitem = appctrl->findAUL(cpid);
1777         }
1778     }
1779     if (NULL != aulitem) {
1780         window->appid = aulitem->m_appid;
1781         ICO_DBG("appid=%s", window->appid.c_str());
1782         ailItem = appctrl->findAIL(window->appid.c_str());
1783
1784         window->layerid = ailItem->m_layer;
1785         window->zoneid  = ailItem->m_displayZone;
1786         window->nodeid  = ailItem->m_nodeID;
1787         if ((window->displayid >= 0) && (window->zoneid >= 0)) {
1788
1789             const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1790             if (NULL != zone) {
1791                 window->zone   = zone->fullname;
1792                 window->x      = zone->x;
1793                 window->y      = zone->y;
1794                 window->width  = zone->width;
1795                 window->height = zone->height;
1796             }
1797         }
1798     }
1799     else{
1800         delete window;
1801         ICO_WRN("ail item not found.");
1802         ICO_TRA("CicoSCWindowController::createSurfaceCB Leave(ENOENT)");
1803         return;
1804     }
1805
1806     if (ilm_surfaceSetDestinationRectangle(window->surfaceid, window->x, window->y,
1807                  window->width, window->height) != ILM_SUCCESS) {
1808         ICO_ERR("CicoSCWindowController::createSurfaceCB "
1809                 "ilm_surfaceSetDestinationRectangle(%08x) Error", window->surfaceid);
1810     }
1811     else if (ilm_surfaceSetSourceRectangle(window->surfaceid, 0, 0,
1812                  window->width, window->height) != ILM_SUCCESS) {
1813         ICO_ERR("CicoSCWindowController::createSurfaceCB "
1814                 "ilm_surfaceSetSourceRectangle(%08x) Error", window->surfaceid);
1815     }
1816     else if (ilm_surfaceSetOrientation(window->surfaceid, ILM_ZERO) != ILM_SUCCESS) {
1817         ICO_ERR("CicoSCWindowController::createSurfaceCB "
1818                 "ilm_surfaceSetOrientation(%08x) Error", window->surfaceid);
1819     }
1820     else if (ilm_commitChanges() != ILM_SUCCESS)    {
1821         ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1822     }
1823
1824     CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
1825     if (layer) {
1826         if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
1827             ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_layerAddSurface(%d,%08x) "
1828                     "Error", window->layerid, window->surfaceid);
1829         }
1830         if (ilm_commitChanges() != ILM_SUCCESS)    {
1831             ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1832         }
1833
1834         layer->addSurface(window->surfaceid, true);
1835         int nsurf;
1836         const int *surfs = layer->getSurfaces(&nsurf);
1837         if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
1838             != ILM_SUCCESS)   {
1839             ICO_ERR("CicoSCWindowController::createSurfaceCB: "
1840                     "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
1841         }
1842         if (ilm_commitChanges() != ILM_SUCCESS)    {
1843             ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1844         }
1845     }
1846     // must set surfaceOpacity after surfcaeAddLayer
1847     if (ilm_surfaceSetOpacity(window->surfaceid , (t_ilm_float)1.0f) != ILM_SUCCESS)    {
1848         ICO_ERR("CicoSCWindowController::createSurfaceCB "
1849                             "ilm_surfaceSetOpacity(%08x) Error", window->surfaceid);
1850     }
1851     else if (ilm_commitChanges() != ILM_SUCCESS)    {
1852         ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1853     }
1854
1855     appctrl->enterAUL(window->appid.c_str(), window->pid, window);
1856
1857     // dump log window information
1858     window->dump();
1859
1860     m_windowList[window->surfaceid] = window;
1861
1862     // set surface attributes
1863     setAttributes(window->surfaceid);
1864
1865     // send message
1866     CicoSCMessage *message = new CicoSCMessage();
1867     message->addRootObject("command", MSG_CMD_CREATE);
1868     message->addRootObject("appid", window->appid);
1869     message->addRootObject("pid", window->pid);
1870     message->addArgObject("surface", window->surfaceid);
1871     message->addArgObject("winname", window->name);
1872     CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1873
1874     if (0 == window->appid.compare(ICO_SC_APPID_DEFAULT_ONS)) {
1875         CicoSCMessageRes *msgOS = new CicoSCMessageRes();
1876         msgOS->addRootObject("command",   MSG_CMD_WINDOW_ID_RES);
1877         msgOS->addRootObject("appid",     window->appid);
1878         msgOS->addRootObject("pid",       window->pid);
1879         msgOS->addWinObject(MSG_PRMKEY_ECU,         "");
1880         msgOS->addWinObject(MSG_PRMKEY_DISPLAY,     "");
1881         msgOS->addWinObject(MSG_PRMKEY_LAYER,       "");
1882         msgOS->addWinObject(MSG_PRMKEY_LAYOUT,      "");
1883         msgOS->addWinObject(MSG_PRMKEY_AREA,        "");
1884         msgOS->addWinObject(MSG_PRMKEY_DISPATCHAPP, "");
1885         msgOS->addWinObject(MSG_PRMKEY_ROLE,        window->name);
1886         msgOS->addWinObject(MSG_PRMKEY_RESOURCEID,  window->surfaceid);
1887         CicoSCServer::getInstance()->sendMessage(window->appid,
1888                                                  (CicoSCMessage*)msgOS);
1889     }
1890
1891     if (NULL != m_resMgr) {
1892         CicoSCCommand cmd;
1893         CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1894
1895         cmd.cmdid = MSG_CMD_CREATE_RES;
1896         cmd.appid = window->appid;
1897         cmd.pid   = window->pid;
1898         cmd.opt = opt;
1899
1900         opt->dispres   = true;
1901         opt->winname   = window->name;
1902         opt->surfaceid = window->surfaceid;
1903
1904         string fullname;
1905         const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1906         if (NULL != zone) {
1907             opt->dispzone = zone->fullname;
1908         }
1909
1910 #if 1   //TODO
1911         opt->soundres  = true;
1912         opt->soundname = window->appid;
1913         opt->soundid   = 0;
1914         CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1915         const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1916         if (NULL != defconf) {
1917             const CicoSCSoundZoneConf *zoneconf =
1918                 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1919             if (NULL != zoneconf) {
1920                 opt->soundzone = zoneconf->fullname;
1921             }
1922         }
1923 #endif
1924         m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1925     }
1926     else {
1927         show(window->surfaceid, NULL, 0);
1928     }
1929
1930     // set surface change notification
1931     if (ilm_surfaceAddNotification(window->surfaceid, wlGeniviSurfaceNotification)
1932             != ILM_SUCCESS) {
1933         ICO_ERR("CicoSCWindowController::createSurfaceCB "
1934                 "ilm_surfaceAddNotification(%08x) Error", window->surfaceid);
1935     }
1936
1937     ICO_TRA("CicoSCWindowController::createSurfaceCB Leave");
1938 }
1939
1940 //--------------------------------------------------------------------------
1941 /**
1942  *  @brief   genivi ivi-shell layer propaty callback
1943  *
1944  *  @param [in] layer           layer id
1945  *  @param [in] LayerProperties layer properties
1946  *  @param [in] mask            change properties
1947  */
1948 //--------------------------------------------------------------------------
1949 void
1950 CicoSCWindowController::wlGeniviLayerNotification(t_ilm_layer layer,
1951                                             struct ilmLayerProperties *LayerProperties,
1952                                             t_ilm_notification_mask mask)
1953 {
1954     ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Enter(%x,,%x)", layer, mask);
1955
1956     if (mask & ILM_NOTIFICATION_VISIBILITY) {
1957         // change layer visibility, send message to HomeScreen
1958         CicoSCMessage *message = new CicoSCMessage();
1959         message->addRootObject("command", MSG_CMD_CHANGE_LAYER_ATTR);
1960         message->addRootObject("appid", "");
1961         message->addArgObject("layer", layer);
1962         message->addArgObject("visible", LayerProperties->visibility ? 1 : 0);
1963         CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1964     }
1965     ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Leave");
1966 }
1967
1968 //--------------------------------------------------------------------------
1969 /**
1970  *  @brief  setup Genivi ivi-shell layer managerment system finctions
1971  *
1972  *  @param      none
1973  */
1974 //--------------------------------------------------------------------------
1975 void
1976 CicoSCWindowController::initializeGeniviLMS(void)
1977 {
1978     t_ilm_uint  NumberOfScreens = 0;
1979     t_ilm_layer *pLayerId, *ppLayerId;
1980     t_ilm_int   LayerNumber;
1981     t_ilm_uint  *pScreenIds;
1982     struct ilmScreenProperties  ScreenProperties;
1983     int                     idxs, idx1, idx2;
1984     int                     DisplayId, LayerId;
1985     const CicoSCDisplayConf *DisplayConf;
1986     const CicoSCLayerConf   *LayerConf;
1987
1988     // get all screen id
1989     if ((ilm_getScreenIDs(&NumberOfScreens, &pScreenIds) != ILM_SUCCESS) ||
1990         (NumberOfScreens <= 0)) {
1991         ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
1992                 "ilm_getScreenIDs() Error(num=%d)", NumberOfScreens);
1993         return;
1994     }
1995     ICO_TRA("initializeGeniviLMS: Screens=%d.%x %x", NumberOfScreens, pScreenIds[0],
1996             NumberOfScreens >= 2 ? pScreenIds[1] : 0);
1997     if ((int)NumberOfScreens > CicoSystemConfig::getInstance()->getNumberofDisplay())   {
1998         ICO_WRN("CicoSCWindowController::initializeGeniviLMS # of screens physical=%d config=%d",
1999                 NumberOfScreens, CicoSystemConfig::getInstance()->getNumberofDisplay());
2000         NumberOfScreens = (t_ilm_uint)CicoSystemConfig::getInstance()->getNumberofDisplay();
2001     }
2002 #if 1           /* At present, GENIVI (ivi-controller) is processing only one Display   */
2003     for (idxs = (int)NumberOfScreens - 1; idxs >= 0; idxs--)
2004 #else
2005     for (idxs = 0; idxs < (int)NumberOfScreens; idxs++)
2006 #endif
2007     {
2008         if (ilm_getPropertiesOfScreen(pScreenIds[idxs], &ScreenProperties) != ILM_SUCCESS)   {
2009             ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2010                     "ilm_getPropertiesOfScreen(%d.%x) Error", idxs, pScreenIds[idxs]);
2011             continue;
2012         }
2013         // It is referred to as Center when there is only one display
2014         if (NumberOfScreens == 1)   {
2015             DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyType(ICO_NODETYPE_CENTER);
2016         }
2017         else    {
2018             DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyNo((int)pScreenIds[idxs]);
2019         }
2020         ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
2021                 "Screen[%d.%x] w/h=%d/%d layers=%d DisplayId=%d",
2022                 idxs, pScreenIds[idxs], ScreenProperties.screenWidth,
2023                 ScreenProperties.screenHeight, ScreenProperties.layerCount, DisplayId);
2024
2025         if ((DisplayId < 0) ||
2026             ((DisplayConf = CicoSystemConfig::getInstance()->findDisplayConfbyId(DisplayId))
2027                 == NULL))   {
2028             ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2029                     "ScreenId.%x not found", pScreenIds[idxs]);
2030         }
2031         else    {
2032             // set genivi layers
2033             for (idx1 = 0; ; idx1++)  {
2034                 LayerConf = CicoSystemConfig::getInstance()->
2035                                                 findLayerConfbyIdx(DisplayId, idx1);
2036                 if (! LayerConf)    break;
2037             }
2038             pLayerId = (t_ilm_layer *)malloc(sizeof(t_ilm_layer) * idx1);
2039             ppLayerId = pLayerId;
2040             LayerNumber = 0;
2041
2042             for (idx1 = 0; ; idx1++)  {
2043                 LayerConf = CicoSystemConfig::getInstance()->
2044                                                 findLayerConfbyIdx(DisplayId, idx1);
2045                 if (! LayerConf)    break;
2046
2047                 LayerId = LayerConf->id + DisplayId * ICO_SC_LAYERID_SCREENBASE;
2048                 for (idx2 = 0; idx2 < LayerNumber; idx2++)  {
2049                     if (LayerId == (int)pLayerId[idx2]) break;
2050                 }
2051                 if (idx2 < LayerNumber) {
2052                     ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
2053                             "layer.%d exist, Skip", LayerId);
2054                     continue;
2055                 }
2056
2057                 if (ilm_layerCreateWithDimension((t_ilm_layer *)&LayerId,
2058                             DisplayConf->width, DisplayConf->height) != ILM_SUCCESS)    {
2059                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2060                             "ilm_layerCreateWithDimension(%d,%d,%d) Error",
2061                             LayerId, DisplayConf->width, DisplayConf->height);
2062                 }
2063                 else if (ilm_commitChanges() != ILM_SUCCESS) {
2064                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2065                             "ilm_commitChanges() Error");
2066                 }
2067                 else if (ilm_layerSetOpacity(LayerId, (t_ilm_float)1.0f) != ILM_SUCCESS) {
2068                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2069                             "ilm_layerSetOpacity(%d) Error", LayerId);
2070                 }
2071                 else if (ilm_layerSetSourceRectangle(LayerId, 0, 0,
2072                              DisplayConf->width, DisplayConf->height) != ILM_SUCCESS)   {
2073                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2074                             "ilm_layerSetSourceRectangle(%d) Error", LayerId);
2075                 }
2076                 else if (ilm_layerSetDestinationRectangle(LayerId, 0, 0,
2077                              DisplayConf->width, DisplayConf->height) != ILM_SUCCESS)   {
2078                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2079                             "ilm_layerSetDestinationRectangle(%d) Error", LayerId);
2080                 }
2081                 else if (ilm_layerSetOrientation(LayerId, ILM_ZERO) != ILM_SUCCESS) {
2082                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2083                             "ilm_layerSetOrientation(%d) Error", LayerId);
2084                 }
2085                 else    {
2086                     if (ilm_commitChanges() != ILM_SUCCESS) {
2087                         ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2088                                 "ilm_commitChanges() Error");
2089                     }
2090                     // SystemController default is layer visible
2091                     if ((ilm_layerSetVisibility(LayerId, 1) != ILM_SUCCESS) ||
2092                         (ilm_commitChanges() != ILM_SUCCESS))   {
2093                         ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2094                                 "ilm_layerSetVisibility() Error");
2095                     }
2096                     ICO_TRA("initializeGeniviLMS: layer=%d created(%d,%d)",
2097                             LayerId, DisplayConf->width, DisplayConf->height);
2098                     *ppLayerId = LayerId;
2099                     ppLayerId ++;
2100                     LayerNumber ++;
2101                 }
2102             }
2103             if (LayerNumber > 0)    {
2104                 ICO_TRA("initializeGeniviLMS: layers %d.%d %d %d %d set to screen %x",
2105                         LayerNumber, pLayerId[0], pLayerId[1], pLayerId[2], pLayerId[3],
2106                         pScreenIds[idxs]);
2107                 if (ilm_displaySetRenderOrder(pScreenIds[idxs], pLayerId, LayerNumber)
2108                     != ILM_SUCCESS)   {
2109                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2110                             "ilm_displaySetRenderOrder(%d) Error", LayerNumber);
2111                 }
2112                 else if (ilm_commitChanges() != ILM_SUCCESS) {
2113                     ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2114                             "ilm_commitChanges() Error");
2115                 }
2116                 ppLayerId = pLayerId;
2117                 for (idx2 = 0; idx2 < LayerNumber; idx2++) {
2118                     if (ilm_layerAddNotification(*ppLayerId, wlGeniviLayerNotification)
2119                         != ILM_SUCCESS)   {
2120                         ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2121                                 "ilm_layerAddNotification(%d) Error", *ppLayerId);
2122                     }
2123                     ppLayerId ++;
2124                 }
2125             }
2126             free(pLayerId);
2127         }
2128     }
2129     free(pScreenIds);
2130 }
2131
2132 //==========================================================================
2133 // private method
2134 //==========================================================================
2135
2136 //--------------------------------------------------------------------------
2137 /**
2138  *  @brief  find window object by surfaceid
2139  *
2140  *  @param [in] surfaceid   wayland surface id
2141  */
2142 //--------------------------------------------------------------------------
2143 CicoSCWindow*
2144 CicoSCWindowController::findWindow(int surfaceid)
2145 {
2146     map<unsigned int, CicoSCWindow*>::iterator itr;
2147     itr = m_windowList.find(surfaceid);
2148     if (m_windowList.end() == itr) {
2149         ICO_TRA("not found window object. surfaceid=%08x", surfaceid);
2150         return NULL;
2151     }
2152
2153     return itr->second;
2154 }
2155
2156 //--------------------------------------------------------------------------
2157 /**
2158  *  @brief  find window object by surfaceid
2159  *
2160  *  @param [in] surfaceid   wayland surface id
2161  */
2162 //--------------------------------------------------------------------------
2163 CicoSCLayer*
2164 CicoSCWindowController::findLayer(int displayid, int layerid)
2165 {
2166     vector<CicoSCDisplay*>::iterator itr;
2167     itr = m_displayList.begin();
2168     for (; itr != m_displayList.end(); ++itr) {
2169         if ((*itr)->displayid != displayid) {
2170             continue;
2171         }
2172         vector<CicoSCLayer*>::iterator itr2;
2173         itr2 = (*itr)->layerList.begin();
2174         for (; itr2 != (*itr)->layerList.end(); ++itr2) {
2175             if ((*itr2)->layerid == layerid) {
2176                 return *itr2;
2177             }
2178         }
2179     }
2180     return NULL;
2181 }
2182
2183 //--------------------------------------------------------------------------
2184 /**
2185  *  @brief  find display zone by id
2186  */
2187 //--------------------------------------------------------------------------
2188 const CicoSCDisplayZone *
2189 CicoSCWindowController::findDisplayZone(int zoneid)
2190 {
2191     vector<CicoSCDisplay*>::iterator itr;
2192     itr = m_displayList.begin();
2193     for (; itr != m_displayList.end(); ++itr) {
2194         std::map<unsigned int, CicoSCDisplayZone*>::iterator itr2;
2195         itr2 = (*itr)->zoneList.find(zoneid);
2196         if ((*itr)->zoneList.end() != itr2) {
2197             return itr2->second;
2198         }
2199     }
2200     return NULL;
2201 }
2202
2203 //--------------------------------------------------------------------------
2204 /**
2205  *  @brief  handle command
2206  *
2207  *  @param [in] cmd     control command
2208  */
2209 //--------------------------------------------------------------------------
2210 void
2211 CicoSCWindowController::handleCommand(const CicoSCCommand * cmd)
2212 {
2213 //    ICO_TRA("CicoSCWindowController::handleCommand Enter(%d)", cmd->cmdid);
2214
2215     CicoSCCmdWinCtrlOpt *opt = static_cast<CicoSCCmdWinCtrlOpt*>(cmd->opt);
2216
2217     switch (cmd->cmdid) {
2218     case MSG_CMD_SHOW:
2219         ICO_DBG("command: MSG_CMD_SHOW");
2220         if (opt->animationTime & ICO_SYC_WIN_SURF_NORESCTL) {
2221             /* show command but not resource control (for HomeScreen)   */
2222             (void)show(opt->surfaceid,
2223                        opt->animation.c_str(),
2224                        opt->animationTime);
2225         }
2226         else {
2227             /* show command (normal)    */
2228             (void)notifyResourceManager(opt->surfaceid,
2229                                         NULL,
2230                                         opt->layerid,
2231                                         opt->animation.c_str(),
2232                                         opt->animationTime);
2233         }
2234         break;
2235     case MSG_CMD_HIDE:
2236         ICO_DBG("command: MSG_CMD_HIDE");
2237         (void)hide(opt->surfaceid, opt->animation.c_str(), opt->animationTime);
2238         break;
2239     case MSG_CMD_MOVE:
2240     {
2241         ICO_DBG("command: MSG_CMD_MOVE");
2242         CicoSCWindow *window = findWindow(opt->surfaceid);
2243         if (NULL == window) {
2244             break;
2245         }
2246         if (true == opt->zone.empty()) {
2247             (void)setGeometry(opt->surfaceid, opt->nodeid, opt->layerid,
2248                               opt->x, opt->y, opt->width, opt->height,
2249                               opt->animation.c_str(), opt->animationTime,
2250                               opt->animation.c_str(), opt->animationTime);
2251         }
2252         else if (opt->zone == window->zone) {
2253             (void)setGeometry(opt->surfaceid, opt->zone.c_str(), opt->layerid,
2254                               opt->animation.c_str(), opt->animationTime,
2255                               opt->animation.c_str(), opt->animationTime);
2256         }
2257         else {
2258             (void)notifyResourceManager(opt->surfaceid,
2259                                         opt->zone.c_str(),
2260                                         opt->layerid,
2261                                         opt->animation.c_str(),
2262                                         opt->animationTime);
2263         }
2264         break;
2265     }
2266     case MSG_CMD_CHANGE_ACTIVE:
2267         ICO_DBG("command: MSG_CMD_CHANGE_ACTIVE");
2268         (void)active(opt->surfaceid, opt->active);
2269         break;
2270     case MSG_CMD_CHANGE_LAYER:
2271         ICO_DBG("command: MSG_CMD_CHANGE_LAYER");
2272         (void)setWindowLayer(opt->surfaceid, opt->layerid);
2273         break;
2274     case MSG_CMD_MAP_GET:
2275         ICO_DBG("command: MSG_CMD_MAP_GET");
2276         (void)setmapGet(opt->surfaceid, opt->animation.c_str());
2277         break;
2278     case MSG_CMD_MAP_THUMB:
2279         ICO_DBG("command: MSG_CMD_MAP_THUMB");
2280         (void)mapSurface(opt->surfaceid, opt->framerate, opt->animation.c_str());
2281         break;
2282     case MSG_CMD_UNMAP_THUMB:
2283         ICO_DBG("command: MSG_CMD_UNMAP_THUMB");
2284         (void)unmapSurface(opt->surfaceid);
2285         break;
2286     case MSG_CMD_SHOW_LAYER:
2287         ICO_DBG("command: MSG_CMD_SHOW_LAYER");
2288         (void)showLayer(opt->displayid, opt->layerid);
2289         break;
2290     case MSG_CMD_HIDE_LAYER:
2291         ICO_DBG("command: MSG_CMD_HIDE_LAYER");
2292         (void)hideLayer(opt->displayid, opt->layerid);
2293         break;
2294     default:
2295         ICO_WRN("command: Unknown(0x%08x)", cmd->cmdid);
2296         break;
2297     }
2298
2299 //    ICO_TRA("CicoSCWindowController::handleCommand Leave");
2300 }
2301
2302 int
2303 CicoSCWindowController::notifyResourceManager(int        surfaceid,
2304                                               const char *zone,
2305                                               int        layerid,
2306                                               const char *animation,
2307                                               int        animationTime)
2308 {
2309     ICO_TRA("CicoSCWindowController::notifyResourceManager Enter"
2310             "(surfaceid=%08x zone=%s layerid=%d "
2311             "animation=%s animationTime=%d)",
2312             surfaceid, zone, layerid, animation, animationTime);
2313
2314     // find window information in window list
2315     CicoSCWindow *window = findWindow(surfaceid);
2316     if (NULL == window) {
2317         ICO_WRN("not found window information");
2318         ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2319         return ICO_SYC_ENOENT;
2320     }
2321
2322     CicoSCCommand cmd;
2323     CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
2324
2325     cmd.cmdid = MSG_CMD_ACQUIRE_RES;
2326     cmd.appid = window->appid;
2327     cmd.pid   = window->pid;
2328     cmd.opt   = opt;
2329
2330     opt->dispres       = true;
2331     opt->winname       = window->name;
2332     opt->layerid       = layerid;
2333     opt->surfaceid     = window->surfaceid;
2334     opt->animation     = animation ? animation : "";
2335     opt->animationTime = animationTime;
2336     string fullname;
2337     if (NULL == zone) {
2338         const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
2339         if (NULL != zone) {
2340             opt->dispzone = zone->fullname;
2341         }
2342         else {
2343             ICO_WRN("not found zone information");
2344             ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2345             return ICO_SYC_ENOENT;
2346         }
2347     }
2348     else {
2349         opt->dispzone = zone;
2350     }
2351 #if 1   //TODO
2352     opt->soundres  = true;
2353     opt->soundname = window->appid;
2354     opt->soundid   = 0;
2355     CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
2356     const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
2357     if (NULL != defconf) {
2358         const CicoSCSoundZoneConf *zoneconf =
2359             sysconf->findSoundZoneConfbyId(defconf->soundzone);
2360         if (NULL != zoneconf) {
2361             opt->soundzone = zoneconf->fullname;
2362         }
2363     }
2364 #endif
2365
2366     m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
2367
2368     ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(EOK)");
2369     return ICO_SYC_EOK;
2370 }
2371
2372 const CicoSCWindow*
2373 CicoSCWindowController::findWindowObj(int32_t pid, uint32_t surfaceid) const
2374 {
2375     const CicoSCWindow* r = NULL;
2376     map<unsigned int, CicoSCWindow*>::const_iterator itr = m_windowList.begin();
2377     for (; itr != m_windowList.end(); ++itr) {
2378         const CicoSCWindow* tmp = itr->second;
2379         if ((pid == tmp->pid) && (surfaceid == (uint32_t)tmp->surfaceid)) {
2380             r = tmp;
2381             break;  // break of for itr
2382         }
2383     }
2384     ICO_TRA("return %x", r);
2385     return r;
2386 }
2387
2388 const CicoSCResourceManager*
2389 CicoSCWindowController::getResourceManager(void) const
2390 {
2391     return m_resMgr;
2392 }
2393
2394 //--------------------------------------------------------------------------
2395 /**
2396  * @brief Window Check Timer
2397  * @param data      this object
2398  */
2399 //--------------------------------------------------------------------------
2400 Eina_Bool
2401 CicoSCWindowController::ico_SCWindowChecker(void *data)
2402 {
2403     struct ico_sc_win_check_t   *tp, *bp;
2404     struct timeval      curtime;
2405     int                 ntime;
2406     int                 delflag;
2407     int                 commflag;
2408     int                 par;
2409     int                 htimer = 0;
2410     double              rate;
2411     int                 x, y;
2412
2413     gettimeofday(&curtime, NULL);
2414
2415     if ((curtime.tv_sec < g_lasttime.tv_sec) ||
2416         ((curtime.tv_sec - g_lasttime.tv_sec) > 2)) {
2417         ntime = ICO_SC_WINCHK_TIMER_BASE;
2418         htimer ++;
2419     }
2420     else    {
2421         ntime = (curtime.tv_sec - g_lasttime.tv_sec) * 1000;
2422         if (curtime.tv_usec >= g_lasttime.tv_usec)  {
2423             ntime += (curtime.tv_usec - g_lasttime.tv_usec) / 1000;
2424         }
2425         else    {
2426             ntime += ((1000000 + curtime.tv_usec - g_lasttime.tv_usec) / 1000) - 1000;
2427         }
2428     }
2429     tp = CicoSCWindowController::win_check_timer;
2430     bp = NULL;
2431     delflag = 0;
2432     commflag = 0;
2433     while (tp)  {
2434         tp->lapsed += ntime;
2435         tp->timeout += ntime;
2436         if (tp->function != ICO_SC_WINCHK_CONTENTS_CHECK)   {
2437             htimer ++;
2438         }
2439
2440         if (tp->timeout >= tp->cycle)   {
2441             /* timedout     */
2442             do  {
2443                 tp->timeout -= tp->cycle;
2444             } while (tp->timeout > 0);
2445
2446             switch (tp->function)   {
2447             case ICO_SC_WINCHK_CONTENTS_CHECK:      /* check contents change    */
2448                 if (tp->state == ICO_SC_WINCONT_CHECK)  {
2449                     // GENIVI-LM 1.6.0 not support contents change event
2450                     // get surface image form GENIVI-LM
2451                     ICO_DBG("CicoSCWindowController::ico_SCWindowChecker "
2452                             "call ilm_takeSurfaceScreenshot %d[%x]",
2453                             tp->surfaceid, tp->surfaceid);
2454                     getInstance()->setmapGet(tp->surfaceid, tp->u.cont.path);
2455                     tp->state = ICO_SC_WINCONT_WAITFILE;
2456                     tp->time = ICO_SC_WINCHK_TIMER_BASE;
2457                     tp->cycle = ICO_SC_WINCHK_TIMER_BASE;
2458                     tp->timeout = 0;
2459                 }
2460                 else    {
2461                     struct stat stat_buf;
2462
2463                     if (stat(tp->u.cont.path, &stat_buf) >= 0)  {
2464                         tp->state = ICO_SC_WINCONT_CHECK;
2465                         tp->time = ICO_SC_WINCHK_CONTENTS_TIME;
2466                         tp->cycle = ICO_SC_WINCHK_CONTENTS_TIME;
2467                         tp->timeout = 0;
2468
2469                         getInstance()->mapSurfaceCB(ICO_SC_WINCHK_MAP_SURFACE_EVENT_MAP,
2470                                                     tp->surfaceid, 0,
2471                                                     tp->u.cont.width, tp->u.cont.height,
2472                                                     tp->u.cont.width * 4, 0);
2473                     }
2474                 }
2475                 break;
2476
2477             case ICO_SC_WINCHK_ANIMA_FADE:          /* fade animation           */
2478                 par = ((tp->lapsed * 100 / tp->time) / 3) * 3;
2479                 if (par == tp->par)     break;
2480
2481                 if (par < 0)    par = 0;
2482                 tp->par = par;
2483                 if (par >= 97)  {
2484                     if (ilm_surfaceSetOpacity(tp->surfaceid, 1.0) != ILM_SUCCESS)   {
2485                         ICO_ERR("CicoSCWindowController::ico_SCWindowChecker "
2486                                 "ilm_surfaceSetOpacity Error %d[%x]",
2487                                 tp->surfaceid, tp->surfaceid);
2488                     }
2489                     if (tp->state != ICO_SC_WINANIMA_SHOW)  {
2490                         if (ilm_surfaceSetVisibility(tp->surfaceid, 0) != ILM_SUCCESS)  {
2491                             ICO_ERR("CicoSCWindowController::ico_SCWindowChecker "
2492                                     "ilm_surfaceSetVisibility Error %d[%x]",
2493                                     tp->surfaceid, tp->surfaceid);
2494                         }
2495                     }
2496                     delflag = 1;
2497                 }
2498                 else    {
2499                     if (tp->state == ICO_SC_WINANIMA_SHOW)  {
2500                         rate = ((double)par) / 100.0;
2501                     }
2502                     else    {
2503                         rate = ((double)(100 - par)) / 100.0;
2504                     }
2505                     if (ilm_surfaceSetOpacity(tp->surfaceid, rate) != ILM_SUCCESS) {
2506                         ICO_ERR("CicoSCWindowController::ico_SCWindowChecker "
2507                                 "ilm_surfaceSetOpacity Error %d[%x]",
2508                                 tp->surfaceid, tp->surfaceid);
2509                     }
2510                 }
2511                 commflag ++;
2512                 break;
2513
2514             case ICO_SC_WINCHK_ANIMA_SLIDETOTOP:        /* slide totop animation    */
2515             case ICO_SC_WINCHK_ANIMA_SLIDETOBUTTOM:     /* slide totop animation    */
2516             case ICO_SC_WINCHK_ANIMA_SLIDETOLEFT:       /* slide totop animation    */
2517             case ICO_SC_WINCHK_ANIMA_SLIDETORIGHT:      /* slide totop animation    */
2518                 par = ((tp->lapsed * 100 / tp->time) / 3) * 3;
2519                 if (par == tp->par)     break;
2520
2521                 if (par < 0)    par = 0;
2522                 tp->par = par;
2523                 if (par >= 97)  {
2524                     if (tp->state != ICO_SC_WINANIMA_SHOW)  {
2525                         if (ilm_surfaceSetVisibility(tp->surfaceid, 0) != ILM_SUCCESS)  {
2526                             ICO_ERR("CicoSCWindowController::ico_SCWindowChecker "
2527                                     "ilm_surfaceSetVisibility Error %d[%x]",
2528                                     tp->surfaceid, tp->surfaceid);
2529                         }
2530                     }
2531                     x = tp->u.anim.x;
2532                     y = tp->u.anim.y;
2533                     delflag = 1;
2534                 }
2535                 else    {
2536                     if (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOTOP)    {
2537                         x = tp->u.anim.x;
2538                         if (tp->state == ICO_SC_WINANIMA_SHOW)  {
2539                             y = tp->u.anim.screen_height -
2540                                 (tp->u.anim.screen_height - tp->u.anim.y) * par / 100;
2541                         }
2542                         else    {
2543                             y = tp->u.anim.y +
2544                                 (tp->u.anim.screen_height - tp->u.anim.y) * par / 100;
2545                         }
2546                     }
2547                     else if (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOBUTTOM) {
2548                         x = tp->u.anim.x;
2549                         if (tp->state == ICO_SC_WINANIMA_SHOW)  {
2550                             y = (-tp->u.anim.height) +
2551                                 (tp->u.anim.y + tp->u.anim.height) * par / 100;
2552                         }
2553                         else    {
2554                             y = tp->u.anim.y -
2555                                 (tp->u.anim.height + tp->u.anim.y) * par / 100;
2556                         }
2557                     }
2558                     else if (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOLEFT)   {
2559                         y = tp->u.anim.y;
2560                         if (tp->state == ICO_SC_WINANIMA_SHOW)  {
2561                             x = tp->u.anim.screen_width -
2562                                 (tp->u.anim.screen_width - tp->u.anim.x) * par / 100;
2563                         }
2564                         else    {
2565                             x = tp->u.anim.x +
2566                                 (tp->u.anim.screen_width - tp->u.anim.x) * par / 100;
2567                         }
2568                     }
2569                     else    {
2570                         y = tp->u.anim.y;
2571                         if (tp->state == ICO_SC_WINANIMA_SHOW)  {
2572                             x = (-tp->u.anim.width) +
2573                                 (tp->u.anim.x + tp->u.anim.width) * par / 100;
2574                         }
2575                         else    {
2576                             x = tp->u.anim.x -
2577                                 (tp->u.anim.x + tp->u.anim.width) * par / 100;
2578                         }
2579                     }
2580                 }
2581                 if (ilm_surfaceSetDestinationRectangle(tp->surfaceid, x, y,
2582                                                        tp->u.anim.width, tp->u.anim.height)
2583                         != ILM_SUCCESS) {
2584                     ICO_ERR("CicoSCWindowController::ico_SCWindowChecker "
2585                             "ilm_surfaceSetDestinationRectangle Error %d[%x]",
2586                             tp->surfaceid, tp->surfaceid);
2587                 }
2588                 commflag ++;
2589                 break;
2590             }
2591         }
2592         if (delflag) {
2593             delflag = 0;
2594             if (bp == NULL) {
2595                 tp = tp->next;
2596                 CicoSCWindowController::win_check_timer = tp;
2597             }
2598             else    {
2599                 bp->next = tp->next;
2600                 tp->next = CicoSCWindowController::win_check_free;
2601                 CicoSCWindowController::win_check_free = tp;
2602                 tp = bp->next;
2603             }
2604         }
2605         else    {
2606             bp = tp;
2607             tp = tp->next;
2608         }
2609     }
2610     if (commflag)   {
2611         if (ilm_commitChanges() != ILM_SUCCESS) {
2612             ICO_ERR("CicoSCWindowController::ico_SCWindowChecker "
2613                     "ilm_commitChanges Error");
2614         }
2615     }
2616     g_lasttime = curtime;
2617     if (((htimer == 0) && (g_hightimer != 0)) ||
2618         ((htimer != 0) && (g_hightimer == 0)))  {
2619         // change timer speed
2620         g_hightimer = 1 - g_hightimer;
2621
2622         ecore_timer_interval_set(g_SCWindowChecker,
2623              ((double)(g_hightimer ?
2624                        ICO_SC_WINCHK_TIMER_BASE : ICO_SC_WINCHK_TIMER_BASE_L)) / 1000.0);
2625     }
2626     return ECORE_CALLBACK_RENEW;
2627 }
2628
2629 //--------------------------------------------------------------------------
2630 /**
2631  * @brief window checker destroy surface
2632  * @param surfaceid surface id
2633  */
2634 //--------------------------------------------------------------------------
2635 void
2636 CicoSCWindowController::windowCheckerRemove(uint32_t surfaceid)
2637 {
2638     struct ico_sc_win_check_t   *tp, *bp, *fp;
2639
2640     ICO_TRA("CicoSCWindowController::windowCheckerRemove: Enter %d[%x]",
2641             surfaceid, surfaceid);
2642
2643     resetWindowMap(surfaceid);
2644
2645     tp = CicoSCWindowController::win_check_timer;
2646     bp = NULL;
2647     while (tp)  {
2648         if (tp->surfaceid == surfaceid) {
2649             // delete check target
2650             if (tp->function == ICO_SC_WINCHK_CONTENTS_CHECK)   {
2651                 ICO_DBG("CicoSCWindowController::windowCheckerRemove: Remove Thumbnail %d",
2652                         tp->surfaceid);
2653             }
2654
2655             fp = tp;
2656             if (bp == NULL) {
2657                 tp = tp->next;
2658                 CicoSCWindowController::win_check_timer = tp;
2659             }
2660             else    {
2661                 bp->next = tp->next;
2662                 tp = tp->next;
2663             }
2664             fp->next = CicoSCWindowController::win_check_free;
2665             CicoSCWindowController::win_check_free = fp;
2666         }
2667         else    {
2668             bp = tp;
2669             tp = tp->next;
2670         }
2671     }
2672     ICO_TRA("CicoSCWindowController::windowCheckerRemove: Leave");
2673 }
2674
2675 //--------------------------------------------------------------------------
2676 /**
2677  * @brief window checker set animation
2678  * @param window    window object
2679  * @param show      show/hide
2680  * @param animation animation name
2681  * @param time      animation time(ms)
2682  */
2683 //--------------------------------------------------------------------------
2684 void
2685 CicoSCWindowController::setWindowAnimation(CicoSCWindow *window,
2686                                            int show, const char *animation, int time)
2687 {
2688     struct ico_sc_win_check_t   *tp, *bp;
2689     uint32_t    surfaceid = window->surfaceid;
2690
2691     ICO_TRA("CicoSCWindowController::setWindowAnimation: Enter %d[%x] %d <%s> %d",
2692             surfaceid, surfaceid, show, animation, time);
2693
2694     tp = CicoSCWindowController::win_check_timer;
2695     bp = NULL;
2696     while (tp)  {
2697         if ((tp->surfaceid == surfaceid) &&
2698             ((tp->function == ICO_SC_WINCHK_ANIMA_FADE) ||
2699              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOTOP) ||
2700              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOBUTTOM) ||
2701              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOLEFT) ||
2702              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETORIGHT)))   {
2703             // same surface target
2704             break;
2705         }
2706         bp = tp;
2707         tp = tp->next;
2708     }
2709     if (! tp)   {
2710         tp = CicoSCWindowController::win_check_free;
2711         if (tp) {
2712             CicoSCWindowController::win_check_free = tp->next;
2713         }
2714         else    {
2715             tp = (struct ico_sc_win_check_t *)malloc(sizeof(struct ico_sc_win_check_t));
2716             if (! tp)   {
2717                 ICO_ERR("CicoSCWindowController::setWindowAnimation: Out of Memory");
2718                 return;
2719             }
2720         }
2721         memset(tp, 0, sizeof(struct ico_sc_win_check_t));
2722         if (bp) {
2723             bp->next = tp;
2724         }
2725         else    {
2726             CicoSCWindowController::win_check_timer = tp;
2727         }
2728     }
2729
2730     tp->surfaceid = surfaceid;
2731     tp->time = time;
2732     tp->lapsed = 0;
2733     tp->par = -1;
2734     tp->timeout = ICO_SC_WINCHK_ANIMATION_TIME;
2735     tp->cycle = ICO_SC_WINCHK_ANIMATION_TIME;
2736     if ((strcasecmp(animation, ICO_SYC_WIN_ANIMATION_SLIDE) == 0) ||
2737         (strcasecmp(animation, ICO_SYC_WIN_ANIMATION_SLIDE_TOTOP) == 0))    {
2738         tp->function = ICO_SC_WINCHK_ANIMA_SLIDETOTOP;
2739     }
2740     else if (strcasecmp(animation, ICO_SYC_WIN_ANIMATION_SLIDE_TOBUTTOM) == 0)  {
2741         tp->function = ICO_SC_WINCHK_ANIMA_SLIDETOBUTTOM;
2742     }
2743     else if (strcasecmp(animation, ICO_SYC_WIN_ANIMATION_SLIDE_TOLEFT) == 0)    {
2744         tp->function = ICO_SC_WINCHK_ANIMA_SLIDETOLEFT;
2745     }
2746     else if (strcasecmp(animation, ICO_SYC_WIN_ANIMATION_SLIDE_TORIGHT) == 0)   {
2747         tp->function = ICO_SC_WINCHK_ANIMA_SLIDETORIGHT;
2748     }
2749     else    {
2750         tp->function = ICO_SC_WINCHK_ANIMA_FADE;
2751     }
2752     tp->state = show;
2753     tp->u.anim.x = window->x;
2754     tp->u.anim.y = window->y;
2755     tp->u.anim.width = window->width;
2756     tp->u.anim.height = window->height;
2757     tp->u.anim.screen_width = 1080;
2758     tp->u.anim.screen_height = 1920;
2759
2760     vector<CicoSCDisplay*>::iterator itr;
2761     itr = m_displayList.begin();
2762     for (; itr != m_displayList.end(); ++itr) {
2763         if ((*itr)->displayid == window->displayid) {
2764             tp->u.anim.screen_width = (*itr)->pWidth;
2765             tp->u.anim.screen_height = (*itr)->pHeight;
2766             break;
2767         }
2768     }
2769     (void) CicoSCWindowController::ico_SCWindowChecker(NULL);
2770
2771     ICO_TRA("CicoSCWindowController::setWindowAnimation: Leave");
2772 }
2773
2774 //--------------------------------------------------------------------------
2775 /**
2776  * @brief window checker reset animation
2777  * @param window    window object
2778  */
2779 //--------------------------------------------------------------------------
2780 void
2781 CicoSCWindowController::resetWindowAnimation(CicoSCWindow *window)
2782 {
2783     struct ico_sc_win_check_t   *tp, *bp;
2784     uint32_t        surfaceid = window->surfaceid;
2785
2786     ICO_TRA("CicoSCWindowController::resetWindowAnimation: Enter %d[%x]",
2787             surfaceid, surfaceid);
2788
2789     tp = CicoSCWindowController::win_check_timer;
2790     bp = NULL;
2791     while (tp)  {
2792         if ((tp->surfaceid == surfaceid) &&
2793             ((tp->function == ICO_SC_WINCHK_ANIMA_FADE) ||
2794              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOTOP) ||
2795              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOBUTTOM) ||
2796              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETOLEFT) ||
2797              (tp->function == ICO_SC_WINCHK_ANIMA_SLIDETORIGHT)))   {
2798             // delete surface target
2799             if (ilm_surfaceSetOpacity(tp->surfaceid, 1.0) != ILM_SUCCESS)   {
2800                 ICO_ERR("CicoSCWindowController::resetWindowAnimation "
2801                         "ilm_surfaceSetOpacity Error %d[%x]",
2802                         tp->surfaceid, tp->surfaceid);
2803             }
2804             if (ilm_surfaceSetDestinationRectangle(tp->surfaceid,
2805                                                    tp->u.anim.x, tp->u.anim.y,
2806                                                    tp->u.anim.width, tp->u.anim.height)
2807                     != ILM_SUCCESS) {
2808                 ICO_ERR("CicoSCWindowController::resetWindowAnimation "
2809                         "ilm_surfaceSetDestinationRectangle Error %d[%x]",
2810                         tp->surfaceid, tp->surfaceid);
2811             }
2812             if (ilm_surfaceSetVisibility(tp->surfaceid,
2813                         (tp->state == ICO_SC_WINANIMA_SHOW) ? 1 : 0) != ILM_SUCCESS)  {
2814                 ICO_ERR("CicoSCWindowController::resetWindowAnimation "
2815                         "ilm_surfaceSetVisibility Error %d[%x]",
2816                         tp->surfaceid, tp->surfaceid);
2817             }
2818             if (ilm_commitChanges() != ILM_SUCCESS) {
2819                 ICO_ERR("CicoSCWindowController::resetWindowAnimation "
2820                         "ilm_commitChanges Error");
2821             }
2822             if (bp == NULL) {
2823                 CicoSCWindowController::win_check_timer = tp->next;
2824             }
2825             else    {
2826                 bp->next = tp->next;
2827             }
2828             tp->next = CicoSCWindowController::win_check_free;
2829             CicoSCWindowController::win_check_free = tp;
2830             break;
2831         }
2832         bp = tp;
2833         tp = tp->next;
2834     }
2835     ICO_TRA("CicoSCWindowController::resetWindowAnimation: Leave");
2836 }
2837
2838 //--------------------------------------------------------------------------
2839 /**
2840  * @brief window checker set map
2841  * @param window    window object
2842  * @param framerate frame rate(frames/sec or -1)
2843  * @param filepath  surface image file path
2844  */
2845 //--------------------------------------------------------------------------
2846 void
2847 CicoSCWindowController::setWindowMap(CicoSCWindow *window,
2848                                      int framerate, const char *filepath)
2849 {
2850     struct ico_sc_win_check_t   *tp, *bp;
2851     uint32_t    surfaceid = window->surfaceid;
2852
2853     ICO_TRA("CicoSCWindowController::setWindowMap: Enter %d[%x],%d,<%s>",
2854             surfaceid, surfaceid, framerate, filepath);
2855
2856     tp = CicoSCWindowController::win_check_timer;
2857     bp = NULL;
2858     while (tp)  {
2859         if ((tp->surfaceid == surfaceid) &&
2860             (tp->function == ICO_SC_WINCHK_CONTENTS_CHECK)) {
2861             // same surface target
2862             break;
2863         }
2864         bp = tp;
2865         tp = tp->next;
2866     }
2867     if (! tp)   {
2868         tp = CicoSCWindowController::win_check_free;
2869         if (tp) {
2870             CicoSCWindowController::win_check_free = tp->next;
2871         }
2872         else    {
2873             tp = (struct ico_sc_win_check_t *)malloc(sizeof(struct ico_sc_win_check_t));
2874             if (! tp)   {
2875                 ICO_ERR("CicoSCWindowController::setWindowMap: Out of Memory");
2876                 return;
2877             }
2878         }
2879         memset(tp, 0, sizeof(struct ico_sc_win_check_t));
2880         if (bp) {
2881             bp->next = tp;
2882         }
2883         else    {
2884             CicoSCWindowController::win_check_timer = tp;
2885         }
2886     }
2887     tp->function = ICO_SC_WINCHK_CONTENTS_CHECK;
2888     tp->surfaceid = surfaceid;
2889     if (framerate <= 0) {
2890         tp->cycle = 0x7fff;
2891     }
2892     else    {
2893         tp->cycle = 1000/framerate;
2894     }
2895     tp->time = 0x7fff;
2896     tp->lapsed = 0;
2897     tp->par = -1;
2898     tp->timeout = 0;
2899     strncpy(tp->u.cont.path, filepath, ICO_SYC_MAX_LEN-1);
2900     tp->state = ICO_SC_WINCONT_CHECK;
2901     tp->u.cont.x = window->x;
2902     tp->u.cont.y = window->y;
2903     tp->u.cont.width = window->width;
2904     tp->u.cont.height = window->height;
2905
2906     (void) CicoSCWindowController::ico_SCWindowChecker(NULL);
2907
2908     ICO_TRA("CicoSCWindowController::setWindowMap: Leave");
2909 }
2910
2911 //--------------------------------------------------------------------------
2912 /**
2913  * @brief window checker reset map
2914  * @param surfaceid surface id
2915  */
2916 //--------------------------------------------------------------------------
2917 void
2918 CicoSCWindowController::resetWindowMap(uint32_t surfaceid)
2919 {
2920     struct ico_sc_win_check_t   *tp, *bp;
2921
2922     ICO_TRA("CicoSCWindowController::resetWindowMap: Enter %d[%x]",
2923             surfaceid, surfaceid);
2924
2925     tp = CicoSCWindowController::win_check_timer;
2926     bp = NULL;
2927     while (tp)  {
2928         if ((tp->surfaceid == surfaceid) &&
2929             (tp->function == ICO_SC_WINCHK_CONTENTS_CHECK)) {
2930             if (bp == NULL) {
2931                 CicoSCWindowController::win_check_timer = tp->next;
2932             }
2933             else    {
2934                 bp->next = tp->next;
2935             }
2936             tp->next = CicoSCWindowController::win_check_free;
2937             CicoSCWindowController::win_check_free = tp;
2938             break;
2939         }
2940         bp = tp;
2941         tp = tp->next;
2942     }
2943     if (tp) {
2944         mapSurfaceCB(ICO_SC_WINCHK_MAP_SURFACE_EVENT_UNMAP,
2945                      tp->surfaceid, 0, tp->u.cont.width, tp->u.cont.height,
2946                      tp->u.cont.width * 4, 0);
2947     }
2948     ICO_TRA("CicoSCWindowController::resetWindowMap: Leave");
2949 }
2950 // vim:set expandtab ts=4 sw=4: