2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
10 //==========================================================================
12 * @file CicoSCWindowController.cpp
14 * @brief This file implementation of CicoSCWindowController class
16 //==========================================================================
24 #include <sys/ioctl.h>
30 #include "CicoSCWindow.h"
31 #include "CicoSCWayland.h"
32 #include "CicoSCWindowController.h"
35 #include "CicoSystemConfig.h"
37 #include "CicoSCDisplay.h"
38 #include "CicoSCLayer.h"
39 #include "CicoSCDisplayZone.h"
40 #include "ico_syc_error.h"
41 #include "ico_syc_type.h"
42 #include "ico_syc_winctl.h"
43 #include "CicoSCCommand.h"
44 #include "ico_syc_msg_cmd_def.h"
45 #include "CicoSCServer.h"
46 #include "CicoSCMessage.h"
47 #include "CicoSCMessageRes.h"
48 #include "CicoSCLifeCycleController.h"
49 #include "CicoSCResourceManager.h"
51 //==========================================================================
52 // private static variable
53 //==========================================================================
54 CicoSCWindowController* CicoSCWindowController::ms_myInstance = NULL;
56 //--------------------------------------------------------------------------
58 * @brief get instance of CicoSCWindowController
60 * @return instance of CicoSCWayland
62 //--------------------------------------------------------------------------
63 CicoSCWindowController*
64 CicoSCWindowController::getInstance(void)
66 if (NULL == ms_myInstance) {
67 ms_myInstance = new CicoSCWindowController();
72 //--------------------------------------------------------------------------
74 * @brief default constructor
76 //--------------------------------------------------------------------------
77 CicoSCWindowController::CicoSCWindowController()
78 : m_resMgr(NULL), m_physicalDisplayTotal(0)
80 CicoSCWayland* wayland = CicoSCWayland::getInstance();
81 wayland->getInstance()->addWaylandIF(ICO_WL_WIN_MGR_IF, this);
82 wayland->getInstance()->addWaylandIF(ICO_WL_IVI_APPLICATION_IF, this);
83 wayland->getInstance()->addWaylandIF(ICO_WL_IVI_CONTROLLER_IF, this);
84 wayland->getInstance()->addWaylandIF(ICO_WL_OUTPUT_IF, this);
87 CicoSCWindowController::ms_myInstance = this;
90 //--------------------------------------------------------------------------
94 //--------------------------------------------------------------------------
95 CicoSCWindowController::~CicoSCWindowController()
97 CicoSCWindowController::ms_myInstance = NULL;
100 //--------------------------------------------------------------------------
102 * @brief initialize display and window database
104 //--------------------------------------------------------------------------
106 CicoSCWindowController::initDB(void)
108 ICO_TRA("CicoSCWindowController::initDB: Enter");
110 const vector<CicoSCDisplayConf*>& displayList =
111 CicoSystemConfig::getInstance()->getDisplayConfList();
112 vector<CicoSCDisplayConf*>::const_iterator itr;
113 itr = displayList.begin();
114 for (; itr != displayList.end(); ++itr) {
115 CicoSCDisplay *display = new CicoSCDisplay();
116 display->displayid = (*itr)->id;
117 display->type = (*itr)->type;
118 display->nodeid = (*itr)->node;
119 display->displayno = (*itr)->no;
120 display->width = (*itr)->width;
121 display->height = (*itr)->height;
122 display->name = (*itr)->name;
124 vector<CicoSCLayerConf*>::const_iterator itr2;
125 itr2 = (*itr)->layerConfList.begin();
126 for (; itr2 != (*itr)->layerConfList.end(); ++itr2) {
127 CicoSCLayer *layer = new CicoSCLayer();
128 layer->layerid = (*itr2)->id;
129 layer->type = (*itr2)->type;
130 layer->width = display->width;
131 layer->height = display->height;
132 layer->displayid = display->displayid;
133 layer->menuoverlap = (*itr2)->menuoverlap;
134 display->layerList.push_back(layer);
137 vector<CicoSCDisplayZoneConf*>::const_iterator itr3;
138 itr3 = (*itr)->zoneConfList.begin();
139 for (; itr3 != (*itr)->zoneConfList.end(); ++itr3) {
140 CicoSCDisplayZone *zone = new CicoSCDisplayZone();
141 zone->zoneid = (*itr3)->id;
142 zone->x = (*itr3)->x;
143 zone->y = (*itr3)->y;
144 zone->width = (*itr3)->w;
145 zone->height = (*itr3)->h;
146 zone->fullname = (*itr3)->fullname;
147 zone->aspectFixed = (*itr3)->aspectFixed;
148 zone->aspectAlignLeft = (*itr3)->aspectAlignLeft;
149 zone->aspectAlignRight = (*itr3)->aspectAlignRight;
150 zone->aspectAlignTop = (*itr3)->aspectAlignTop;
151 zone->aspectAlignBottom = (*itr3)->aspectAlignBottom;
152 display->zoneList[zone->zoneid] = zone;
155 m_displayList.push_back(display);
158 ICO_TRA("CicoSCWindowController::initDB: Leave");
162 //--------------------------------------------------------------------------
164 * @brief set resource manager instance
166 * @param [in] resMgr resource manager instance
168 //--------------------------------------------------------------------------
170 CicoSCWindowController::setResourceManager(CicoSCResourceManager *resMgr)
175 //--------------------------------------------------------------------------
177 * @brief show a target window
179 * @param [in] surfaceid wayland surface id
180 * @param [in] animation animation name
181 * @param [in] animationTime animation time
183 * @return ICO_SYC_EOK on success, other on error
184 * @retval ICO_SYC_EOK success
185 * @retval ICO_SYC_ESRCH error(not initialized)
186 * @retval ICO_SYC_ENOENT error(not exist)
188 //--------------------------------------------------------------------------
190 CicoSCWindowController::show(int surfaceid,
191 const char *animation,
194 ICO_TRA("CicoSCWindowController::show Enter"
195 "(surfaceid=0x%08X animation=%s animationTime=%d)",
196 surfaceid, animation, animationTime);
198 // find window information in window list
199 CicoSCWindow *window = findWindow(surfaceid);
200 if (NULL == window) {
201 ICO_WRN("not found window information");
202 ICO_TRA("CicoSCWindowController::show Leave(ENOENT)");
203 return ICO_SYC_ENOENT;
206 // update visible attr
207 window->visible = true;
209 // update current displayed window at display zone
210 CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
212 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
213 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
214 ICO_DBG("Entry display zone[%d] current displayed window"
216 zone->zoneid, window->surfaceid, window->appid.c_str());
217 zone->displayedWindow = window;
221 // set animation request to Multi Window Manager
222 int raiseFlag = ICO_SYC_WIN_RAISE_NOCHANGE;
223 if (animationTime & ICO_SYC_WIN_SURF_RAISE) {
224 raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
226 else if (animationTime & ICO_SYC_WIN_SURF_LOWER) {
227 raiseFlag = ICO_SYC_WIN_RAISE_LOWER;
229 else if (((animationTime & ICO_SYC_WIN_SURF_NOCHANGE) == 0) &&
230 (false == window->raise)) {
231 raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
233 if ((NULL != animation) && (animation[0] != '\0')) {
234 // set animation request to Multi Window Manager
235 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
236 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
237 animation, animationTime & ~ICO_SYC_WIN_SURF_FLAGS);
240 // set raise/lower request (if need)
241 if (raiseFlag != ICO_SYC_WIN_RAISE_NOCHANGE) {
242 raiselower(window, (raiseFlag == ICO_SYC_WIN_RAISE_RAISE));
245 // set visible request to Multi Window Manager
246 CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_WIN_VISIBLE_SHOW);
249 CicoSCWayland::getInstance()->flushDisplay();
251 ICO_TRA("CicoSCWindowController::show Leave(EOK)");
255 //--------------------------------------------------------------------------
257 * @brief raise/lower a target window
259 * @param [in] window target window
260 * @param [in] raise raise(true)/lower(false)
264 //--------------------------------------------------------------------------
266 CicoSCWindowController::raiselower(CicoSCWindow *window, bool raise)
268 ICO_TRA("CicoSCWindowController::raiselower(%08x,%d)", window->surfaceid, raise);
270 window->raise = raise;
272 CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
274 ICO_ERR("CicoSCWindowController::raiselower: surface.%08x has no layer(%d)",
275 window->surfaceid, window->layerid);
278 if ((raise) && (layer->is_topSurface(window->surfaceid))) {
279 ICO_DBG("CicoSCWindowController::raiselower %08x raise but top",
282 else if ((! raise) && (layer->is_buttomSurface(window->surfaceid))) {
283 ICO_DBG("CicoSCWindowController::raiselower %08x lower but buttom",
287 layer->addSurface(window->surfaceid, raise);
290 const int *surfs = layer->getSurfaces(&nsurf);
291 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
293 ICO_ERR("CicoSCWindowController::raiselower "
294 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
299 //--------------------------------------------------------------------------
301 * @brief hide a target window
303 * @param [in] surfaceid wayland surface id
304 * @param [in] animation animation name
305 * @param [in] animationTime animation time
307 * @return ICO_SYC_EOK on success, other on error
308 * @retval ICO_SYC_EOK success
309 * @retval ICO_SYC_ESRCH error(not initialized)
310 * @retval ICO_SYC_ENOENT error(not exist)
312 //--------------------------------------------------------------------------
314 CicoSCWindowController::hide(int surfaceid,
315 const char *animation,
318 ICO_TRA("CicoSCWindowController::hide Enter"
319 "(surfaceid=0x%08X animation=%s animationTime=%d)",
320 surfaceid, animation, animationTime);
322 // find window information in window list
323 CicoSCWindow *window = findWindow(surfaceid);
324 if (NULL == window) {
325 ICO_WRN("not found window information");
326 ICO_TRA("CicoSCWindowController::hide Leave(ENOENT)");
327 return ICO_SYC_ENOENT;
330 if (false == window->visible) {
331 ICO_DBG("already hide state");
332 ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
336 // update window attr
337 window->visible = false;
339 // update current displayed window at display zone
340 CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
342 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
343 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
344 (getDisplayedWindow(zone->zoneid) == surfaceid)) {
345 ICO_DBG("Exit display zone[%d] current displayed window"
347 zone->zoneid, window->surfaceid, window->appid.c_str());
348 zone->displayedWindow = NULL;
352 // set animation request to Multi Window Manager
353 if ((NULL != animation) && (animation[0] != '\0')) {
354 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
355 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE,
356 animation, animationTime & ~ICO_SYC_WIN_SURF_FLAGS);
359 // set visible request to Multi Window Manager
360 CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_LAYER_VISIBLE_HIDE);
363 CicoSCWayland::getInstance()->flushDisplay();
365 ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
369 //--------------------------------------------------------------------------
371 * @brief resize window(surface) size
373 * @param [in] surfaceid wayland surface id
374 * @param [in] w window width
375 * @param [in] h window height
376 * @param [in] animation animation name
377 * @param [in] animationTime animation time
379 * @return ICO_SYC_EOK on success, other on error
380 * @retval ICO_SYC_EOK success
381 * @retval ICO_SYC_ESRCH error(not initialized)
382 * @retval ICO_SYC_ENOENT error(window dose not exist)
384 //--------------------------------------------------------------------------
386 CicoSCWindowController::resize(int surfaceid,
389 const char *animation,
392 ICO_TRA("CicoSCWindowController::resize Enter"
393 "(surfaceid=0x%08X h=%d w=%d animation=%s animationTime=%d)",
394 surfaceid, w, h, animation, animationTime);
396 // find window information in window list
397 CicoSCWindow *window = findWindow(surfaceid);
398 if (NULL == window) {
399 ICO_WRN("not found window information");
400 ICO_TRA("CicoSCWindowController::resize Leave(ENOENT)");
401 return ICO_SYC_ENOENT;
404 // set animation request to Multi Window Manager
405 if ((NULL != animation) && (animation[0] != '\0')) {
406 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
407 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
408 animation, animationTime);
411 // set visible request to Multi Window Manager
414 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, window->nodeid,
415 window->x, window->y, w, h);
418 CicoSCWayland::getInstance()->flushDisplay();
420 ICO_TRA("CicoSCWindowController::resize Leave(EOK)");
424 //--------------------------------------------------------------------------
426 * @brief move window(surface) position
428 * @param [in] surfaceid wayland surface id
429 * @param [in] nodeid node id
430 * @param [in] x window width
431 * @param [in] y window height
432 * @param [in] animation animation name
433 * @param [in] animationTime animation time
435 * @return ICO_SYC_EOK on success, other on error
436 * @retval ICO_SYC_EOK success
437 * @retval ICO_SYC_ESRCH error(not initialized)
438 * @retval ICO_SYC_ENOENT error(window dose not exist)
440 //--------------------------------------------------------------------------
442 CicoSCWindowController::move(int surfaceid,
446 const char *animation,
449 ICO_TRA("CicoSCWindowController::move Enter"
450 "(surfaceid=0x%08X nodeid=%d x=%d y=%d "
451 "animation=%s animationTime=%d)",
452 surfaceid, nodeid, x, y, animation, animationTime);
454 // find window information in window list
455 CicoSCWindow *window = findWindow(surfaceid);
456 if (NULL == window) {
457 ICO_WRN("CicoSCWindowController::move not found window(%08x)", surfaceid);
458 ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
459 return ICO_SYC_ENOENT;
462 if (nodeid >= (int)m_physicalDisplayTotal) {
463 ICO_WRN("CicoSCWindowController::move not found node(%d)", nodeid);
464 ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
465 return ICO_SYC_ENOENT;
468 // set animation request to Multi Window Manager
469 if ((NULL != animation) && (animation[0] != '\0')) {
470 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
471 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
472 animation, animationTime);
475 int moveNodeId = ICO_SYC_WIN_NOCHANGE;
480 // set visible request to Multi Window Manager
483 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid,
485 window->width, window->height);
488 CicoSCWayland::getInstance()->flushDisplay();
490 ICO_TRA("CicoSCWindowController::move Leave(EOK)");
494 //--------------------------------------------------------------------------
496 * @brief raise window(surface)
498 * @param [in] surfaceid wayland surface id
499 * @param [in] animation animation name
500 * @param [in] animationTime animation time
502 * @return ICO_SYC_EOK on success, other on error
503 * @retval ICO_SYC_EOK success
504 * @retval ICO_SYC_ESRCH error(not initialized)
505 * @retval ICO_SYC_ENOENT error(layer dose not exist)
507 //--------------------------------------------------------------------------
509 CicoSCWindowController::raise(int surfaceid,
510 const char *animation,
513 ICO_TRA("CicoSCWindowController::raise Enter"
514 "(surfaceid=0x%08X animation=%s animationTime=%d)",
515 surfaceid, animation, animationTime);
517 // find window information in window list
518 CicoSCWindow *window = findWindow(surfaceid);
519 if (NULL == window) {
520 ICO_WRN("not found window information");
521 ICO_TRA("CicoSCWindowController::raise Leave(ENOENT)");
522 return ICO_SYC_ENOENT;
525 // set animation request to Multi Window Manager
526 if ((NULL != animation) && (animation[0] != '\0')) {
527 CicoSCWindowController::setAnimation(window->surfaceid,
528 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
529 animation, animationTime);
531 // set raise request to Multi Window Manager
532 raiselower(window, true);
533 if (ilm_commitChanges() != ILM_SUCCESS) {
534 ICO_ERR("CicoSCWindowController::raise ilm_commitChanges() Error");
538 CicoSCWayland::getInstance()->flushDisplay();
540 ICO_TRA("CicoSCWindowController::raise Leave(EOK)");
544 //--------------------------------------------------------------------------
546 * @brief set window(surface) geometry
548 * @param [in] surfaceid wayland surface id
549 * @param [in] nodeid node id
550 * @param [in] layerid layer id
551 * @param [in] x window x position
552 * @param [in] y window y position
553 * @param [in] w window width
554 * @param [in] h window height
555 * @param [in] resizeAnimation resize animation name
556 * @param [in] resizeAnimationTime resize animation time
557 * @param [in] moveAnimation move animation name
558 * @param [in] moveanimationTime move animation time
560 * @return ICO_SYC_EOK on success, other on error
561 * @retval ICO_SYC_EOK success
562 * @retval ICO_SYC_ESRCH error(not initialized)
563 * @retval ICO_SYC_ENOENT error(window dose not exist)
565 //--------------------------------------------------------------------------
567 CicoSCWindowController::setGeometry(int surfaceid,
574 const char *resizeAnimation,
575 int resizeAnimationTime,
576 const char *moveAnimation,
577 int moveAnimationTime)
579 ICO_TRA("CicoSCWindowController::setGeometry Enter"
580 "(surfaceid=0x%08X nodeid=%d layerid=%d x=%d y=%d w=%d h=%d "
581 "resizeAnimation=%s resizeAnimationTime=%d "
582 "moveAnimation=%s moveAnimationTime=%d)",
583 surfaceid, nodeid, layerid, x, y, w, h,
584 resizeAnimation, resizeAnimationTime,
585 moveAnimation, moveAnimationTime);
587 // find window information in window list
588 CicoSCWindow *window = findWindow(surfaceid);
589 if (NULL == window) {
590 ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
591 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
592 return ICO_SYC_ENOENT;
595 if (nodeid >= (int)m_physicalDisplayTotal) {
596 ICO_WRN("CicoSCWindowController::setGeometry not found node(%d)", nodeid);
597 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
598 return ICO_SYC_ENOENT;
601 // set animation request to Multi Window Manager
602 const char *animation = "";
603 if (NULL != resizeAnimation) {
604 animation = resizeAnimation;
606 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
607 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
608 animation, resizeAnimationTime);
610 if (NULL != moveAnimation) {
611 animation = moveAnimation;
613 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
614 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
615 animation, moveAnimationTime);
617 int moveNodeId = ICO_SYC_WIN_NOCHANGE;
622 moveNodeId = window->nodeid;
625 if (m_physicalDisplayTotal <= (unsigned int)moveNodeId) {
626 ICO_WRN("nodeid(%d) is over physical display total(%d)",
627 m_physicalDisplayTotal, nodeid);
628 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
629 return ICO_SYC_EINVAL;
632 int moveX = window->x;
638 int moveY = window->y;
644 int moveW = window->width;
650 int moveH = window->height;
656 // set window layer to Multi Window Manager
658 setWindowLayer(window->surfaceid, layerid);
661 // update window attr
662 window->nodeid = moveNodeId;
664 // set visible request to Multi Window Manager
665 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, moveNodeId,
666 moveX, moveY, moveW, moveH);
669 CicoSCWayland::getInstance()->flushDisplay();
671 ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
675 //--------------------------------------------------------------------------
677 * @brief set window(surface) geometry
679 * @param [in] surfaceid wayland surface id
680 * @param [in] layerid layer id
681 * @param [in] nodeid node id
682 * @param [in] zone display zone name
683 * @param [in] resizeAnimation resize animation name
684 * @param [in] resizeAnimationTime resize animation time
685 * @param [in] moveAnimation move animation name
686 * @param [in] moveanimationTime move animation time
688 * @return ICO_SYC_EOK on success, other on error
689 * @retval ICO_SYC_EOK success
690 * @retval ICO_SYC_ESRCH error(not initialized)
691 * @retval ICO_SYC_ENOENT error(window dose not exist)
692 * @retval ICO_SYC_EINVAL error(zone is null, zone name is invalid)
694 //--------------------------------------------------------------------------
696 CicoSCWindowController::setGeometry(int surfaceid,
699 const char *resizeAnimation,
700 int resizeAnimationTime,
701 const char *moveAnimation,
702 int moveAnimationTime)
704 ICO_TRA("CicoSCWindowController::setGeometry Enter"
705 "(surfaceid=0x%08X zone=%s layerid=%d "
706 "resizeAnimation=%s resizeAnimationTime=%d "
707 "moveAnimation=%s moveAnimationTime=%d)",
708 surfaceid, zone, layerid,
709 resizeAnimation, resizeAnimationTime,
710 moveAnimation, moveAnimationTime);
712 // find window information in window list
713 CicoSCWindow *window = findWindow(surfaceid);
714 if (NULL == window) {
715 ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
716 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
717 return ICO_SYC_ENOENT;
720 // find zone information
721 if ((NULL == zone) || ('\0' == zone[0])) {
722 ICO_WRN("zone value is invalid");
723 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
724 return ICO_SYC_EINVAL;
727 vector<CicoSCDisplay*>::iterator itr;
728 itr = m_displayList.begin();
729 CicoSCDisplayZone* dispzone = NULL;
731 for (; itr != m_displayList.end(); ++itr) {
732 dispzone = (*itr)->findDisplayZonebyFullName(zone);
733 if (NULL != dispzone) {
734 displayno = (*itr)->displayno;
738 if (NULL == dispzone) {
739 ICO_WRN("display zone name(%s) is invalid.", zone);
740 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
741 return ICO_SYC_EINVAL;
743 if (m_physicalDisplayTotal <= (unsigned int)displayno) {
744 ICO_WRN("nodeid(%d) is over physical display total(%d)",
745 m_physicalDisplayTotal, displayno);
746 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
747 return ICO_SYC_EINVAL;
750 if (window->zoneid != dispzone->zoneid) {
751 // update current displayed window at display zone
752 CicoSCDisplayZone* olddispzone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
753 if (NULL != olddispzone) {
754 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
755 if ((NULL != layer) &&
756 (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
757 (getDisplayedWindow(olddispzone->zoneid) == surfaceid)) {
758 ICO_DBG("Exit display zone[%d] current displayed window"
760 olddispzone->zoneid, window->surfaceid,
761 window->appid.c_str());
762 olddispzone->displayedWindow = NULL;
766 CicoSCLayer *layer = findLayer(displayno, window->layerid);
767 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
768 ICO_DBG("Entry display zone[%d] current displayed window"
770 dispzone->zoneid, window->surfaceid, window->appid.c_str());
771 dispzone->displayedWindow = window;
775 // update window attr
776 window->zoneid = dispzone->zoneid;
777 window->zone = dispzone->fullname;
778 setAttributes(window->surfaceid);
780 int ret = setGeometry(surfaceid, displayno, layerid,
781 dispzone->x, dispzone->y,
782 dispzone->width, dispzone->height,
783 resizeAnimation, resizeAnimationTime,
784 moveAnimation, moveAnimationTime);
786 ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
790 //--------------------------------------------------------------------------
792 * @brief lower window(surface)
794 * @param [in] surfaceid wayland surface id
795 * @param [in] animation animation name
796 * @param [in] animationTime animation time
798 * @return ICO_SYC_EOK on success, other on error
799 * @retval ICO_SYC_EOK success
800 * @retval ICO_SYC_ESRCH error(not initialized)
801 * @retval ICO_SYC_ENOENT error(layer dose not exist)
803 //--------------------------------------------------------------------------
805 CicoSCWindowController::lower(int surfaceid,
806 const char *animation,
809 ICO_TRA("CicoSCWindowController::lower Enter"
810 "(surfaceid=0x%08X animation=%s animationTime=%d)",
811 surfaceid, animation, animationTime);
813 // find window information in window list
814 CicoSCWindow *window = findWindow(surfaceid);
815 if (NULL == window) {
816 ICO_WRN("not found window information");
817 ICO_TRA("CicoSCWindowController::lower Leave(ENOENT)");
818 return ICO_SYC_ENOENT;
821 // set animation request to Multi Window Manager
822 if ((NULL != animation) && (animation[0] != '\0')) {
823 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
824 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE,
825 animation, animationTime);
828 // set lower request to Multi Window Manager
829 raiselower(window, false);
830 if (ilm_commitChanges() != ILM_SUCCESS) {
831 ICO_ERR("CicoSCWindowController::lower ilm_commitChanges() Error");
835 CicoSCWayland::getInstance()->flushDisplay();
837 ICO_TRA("CicoSCWindowController::lower Leave(EOK)");
841 //--------------------------------------------------------------------------
843 * @brief set window(surface) animation
845 * @param [in] surfaceid wayland surface id
846 * @param [in] target target(pointer and/or keyboard)
847 * @param [in] type set animation target
848 * @param [in] animation animation information
849 * @param [in] time animation time
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(layer dose not exist)
856 //--------------------------------------------------------------------------
858 CicoSCWindowController::setWindowAnimation(int surfaceid, int type,
859 const char *animation, int time)
861 CicoSCWindow *window = NULL;
863 ICO_TRA("CicoSCWindowController::setWindowAnimation Enter"
864 "(surfaceid=%08X, type=%x, animation=<%s>, time=%d)",
865 surfaceid, type, animation ? animation : "(null)", time);
867 // find window information in window list
868 window = findWindow(surfaceid);
869 if (NULL == window) {
870 ICO_WRN("not found window information");
871 ICO_TRA("CicoSCWindowController::setWindowAnimation Leave(ENOENT)");
872 return ICO_SYC_ENOENT;
875 // set animation request to Multi Window Manager
876 CicoSCWlWinMgrIF::setAnimation(surfaceid, type, animation, time);
879 CicoSCWayland::getInstance()->flushDisplay();
881 ICO_TRA("CicoSCWindowController::setWindowAnimation Leave(EOK)");
885 //--------------------------------------------------------------------------
887 * @brief set window layer
889 * @param [in] surfaceid wayland surface id
890 * @param [in] layer layer id
892 * @return ICO_SYC_EOK on success, other on error
893 * @retval ICO_SYC_EOK success
894 * @retval ICO_SYC_ESRCH error(not initialized)
895 * @retval ICO_SYC_ENOENT error(window or layer dose not exist)
897 //--------------------------------------------------------------------------
899 CicoSCWindowController::setWindowLayer(int surfaceid, int layerid)
901 ICO_TRA("CicoSCWindowController::setWindowLayer Enter"
902 "(surfaceid=0x%08X layerid=%x)", surfaceid, layerid);
904 // find window information in window list
905 CicoSCWindow* window = findWindow(surfaceid);
906 if (NULL == window) {
907 ICO_WRN("not found window information");
908 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT)");
909 return ICO_SYC_ENOENT;
911 if (window->layerid == layerid) {
912 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(same layer %d)", layerid);
916 // find new layer information in layer list
917 CicoSCLayer* layer = findLayer(window->displayid, layerid);
919 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT[disp=%d,layer=%d])",
920 window->displayid, layerid);
921 return ICO_SYC_ENOENT;
924 // find old layer information and remove surface if need
925 CicoSCLayer* oldlayer = findLayer(window->displayid, window->layerid);
927 if (ilm_layerRemoveSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
928 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerRemoveSurface(%d,%08x)"
929 " Error", window->layerid, window->surfaceid);
931 // must need ilm_commitChanges() after ilm_layerRemoveSurface()
932 if (ilm_commitChanges() != ILM_SUCCESS) {
933 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
936 oldlayer->removeSurface(window->surfaceid);
938 const int *oldsurfs = oldlayer->getSurfaces(&noldsurf);
939 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)oldsurfs, noldsurf)
941 ICO_ERR("CicoSCWindowController::setWindowLayer "
942 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, noldsurf);
944 if (ilm_commitChanges() != ILM_SUCCESS) {
945 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
949 // update window attr
950 window->layerid = layerid;
952 // set window layer request
953 if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
954 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerAddSurface(%d,%08x) Error",
955 window->layerid, window->surfaceid);
957 if (ilm_commitChanges() != ILM_SUCCESS) {
958 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
961 // add surface to new layer
962 layer->addSurface(window->surfaceid, true);
964 const int *surfs = layer->getSurfaces(&nsurf);
965 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
967 ICO_ERR("CicoSCWindowController::setWindowLayer "
968 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
970 if (ilm_commitChanges() != ILM_SUCCESS) {
971 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
975 CicoSCWayland::getInstance()->flushDisplay();
977 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(EOK)");
981 //--------------------------------------------------------------------------
985 * @param [in] displayid display id
986 * @param [in] layerid layer id
988 * @return ICO_SYC_EOK on success, other on error
989 * @retval ICO_SYC_EOK success
990 * @retval ICO_SYC_ESRCH error(not initialized)
991 * @retval ICO_SYC_ENOENT error(layer dose not exist)
993 //--------------------------------------------------------------------------
995 CicoSCWindowController::showLayer(int displayid, int layerid)
997 ICO_TRA("CicoSCWindowController::showLayer Enter"
998 "(displayid=%d layerid=%d)", displayid, layerid);
1000 // find layer information in layer list
1001 CicoSCLayer* layer = findLayer(displayid, layerid);
1002 if (NULL == layer) {
1003 ICO_WRN("not found layer information");
1004 ICO_TRA("CicoSCWindowController::showLayer Leave(ENOENT)");
1005 return ICO_SYC_ENOENT;
1008 CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_SHOW);
1011 CicoSCWayland::getInstance()->flushDisplay();
1013 ICO_TRA("CicoSCWindowController::showLayer Leave(EOK)");
1017 //--------------------------------------------------------------------------
1021 * @param [in] displayid display id
1022 * @param [in] layerid layer id
1024 * @return ICO_SYC_EOK on success, other on error
1025 * @retval ICO_SYC_EOK success
1026 * @retval ICO_SYC_ESRCH error(not initialized)
1027 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1029 //--------------------------------------------------------------------------
1031 CicoSCWindowController::hideLayer(int displayid, int layerid)
1033 ICO_TRA("CicoSCWindowController::hideLayer Enter"
1034 "displayid=%d layerid=%d)",
1035 displayid, layerid);
1037 // find layer information in layer list
1038 CicoSCLayer* layer = findLayer(displayid, layerid);
1039 if (NULL == layer) {
1040 ICO_WRN("not found layer information");
1041 ICO_TRA("CicoSCWindowController::hideLayer Leave(ENOENT)");
1042 return ICO_SYC_ENOENT;
1045 CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_HIDE);
1048 CicoSCWayland::getInstance()->flushDisplay();
1050 ICO_TRA("CicoSCWindowController::hideVisible Leave(EOK)");
1054 //--------------------------------------------------------------------------
1056 * @brief active window(surface)
1058 * @param [in] surfaceid wayland surface id
1059 * @param [in] target target(pointer and/or keyboard)
1061 * @return ICO_SYC_EOK on success, other on error
1062 * @retval ICO_SYC_EOK success
1063 * @retval ICO_SYC_ESRCH error(not initialized)
1064 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1066 //--------------------------------------------------------------------------
1068 CicoSCWindowController::active(int surfaceid, int target)
1070 CicoSCWindow *window = NULL;
1072 ICO_TRA("CicoSCWindowController::active Enter"
1073 "(surfaceid=0x%08X, target=%08X)", surfaceid, target);
1075 // find window information in window list
1077 window = findWindow(surfaceid);
1078 if (NULL == window) {
1079 ICO_WRN("not found window information");
1080 ICO_TRA("CicoSCWindowController::active Leave(ENOENT)");
1081 return ICO_SYC_ENOENT;
1089 // set active request to Multi Window Manager
1090 CicoSCWlWinMgrIF::setActive(surfaceid, target);
1093 CicoSCWayland::getInstance()->flushDisplay();
1095 // update visible attr
1097 window->raise = true;
1100 // update active window
1101 map<unsigned int, CicoSCWindow*>::iterator itr;
1102 itr = m_windowList.begin();
1103 for (; itr != m_windowList.end(); ++itr) {
1104 CicoSCWindow* window = itr->second;
1105 if ((surfaceid != 0) && (window->surfaceid == surfaceid)) {
1106 window->active = target;
1113 window->active &= ~target;
1118 ICO_TRA("CicoSCWindowController::active Leave(EOK)");
1122 //--------------------------------------------------------------------------
1124 * @brief set surface map get
1126 * @param [in] surfaceid wayland surface id
1127 * @param [in] filepath surface image pixel file path
1129 * @return ICO_SYC_EOK on success, other on error(currently EOK only)
1130 * @retval ICO_SYC_EOK success
1132 //--------------------------------------------------------------------------
1134 CicoSCWindowController::setmapGet(int surfaceid, const char *filepath)
1136 ICO_TRA("CicoSCWindowController::setmapGet Enter");
1138 CicoSCWlWinMgrIF::setmapGet(surfaceid, filepath);
1139 CicoSCWayland::getInstance()->flushDisplay();
1141 ICO_TRA("CicoSCWindowController::setmapGet Leave(EOK)");
1145 //--------------------------------------------------------------------------
1147 * @brief map surface
1149 * @param [in] surfaceid wayland surface id
1150 * @param [in] framerate surface change frame rate(frames par sec)
1151 * @param [in] filepath surface image pixel file path
1153 * @return ICO_SYC_EOK on success, other on error
1154 * @retval ICO_SYC_EOK success
1155 * @retval ICO_SYC_ESRCH error(not initialized)
1156 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1158 //--------------------------------------------------------------------------
1160 CicoSCWindowController::mapSurface(int surfaceid, int framerate, const char *filepath)
1162 ICO_TRA("CicoSCWindowController::mapSurface Enter(0x%08x,%d,%s)",
1163 surfaceid, framerate, filepath ? filepath : "(null)");
1165 // find window information in window list
1166 CicoSCWindow *window = findWindow(surfaceid);
1167 if (NULL == window) {
1168 ICO_WRN("not found window information");
1169 ICO_TRA("CicoSCWindowController::mapSurface Leave(ENOENT)");
1170 return ICO_SYC_ENOENT;
1173 if (framerate < 0) {
1177 CicoSCWlWinMgrIF::mapSurface(surfaceid, framerate, filepath);
1178 CicoSCWayland::getInstance()->flushDisplay();
1180 ICO_TRA("CicoSCWindowController::mapSurface Leave(EOK)");
1184 //--------------------------------------------------------------------------
1186 * @brief unmap surface
1188 * @param [in] surfaceid wayland surface id
1190 * @return ICO_SYC_EOK on success, other on error
1191 * @retval ICO_SYC_EOK success
1192 * @retval ICO_SYC_ESRCH error(not initialized)
1193 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1195 //--------------------------------------------------------------------------
1197 CicoSCWindowController::unmapSurface(int surfaceid)
1199 ICO_TRA("CicoSCWindowController::unmapSurface Enter(0x%08x)", surfaceid);
1201 // find window information in window list
1202 CicoSCWindow *window = findWindow(surfaceid);
1203 if (NULL == window) {
1204 ICO_WRN("not found window information");
1205 ICO_TRA("CicoSCWindowController::unmapSurface Leave(ENOENT)");
1206 return ICO_SYC_ENOENT;
1209 CicoSCWlWinMgrIF::unmapSurface(surfaceid);
1210 CicoSCWayland::getInstance()->flushDisplay();
1212 ICO_TRA("CicoSCWindowController::unmapSurface Leave(EOK)");
1216 //--------------------------------------------------------------------------
1218 * @brief get displayed window by display zone id
1220 * @param [in] zoneid display zone id
1222 * @return surface id on success, -1 on not displayed
1224 //--------------------------------------------------------------------------
1226 CicoSCWindowController::getDisplayedWindow(int zoneid)
1228 const CicoSCDisplayZone* zone = findDisplayZone(zoneid);
1233 if (NULL == zone->displayedWindow) {
1237 return zone->displayedWindow->surfaceid;
1240 //--------------------------------------------------------------------------
1242 * @brief set surface attributes
1244 * @param [in] surfaceid surface id
1246 * @retval ICO_SYC_EOK success
1247 * @retval ICO_SYC_ESRCH error(not initialized)
1248 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1250 //--------------------------------------------------------------------------
1252 CicoSCWindowController::setAttributes(int surfaceid)
1254 ICO_TRA("CicoSCWindowController::setAttributes Enter"
1255 "(surfaceid=0x%08X)", surfaceid);
1257 // find window information in window list
1258 CicoSCWindow *window = findWindow(surfaceid);
1259 if (NULL == window) {
1260 ICO_WRN("not found window information");
1261 ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1262 return ICO_SYC_ENOENT;
1266 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1268 ICO_WRN("not found zone information");
1269 ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1270 return ICO_SYC_ENOENT;
1273 uint32_t attributes = 0;
1274 if (true == zone->aspectFixed) {
1275 attributes |= ICO_SYC_WIN_ASPECT_FIXED;
1276 if (true == zone->aspectAlignLeft) {
1277 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_LEFT;
1279 if (true == zone->aspectAlignRight) {
1280 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_RIGHT;
1282 if (true == zone->aspectAlignTop) {
1283 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_TOP;
1285 if (true == zone->aspectAlignBottom) {
1286 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_BOTTOM;
1289 ICO_TRA("CicoSCWindowController::setAttributes Leave(EOK)");
1293 //--------------------------------------------------------------------------
1295 * @brief wayland surface active callback
1297 * @param [in] data user data(unused)
1298 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1299 * @param [in] surfaceid ico_window_mgr surface Id
1300 * @param [in] select select device(unused)
1301 * (0=not active/1=pointer/2=touch)
1303 //--------------------------------------------------------------------------
1305 CicoSCWindowController::activeCB(void *data,
1306 struct ico_window_mgr *ico_window_mgr,
1310 ICO_TRA("CicoSCWindowController::activeCB Enter"
1311 "(surfaceid=0x%08X select=%d)", surfaceid, select);
1313 CicoSCWindow *window = findWindow(surfaceid);
1314 if (NULL == window) {
1315 ICO_WRN("not found window information");
1316 ICO_TRA("CicoSCWindowController::activeCB Leave(not found window)");
1321 ICO_TRA("CicoSCWindowController::activeCB Leave(not active)");
1325 if (0 != window->active) {
1326 ICO_TRA("CicoSCWindowController::activeCB Leave(already active)");
1331 CicoSCMessage *message = new CicoSCMessage();
1332 message->addRootObject("command", MSG_CMD_CHANGE_ACTIVE);
1333 message->addRootObject("appid", window->appid);
1334 message->addRootObject("pid", window->pid);
1335 message->addArgObject("surface", window->surfaceid);
1336 message->addArgObject("winname", window->name);
1337 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1339 ICO_TRA("CicoSCWindowController::activeCB Leave");
1342 //--------------------------------------------------------------------------
1344 * @brief surface map event callback
1346 * @param [in] data user data(unused)
1347 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1348 * @param [in] event event
1349 * @param [in] surfaceid surface Id
1350 * @param [in] type surface type (EGL buffer/Shared memory)
1351 * @param [in] width surface width
1352 * @param [in] height surface height
1353 * @param [in] stride surface buffer(frame buffer) stride
1354 * @param [in] format surface buffer format
1356 //--------------------------------------------------------------------------
1358 CicoSCWindowController::mapSurfaceCB(void *data,
1359 struct ico_window_mgr *ico_window_mgr,
1370 ICO_TRA("CicoSCWindowController::mapSurfaceCB Enter(ev=%d surf=%x "
1371 "type=%d w/h=%d/%d stride=%d form=%x)",
1372 event, surfaceid, type, width, height, stride, format);
1374 CicoSCWindow *window = findWindow(surfaceid);
1375 if (NULL == window) {
1379 // convert event to command
1381 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
1382 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
1383 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
1384 command = MSG_CMD_MAP_THUMB;
1386 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
1387 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
1388 command = MSG_CMD_UNMAP_THUMB;
1391 ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave(Unknown event(%d))", event);
1396 CicoSCMessage *message = new CicoSCMessage();
1397 message->addRootObject("command", command);
1398 message->addRootObject("appid", window->appid);
1399 message->addArgObject("surface", window->surfaceid);
1400 message->addArgObject("attr", type);
1401 message->addArgObject("width", width);
1402 message->addArgObject("height", height);
1403 message->addArgObject("stride", stride);
1404 message->addArgObject("format", format);
1405 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1407 ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave");
1410 //--------------------------------------------------------------------------
1412 * @brief surface update event callback
1414 * @param [in] data user data(unused)
1415 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1416 * @param [in] surfaceid surface Id
1417 * @param [in] visible visibility
1418 * @param [in] srcwidth application buffer width
1419 * @param [in] srcheight application buffer height
1422 * @param [in] width width
1423 * @param [in] height height
1425 //--------------------------------------------------------------------------
1427 CicoSCWindowController::updateSurfaceCB(void *data,
1428 struct ico_window_mgr *ico_window_mgr,
1438 ICO_TRA("CicoSCWindowController::updateSurfaceCB: Enter(%08x %d,%d,%d,%d,%d,%d,%d)",
1439 surfaceid, visible, srcwidth, srcheight, x, y, width, height);
1441 CicoSCWindow *window = findWindow(surfaceid);
1442 if (NULL == window) {
1443 ICO_WRN("CicoSCWindowController::updateSurfaceCB: not found window(%08x)",
1445 ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
1450 window->visible = visible;
1451 window->srcwidth = srcwidth;
1452 window->srcheight = srcheight;
1455 window->width = width;
1456 window->height = height;
1457 window->nodeid = window->layerid / ICO_SC_LAYERID_SCREENBASE;
1459 // notify to homescreen
1460 CicoSCMessage *message = new CicoSCMessage();
1461 message->addRootObject("command", MSG_CMD_CHANGE_ATTR);
1462 message->addRootObject("appid", window->appid);
1463 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1465 message->addArgObject("zone", zone->fullname);
1468 message->addArgObject("zone", "");
1470 message->addArgObject("surface", window->surfaceid);
1471 message->addArgObject("winname", window->name);
1472 message->addArgObject("node", window->nodeid);
1473 message->addArgObject("layer", window->layerid);
1474 message->addArgObject("pos_x", window->x);
1475 message->addArgObject("pos_y", window->y);
1476 message->addArgObject("width", window->width);
1477 message->addArgObject("height", window->height);
1478 message->addArgObject("raise", window->raise ? 1 : 0);
1479 message->addArgObject("visible", window->visible ? 1 : 0);
1480 message->addArgObject("active", window->active ? 1 : 0);
1481 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1483 ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
1486 //--------------------------------------------------------------------------
1488 * @brief wayland surface destroy callback
1490 * @param [in] data user data(unused)
1491 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1492 * @param [in] surfaceid ico_window_mgr surface Id
1494 //--------------------------------------------------------------------------
1496 CicoSCWindowController::destroySurfaceCB(void *data,
1497 struct ico_window_mgr *ico_window_mgr,
1500 ICO_TRA("CicoSCWindowController::destroySurfaceCB: Enter(%08x)", surfaceid);
1502 CicoSCWindow *window = findWindow(surfaceid);
1503 if (NULL == window) {
1504 ICO_WRN("not found window(%08x)", surfaceid);
1505 ICO_TRA("CicoSCWindowController::destroySurfaceCB Leave");
1510 CicoSCMessage *message = new CicoSCMessage();
1511 message->addRootObject("command", MSG_CMD_DESTROY);
1512 message->addRootObject("appid", window->appid);
1513 message->addRootObject("pid", window->pid);
1514 message->addArgObject("surface", window->surfaceid);
1515 message->addArgObject("winname", window->name);
1516 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1518 // TODO delete window in application
1519 if (NULL != m_resMgr) {
1521 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1523 cmd.cmdid = MSG_CMD_DESTORY_RES;
1524 cmd.appid = window->appid;
1525 cmd.pid = window->pid;
1528 opt->dispres = true;
1529 opt->winname = window->name;
1530 opt->surfaceid = window->surfaceid;
1533 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1535 opt->dispzone = zone->fullname;
1538 opt->soundres = true;
1539 opt->soundname = window->appid;
1541 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1542 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1543 if (NULL != defconf) {
1544 const CicoSCSoundZoneConf *zoneconf =
1545 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1546 if (NULL != zoneconf) {
1547 opt->soundzone = zoneconf->fullname;
1550 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1552 // delete window in list
1553 m_windowList.erase(window->surfaceid);
1556 ICO_TRA("CicoSCWindowController::destroySurfaceCB: Leave");
1559 //--------------------------------------------------------------------------
1561 * @brief wayland update surface name callback
1563 * @param [in] surfaceid surface Id
1564 * @param [in] winname surface name (title)
1566 //--------------------------------------------------------------------------
1568 CicoSCWindowController::updateWinnameCB(uint32_t surfaceid,
1569 const char *winname)
1571 ICO_TRA("CicoSCWindowController::updateWinnameCB: Enter(%08x,<%s>)",
1572 surfaceid, winname ? winname : "(null)");
1574 CicoSCWindow *window = findWindow(surfaceid);
1575 if (NULL == window) {
1576 ICO_WRN("CicoSCWindowController::updateWinnameCB: not found window(%08x)",
1578 ICO_TRA("CicoSCWindowController::updateWinnameCB Leave");
1582 window->name = winname;
1585 CicoSCMessage *message = new CicoSCMessage();
1586 message->addRootObject("command", MSG_CMD_NAME);
1587 message->addRootObject("appid", window->appid);
1588 message->addRootObject("pid", window->pid);
1589 message->addArgObject("surface", window->surfaceid);
1590 message->addArgObject("winname", window->name);
1591 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1593 ICO_TRA("CicoSCWindowController::updateWinnameCB: Leave");
1596 //--------------------------------------------------------------------------
1598 * @brief wayland display attribute callback
1600 * @param [in] data user data(unused)
1601 * @param [in] wl_output wayland wl_output interface
1602 * @param [in] x display upper-left X coordinate
1603 * @param [in] y display upper-left Y coordinate
1604 * @param [in] physical_width display physical width
1605 * @param [in] physical_height display physical height
1606 * @param [in] subpixel display sub pixel
1607 * @param [in] make display maker
1608 * @param [in] model display model
1609 * @param [in] transform transform
1611 //--------------------------------------------------------------------------
1613 CicoSCWindowController::outputGeometryCB(void *data,
1614 struct wl_output *wl_output,
1617 int32_t physical_width,
1618 int32_t physical_height,
1624 ICO_TRA("CicoSCWindowController::outputGeometryCB Enter"
1625 "(x=%d y=%d physical_width=%d physical_height=%d "
1626 "subpixel=%d make=%s model=%s transform=%d)",
1627 x, y, physical_width, physical_height,
1628 subpixel, make, model, transform);
1630 ++m_physicalDisplayTotal;
1631 if (0 == m_displayList.size()) {
1632 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1633 "(display is zero)");
1637 if (m_displayList.size() < m_physicalDisplayTotal) {
1638 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1639 "(display total unmatch)");
1643 CicoSCDisplay* display = m_displayList.at(m_physicalDisplayTotal-1);
1644 switch (transform) {
1645 case WL_OUTPUT_TRANSFORM_90:
1646 case WL_OUTPUT_TRANSFORM_270:
1647 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
1648 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
1649 display->pWidth = physical_height;
1650 display->pHeight = physical_width;
1651 display->orientation = CicoSCDisplay::ORIENTATION_VERTICAL;
1653 case WL_OUTPUT_TRANSFORM_NORMAL:
1654 case WL_OUTPUT_TRANSFORM_180:
1655 case WL_OUTPUT_TRANSFORM_FLIPPED:
1656 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
1658 display->pWidth = physical_width;
1659 display->pHeight = physical_height;
1660 display->orientation = CicoSCDisplay::ORIENTATION_HORIZONTAL;
1665 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave");
1668 //--------------------------------------------------------------------------
1670 * @brief wayland display mode callback
1672 * @param [in] data user data(unused)
1673 * @param [in] wl_output wayland wl_output interface
1674 * @param [in] flags flags
1675 * @param [in] width display width
1676 * @param [in] height display height
1677 * @param [in] refresh display refresh rate
1679 //--------------------------------------------------------------------------
1681 CicoSCWindowController::outputModeCB(void *data,
1682 struct wl_output *wl_output,
1688 ICO_TRA("CicoSCWindowController::outputModeCB Enter"
1689 "(flags=%d width=%d height=%d refresh=%d)",
1690 flags, width, height, refresh);
1692 if (0 == m_displayList.size()) {
1693 ICO_TRA("CicoSCWindowController::outputModeCB Leave(display is zero)");
1697 CicoSCDisplay* display = m_displayList.at(0);
1698 if (flags & WL_OUTPUT_MODE_CURRENT) {
1699 if (display->orientation == CicoSCDisplay::ORIENTATION_VERTICAL) {
1700 display->pWidth = height;
1701 display->pHeight = width;
1704 display->pWidth = width;
1705 display->pHeight = height;
1710 ICO_TRA("CicoSCWindowController::outputModeCB Leave");
1713 //--------------------------------------------------------------------------
1715 * @brief wayland genivi ivi-shell surface create callback
1717 * @param [in] data user data
1718 * @param [in] ivi_controller wayland ivi-controller plugin interface
1719 * @param [in] id_surface surface id
1721 //--------------------------------------------------------------------------
1723 CicoSCWindowController::createSurfaceCB(void *data,
1724 struct ivi_controller *ivi_controller,
1725 uint32_t id_surface)
1728 struct ilmSurfaceProperties SurfaceProperties;
1730 ICO_TRA("CicoSCWindowController::createSurfaceCB Enter"
1731 "(surfaceid=0x%08x)", id_surface);
1733 if (ilm_getPropertiesOfSurface(id_surface, &SurfaceProperties) != ILM_SUCCESS) {
1734 ICO_ERR("CicoSCWindowController::createSurfaceCB: ilm_getPropertiesOfSurface(%x) Error",
1738 ICO_TRA("createSurfaceCB: surface=%08x w/h=%d/%d->%d/%d",
1739 id_surface, SurfaceProperties.sourceWidth, SurfaceProperties.sourceHeight,
1740 SurfaceProperties.destWidth, SurfaceProperties.destHeight);
1742 CicoSCWindow* window = new CicoSCWindow();
1743 window->surfaceid = id_surface;
1744 window->name = CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(id_surface, &pid);
1746 window->displayid = 0; // currently fixed 0
1747 window->raise = 1; // created surface is top of layer
1748 window->srcwidth = SurfaceProperties.sourceWidth;
1749 window->srcheight = SurfaceProperties.sourceHeight;
1750 window->width = SurfaceProperties.destWidth;
1751 window->height = SurfaceProperties.destHeight;
1752 window->layerid = 0;
1754 CicoSCLifeCycleController* appctrl;
1755 appctrl = CicoSCLifeCycleController::getInstance();
1756 const CicoAilItems* ailItem = NULL;
1757 const CicoAulItems* aulitem = appctrl->findAUL(window->pid);
1758 if (NULL != aulitem) {
1759 window->appid = aulitem->m_appid;
1760 ICO_DBG("appid=%s", window->appid.c_str());
1761 ailItem = appctrl->findAIL(window->appid.c_str());
1764 ICO_DBG("application information not found.");
1767 if (NULL != ailItem) {
1768 window->layerid = ailItem->m_layer;
1769 window->zoneid = ailItem->m_displayZone;
1770 window->nodeid = ailItem->m_nodeID;
1771 if ((window->displayid >= 0) && (window->zoneid >= 0)) {
1773 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1775 window->zone = zone->fullname;
1776 window->x = zone->x;
1777 window->y = zone->y;
1778 window->width = zone->width;
1779 window->height = zone->height;
1785 ICO_WRN("ail item not found.");
1786 ICO_TRA("CicoSCWindowController::createSurfaceCB Leave(ENOENT)");
1790 if (ilm_surfaceSetDestinationRectangle(window->surfaceid, window->x, window->y,
1791 window->width, window->height) != ILM_SUCCESS) {
1792 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1793 "ilm_surfaceSetDestinationRectangle(%08x) Error", window->surfaceid);
1795 else if (ilm_surfaceSetSourceRectangle(window->surfaceid, 0, 0,
1796 window->width, window->height) != ILM_SUCCESS) {
1797 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1798 "ilm_surfaceSetSourceRectangle(%08x) Error", window->surfaceid);
1800 else if (ilm_surfaceSetOrientation(window->surfaceid, ILM_ZERO) != ILM_SUCCESS) {
1801 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1802 "ilm_surfaceSetOrientation(%08x) Error", window->surfaceid);
1804 else if (ilm_commitChanges() != ILM_SUCCESS) {
1805 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1808 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
1810 if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
1811 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_layerAddSurface(%d,%08x) "
1812 "Error", window->layerid, window->surfaceid);
1814 if (ilm_commitChanges() != ILM_SUCCESS) {
1815 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1818 layer->addSurface(window->surfaceid, true);
1820 const int *surfs = layer->getSurfaces(&nsurf);
1821 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
1823 ICO_ERR("CicoSCWindowController::createSurfaceCB: "
1824 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
1826 if (ilm_commitChanges() != ILM_SUCCESS) {
1827 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1830 // must set surfaceOpacity after surfcaeAddLayer
1831 if (ilm_surfaceSetOpacity(window->surfaceid , (t_ilm_float)1.0f) != ILM_SUCCESS) {
1832 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1833 "ilm_surfaceSetOpacity(%08x) Error", window->surfaceid);
1835 else if (ilm_commitChanges() != ILM_SUCCESS) {
1836 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1839 appctrl->enterAUL(window->appid.c_str(), window->pid, window);
1841 // dump log window information
1844 m_windowList[window->surfaceid] = window;
1846 // set surface attributes
1847 setAttributes(window->surfaceid);
1850 CicoSCMessage *message = new CicoSCMessage();
1851 message->addRootObject("command", MSG_CMD_CREATE);
1852 message->addRootObject("appid", window->appid);
1853 message->addRootObject("pid", window->pid);
1854 message->addArgObject("surface", window->surfaceid);
1855 message->addArgObject("winname", window->name);
1856 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1858 if (0 == window->appid.compare(ICO_SC_APPID_DEFAULT_ONS)) {
1859 CicoSCMessageRes *msgOS = new CicoSCMessageRes();
1860 msgOS->addRootObject("command", MSG_CMD_WINDOW_ID_RES);
1861 msgOS->addRootObject("appid", window->appid);
1862 msgOS->addRootObject("pid", window->pid);
1863 msgOS->addWinObject(MSG_PRMKEY_ECU, "");
1864 msgOS->addWinObject(MSG_PRMKEY_DISPLAY, "");
1865 msgOS->addWinObject(MSG_PRMKEY_LAYER, "");
1866 msgOS->addWinObject(MSG_PRMKEY_LAYOUT, "");
1867 msgOS->addWinObject(MSG_PRMKEY_AREA, "");
1868 msgOS->addWinObject(MSG_PRMKEY_DISPATCHAPP, "");
1869 msgOS->addWinObject(MSG_PRMKEY_ROLE, window->name);
1870 msgOS->addWinObject(MSG_PRMKEY_RESOURCEID, window->surfaceid);
1871 CicoSCServer::getInstance()->sendMessage(window->appid,
1872 (CicoSCMessage*)msgOS);
1875 if (NULL != m_resMgr) {
1877 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1879 cmd.cmdid = MSG_CMD_CREATE_RES;
1880 cmd.appid = window->appid;
1881 cmd.pid = window->pid;
1884 opt->dispres = true;
1885 opt->winname = window->name;
1886 opt->surfaceid = window->surfaceid;
1889 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1891 opt->dispzone = zone->fullname;
1895 opt->soundres = true;
1896 opt->soundname = window->appid;
1898 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1899 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1900 if (NULL != defconf) {
1901 const CicoSCSoundZoneConf *zoneconf =
1902 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1903 if (NULL != zoneconf) {
1904 opt->soundzone = zoneconf->fullname;
1908 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1911 show(window->surfaceid, NULL, 0);
1913 ICO_TRA("CicoSCWindowController::createSurfaceCB Leave");
1916 //--------------------------------------------------------------------------
1918 * @brief genivi ivi-shell layer propaty callback
1920 * @param [in] layer layer id
1921 * @param [in] LayerProperties layer properties
1922 * @param [in] mask change properties
1924 //--------------------------------------------------------------------------
1926 CicoSCWindowController::wlGeniviLayerNotification(t_ilm_layer layer,
1927 struct ilmLayerProperties *LayerProperties,
1928 t_ilm_notification_mask mask)
1930 ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Enter(%x,,%x)", layer, mask);
1932 if (mask & ILM_NOTIFICATION_VISIBILITY) {
1933 // change layer visibility, send message to HomeScreen
1934 CicoSCMessage *message = new CicoSCMessage();
1935 message->addRootObject("command", MSG_CMD_CHANGE_LAYER_ATTR);
1936 message->addRootObject("appid", "");
1937 message->addArgObject("layer", layer);
1938 message->addArgObject("visible", LayerProperties->visibility ? 1 : 0);
1939 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1941 ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Leave");
1944 //--------------------------------------------------------------------------
1946 * @brief setup Genivi ivi-shell layer managerment system finctions
1950 //--------------------------------------------------------------------------
1952 CicoSCWindowController::initializeGeniviLMS(void)
1954 t_ilm_uint NumberOfScreens = 16;
1955 t_ilm_uint ScreenIds[16];
1956 t_ilm_layer *pLayerId, *ppLayerId;
1957 t_ilm_int LayerNumber;
1958 t_ilm_uint *pScreenIds = ScreenIds;
1959 struct ilmScreenProperties ScreenProperties;
1961 int DisplayId, LayerId;
1962 const CicoSCDisplayConf *DisplayConf;
1963 const CicoSCLayerConf *LayerConf;
1965 // get all screen id
1966 memset(ScreenIds, 0, sizeof(ScreenIds));
1967 if ((ilm_getScreenIDs(&NumberOfScreens, &pScreenIds) != ILM_SUCCESS) ||
1968 (ilm_commitChanges() != ILM_SUCCESS)) {
1969 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
1970 "ilm_getScreenIDs() Error");
1973 ICO_TRA("initializeGeniviLMS: Screens=%d.%x %x %x %x",
1974 NumberOfScreens, ScreenIds[0], ScreenIds[1], ScreenIds[2], ScreenIds[3]);
1975 if ((int)NumberOfScreens > CicoSystemConfig::getInstance()->getNumberofDisplay()) {
1976 NumberOfScreens = (t_ilm_uint)CicoSystemConfig::getInstance()->getNumberofDisplay();
1978 for (idx = 0; idx < (int)NumberOfScreens; idx++) {
1979 ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
1980 "call ilm_getPropertiesOfScreen(%x)", ScreenIds[idx]);
1981 if ((ilm_getPropertiesOfScreen(ScreenIds[idx], &ScreenProperties) != ILM_SUCCESS) ||
1982 (ilm_commitChanges() != ILM_SUCCESS)) {
1983 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
1984 "ilm_getPropertiesOfScreen(%d.%x) Error", idx, ScreenIds[idx]);
1987 ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
1988 "Screen[%d.%x] w/h=%d/%d layers=%d",
1989 idx, ScreenIds[idx], ScreenProperties.screenWidth,
1990 ScreenProperties.screenHeight, ScreenProperties.layerCount);
1992 DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyNo((int)ScreenIds[idx]);
1993 if ((DisplayId < 0) ||
1994 ((DisplayConf = CicoSystemConfig::getInstance()->findDisplayConfbyId(DisplayId))
1996 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
1997 "ScreenId.%x not found", ScreenIds[idx]);
2000 // set genivi layers
2001 for (idx = 0; ; idx++) {
2002 LayerConf = CicoSystemConfig::getInstance()->
2003 findLayerConfbyIdx(DisplayId, idx);
2004 if (! LayerConf) break;
2006 pLayerId = (t_ilm_layer *)malloc(sizeof(t_ilm_layer) * idx);
2007 ppLayerId = pLayerId;
2010 for (idx = 0; ; idx++) {
2011 LayerConf = CicoSystemConfig::getInstance()->
2012 findLayerConfbyIdx(DisplayId, idx);
2013 if (! LayerConf) break;
2015 LayerId = LayerConf->id + DisplayId * ICO_SC_LAYERID_SCREENBASE;
2016 for (idx2 = 0; idx2 < LayerNumber; idx2++) {
2017 if (LayerId == (int)pLayerId[idx2]) break;
2019 if (idx2 < LayerNumber) {
2020 ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
2021 "layer.%d exist, Skip", LayerId);
2025 if (ilm_layerCreateWithDimension((t_ilm_layer *)&LayerId,
2026 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
2027 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2028 "ilm_layerCreateWithDimension(%d,%d,%d) Error",
2029 LayerId, DisplayConf->width, DisplayConf->height);
2031 else if (ilm_commitChanges() != ILM_SUCCESS) {
2032 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2033 "ilm_commitChanges() Error");
2035 else if (ilm_layerSetOpacity(LayerId, (t_ilm_float)1.0f) != ILM_SUCCESS) {
2036 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2037 "ilm_layerSetOpacity(%d) Error", LayerId);
2039 else if (ilm_layerSetSourceRectangle(LayerId, 0, 0,
2040 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
2041 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2042 "ilm_layerSetSourceRectangle(%d) Error", LayerId);
2044 else if (ilm_layerSetDestinationRectangle(LayerId, 0, 0,
2045 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
2046 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2047 "ilm_layerSetDestinationRectangle(%d) Error", LayerId);
2049 else if (ilm_layerSetOrientation(LayerId, ILM_ZERO) != ILM_SUCCESS) {
2050 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2051 "ilm_layerSetOrientation(%d) Error", LayerId);
2054 if (ilm_commitChanges() != ILM_SUCCESS) {
2055 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2056 "ilm_commitChanges() Error");
2058 // SystemController default is layer visible
2059 if ((ilm_layerSetVisibility(LayerId, 1) != ILM_SUCCESS) ||
2060 (ilm_commitChanges() != ILM_SUCCESS)) {
2061 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2062 "ilm_layerSetVisibility() Error");
2064 ICO_TRA("initializeGeniviLMS: layer=%d created(%d,%d)",
2065 LayerId, DisplayConf->width, DisplayConf->height);
2066 *ppLayerId = LayerId;
2071 if (LayerNumber > 0) {
2072 if (ilm_displaySetRenderOrder(ScreenIds[idx], pLayerId, LayerNumber)
2074 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2075 "ilm_displaySetRenderOrder(%d) Error", LayerNumber);
2077 else if (ilm_commitChanges() != ILM_SUCCESS) {
2078 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2079 "ilm_commitChanges() Error");
2081 ppLayerId = pLayerId;
2082 for (idx = 0; idx < LayerNumber; idx++) {
2083 if (ilm_layerAddNotification(*ppLayerId, wlGeniviLayerNotification)
2085 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2086 "ilm_layerAddNotification(%d) Error", *ppLayerId);
2096 //==========================================================================
2098 //==========================================================================
2100 //--------------------------------------------------------------------------
2102 * @brief find window object by surfaceid
2104 * @param [in] surfaceid wayland surface id
2106 //--------------------------------------------------------------------------
2108 CicoSCWindowController::findWindow(int surfaceid)
2110 map<unsigned int, CicoSCWindow*>::iterator itr;
2111 itr = m_windowList.find(surfaceid);
2112 if (m_windowList.end() == itr) {
2113 ICO_TRA("not found window object. surfaceid=0x%08X", surfaceid);
2120 //--------------------------------------------------------------------------
2122 * @brief find window object by surfaceid
2124 * @param [in] surfaceid wayland surface id
2126 //--------------------------------------------------------------------------
2128 CicoSCWindowController::findLayer(int displayid, int layerid)
2130 vector<CicoSCDisplay*>::iterator itr;
2131 itr = m_displayList.begin();
2132 for (; itr != m_displayList.end(); ++itr) {
2133 if ((*itr)->displayid != displayid) {
2136 vector<CicoSCLayer*>::iterator itr2;
2137 itr2 = (*itr)->layerList.begin();
2138 for (; itr2 != (*itr)->layerList.end(); ++itr2) {
2139 if ((*itr2)->layerid == layerid) {
2147 //--------------------------------------------------------------------------
2149 * @brief find display zone by id
2151 //--------------------------------------------------------------------------
2152 const CicoSCDisplayZone *
2153 CicoSCWindowController::findDisplayZone(int zoneid)
2155 vector<CicoSCDisplay*>::iterator itr;
2156 itr = m_displayList.begin();
2157 for (; itr != m_displayList.end(); ++itr) {
2158 std::map<unsigned int, CicoSCDisplayZone*>::iterator itr2;
2159 itr2 = (*itr)->zoneList.find(zoneid);
2160 if ((*itr)->zoneList.end() != itr2) {
2161 return itr2->second;
2167 //--------------------------------------------------------------------------
2169 * @brief handle command
2171 * @param [in] cmd control command
2173 //--------------------------------------------------------------------------
2175 CicoSCWindowController::handleCommand(const CicoSCCommand * cmd)
2177 // ICO_TRA("CicoSCWindowController::handleCommand Enter(%d)", cmd->cmdid);
2179 CicoSCCmdWinCtrlOpt *opt = static_cast<CicoSCCmdWinCtrlOpt*>(cmd->opt);
2181 switch (cmd->cmdid) {
2183 ICO_DBG("command: MSG_CMD_SHOW");
2184 if (opt->animationTime & ICO_SYC_WIN_SURF_NORESCTL) {
2185 /* show command but not resource control (for HomeScreen) */
2186 (void)show(opt->surfaceid,
2187 opt->animation.c_str(),
2188 opt->animationTime);
2191 /* show command (normal) */
2192 (void)notifyResourceManager(opt->surfaceid,
2195 opt->animation.c_str(),
2196 opt->animationTime);
2200 ICO_DBG("command: MSG_CMD_HIDE");
2201 (void)hide(opt->surfaceid, opt->animation.c_str(), opt->animationTime);
2205 ICO_DBG("command: MSG_CMD_MOVE");
2206 CicoSCWindow *window = findWindow(opt->surfaceid);
2207 if (NULL == window) {
2210 if (true == opt->zone.empty()) {
2211 (void)setGeometry(opt->surfaceid, opt->nodeid, opt->layerid,
2212 opt->x, opt->y, opt->width, opt->height,
2213 opt->animation.c_str(), opt->animationTime,
2214 opt->animation.c_str(), opt->animationTime);
2216 else if (opt->zone == window->zone) {
2217 (void)setGeometry(opt->surfaceid, opt->zone.c_str(), opt->layerid,
2218 opt->animation.c_str(), opt->animationTime,
2219 opt->animation.c_str(), opt->animationTime);
2222 (void)notifyResourceManager(opt->surfaceid,
2225 opt->animation.c_str(),
2226 opt->animationTime);
2230 case MSG_CMD_ANIMATION:
2231 ICO_DBG("command: MSG_CMD_ANIMATION");
2232 (void)setWindowAnimation(opt->surfaceid, opt->animationType,
2233 opt->animation.c_str(), opt->animationTime);
2235 case MSG_CMD_CHANGE_ACTIVE:
2236 ICO_DBG("command: MSG_CMD_CHANGE_ACTIVE");
2237 (void)active(opt->surfaceid, opt->active);
2239 case MSG_CMD_CHANGE_LAYER:
2240 ICO_DBG("command: MSG_CMD_CHANGE_LAYER");
2241 (void)setWindowLayer(opt->surfaceid, opt->layerid);
2243 case MSG_CMD_MAP_GET:
2244 ICO_DBG("command: MSG_CMD_MAP_GET");
2245 (void)setmapGet(opt->surfaceid, opt->animation.c_str());
2247 case MSG_CMD_MAP_THUMB:
2248 ICO_DBG("command: MSG_CMD_MAP_THUMB");
2249 (void)mapSurface(opt->surfaceid, opt->framerate, opt->animation.c_str());
2251 case MSG_CMD_UNMAP_THUMB:
2252 ICO_DBG("command: MSG_CMD_UNMAP_THUMB");
2253 (void)unmapSurface(opt->surfaceid);
2255 case MSG_CMD_SHOW_LAYER:
2256 ICO_DBG("command: MSG_CMD_SHOW_LAYER");
2257 (void)showLayer(opt->displayid, opt->layerid);
2259 case MSG_CMD_HIDE_LAYER:
2260 ICO_DBG("command: MSG_CMD_HIDE_LAYER");
2261 (void)hideLayer(opt->displayid, opt->layerid);
2264 ICO_WRN("command: Unknown(0x%08X)", cmd->cmdid);
2268 // ICO_TRA("CicoSCWindowController::handleCommand Leave");
2272 CicoSCWindowController::notifyResourceManager(int surfaceid,
2275 const char *animation,
2278 ICO_TRA("CicoSCWindowController::notifyResourceManager Enter"
2279 "(surfaceid=0x%08X zone=%s layerid=%d "
2280 "animation=%s animationTime=%d)",
2281 surfaceid, zone, layerid, animation, animationTime);
2283 // find window information in window list
2284 CicoSCWindow *window = findWindow(surfaceid);
2285 if (NULL == window) {
2286 ICO_WRN("not found window information");
2287 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2288 return ICO_SYC_ENOENT;
2292 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
2294 cmd.cmdid = MSG_CMD_ACQUIRE_RES;
2295 cmd.appid = window->appid;
2296 cmd.pid = window->pid;
2299 opt->dispres = true;
2300 opt->winname = window->name;
2301 opt->layerid = layerid;
2302 opt->surfaceid = window->surfaceid;
2303 opt->animation = animation ? animation : "";
2304 opt->animationTime = animationTime;
2307 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
2309 opt->dispzone = zone->fullname;
2312 ICO_WRN("not found zone information");
2313 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2314 return ICO_SYC_ENOENT;
2318 opt->dispzone = zone;
2321 opt->soundres = true;
2322 opt->soundname = window->appid;
2324 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
2325 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
2326 if (NULL != defconf) {
2327 const CicoSCSoundZoneConf *zoneconf =
2328 sysconf->findSoundZoneConfbyId(defconf->soundzone);
2329 if (NULL != zoneconf) {
2330 opt->soundzone = zoneconf->fullname;
2335 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
2337 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(EOK)");
2342 CicoSCWindowController::findWindowObj(int32_t pid, uint32_t surfaceid) const
2344 const CicoSCWindow* r = NULL;
2345 map<unsigned int, CicoSCWindow*>::const_iterator itr = m_windowList.begin();
2346 for (; itr != m_windowList.end(); ++itr) {
2347 const CicoSCWindow* tmp = itr->second;
2348 if ((pid == tmp->pid) && (surfaceid == (uint32_t)tmp->surfaceid)) {
2350 break; // break of for itr
2353 ICO_TRA("return %x", r);
2357 const CicoSCResourceManager*
2358 CicoSCWindowController::getResourceManager(void) const
2362 // vim:set expandtab ts=4 sw=4: