2 * Copyright (c) 2013-2014, 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 "CicoSCLifeCycleController.h"
48 #include "CicoSCResourceManager.h"
50 //==========================================================================
51 // private static variable
52 //==========================================================================
53 CicoSCWindowController* CicoSCWindowController::ms_myInstance = NULL;
55 //--------------------------------------------------------------------------
57 * @brief get instance of CicoSCWindowController
59 * @return instance of CicoSCWayland
61 //--------------------------------------------------------------------------
62 CicoSCWindowController*
63 CicoSCWindowController::getInstance(void)
65 if (NULL == ms_myInstance) {
66 ms_myInstance = new CicoSCWindowController();
71 //--------------------------------------------------------------------------
73 * @brief default constructor
75 //--------------------------------------------------------------------------
76 CicoSCWindowController::CicoSCWindowController()
77 : m_resMgr(NULL), m_physicalDisplayTotal(0)
79 CicoSCWayland* wayland = CicoSCWayland::getInstance();
80 wayland->getInstance()->addWaylandIF(ICO_WL_WIN_MGR_IF, this);
81 wayland->getInstance()->addWaylandIF(ICO_WL_IVI_APPLICATION_IF, this);
82 wayland->getInstance()->addWaylandIF(ICO_WL_IVI_CONTROLLER_IF, this);
83 wayland->getInstance()->addWaylandIF(ICO_WL_OUTPUT_IF, this);
86 CicoSCWindowController::ms_myInstance = this;
89 //--------------------------------------------------------------------------
93 //--------------------------------------------------------------------------
94 CicoSCWindowController::~CicoSCWindowController()
96 CicoSCWindowController::ms_myInstance = NULL;
99 //--------------------------------------------------------------------------
101 * @brief initialize display and window database
103 //--------------------------------------------------------------------------
105 CicoSCWindowController::initDB(void)
107 ICO_TRA("CicoSCWindowController::initDB: Enter");
109 const vector<CicoSCDisplayConf*>& displayList =
110 CicoSystemConfig::getInstance()->getDisplayConfList();
111 vector<CicoSCDisplayConf*>::const_iterator itr;
112 itr = displayList.begin();
113 for (; itr != displayList.end(); ++itr) {
114 CicoSCDisplay *display = new CicoSCDisplay();
115 display->displayid = (*itr)->id;
116 display->type = (*itr)->type;
117 display->nodeid = (*itr)->node;
118 display->displayno = (*itr)->no;
119 display->width = (*itr)->width;
120 display->height = (*itr)->height;
121 display->name = (*itr)->name;
123 vector<CicoSCLayerConf*>::const_iterator itr2;
124 itr2 = (*itr)->layerConfList.begin();
125 for (; itr2 != (*itr)->layerConfList.end(); ++itr2) {
126 CicoSCLayer *layer = new CicoSCLayer();
127 layer->layerid = (*itr2)->id;
128 layer->type = (*itr2)->type;
129 layer->width = display->width;
130 layer->height = display->height;
131 layer->displayid = display->displayid;
132 layer->menuoverlap = (*itr2)->menuoverlap;
133 display->layerList.push_back(layer);
136 vector<CicoSCDisplayZoneConf*>::const_iterator itr3;
137 itr3 = (*itr)->zoneConfList.begin();
138 for (; itr3 != (*itr)->zoneConfList.end(); ++itr3) {
139 CicoSCDisplayZone *zone = new CicoSCDisplayZone();
140 zone->zoneid = (*itr3)->id;
141 zone->x = (*itr3)->x;
142 zone->y = (*itr3)->y;
143 zone->width = (*itr3)->w;
144 zone->height = (*itr3)->h;
145 zone->fullname = (*itr3)->fullname;
146 zone->aspectFixed = (*itr3)->aspectFixed;
147 zone->aspectAlignLeft = (*itr3)->aspectAlignLeft;
148 zone->aspectAlignRight = (*itr3)->aspectAlignRight;
149 zone->aspectAlignTop = (*itr3)->aspectAlignTop;
150 zone->aspectAlignBottom = (*itr3)->aspectAlignBottom;
151 display->zoneList[zone->zoneid] = zone;
154 m_displayList.push_back(display);
157 ICO_TRA("CicoSCWindowController::initDB: Leave");
161 //--------------------------------------------------------------------------
163 * @brief set resource manager instance
165 * @param [in] resMgr resource manager instance
167 //--------------------------------------------------------------------------
169 CicoSCWindowController::setResourceManager(CicoSCResourceManager *resMgr)
174 //--------------------------------------------------------------------------
176 * @brief show a target window
178 * @param [in] surfaceid wayland surface id
179 * @param [in] animation animation name
180 * @param [in] animationTime animation time
182 * @return ICO_SYC_EOK on success, other on error
183 * @retval ICO_SYC_EOK success
184 * @retval ICO_SYC_ESRCH error(not initialized)
185 * @retval ICO_SYC_ENOENT error(not exist)
187 //--------------------------------------------------------------------------
189 CicoSCWindowController::show(int surfaceid,
190 const char *animation,
193 ICO_TRA("CicoSCWindowController::show Enter"
194 "(surfaceid=0x%08X animation=%s animationTime=%d)",
195 surfaceid, animation, animationTime);
197 // find window information in window list
198 CicoSCWindow *window = findWindow(surfaceid);
199 if (NULL == window) {
200 ICO_WRN("not found window information");
201 ICO_TRA("CicoSCWindowController::show Leave(ENOENT)");
202 return ICO_SYC_ENOENT;
205 // update visible attr
206 window->visible = true;
208 // update current displayed window at display zone
209 CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
211 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
212 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
213 ICO_DBG("Entry display zone[%d] current displayed window"
215 zone->zoneid, window->surfaceid, window->appid.c_str());
216 zone->displayedWindow = window;
220 // set animation request to Multi Window Manager
221 int animaFlag = ICO_SYC_ANIMATION_OFF;
222 int raiseFlag = ICO_SYC_WIN_RAISE_NOCHANGE;
223 if (animationTime & ICO_SYC_WIN_SURF_RAISE) {
224 raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
225 window->raise = true;
227 else if (animationTime & ICO_SYC_WIN_SURF_LOWER) {
228 raiseFlag = ICO_SYC_WIN_RAISE_LOWER;
229 window->raise = false;
231 else if (((animationTime & ICO_SYC_WIN_SURF_NOCHANGE) == 0) &&
232 (false == window->raise)) {
233 raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
234 window->raise = true;
236 if ((NULL != animation) && (animation[0] != '\0')) {
237 // set animation request to Multi Window Manager
238 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
239 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
240 animation, animationTime & ~ICO_SYC_WIN_SURF_FLAGS);
241 animaFlag = ICO_SYC_ANIMATION_ON;
244 // set visible request to Multi Window Manager
245 CicoSCWlWinMgrIF::setVisible(window->surfaceid,
246 ICO_SYC_WIN_VISIBLE_SHOW,
247 raiseFlag, animaFlag);
250 CicoSCWayland::getInstance()->flushDisplay();
252 ICO_TRA("CicoSCWindowController::show Leave(EOK)");
256 //--------------------------------------------------------------------------
258 * @brief hide a target window
260 * @param [in] surfaceid wayland surface id
261 * @param [in] animation animation name
262 * @param [in] animationTime animation time
264 * @return ICO_SYC_EOK on success, other on error
265 * @retval ICO_SYC_EOK success
266 * @retval ICO_SYC_ESRCH error(not initialized)
267 * @retval ICO_SYC_ENOENT error(not exist)
269 //--------------------------------------------------------------------------
271 CicoSCWindowController::hide(int surfaceid,
272 const char *animation,
275 ICO_TRA("CicoSCWindowController::hide Enter"
276 "(surfaceid=0x%08X animation=%s animationTime=%d)",
277 surfaceid, animation, animationTime);
279 // find window information in window list
280 CicoSCWindow *window = findWindow(surfaceid);
281 if (NULL == window) {
282 ICO_WRN("not found window information");
283 ICO_TRA("CicoSCWindowController::hide Leave(ENOENT)");
284 return ICO_SYC_ENOENT;
287 if (false == window->visible) {
288 ICO_DBG("already hide state");
289 ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
293 // update window attr
294 window->visible = false;
296 // update current displayed window at display zone
297 CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
299 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
300 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
301 (getDisplayedWindow(zone->zoneid) == surfaceid)) {
302 ICO_DBG("Exit display zone[%d] current displayed window"
304 zone->zoneid, window->surfaceid, window->appid.c_str());
305 zone->displayedWindow = NULL;
309 // set animation request to Multi Window Manager
310 int animaFlag = ICO_SYC_ANIMATION_OFF;
311 if ((NULL != animation) && (animation[0] != '\0')) {
312 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
313 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE,
314 animation, animationTime & ~ICO_SYC_WIN_SURF_FLAGS);
315 animaFlag = ICO_SYC_ANIMATION_ON;
318 // set visible request to Multi Window Manager
319 CicoSCWlWinMgrIF::setVisible(window->surfaceid,
320 ICO_SYC_LAYER_VISIBLE_HIDE,
321 ICO_SYC_WIN_RAISE_NOCHANGE, animaFlag);
324 CicoSCWayland::getInstance()->flushDisplay();
326 ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
330 //--------------------------------------------------------------------------
332 * @brief resize window(surface) size
334 * @param [in] surfaceid wayland surface id
335 * @param [in] w window width
336 * @param [in] h window height
337 * @param [in] animation animation name
338 * @param [in] animationTime animation time
340 * @return ICO_SYC_EOK on success, other on error
341 * @retval ICO_SYC_EOK success
342 * @retval ICO_SYC_ESRCH error(not initialized)
343 * @retval ICO_SYC_ENOENT error(window dose not exist)
345 //--------------------------------------------------------------------------
347 CicoSCWindowController::resize(int surfaceid,
350 const char *animation,
353 ICO_TRA("CicoSCWindowController::resize Enter"
354 "(surfaceid=0x%08X h=%d w=%d animation=%s animationTime=%d)",
355 surfaceid, w, h, animation, animationTime);
357 // find window information in window list
358 CicoSCWindow *window = findWindow(surfaceid);
359 if (NULL == window) {
360 ICO_WRN("not found window information");
361 ICO_TRA("CicoSCWindowController::resize Leave(ENOENT)");
362 return ICO_SYC_ENOENT;
365 // set animation request to Multi Window Manager
366 int animaFlag = ICO_SYC_ANIMATION_OFF;
367 if ((NULL != animation) && (animation[0] != '\0')) {
368 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
369 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
370 animation, animationTime);
371 animaFlag = ICO_SYC_ANIMATION_ON;
374 // set visible request to Multi Window Manager
377 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, window->nodeid,
378 window->x, window->y,
382 CicoSCWayland::getInstance()->flushDisplay();
384 ICO_TRA("CicoSCWindowController::resize Leave(EOK)");
388 //--------------------------------------------------------------------------
390 * @brief move window(surface) position
392 * @param [in] surfaceid wayland surface id
393 * @param [in] nodeid node id
394 * @param [in] x window width
395 * @param [in] y window height
396 * @param [in] animation animation name
397 * @param [in] animationTime animation time
399 * @return ICO_SYC_EOK on success, other on error
400 * @retval ICO_SYC_EOK success
401 * @retval ICO_SYC_ESRCH error(not initialized)
402 * @retval ICO_SYC_ENOENT error(window dose not exist)
404 //--------------------------------------------------------------------------
406 CicoSCWindowController::move(int surfaceid,
410 const char *animation,
413 ICO_TRA("CicoSCWindowController::move Enter"
414 "(surfaceid=0x%08X nodeid=%d x=%d y=%d "
415 "animation=%s animationTime=%d)",
416 surfaceid, nodeid, x, y, animation, animationTime);
418 // find window information in window list
419 CicoSCWindow *window = findWindow(surfaceid);
420 if (NULL == window) {
421 ICO_WRN("not found window information");
422 ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
423 return ICO_SYC_ENOENT;
426 // set animation request to Multi Window Manager
427 int animaFlag = ICO_SYC_ANIMATION_OFF;
428 if ((NULL != animation) && (animation[0] != '\0')) {
429 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
430 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
431 animation, animationTime);
432 animaFlag = ICO_SYC_ANIMATION_ON;
435 int moveNodeId = ICO_SYC_WIN_NOCHANGE;
440 // set visible request to Multi Window Manager
443 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid,
445 window->width, window->height,
449 CicoSCWayland::getInstance()->flushDisplay();
451 ICO_TRA("CicoSCWindowController::move Leave(EOK)");
455 //--------------------------------------------------------------------------
457 * @brief raise window(surface)
459 * @param [in] surfaceid wayland surface id
460 * @param [in] animation animation name
461 * @param [in] animationTime animation time
463 * @return ICO_SYC_EOK on success, other on error
464 * @retval ICO_SYC_EOK success
465 * @retval ICO_SYC_ESRCH error(not initialized)
466 * @retval ICO_SYC_ENOENT error(layer dose not exist)
468 //--------------------------------------------------------------------------
470 CicoSCWindowController::raise(int surfaceid,
471 const char *animation,
474 ICO_TRA("CicoSCWindowController::raise Enter"
475 "(surfaceid=0x%08X animation=%s animationTime=%d)",
476 surfaceid, animation, animationTime);
478 // find window information in window list
479 CicoSCWindow *window = findWindow(surfaceid);
480 if (NULL == window) {
481 ICO_WRN("not found window information");
482 ICO_TRA("CicoSCWindowController::raise Leave(ENOENT)");
483 return ICO_SYC_ENOENT;
486 // update visible attr
487 window->raise = true;
489 // set animation request to Multi Window Manager
490 int animaFlag = ICO_SYC_ANIMATION_OFF;
491 if ((NULL != animation) && (animation[0] != '\0')) {
492 CicoSCWindowController::setAnimation(window->surfaceid,
493 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
494 animation, animationTime);
495 animaFlag = ICO_SYC_ANIMATION_ON;
498 // set visible request to Multi Window Manager
499 CicoSCWlWinMgrIF::setVisible(window->surfaceid,
500 ICO_SYC_WIN_VISIBLE_NOCHANGE,
501 ICO_SYC_WIN_RAISE_RAISE, animaFlag);
504 CicoSCWayland::getInstance()->flushDisplay();
506 ICO_TRA("CicoSCWindowController::raise Leave(EOK)");
510 //--------------------------------------------------------------------------
512 * @brief set window(surface) geometry
514 * @param [in] surfaceid wayland surface id
515 * @param [in] nodeid node id
516 * @param [in] layerid layer id
517 * @param [in] x window x position
518 * @param [in] y window y position
519 * @param [in] w window width
520 * @param [in] h window height
521 * @param [in] resizeAnimation resize animation name
522 * @param [in] resizeAnimationTime resize animation time
523 * @param [in] moveAnimation move animation name
524 * @param [in] moveanimationTime move animation time
526 * @return ICO_SYC_EOK on success, other on error
527 * @retval ICO_SYC_EOK success
528 * @retval ICO_SYC_ESRCH error(not initialized)
529 * @retval ICO_SYC_ENOENT error(window dose not exist)
531 //--------------------------------------------------------------------------
533 CicoSCWindowController::setGeometry(int surfaceid,
540 const char *resizeAnimation,
541 int resizeAnimationTime,
542 const char *moveAnimation,
543 int moveAnimationTime)
545 ICO_TRA("CicoSCWindowController::setGeometry Enter"
546 "(surfaceid=0x%08X nodeid=%d layerid=%d x=%d y=%d w=%d h=%d "
547 "resizeAnimation=%s resizeAnimationTime=%d "
548 "moveAnimation=%s moveAnimationTime=%d)",
549 surfaceid, nodeid, layerid, x, y, w, h,
550 resizeAnimation, resizeAnimationTime,
551 moveAnimation, moveAnimationTime);
553 // find window information in window list
554 CicoSCWindow *window = findWindow(surfaceid);
555 if (NULL == window) {
556 ICO_WRN("not found window information");
557 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
558 return ICO_SYC_ENOENT;
561 // set animation request to Multi Window Manager
562 const char *animation = "";
563 if (NULL != resizeAnimation) {
564 animation = resizeAnimation;
566 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
567 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
568 animation, resizeAnimationTime);
570 if (NULL != moveAnimation) {
571 animation = moveAnimation;
573 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
574 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
575 animation, moveAnimationTime);
577 int moveNodeId = ICO_SYC_WIN_NOCHANGE;
582 moveNodeId = window->nodeid;
585 if (m_physicalDisplayTotal <= (unsigned int)moveNodeId) {
586 ICO_WRN("nodeid(%d) is over physical display total(%d)",
587 m_physicalDisplayTotal, nodeid);
588 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
589 return ICO_SYC_EINVAL;
592 int moveX = window->x;
598 int moveY = window->y;
604 int moveW = window->width;
610 int moveH = window->height;
616 // set window layer to Multi Window Manager
618 setWindowLayer(window->surfaceid, layerid);
621 // update window attr
622 window->nodeid = moveNodeId;
624 // set visible request to Multi Window Manager
625 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, moveNodeId,
626 moveX, moveY, moveW, moveH,
627 ICO_SYC_ANIMATION_ON);
630 CicoSCWayland::getInstance()->flushDisplay();
632 ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
636 //--------------------------------------------------------------------------
638 * @brief set window(surface) geometry
640 * @param [in] surfaceid wayland surface id
641 * @param [in] layerid layer id
642 * @param [in] nodeid node id
643 * @param [in] zone display zone name
644 * @param [in] resizeAnimation resize animation name
645 * @param [in] resizeAnimationTime resize animation time
646 * @param [in] moveAnimation move animation name
647 * @param [in] moveanimationTime move animation time
649 * @return ICO_SYC_EOK on success, other on error
650 * @retval ICO_SYC_EOK success
651 * @retval ICO_SYC_ESRCH error(not initialized)
652 * @retval ICO_SYC_ENOENT error(window dose not exist)
653 * @retval ICO_SYC_EINVAL error(zone is null, zone name is invalid)
655 //--------------------------------------------------------------------------
657 CicoSCWindowController::setGeometry(int surfaceid,
660 const char *resizeAnimation,
661 int resizeAnimationTime,
662 const char *moveAnimation,
663 int moveAnimationTime)
665 ICO_TRA("CicoSCWindowController::setGeometry Enter"
666 "(surfaceid=0x%08X zone=%s layerid=%d "
667 "resizeAnimation=%s resizeAnimationTime=%d "
668 "moveAnimation=%s moveAnimationTime=%d)",
669 surfaceid, zone, layerid,
670 resizeAnimation, resizeAnimationTime,
671 moveAnimation, moveAnimationTime);
673 // find window information in window list
674 CicoSCWindow *window = findWindow(surfaceid);
675 if (NULL == window) {
676 ICO_WRN("not found window information");
677 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
678 return ICO_SYC_ENOENT;
681 if ((NULL == zone) || ('\0' == zone[0])) {
682 ICO_WRN("zone value is invalid");
683 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
684 return ICO_SYC_EINVAL;
687 vector<CicoSCDisplay*>::iterator itr;
688 itr = m_displayList.begin();
689 CicoSCDisplayZone* dispzone = NULL;
691 for (; itr != m_displayList.end(); ++itr) {
692 dispzone = (*itr)->findDisplayZonebyFullName(zone);
693 if (NULL != dispzone) {
694 displayno = (*itr)->displayno;
699 if (NULL == dispzone) {
700 ICO_WRN("display zone name(%s) is invalid.", zone);
701 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
702 return ICO_SYC_EINVAL;
705 if (m_physicalDisplayTotal <= (unsigned int)displayno) {
706 ICO_WRN("nodeid(%d) is over physical display total(%d)",
707 m_physicalDisplayTotal, displayno);
708 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
709 return ICO_SYC_EINVAL;
712 if (window->zoneid != dispzone->zoneid) {
713 // update current displayed window at display zone
714 CicoSCDisplayZone* olddispzone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
715 if (NULL != olddispzone) {
716 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
717 if ((NULL != layer) &&
718 (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
719 (getDisplayedWindow(olddispzone->zoneid) == surfaceid)) {
720 ICO_DBG("Exit display zone[%d] current displayed window"
722 olddispzone->zoneid, window->surfaceid,
723 window->appid.c_str());
724 olddispzone->displayedWindow = NULL;
728 CicoSCLayer *layer = findLayer(displayno, window->layerid);
729 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
730 ICO_DBG("Entry display zone[%d] current displayed window"
732 dispzone->zoneid, window->surfaceid, window->appid.c_str());
733 dispzone->displayedWindow = window;
737 // update window attr
738 window->zoneid = dispzone->zoneid;
739 window->zone = dispzone->fullname;
740 setAttributes(window->surfaceid);
742 int ret = setGeometry(surfaceid, displayno, layerid,
743 dispzone->x, dispzone->y,
744 dispzone->width, dispzone->height,
745 resizeAnimation, resizeAnimationTime,
746 moveAnimation, moveAnimationTime);
748 ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
752 //--------------------------------------------------------------------------
754 * @brief lower window(surface)
756 * @param [in] surfaceid wayland surface id
757 * @param [in] animation animation name
758 * @param [in] animationTime animation time
760 * @return ICO_SYC_EOK on success, other on error
761 * @retval ICO_SYC_EOK success
762 * @retval ICO_SYC_ESRCH error(not initialized)
763 * @retval ICO_SYC_ENOENT error(layer dose not exist)
765 //--------------------------------------------------------------------------
767 CicoSCWindowController::lower(int surfaceid,
768 const char *animation,
771 ICO_TRA("CicoSCWindowController::lower Enter"
772 "(surfaceid=0x%08X animation=%s animationTime=%d)",
773 surfaceid, animation, animationTime);
775 // find window information in window list
776 CicoSCWindow *window = findWindow(surfaceid);
777 if (NULL == window) {
778 ICO_WRN("not found window information");
779 ICO_TRA("CicoSCWindowController::lower Leave(ENOENT)");
780 return ICO_SYC_ENOENT;
783 // update visible attr
784 window->raise = false;
786 // set animation request to Multi Window Manager
787 int animaFlag = ICO_SYC_ANIMATION_OFF;
788 if ((NULL != animation) && (animation[0] != '\0')) {
789 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
790 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE,
791 animation, animationTime);
792 animaFlag = ICO_SYC_ANIMATION_ON;
795 // set visible request to Multi Window Manager
796 CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_WIN_VISIBLE_NOCHANGE,
797 ICO_SYC_WIN_RAISE_LOWER, animaFlag);
800 CicoSCWayland::getInstance()->flushDisplay();
802 ICO_TRA("CicoSCWindowController::lower Leave(EOK)");
806 //--------------------------------------------------------------------------
808 * @brief set window layer
810 * @param [in] surfaceid wayland surface id
811 * @param [in] layer layer id
813 * @return ICO_SYC_EOK on success, other on error
814 * @retval ICO_SYC_EOK success
815 * @retval ICO_SYC_ESRCH error(not initialized)
816 * @retval ICO_SYC_ENOENT error(window or layer dose not exist)
818 //--------------------------------------------------------------------------
820 CicoSCWindowController::setWindowLayer(int surfaceid, int layerid)
824 ICO_TRA("CicoSCWindowController::setWindowLayer Enter"
825 "(surfaceid=0x%08X layerid=%x)", surfaceid, layerid);
827 // find window information in window list
828 CicoSCWindow* window = findWindow(surfaceid);
829 if (NULL == window) {
830 ICO_WRN("not found window information");
831 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT)");
832 return ICO_SYC_ENOENT;
835 // find layer information in layer list
836 CicoSCLayer* layer = findLayer(window->displayid, layerid);
838 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT[disp=%d,layer=%d])",
839 window->displayid, layerid);
840 return ICO_SYC_ENOENT;
843 // update window attr
844 oldlayerid = window->layerid;
845 window->layerid = layerid;
847 // set window layer request to Multi Window Manager
848 CicoSCWlWinMgrIF::setWindowLayer(window->surfaceid,
849 (uint32_t)window->layerid, oldlayerid);
851 CicoSCWayland::getInstance()->flushDisplay();
853 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(EOK)");
857 //--------------------------------------------------------------------------
861 * @param [in] displayid display id
862 * @param [in] layerid layer id
864 * @return ICO_SYC_EOK on success, other on error
865 * @retval ICO_SYC_EOK success
866 * @retval ICO_SYC_ESRCH error(not initialized)
867 * @retval ICO_SYC_ENOENT error(layer dose not exist)
869 //--------------------------------------------------------------------------
871 CicoSCWindowController::showLayer(int displayid, int layerid)
873 ICO_TRA("CicoSCWindowController::showLayer Enter"
874 "(displayid=%d layerid=%d)", displayid, layerid);
876 // find layer information in layer list
877 CicoSCLayer* layer = findLayer(displayid, layerid);
879 ICO_WRN("not found layer information");
880 ICO_TRA("CicoSCWindowController::showLayer Leave(ENOENT)");
881 return ICO_SYC_ENOENT;
884 CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_SHOW);
887 CicoSCWayland::getInstance()->flushDisplay();
889 ICO_TRA("CicoSCWindowController::showLayer Leave(EOK)");
893 //--------------------------------------------------------------------------
897 * @param [in] displayid display id
898 * @param [in] layerid layer id
900 * @return ICO_SYC_EOK on success, other on error
901 * @retval ICO_SYC_EOK success
902 * @retval ICO_SYC_ESRCH error(not initialized)
903 * @retval ICO_SYC_ENOENT error(layer dose not exist)
905 //--------------------------------------------------------------------------
907 CicoSCWindowController::hideLayer(int displayid, int layerid)
909 ICO_TRA("CicoSCWindowController::hideLayer Enter"
910 "displayid=%d layerid=%d)",
913 // find layer information in layer list
914 CicoSCLayer* layer = findLayer(displayid, layerid);
916 ICO_WRN("not found layer information");
917 ICO_TRA("CicoSCWindowController::hideLayer Leave(ENOENT)");
918 return ICO_SYC_ENOENT;
921 CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_HIDE);
924 CicoSCWayland::getInstance()->flushDisplay();
926 ICO_TRA("CicoSCWindowController::hideVisible Leave(EOK)");
930 //--------------------------------------------------------------------------
932 * @brief active window(surface)
934 * @param [in] surfaceid wayland surface id
935 * @param [in] target target(pointer and/or keyboard)
937 * @return ICO_SYC_EOK on success, other on error
938 * @retval ICO_SYC_EOK success
939 * @retval ICO_SYC_ESRCH error(not initialized)
940 * @retval ICO_SYC_ENOENT error(layer dose not exist)
942 //--------------------------------------------------------------------------
944 CicoSCWindowController::active(int surfaceid, int target)
946 CicoSCWindow *window = NULL;
948 ICO_TRA("CicoSCWindowController::active Enter"
949 "(surfaceid=0x%08X, target=%08X)", surfaceid, target);
951 // find window information in window list
953 window = findWindow(surfaceid);
954 if (NULL == window) {
955 ICO_WRN("not found window information");
956 ICO_TRA("CicoSCWindowController::active Leave(ENOENT)");
957 return ICO_SYC_ENOENT;
965 // set active request to Multi Window Manager
966 CicoSCWlWinMgrIF::setActive(surfaceid, target);
969 CicoSCWayland::getInstance()->flushDisplay();
971 // update visible attr
973 window->raise = true;
976 // update active window
977 map<unsigned int, CicoSCWindow*>::iterator itr;
978 itr = m_windowList.begin();
979 for (; itr != m_windowList.end(); ++itr) {
980 CicoSCWindow* window = itr->second;
981 if ((surfaceid != 0) && (window->surfaceid == surfaceid)) {
982 window->active = target;
989 window->active &= ~target;
994 ICO_TRA("CicoSCWindowController::active Leave(EOK)");
998 //--------------------------------------------------------------------------
1000 * @brief set surface map get
1002 * @param [in] surfaceid wayland surface id
1003 * @param [in] filepath surface image pixel file path
1005 * @return ICO_SYC_EOK on success, other on error(currently EOK only)
1006 * @retval ICO_SYC_EOK success
1008 //--------------------------------------------------------------------------
1010 CicoSCWindowController::setmapGet(int surfaceid, const char *filepath)
1012 ICO_TRA("CicoSCWindowController::setmapGet Enter");
1014 CicoSCWlWinMgrIF::setmapGet(surfaceid, filepath);
1015 CicoSCWayland::getInstance()->flushDisplay();
1017 ICO_TRA("CicoSCWindowController::setmapGet Leave(EOK)");
1021 //--------------------------------------------------------------------------
1023 * @brief map surface
1025 * @param [in] surfaceid wayland surface id
1026 * @param [in] framerate surface change frame rate(frames par sec)
1027 * @param [in] filepath surface image pixel file path
1029 * @return ICO_SYC_EOK on success, other on error
1030 * @retval ICO_SYC_EOK success
1031 * @retval ICO_SYC_ESRCH error(not initialized)
1032 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1034 //--------------------------------------------------------------------------
1036 CicoSCWindowController::mapSurface(int surfaceid, int framerate, const char *filepath)
1038 ICO_TRA("CicoSCWindowController::mapSurface Enter(0x%08x,%d,%s)",
1039 surfaceid, framerate, filepath ? filepath : "(null)");
1041 // find window information in window list
1042 CicoSCWindow *window = findWindow(surfaceid);
1043 if (NULL == window) {
1044 ICO_WRN("not found window information");
1045 ICO_TRA("CicoSCWindowController::mapSurface Leave(ENOENT)");
1046 return ICO_SYC_ENOENT;
1049 if (framerate < 0) {
1053 CicoSCWlWinMgrIF::mapSurface(surfaceid, framerate, filepath);
1054 CicoSCWayland::getInstance()->flushDisplay();
1056 ICO_TRA("CicoSCWindowController::mapSurface Leave(EOK)");
1060 //--------------------------------------------------------------------------
1062 * @brief unmap surface
1064 * @param [in] surfaceid wayland surface id
1066 * @return ICO_SYC_EOK on success, other on error
1067 * @retval ICO_SYC_EOK success
1068 * @retval ICO_SYC_ESRCH error(not initialized)
1069 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1071 //--------------------------------------------------------------------------
1073 CicoSCWindowController::unmapSurface(int surfaceid)
1075 ICO_TRA("CicoSCWindowController::unmapSurface Enter(0x%08x)", surfaceid);
1077 // find window information in window list
1078 CicoSCWindow *window = findWindow(surfaceid);
1079 if (NULL == window) {
1080 ICO_WRN("not found window information");
1081 ICO_TRA("CicoSCWindowController::unmapSurface Leave(ENOENT)");
1082 return ICO_SYC_ENOENT;
1085 CicoSCWlWinMgrIF::unmapSurface(surfaceid);
1086 CicoSCWayland::getInstance()->flushDisplay();
1088 ICO_TRA("CicoSCWindowController::unmapSurface Leave(EOK)");
1092 //--------------------------------------------------------------------------
1094 * @brief get displayed window by display zone id
1096 * @param [in] zoneid display zone id
1098 * @return surface id on success, -1 on not displayed
1100 //--------------------------------------------------------------------------
1102 CicoSCWindowController::getDisplayedWindow(int zoneid)
1104 const CicoSCDisplayZone* zone = findDisplayZone(zoneid);
1109 if (NULL == zone->displayedWindow) {
1113 return zone->displayedWindow->surfaceid;
1116 //--------------------------------------------------------------------------
1118 * @brief set surface attributes
1120 * @param [in] surfaceid surface id
1122 * @retval ICO_SYC_EOK success
1123 * @retval ICO_SYC_ESRCH error(not initialized)
1124 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1126 //--------------------------------------------------------------------------
1128 CicoSCWindowController::setAttributes(int surfaceid)
1130 ICO_TRA("CicoSCWindowController::setAttributes Enter"
1131 "(surfaceid=0x%08X)", surfaceid);
1133 // find window information in window list
1134 CicoSCWindow *window = findWindow(surfaceid);
1135 if (NULL == window) {
1136 ICO_WRN("not found window information");
1137 ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1138 return ICO_SYC_ENOENT;
1142 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1144 ICO_WRN("not found zone information");
1145 ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1146 return ICO_SYC_ENOENT;
1149 uint32_t attributes = 0;
1150 if (true == zone->aspectFixed) {
1151 attributes |= ICO_SYC_WIN_ASPECT_FIXED;
1152 if (true == zone->aspectAlignLeft) {
1153 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_LEFT;
1155 if (true == zone->aspectAlignRight) {
1156 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_RIGHT;
1158 if (true == zone->aspectAlignTop) {
1159 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_TOP;
1161 if (true == zone->aspectAlignBottom) {
1162 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_BOTTOM;
1165 ICO_TRA("CicoSCWindowController::setAttributes Leave(EOK)");
1169 //--------------------------------------------------------------------------
1171 * @brief wayland surface active callback
1173 * @param [in] data user data(unused)
1174 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1175 * @param [in] surfaceid ico_window_mgr surface Id
1176 * @param [in] select select device(unused)
1177 * (0=not active/1=pointer/2=touch)
1179 //--------------------------------------------------------------------------
1181 CicoSCWindowController::activeCB(void *data,
1182 struct ico_window_mgr *ico_window_mgr,
1186 ICO_TRA("CicoSCWindowController::activeCB Enter"
1187 "(surfaceid=0x%08X select=%d)", surfaceid, select);
1189 CicoSCWindow *window = findWindow(surfaceid);
1190 if (NULL == window) {
1191 ICO_WRN("not found window information");
1192 ICO_TRA("CicoSCWindowController::activeCB Leave(not found window)");
1197 ICO_TRA("CicoSCWindowController::activeCB Leave(not active)");
1201 if (0 != window->active) {
1202 ICO_TRA("CicoSCWindowController::activeCB Leave(already active)");
1207 CicoSCMessage *message = new CicoSCMessage();
1208 message->addRootObject("command", MSG_CMD_CHANGE_ACTIVE);
1209 message->addRootObject("appid", window->appid);
1210 message->addRootObject("pid", window->pid);
1211 message->addArgObject("surface", window->surfaceid);
1212 message->addArgObject("winname", window->name);
1213 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1215 ICO_TRA("CicoSCWindowController::activeCB Leave");
1218 //--------------------------------------------------------------------------
1220 * @brief surface map event callback
1222 * @param [in] data user data(unused)
1223 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1224 * @param [in] event event
1225 * @param [in] surfaceid surface Id
1226 * @param [in] type surface type (EGL buffer/Shared memory)
1227 * @param [in] width surface width
1228 * @param [in] height surface height
1229 * @param [in] stride surface buffer(frame buffer) stride
1230 * @param [in] format surface buffer format
1232 //--------------------------------------------------------------------------
1234 CicoSCWindowController::mapSurfaceCB(void *data,
1235 struct ico_window_mgr *ico_window_mgr,
1246 ICO_TRA("CicoSCWindowController::mapSurfaceCB Enter(ev=%d surf=%x "
1247 "type=%d w/h=%d/%d stride=%d form=%x)",
1248 event, surfaceid, type, width, height, stride, format);
1250 CicoSCWindow *window = findWindow(surfaceid);
1251 if (NULL == window) {
1255 // convert event to command
1257 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
1258 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
1259 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
1260 command = MSG_CMD_MAP_THUMB;
1262 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
1263 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
1264 command = MSG_CMD_UNMAP_THUMB;
1267 ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave(Unknown event(%d))", event);
1272 CicoSCMessage *message = new CicoSCMessage();
1273 message->addRootObject("command", command);
1274 message->addRootObject("appid", window->appid);
1275 message->addArgObject("surface", window->surfaceid);
1276 message->addArgObject("attr", type);
1277 message->addArgObject("width", width);
1278 message->addArgObject("height", height);
1279 message->addArgObject("stride", stride);
1280 message->addArgObject("format", format);
1281 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1283 ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave");
1286 //--------------------------------------------------------------------------
1288 * @brief wayland display attribute callback
1290 * @param [in] data user data(unused)
1291 * @param [in] wl_output wayland wl_output interface
1292 * @param [in] x display upper-left X coordinate
1293 * @param [in] y display upper-left Y coordinate
1294 * @param [in] physical_width display physical width
1295 * @param [in] physical_height display physical height
1296 * @param [in] subpixel display sub pixel
1297 * @param [in] make display maker
1298 * @param [in] model display model
1299 * @param [in] transform transform
1301 //--------------------------------------------------------------------------
1303 CicoSCWindowController::outputGeometryCB(void *data,
1304 struct wl_output *wl_output,
1307 int32_t physical_width,
1308 int32_t physical_height,
1314 ICO_TRA("CicoSCWindowController::outputGeometryCB Enter"
1315 "(x=%d y=%d physical_width=%d physical_height=%d "
1316 "subpixel=%d make=%s model=%s transform=%d)",
1317 x, y, physical_width, physical_height,
1318 subpixel, make, model, transform);
1320 ++m_physicalDisplayTotal;
1321 if (0 == m_displayList.size()) {
1322 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1323 "(display is zero)");
1327 if (m_displayList.size() < m_physicalDisplayTotal) {
1328 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1329 "(display total unmatch)");
1333 CicoSCDisplay* display = m_displayList.at(m_physicalDisplayTotal-1);
1334 switch (transform) {
1335 case WL_OUTPUT_TRANSFORM_90:
1336 case WL_OUTPUT_TRANSFORM_270:
1337 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
1338 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
1339 display->pWidth = physical_height;
1340 display->pHeight = physical_width;
1341 display->orientation = CicoSCDisplay::ORIENTATION_VERTICAL;
1343 case WL_OUTPUT_TRANSFORM_NORMAL:
1344 case WL_OUTPUT_TRANSFORM_180:
1345 case WL_OUTPUT_TRANSFORM_FLIPPED:
1346 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
1348 display->pWidth = physical_width;
1349 display->pHeight = physical_height;
1350 display->orientation = CicoSCDisplay::ORIENTATION_HORIZONTAL;
1355 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave");
1358 //--------------------------------------------------------------------------
1360 * @brief wayland display mode callback
1362 * @param [in] data user data(unused)
1363 * @param [in] wl_output wayland wl_output interface
1364 * @param [in] flags flags
1365 * @param [in] width display width
1366 * @param [in] height display height
1367 * @param [in] refresh display refresh rate
1369 //--------------------------------------------------------------------------
1371 CicoSCWindowController::outputModeCB(void *data,
1372 struct wl_output *wl_output,
1378 ICO_TRA("CicoSCWindowController::outputModeCB Enter"
1379 "(flags=%d width=%d height=%d refresh=%d)",
1380 flags, width, height, refresh);
1382 if (0 == m_displayList.size()) {
1383 ICO_TRA("CicoSCWindowController::outputModeCB Leave(display is zero)");
1387 CicoSCDisplay* display = m_displayList.at(0);
1388 if (flags & WL_OUTPUT_MODE_CURRENT) {
1389 if (display->orientation == CicoSCDisplay::ORIENTATION_VERTICAL) {
1390 display->pWidth = height;
1391 display->pHeight = width;
1394 display->pWidth = width;
1395 display->pHeight = height;
1400 ICO_TRA("CicoSCWindowController::outputModeCB Leave");
1403 //--------------------------------------------------------------------------
1405 * @brief wayland genivi ivi-shell surface create callback
1407 * @param [in] data user data
1408 * @param [in] ivi_controller wayland ivi-controller plugin interface
1409 * @param [in] id_surface surface id
1411 //--------------------------------------------------------------------------
1413 CicoSCWindowController::createSurfaceCB(void *data,
1414 struct ivi_controller *ivi_controller,
1415 uint32_t id_surface)
1419 struct ilmSurfaceProperties SurfaceProperties;
1421 ICO_TRA("CicoSCWindowController::createSurfaceCB Enter"
1422 "(surfaceid=0x%08x)", id_surface);
1424 if ((ilm_getPropertiesOfSurface(id_surface, &SurfaceProperties) != ILM_SUCCESS) ||
1425 (ilm_commitChanges() != ILM_SUCCESS)) {
1426 ICO_ERR("CicoSCWindowController::createSurfaceCB: ilm_getPropertiesOfSurface(%x) Error",
1430 ICO_TRA("createSurfaceCB: surface=%08x pid=%d w/h=%d/%d->%d/%d",
1431 id_surface, SurfaceProperties.creatorPid,
1432 SurfaceProperties.sourceWidth, SurfaceProperties.sourceHeight,
1433 SurfaceProperties.destWidth, SurfaceProperties.destHeight);
1435 CicoSCWindow* window = new CicoSCWindow();
1436 window->surfaceid = id_surface;
1437 window->name = CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(id_surface, &pid);
1439 window->displayid = 0; // currently fixed 0
1440 window->raise = 1; // created surface is top of layer
1442 CicoSCLifeCycleController* appctrl;
1443 appctrl = CicoSCLifeCycleController::getInstance();
1444 const CicoAilItems* ailItem = NULL;
1445 const CicoAulItems* aulitem = appctrl->findAUL(window->pid);
1446 if (NULL != aulitem) {
1447 window->appid = aulitem->m_appid;
1448 ICO_DBG("appid=%s", window->appid.c_str());
1449 ailItem = appctrl->findAIL(window->appid.c_str());
1452 ICO_DBG("application information not found.");
1455 if (NULL != ailItem) {
1456 window->layerid = ailItem->m_layer;
1457 window->zoneid = ailItem->m_displayZone;
1458 window->nodeid = ailItem->m_nodeID;
1459 if ((window->displayid >= 0) && (window->zoneid >= 0)) {
1461 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1463 window->zone = zone->fullname;
1464 window->x = zone->x;
1465 window->y = zone->y;
1466 window->width = zone->width;
1467 window->height = zone->height;
1473 ICO_WRN("ail item not found.");
1474 ICO_TRA("CicoSCWindowController::createSurfaceCB Leave(ENOENT)");
1478 CicoSCLayer *blayer = findLayer(window->displayid, window->layerid);
1480 blayer->addSurface(window->surfaceid, true);
1482 const int *surfs = blayer->getSurfaces(&nsurf);
1483 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
1485 ICO_ERR("CicoSCWindowController::createSurfaceCB: "
1486 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
1488 else if (ilm_commitChanges() != ILM_SUCCESS) {
1489 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1493 appctrl->enterAUL(window->appid.c_str(), window->pid, window);
1495 // dump log window information
1498 m_windowList[window->surfaceid] = window;
1500 // set surface attributes
1501 setAttributes(window->surfaceid);
1504 CicoSCMessage *message = new CicoSCMessage();
1505 message->addRootObject("command", MSG_CMD_CREATE);
1506 message->addRootObject("appid", window->appid);
1507 message->addRootObject("pid", window->pid);
1508 message->addArgObject("surface", window->surfaceid);
1509 message->addArgObject("winname", window->name);
1510 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1512 if (NULL != m_resMgr) {
1514 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1516 cmd.cmdid = MSG_CMD_CREATE_RES;
1517 cmd.appid = window->appid;
1518 cmd.pid = window->pid;
1521 opt->dispres = true;
1522 opt->winname = window->name;
1523 opt->surfaceid = window->surfaceid;
1526 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1528 opt->dispzone = zone->fullname;
1532 opt->soundres = true;
1533 opt->soundname = window->appid;
1535 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1536 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1537 if (NULL != defconf) {
1538 const CicoSCSoundZoneConf *zoneconf =
1539 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1540 if (NULL != zoneconf) {
1541 opt->soundzone = zoneconf->fullname;
1545 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1548 show(window->surfaceid, NULL, 0);
1552 if ((ret = ilm_surfaceAddNotification(window->surfaceid, wlGeniviSurfaceNotification))
1554 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_surfaceAddNotification(%08x) "
1555 "Error.%d", window->surfaceid, ret);
1557 ICO_TRA("CicoSCWindowController::createSurfaceCB Leave");
1560 //--------------------------------------------------------------------------
1562 * @brief genivi ivi-shell layer propaty callback
1564 * @param [in] layer layer id
1565 * @param [in] LayerProperties layer properties
1566 * @param [in] mask change properties
1568 //--------------------------------------------------------------------------
1570 CicoSCWindowController::wlGeniviLayerNotification(t_ilm_layer layer,
1571 struct ilmLayerProperties *LayerProperties,
1572 t_ilm_notification_mask mask)
1574 ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Enter(%x,,%x)", layer, mask);
1576 if (mask & ILM_NOTIFICATION_VISIBILITY) {
1577 // change layer visibility, send message to HomeScreen
1578 CicoSCMessage *message = new CicoSCMessage();
1579 message->addRootObject("command", MSG_CMD_CHANGE_LAYER_ATTR);
1580 message->addRootObject("appid", "");
1581 message->addArgObject("layer", layer);
1582 message->addArgObject("visible", LayerProperties->visibility ? 1 : 0);
1583 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1585 ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Leave");
1588 //--------------------------------------------------------------------------
1590 * @brief genivi ivi-shell surface propaty callback
1592 * @param [in] surface surface id
1593 * @param [in] SurfaceProperties surface properties
1594 * @param [in] mask change properties
1596 //--------------------------------------------------------------------------
1598 CicoSCWindowController::wlGeniviSurfaceNotification(t_ilm_surface surface,
1599 struct ilmSurfaceProperties *SurfaceProperties,
1600 t_ilm_notification_mask mask)
1604 ICO_TRA("CicoSCWindowController::wlGeniviSurfaceNotification Enter(%x,,%x)", surface, mask);
1605 newVisible = SurfaceProperties->visibility ? ICO_SYC_WIN_VISIBLE_SHOW
1606 : ICO_SYC_WIN_VISIBLE_HIDE;
1607 CicoSCWindow *window = CicoSCWindowController::getInstance()->findWindow(surface);
1608 if (NULL == window) {
1609 ICO_WRN("CicoSCWindowController::wlGeniviSurfaceNotification Leave(surface=%08x not exist)", surface);
1612 if ((window->visible != newVisible) ||
1613 (window->x != (int)SurfaceProperties->destX) ||
1614 (window->y != (int)SurfaceProperties->destY) ||
1615 (window->width != (int)SurfaceProperties->destWidth) ||
1616 (window->height != (int)SurfaceProperties->destHeight)) {
1617 // change visibility
1618 window->visible = newVisible;
1619 window->x = (int)SurfaceProperties->destX;
1620 window->y = (int)SurfaceProperties->destY;
1621 window->width = (int)SurfaceProperties->destWidth;
1622 window->height = (int)SurfaceProperties->destHeight;
1625 window->visible = newVisible;
1627 // notify to homescreen
1628 CicoSCMessage *message = new CicoSCMessage();
1629 message->addRootObject("command", MSG_CMD_CHANGE_ATTR);
1630 message->addRootObject("appid", window->appid);
1631 const CicoSCDisplayZone* zone
1632 = CicoSCWindowController::getInstance()->findDisplayZone(window->zoneid);
1634 message->addArgObject("zone", zone->fullname);
1637 message->addArgObject("zone", "");
1639 message->addArgObject("surface", window->surfaceid);
1640 message->addArgObject("winname", window->name);
1641 message->addArgObject("node", window->nodeid);
1642 message->addArgObject("layer", window->layerid);
1643 message->addArgObject("pos_x", window->x);
1644 message->addArgObject("pos_y", window->y);
1645 message->addArgObject("width", window->width);
1646 message->addArgObject("height", window->height);
1647 message->addArgObject("raise", window->raise ? 1 : 0);
1648 message->addArgObject("visible", window->visible ? 1 : 0);
1649 message->addArgObject("active", window->active ? 1 : 0);
1650 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1653 ICO_TRA("CicoSCWindowController::wlGeniviSurfaceNotification Leave(no change)");
1657 //--------------------------------------------------------------------------
1659 * @brief setup Genivi ivi-shell notification(callback) finctions
1663 //--------------------------------------------------------------------------
1665 CicoSCWindowController::initializeGeniviNotifications(void)
1667 t_ilm_uint NumberOfScreens = 16;
1668 t_ilm_uint ScreenIds[16];
1669 t_ilm_layer *pLayerId, *ppLayerId;
1670 t_ilm_int LayerNumber;
1671 t_ilm_uint *pScreenIds = ScreenIds;
1672 struct ilmScreenProperties ScreenProperties;
1674 const CicoSCDisplayConf *DisplayConf;
1675 const CicoSCLayerConf *LayerConf;
1678 // get all screen id
1679 memset(ScreenIds, 0, sizeof(ScreenIds));
1680 if ((ilm_getScreenIDs(&NumberOfScreens, &pScreenIds) != ILM_SUCCESS) ||
1681 (ilm_commitChanges() != ILM_SUCCESS)) {
1682 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1683 "ilm_getScreenIDs() Error");
1686 ICO_TRA("initializeGeniviNotifications: Screens=%d.%x %x %x %x",
1687 NumberOfScreens, ScreenIds[0], ScreenIds[1], ScreenIds[2], ScreenIds[3]);
1688 for (idx = 0; idx < (int)NumberOfScreens; idx++) {
1689 ICO_TRA("CicoSCWindowController::initializeGeniviNotifications: call ilm_getPropertiesOfScreen(%x)", ScreenIds[idx]);
1690 if ((ilm_getPropertiesOfScreen(ScreenIds[idx], &ScreenProperties) != ILM_SUCCESS) ||
1691 (ilm_commitChanges() != ILM_SUCCESS)) {
1692 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1693 "ilm_getPropertiesOfScreen(%d.%x) Error", idx, ScreenIds[idx]);
1696 ICO_TRA("CicoSCWindowController::initializeGeniviNotifications: "
1697 "Screen[%d.%x] w/h=%d/%d layers=%d",
1698 idx, ScreenIds[idx], ScreenProperties.screenWidth,
1699 ScreenProperties.screenHeight, ScreenProperties.layerCount);
1701 DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyNo((int)ScreenIds[idx]);
1702 if ((DisplayId < 0) ||
1703 ((DisplayConf = CicoSystemConfig::getInstance()->findDisplayConfbyId(DisplayId))
1705 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1706 "ScreenId.%x not found", ScreenIds[idx]);
1710 CicoSystemConfig::getInstance()->setDisplaySize(DisplayId,
1711 ScreenProperties.screenWidth,
1712 ScreenProperties.screenHeight);
1714 // set genivi layers
1715 for (idx = 0; ; idx++) {
1716 LayerConf = CicoSystemConfig::getInstance()->
1717 findLayerConfbyIdx(DisplayId, idx);
1718 if (! LayerConf) break;
1720 pLayerId = (t_ilm_layer *)malloc(sizeof(t_ilm_layer) * idx);
1721 ppLayerId = pLayerId;
1724 for (idx = 0; ; idx++) {
1725 LayerConf = CicoSystemConfig::getInstance()->
1726 findLayerConfbyIdx(DisplayId, idx);
1727 if (! LayerConf) break;
1729 LayerId = (DisplayId << 16) | LayerConf->id;
1730 if (ilm_layerCreateWithDimension((t_ilm_layer *)&LayerId,
1731 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
1732 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1733 "ilm_layerCreateWithDimension(%x,%d,%d) Error",
1734 LayerId, DisplayConf->width, DisplayConf->height);
1736 else if (ilm_commitChanges() != ILM_SUCCESS) {
1737 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1738 "ilm_commitChanges() Error");
1740 else if (ilm_layerSetOpacity(LayerId, (t_ilm_float)1.0f) != ILM_SUCCESS) {
1741 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1742 "ilm_layerSetOpacity(%x) Error", LayerId);
1744 else if (ilm_layerSetSourceRectangle(LayerId, 0, 0,
1745 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
1746 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1747 "ilm_layerSetSourceRectangle(%x) Error", LayerId);
1749 else if (ilm_layerSetDestinationRectangle(LayerId, 0, 0,
1750 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
1751 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1752 "ilm_layerSetDestinationRectangle(%x) Error", LayerId);
1754 else if (ilm_layerSetOrientation(LayerId, ILM_ZERO) != ILM_SUCCESS) {
1755 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1756 "ilm_layerSetOrientation(%x) Error", LayerId);
1758 else if (ilm_layerSetOrientation(LayerId, ILM_ZERO) != ILM_SUCCESS) {
1759 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1760 "ilm_layerSetOrientation(%x) Error", LayerId);
1762 else if (ilm_layerAddNotification(LayerId, wlGeniviLayerNotification)
1764 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1765 "ilm_layerAddNotification(%x) Error", LayerId);
1768 if (ilm_commitChanges() != ILM_SUCCESS) {
1769 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1770 "ilm_commitChanges() Error");
1772 ICO_TRA("initializeGeniviNotifications: layer=%x created(%d,%d)",
1773 LayerId, DisplayConf->width, DisplayConf->height);
1774 *ppLayerId = LayerId;
1779 if (LayerNumber > 0) {
1780 if (ilm_displaySetRenderOrder(ScreenIds[idx], pLayerId, LayerNumber)
1782 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1783 "ilm_displaySetRenderOrder(%d) Error", LayerNumber);
1785 else if (ilm_commitChanges() != ILM_SUCCESS) {
1786 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1787 "ilm_commitChanges() Error");
1789 ppLayerId = pLayerId;
1790 for (idx = 0; idx < LayerNumber; idx++) {
1791 if (ilm_layerAddNotification(*ppLayerId, wlGeniviLayerNotification)
1793 ICO_ERR("CicoSCWindowController::initializeGeniviNotifications "
1794 "ilm_layerAddNotification(%x) Error", *ppLayerId);
1804 //==========================================================================
1806 //==========================================================================
1808 //--------------------------------------------------------------------------
1810 * @brief find window object by surfaceid
1812 * @param [in] surfaceid wayland surface id
1814 //--------------------------------------------------------------------------
1816 CicoSCWindowController::findWindow(int surfaceid)
1818 map<unsigned int, CicoSCWindow*>::iterator itr;
1819 itr = m_windowList.find(surfaceid);
1820 if (m_windowList.end() == itr) {
1821 ICO_TRA("not found window object. surfaceid=0x%08X", surfaceid);
1828 //--------------------------------------------------------------------------
1830 * @brief find window object by surfaceid
1832 * @param [in] surfaceid wayland surface id
1834 //--------------------------------------------------------------------------
1836 CicoSCWindowController::findLayer(int displayid, int layerid)
1838 vector<CicoSCDisplay*>::iterator itr;
1839 itr = m_displayList.begin();
1840 for (; itr != m_displayList.end(); ++itr) {
1841 if ((*itr)->displayid != displayid) {
1844 vector<CicoSCLayer*>::iterator itr2;
1845 itr2 = (*itr)->layerList.begin();
1846 for (; itr2 != (*itr)->layerList.end(); ++itr2) {
1847 if ((*itr2)->layerid == layerid) {
1855 //--------------------------------------------------------------------------
1857 * @brief find display zone by id
1859 //--------------------------------------------------------------------------
1860 const CicoSCDisplayZone *
1861 CicoSCWindowController::findDisplayZone(int zoneid)
1863 vector<CicoSCDisplay*>::iterator itr;
1864 itr = m_displayList.begin();
1865 for (; itr != m_displayList.end(); ++itr) {
1866 std::map<unsigned int, CicoSCDisplayZone*>::iterator itr2;
1867 itr2 = (*itr)->zoneList.find(zoneid);
1868 if ((*itr)->zoneList.end() != itr2) {
1869 return itr2->second;
1875 //--------------------------------------------------------------------------
1877 * @brief handle command
1879 * @param [in] cmd control command
1881 //--------------------------------------------------------------------------
1883 CicoSCWindowController::handleCommand(const CicoSCCommand * cmd)
1885 // ICO_TRA("CicoSCWindowController::handleCommand Enter(%d)", cmd->cmdid);
1887 CicoSCCmdWinCtrlOpt *opt = static_cast<CicoSCCmdWinCtrlOpt*>(cmd->opt);
1889 switch (cmd->cmdid) {
1891 ICO_DBG("command: MSG_CMD_SHOW");
1892 if (opt->animationTime & ICO_SYC_WIN_SURF_NORESCTL) {
1893 /* show command but not resource control (for HomeScreen) */
1894 (void)show(opt->surfaceid,
1895 opt->animation.c_str(),
1896 opt->animationTime);
1899 /* show command (normal) */
1900 (void)notifyResourceManager(opt->surfaceid,
1903 opt->animation.c_str(),
1904 opt->animationTime);
1908 ICO_DBG("command: MSG_CMD_HIDE");
1909 (void)hide(opt->surfaceid, opt->animation.c_str(), opt->animationTime);
1913 ICO_DBG("command: MSG_CMD_MOVE");
1914 CicoSCWindow *window = findWindow(opt->surfaceid);
1915 if (NULL == window) {
1918 if (true == opt->zone.empty()) {
1919 (void)setGeometry(opt->surfaceid, opt->nodeid, opt->layerid,
1920 opt->x, opt->y, opt->width, opt->height,
1921 opt->animation.c_str(), opt->animationTime,
1922 opt->animation.c_str(), opt->animationTime);
1924 else if (opt->zone == window->zone) {
1925 (void)setGeometry(opt->surfaceid, opt->zone.c_str(), opt->layerid,
1926 opt->animation.c_str(), opt->animationTime,
1927 opt->animation.c_str(), opt->animationTime);
1930 (void)notifyResourceManager(opt->surfaceid,
1933 opt->animation.c_str(),
1934 opt->animationTime);
1938 case MSG_CMD_CHANGE_ACTIVE:
1939 ICO_DBG("command: MSG_CMD_CHANGE_ACTIVE");
1940 (void)active(opt->surfaceid, opt->active);
1942 case MSG_CMD_CHANGE_LAYER:
1943 ICO_DBG("command: MSG_CMD_CHANGE_LAYER");
1944 (void)setWindowLayer(opt->surfaceid, opt->layerid);
1946 case MSG_CMD_MAP_GET:
1947 ICO_DBG("command: MSG_CMD_MAP_GET");
1948 (void)setmapGet(opt->surfaceid, opt->animation.c_str());
1950 case MSG_CMD_MAP_THUMB:
1951 ICO_DBG("command: MSG_CMD_MAP_THUMB");
1952 (void)mapSurface(opt->surfaceid, opt->framerate, opt->animation.c_str());
1954 case MSG_CMD_UNMAP_THUMB:
1955 ICO_DBG("command: MSG_CMD_UNMAP_THUMB");
1956 (void)unmapSurface(opt->surfaceid);
1958 case MSG_CMD_SHOW_LAYER:
1959 ICO_DBG("command: MSG_CMD_SHOW_LAYER");
1960 (void)showLayer(opt->displayid, opt->layerid);
1962 case MSG_CMD_HIDE_LAYER:
1963 ICO_DBG("command: MSG_CMD_HIDE_LAYER");
1964 (void)hideLayer(opt->displayid, opt->layerid);
1967 ICO_WRN("command: Unknown(0x%08X)", cmd->cmdid);
1971 // ICO_TRA("CicoSCWindowController::handleCommand Leave");
1975 CicoSCWindowController::notifyResourceManager(int surfaceid,
1978 const char *animation,
1981 ICO_TRA("CicoSCWindowController::notifyResourceManager Enter"
1982 "(surfaceid=0x%08X zone=%s layerid=%d "
1983 "animation=%s animationTime=%d)",
1984 surfaceid, zone, layerid, animation, animationTime);
1986 // find window information in window list
1987 CicoSCWindow *window = findWindow(surfaceid);
1988 if (NULL == window) {
1989 ICO_WRN("not found window information");
1990 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
1991 return ICO_SYC_ENOENT;
1995 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1997 cmd.cmdid = MSG_CMD_ACQUIRE_RES;
1998 cmd.appid = window->appid;
1999 cmd.pid = window->pid;
2002 opt->dispres = true;
2003 opt->winname = window->name;
2004 opt->layerid = layerid;
2005 opt->surfaceid = window->surfaceid;
2006 opt->animation = animation ? animation : "";
2007 opt->animationTime = animationTime;
2010 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
2012 opt->dispzone = zone->fullname;
2015 ICO_WRN("not found zone information");
2016 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2017 return ICO_SYC_ENOENT;
2021 opt->dispzone = zone;
2024 opt->soundres = true;
2025 opt->soundname = window->appid;
2027 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
2028 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
2029 if (NULL != defconf) {
2030 const CicoSCSoundZoneConf *zoneconf =
2031 sysconf->findSoundZoneConfbyId(defconf->soundzone);
2032 if (NULL != zoneconf) {
2033 opt->soundzone = zoneconf->fullname;
2038 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
2040 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(EOK)");
2043 // vim:set expandtab ts=4 sw=4: