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/types.h>
25 #include <sys/ioctl.h>
33 #include "CicoSCWindow.h"
34 #include "CicoSCWayland.h"
35 #include "CicoSCWindowController.h"
38 #include "CicoSystemConfig.h"
40 #include "CicoSCDisplay.h"
41 #include "CicoSCLayer.h"
42 #include "CicoSCDisplayZone.h"
43 #include "ico_syc_error.h"
44 #include "ico_syc_type.h"
45 #include "ico_syc_winctl.h"
46 #include "CicoSCCommand.h"
47 #include "ico_syc_msg_cmd_def.h"
48 #include "CicoSCServer.h"
49 #include "CicoSCMessage.h"
50 #include "CicoSCMessageRes.h"
51 #include "CicoSCLifeCycleController.h"
52 #include "CicoSCResourceManager.h"
54 //==========================================================================
55 // private static variable
56 //==========================================================================
57 CicoSCWindowController* CicoSCWindowController::ms_myInstance = NULL;
59 //--------------------------------------------------------------------------
61 * @brief get instance of CicoSCWindowController
63 * @return instance of CicoSCWindowController
65 //--------------------------------------------------------------------------
66 CicoSCWindowController*
67 CicoSCWindowController::getInstance(void)
69 if (NULL == ms_myInstance) {
70 ms_myInstance = new CicoSCWindowController();
75 //--------------------------------------------------------------------------
77 * @brief default constructor
79 //--------------------------------------------------------------------------
80 CicoSCWindowController::CicoSCWindowController()
81 : m_resMgr(NULL), m_physicalDisplayTotal(0)
83 CicoSCWayland* wayland = CicoSCWayland::getInstance();
84 wayland->getInstance()->addWaylandIF(ICO_WL_WIN_MGR_IF, this);
85 wayland->getInstance()->addWaylandIF(ICO_WL_IVI_APPLICATION_IF, this);
86 wayland->getInstance()->addWaylandIF(ICO_WL_IVI_CONTROLLER_IF, this);
87 wayland->getInstance()->addWaylandIF(ICO_WL_OUTPUT_IF, this);
90 CicoSCWindowController::ms_myInstance = this;
93 //--------------------------------------------------------------------------
97 //--------------------------------------------------------------------------
98 CicoSCWindowController::~CicoSCWindowController()
100 CicoSCWindowController::ms_myInstance = NULL;
103 //--------------------------------------------------------------------------
105 * @brief initialize display and window database
107 //--------------------------------------------------------------------------
109 CicoSCWindowController::initDB(void)
111 ICO_TRA("CicoSCWindowController::initDB: Enter");
113 const vector<CicoSCDisplayConf*>& displayList =
114 CicoSystemConfig::getInstance()->getDisplayConfList();
115 vector<CicoSCDisplayConf*>::const_iterator itr;
116 itr = displayList.begin();
117 for (; itr != displayList.end(); ++itr) {
118 CicoSCDisplay *display = new CicoSCDisplay();
119 display->displayid = (*itr)->id;
120 display->type = (*itr)->type;
121 display->nodeid = (*itr)->node;
122 display->displayno = (*itr)->no;
123 display->width = (*itr)->width;
124 display->height = (*itr)->height;
125 display->name = (*itr)->name;
127 vector<CicoSCLayerConf*>::const_iterator itr2;
128 itr2 = (*itr)->layerConfList.begin();
129 for (; itr2 != (*itr)->layerConfList.end(); ++itr2) {
130 CicoSCLayer *layer = new CicoSCLayer();
131 layer->layerid = (*itr2)->id;
132 layer->type = (*itr2)->type;
133 layer->width = display->width;
134 layer->height = display->height;
135 layer->displayid = display->displayid;
136 layer->menuoverlap = (*itr2)->menuoverlap;
137 display->layerList.push_back(layer);
140 vector<CicoSCDisplayZoneConf*>::const_iterator itr3;
141 itr3 = (*itr)->zoneConfList.begin();
142 for (; itr3 != (*itr)->zoneConfList.end(); ++itr3) {
143 CicoSCDisplayZone *zone = new CicoSCDisplayZone();
144 zone->zoneid = (*itr3)->id;
145 zone->x = (*itr3)->x;
146 zone->y = (*itr3)->y;
147 zone->width = (*itr3)->w;
148 zone->height = (*itr3)->h;
149 zone->fullname = (*itr3)->fullname;
150 zone->aspectFixed = (*itr3)->aspectFixed;
151 zone->aspectAlignLeft = (*itr3)->aspectAlignLeft;
152 zone->aspectAlignRight = (*itr3)->aspectAlignRight;
153 zone->aspectAlignTop = (*itr3)->aspectAlignTop;
154 zone->aspectAlignBottom = (*itr3)->aspectAlignBottom;
155 display->zoneList[zone->zoneid] = zone;
158 m_displayList.push_back(display);
161 ICO_TRA("CicoSCWindowController::initDB: Leave");
165 //--------------------------------------------------------------------------
167 * @brief set resource manager instance
169 * @param [in] resMgr resource manager instance
171 //--------------------------------------------------------------------------
173 CicoSCWindowController::setResourceManager(CicoSCResourceManager *resMgr)
178 //--------------------------------------------------------------------------
180 * @brief show a target window
182 * @param [in] surfaceid wayland surface id
183 * @param [in] animation animation name
184 * @param [in] animationTime animation time
186 * @return ICO_SYC_EOK on success, other on error
187 * @retval ICO_SYC_EOK success
188 * @retval ICO_SYC_ESRCH error(not initialized)
189 * @retval ICO_SYC_ENOENT error(not exist)
191 //--------------------------------------------------------------------------
193 CicoSCWindowController::show(int surfaceid,
194 const char *animation,
197 int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
198 animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
200 ICO_TRA("CicoSCWindowController::show Enter"
201 "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
202 surfaceid, animation, type, animationTime);
204 // find window information in window list
205 CicoSCWindow *window = findWindow(surfaceid);
206 if (NULL == window) {
207 ICO_WRN("not found window information");
208 ICO_TRA("CicoSCWindowController::show Leave(ENOENT)");
209 return ICO_SYC_ENOENT;
212 // update visible attr
213 window->visible = true;
215 // update current displayed window at display zone
216 CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
218 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
219 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
220 ICO_DBG("Entry display zone[%d] current displayed window"
222 zone->zoneid, window->surfaceid, window->appid.c_str());
223 zone->displayedWindow = window;
227 // set animation request to Multi Window Manager
228 int raiseFlag = ICO_SYC_WIN_RAISE_NOCHANGE;
229 if (type & ICO_SYC_WIN_SURF_RAISE) {
230 raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
232 else if (type & ICO_SYC_WIN_SURF_LOWER) {
233 raiseFlag = ICO_SYC_WIN_RAISE_LOWER;
235 else if (((type & ICO_SYC_WIN_SURF_NOCHANGE) == 0) &&
236 (false == window->raise)) {
237 raiseFlag = ICO_SYC_WIN_RAISE_RAISE;
239 if ((NULL != animation) && (animation[0] != '\0')) {
240 // set animation request to Multi Window Manager
241 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
242 (type & ICO_SYC_WIN_SURF_ONESHOT) ?
243 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW |
244 ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
245 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
246 animation, animationTime);
249 // set raise/lower request (if need)
250 if (raiseFlag != ICO_SYC_WIN_RAISE_NOCHANGE) {
251 raiselower(window, (raiseFlag == ICO_SYC_WIN_RAISE_RAISE));
254 // set visible request to Multi Window Manager
255 CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_WIN_VISIBLE_SHOW);
258 CicoSCWayland::getInstance()->flushDisplay();
260 ICO_TRA("CicoSCWindowController::show Leave(EOK)");
264 //--------------------------------------------------------------------------
266 * @brief raise/lower a target window
268 * @param [in] window target window
269 * @param [in] raise raise(true)/lower(false)
273 //--------------------------------------------------------------------------
275 CicoSCWindowController::raiselower(CicoSCWindow *window, bool raise)
277 ICO_TRA("CicoSCWindowController::raiselower(%08x,%d)", window->surfaceid, raise);
279 window->raise = raise;
281 CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
283 ICO_ERR("CicoSCWindowController::raiselower: surface.%08x has no layer(%d)",
284 window->surfaceid, window->layerid);
287 if ((raise) && (layer->is_topSurface(window->surfaceid))) {
288 ICO_DBG("CicoSCWindowController::raiselower %08x raise but top",
291 else if ((! raise) && (layer->is_buttomSurface(window->surfaceid))) {
292 ICO_DBG("CicoSCWindowController::raiselower %08x lower but buttom",
296 layer->addSurface(window->surfaceid, raise);
299 const int *surfs = layer->getSurfaces(&nsurf);
300 ICO_TRA("CicoSCWindowControllerCicoSCWindowController layer.%d %d.%x %x %x %x",
301 window->layerid, nsurf, surfs[0], surfs[1], surfs[2], surfs[3]);
303 ICO_TRA("CicoSCWindowControllerCicoSCWindowController .%x %x %x %x",
304 surfs[4], surfs[5], surfs[6], surfs[7]);
306 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
308 ICO_ERR("CicoSCWindowController::raiselower "
309 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
314 //--------------------------------------------------------------------------
316 * @brief hide a target window
318 * @param [in] surfaceid wayland surface id
319 * @param [in] animation animation name
320 * @param [in] animationTime animation time
322 * @return ICO_SYC_EOK on success, other on error
323 * @retval ICO_SYC_EOK success
324 * @retval ICO_SYC_ESRCH error(not initialized)
325 * @retval ICO_SYC_ENOENT error(not exist)
327 //--------------------------------------------------------------------------
329 CicoSCWindowController::hide(int surfaceid,
330 const char *animation,
333 int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
334 animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
336 ICO_TRA("CicoSCWindowController::hide Enter"
337 "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
338 surfaceid, animation, type, animationTime);
340 // find window information in window list
341 CicoSCWindow *window = findWindow(surfaceid);
342 if (NULL == window) {
343 ICO_WRN("not found window information");
344 ICO_TRA("CicoSCWindowController::hide Leave(ENOENT)");
345 return ICO_SYC_ENOENT;
348 if (false == window->visible) {
349 ICO_DBG("already hide state");
350 ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
354 // update window attr
355 window->visible = false;
357 // update current displayed window at display zone
358 CicoSCDisplayZone* zone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
360 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
361 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
362 (getDisplayedWindow(zone->zoneid) == surfaceid)) {
363 ICO_DBG("Exit display zone[%d] current displayed window"
365 zone->zoneid, window->surfaceid, window->appid.c_str());
366 zone->displayedWindow = NULL;
370 // set animation request to Multi Window Manager
371 if ((NULL != animation) && (animation[0] != '\0')) {
372 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
373 (type & ICO_SYC_WIN_SURF_ONESHOT) ?
374 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE |
375 ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
376 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE,
377 animation, animationTime);
380 // set visible request to Multi Window Manager
381 CicoSCWlWinMgrIF::setVisible(window->surfaceid, ICO_SYC_LAYER_VISIBLE_HIDE);
384 CicoSCWayland::getInstance()->flushDisplay();
386 ICO_TRA("CicoSCWindowController::hide Leave(EOK)");
390 //--------------------------------------------------------------------------
392 * @brief resize window(surface) size
394 * @param [in] surfaceid wayland surface id
395 * @param [in] w window width
396 * @param [in] h window height
397 * @param [in] animation animation name
398 * @param [in] animationTime animation time
400 * @return ICO_SYC_EOK on success, other on error
401 * @retval ICO_SYC_EOK success
402 * @retval ICO_SYC_ESRCH error(not initialized)
403 * @retval ICO_SYC_ENOENT error(window dose not exist)
405 //--------------------------------------------------------------------------
407 CicoSCWindowController::resize(int surfaceid,
410 const char *animation,
413 int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
414 animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
416 ICO_TRA("CicoSCWindowController::resize Enter"
417 "(surfaceid=%08x h=%d w=%d animation=%s type=%x animationTime=%d)",
418 surfaceid, w, h, animation, type, animationTime);
420 // find window information in window list
421 CicoSCWindow *window = findWindow(surfaceid);
422 if (NULL == window) {
423 ICO_WRN("not found window information");
424 ICO_TRA("CicoSCWindowController::resize Leave(ENOENT)");
425 return ICO_SYC_ENOENT;
428 // set animation request to Multi Window Manager
429 if ((NULL != animation) && (animation[0] != '\0')) {
430 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
431 (type & ICO_SYC_WIN_SURF_ONESHOT) ?
432 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE |
433 ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
434 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
435 animation, animationTime);
438 // set visible request to Multi Window Manager
441 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, window->nodeid,
442 window->x, window->y, w, h);
445 CicoSCWayland::getInstance()->flushDisplay();
447 ICO_TRA("CicoSCWindowController::resize Leave(EOK)");
451 //--------------------------------------------------------------------------
453 * @brief move window(surface) position
455 * @param [in] surfaceid wayland surface id
456 * @param [in] nodeid node id
457 * @param [in] x window width
458 * @param [in] y window height
459 * @param [in] animation animation name
460 * @param [in] animationTime animation time
462 * @return ICO_SYC_EOK on success, other on error
463 * @retval ICO_SYC_EOK success
464 * @retval ICO_SYC_ESRCH error(not initialized)
465 * @retval ICO_SYC_ENOENT error(window dose not exist)
467 //--------------------------------------------------------------------------
469 CicoSCWindowController::move(int surfaceid,
473 const char *animation,
476 int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
477 animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
479 ICO_TRA("CicoSCWindowController::move Enter"
480 "(surfaceid=%08x nodeid=%d x=%d y=%d "
481 "animation=%s type=%x animationTime=%d)",
482 surfaceid, nodeid, x, y, animation, type, animationTime);
484 // find window information in window list
485 CicoSCWindow *window = findWindow(surfaceid);
486 if (NULL == window) {
487 ICO_WRN("CicoSCWindowController::move not found window(%08x)", surfaceid);
488 ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
489 return ICO_SYC_ENOENT;
492 if (nodeid >= (int)m_physicalDisplayTotal) {
493 ICO_WRN("CicoSCWindowController::move not found node(%d)", nodeid);
494 ICO_TRA("CicoSCWindowController::move Leave(ENOENT)");
495 return ICO_SYC_ENOENT;
498 // set animation request to Multi Window Manager
499 if ((NULL != animation) && (animation[0] != '\0')) {
500 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
501 (type & ICO_SYC_WIN_SURF_ONESHOT) ?
502 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE |
503 ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
504 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
505 animation, animationTime);
508 int moveNodeId = ICO_SYC_WIN_NOCHANGE;
513 // set visible request to Multi Window Manager
516 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid,
518 window->width, window->height);
521 CicoSCWayland::getInstance()->flushDisplay();
523 ICO_TRA("CicoSCWindowController::move Leave(EOK)");
527 //--------------------------------------------------------------------------
529 * @brief raise window(surface)
531 * @param [in] surfaceid wayland surface id
532 * @param [in] animation animation name
533 * @param [in] animationTime animation time
535 * @return ICO_SYC_EOK on success, other on error
536 * @retval ICO_SYC_EOK success
537 * @retval ICO_SYC_ESRCH error(not initialized)
538 * @retval ICO_SYC_ENOENT error(layer dose not exist)
540 //--------------------------------------------------------------------------
542 CicoSCWindowController::raise(int surfaceid,
543 const char *animation,
546 int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
547 animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
549 ICO_TRA("CicoSCWindowController::raise Enter"
550 "(surfaceid=%08x animation=%s type=%x animationTime=%d)",
551 surfaceid, animation, type, animationTime);
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::raise Leave(ENOENT)");
558 return ICO_SYC_ENOENT;
561 // set animation request to Multi Window Manager
562 if ((NULL != animation) && (animation[0] != '\0')) {
563 CicoSCWindowController::setAnimation(window->surfaceid,
564 (type & ICO_SYC_WIN_SURF_ONESHOT) ?
565 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW |
566 ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
567 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
568 animation, animationTime);
570 // set raise request to Multi Window Manager
571 raiselower(window, true);
572 if (ilm_commitChanges() != ILM_SUCCESS) {
573 ICO_ERR("CicoSCWindowController::raise ilm_commitChanges() Error");
577 CicoSCWayland::getInstance()->flushDisplay();
579 ICO_TRA("CicoSCWindowController::raise Leave(EOK)");
583 //--------------------------------------------------------------------------
585 * @brief set window(surface) geometry
587 * @param [in] surfaceid wayland surface id
588 * @param [in] nodeid node id
589 * @param [in] layerid layer id
590 * @param [in] x window x position
591 * @param [in] y window y position
592 * @param [in] w window width
593 * @param [in] h window height
594 * @param [in] resizeAnimation resize animation name
595 * @param [in] resizeAnimationTime resize animation time
596 * @param [in] moveAnimation move animation name
597 * @param [in] moveanimationTime move animation time
599 * @return ICO_SYC_EOK on success, other on error
600 * @retval ICO_SYC_EOK success
601 * @retval ICO_SYC_ESRCH error(not initialized)
602 * @retval ICO_SYC_ENOENT error(window dose not exist)
604 //--------------------------------------------------------------------------
606 CicoSCWindowController::setGeometry(int surfaceid,
613 const char *resizeAnimation,
614 int resizeAnimationTime,
615 const char *moveAnimation,
616 int moveAnimationTime)
618 ICO_TRA("CicoSCWindowController::setGeometry Enter"
619 "(surfaceid=%08x nodeid=%d layerid=%d x=%d y=%d w=%d h=%d "
620 "resizeAnimation=%s resizeAnimationTime=%d "
621 "moveAnimation=%s moveAnimationTime=%d)",
622 surfaceid, nodeid, layerid, x, y, w, h,
623 resizeAnimation, resizeAnimationTime,
624 moveAnimation, moveAnimationTime);
626 // find window information in window list
627 CicoSCWindow *window = findWindow(surfaceid);
628 if (NULL == window) {
629 ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
630 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
631 return ICO_SYC_ENOENT;
634 if (nodeid >= (int)m_physicalDisplayTotal) {
635 ICO_WRN("CicoSCWindowController::setGeometry not found node(%d)", nodeid);
636 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
637 return ICO_SYC_ENOENT;
640 // set animation request to Multi Window Manager
641 const char *animation = "";
642 if (NULL != resizeAnimation) {
643 animation = resizeAnimation;
645 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
646 ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE,
647 animation, resizeAnimationTime);
649 if (NULL != moveAnimation) {
650 animation = moveAnimation;
652 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
653 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
654 animation, moveAnimationTime);
656 int moveNodeId = ICO_SYC_WIN_NOCHANGE;
661 moveNodeId = window->nodeid;
664 if (m_physicalDisplayTotal <= (unsigned int)moveNodeId) {
665 ICO_WRN("nodeid(%d) is over physical display total(%d)",
666 m_physicalDisplayTotal, nodeid);
667 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
668 return ICO_SYC_EINVAL;
671 int moveX = window->x;
677 int moveY = window->y;
683 int moveW = window->width;
689 int moveH = window->height;
695 // set window layer to Multi Window Manager
697 setWindowLayer(window->surfaceid, layerid);
700 // update window attr
701 window->nodeid = moveNodeId;
703 // set visible request to Multi Window Manager
704 CicoSCWlWinMgrIF::setPositionsize(window->surfaceid, moveNodeId,
705 moveX, moveY, moveW, moveH);
708 CicoSCWayland::getInstance()->flushDisplay();
710 ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
714 //--------------------------------------------------------------------------
716 * @brief set window(surface) geometry
718 * @param [in] surfaceid wayland surface id
719 * @param [in] layerid layer id
720 * @param [in] nodeid node id
721 * @param [in] zone display zone name
722 * @param [in] resizeAnimation resize animation name
723 * @param [in] resizeAnimationTime resize animation time
724 * @param [in] moveAnimation move animation name
725 * @param [in] moveanimationTime move animation time
727 * @return ICO_SYC_EOK on success, other on error
728 * @retval ICO_SYC_EOK success
729 * @retval ICO_SYC_ESRCH error(not initialized)
730 * @retval ICO_SYC_ENOENT error(window dose not exist)
731 * @retval ICO_SYC_EINVAL error(zone is null, zone name is invalid)
733 //--------------------------------------------------------------------------
735 CicoSCWindowController::setGeometry(int surfaceid,
738 const char *resizeAnimation,
739 int resizeAnimationTime,
740 const char *moveAnimation,
741 int moveAnimationTime)
743 ICO_TRA("CicoSCWindowController::setGeometry Enter"
744 "(surfaceid=%08x zone=%s layerid=%d "
745 "resizeAnimation=%s resizeAnimationTime=%d "
746 "moveAnimation=%s moveAnimationTime=%d)",
747 surfaceid, zone, layerid,
748 resizeAnimation, resizeAnimationTime,
749 moveAnimation, moveAnimationTime);
751 // find window information in window list
752 CicoSCWindow *window = findWindow(surfaceid);
753 if (NULL == window) {
754 ICO_WRN("CicoSCWindowController::setGeometry not found window(%08x)", surfaceid);
755 ICO_TRA("CicoSCWindowController::setGeometry Leave(ENOENT)");
756 return ICO_SYC_ENOENT;
759 // find zone information
760 if ((NULL == zone) || ('\0' == zone[0])) {
761 ICO_WRN("zone value is invalid");
762 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
763 return ICO_SYC_EINVAL;
766 vector<CicoSCDisplay*>::iterator itr;
767 itr = m_displayList.begin();
768 CicoSCDisplayZone* dispzone = NULL;
770 for (; itr != m_displayList.end(); ++itr) {
771 dispzone = (*itr)->findDisplayZonebyFullName(zone);
772 if (NULL != dispzone) {
773 displayno = (*itr)->displayno;
777 if (NULL == dispzone) {
778 ICO_WRN("display zone name(%s) is invalid.", zone);
779 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
780 return ICO_SYC_EINVAL;
782 if (m_physicalDisplayTotal <= (unsigned int)displayno) {
783 ICO_WRN("nodeid(%d) is over physical display total(%d)",
784 m_physicalDisplayTotal, displayno);
785 ICO_TRA("CicoSCWindowController::setGeometry Leave(EINVAL)");
786 return ICO_SYC_EINVAL;
789 if (window->zoneid != dispzone->zoneid) {
790 // update current displayed window at display zone
791 CicoSCDisplayZone* olddispzone = (CicoSCDisplayZone*)findDisplayZone(window->zoneid);
792 if (NULL != olddispzone) {
793 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
794 if ((NULL != layer) &&
795 (layer->type == ICO_LAYER_TYPE_APPLICATION) &&
796 (getDisplayedWindow(olddispzone->zoneid) == surfaceid)) {
797 ICO_DBG("Exit display zone[%d] current displayed window"
799 olddispzone->zoneid, window->surfaceid,
800 window->appid.c_str());
801 olddispzone->displayedWindow = NULL;
805 CicoSCLayer *layer = findLayer(displayno, window->layerid);
806 if ((NULL != layer) && (layer->type == ICO_LAYER_TYPE_APPLICATION)) {
807 ICO_DBG("Entry display zone[%d] current displayed window"
809 dispzone->zoneid, window->surfaceid, window->appid.c_str());
810 dispzone->displayedWindow = window;
814 // update window attr
815 window->zoneid = dispzone->zoneid;
816 window->zone = dispzone->fullname;
817 setAttributes(window->surfaceid);
819 int ret = setGeometry(surfaceid, displayno, layerid,
820 dispzone->x, dispzone->y,
821 dispzone->width, dispzone->height,
822 resizeAnimation, resizeAnimationTime,
823 moveAnimation, moveAnimationTime);
825 ICO_TRA("CicoSCWindowController::setGeometry Leave(EOK)");
829 //--------------------------------------------------------------------------
831 * @brief lower window(surface)
833 * @param [in] surfaceid wayland surface id
834 * @param [in] animation animation name
835 * @param [in] animationTime animation time
837 * @return ICO_SYC_EOK on success, other on error
838 * @retval ICO_SYC_EOK success
839 * @retval ICO_SYC_ESRCH error(not initialized)
840 * @retval ICO_SYC_ENOENT error(layer dose not exist)
842 //--------------------------------------------------------------------------
844 CicoSCWindowController::lower(int surfaceid,
845 const char *animation,
848 int type = animationTime & ICO_SYC_WIN_SURF_FLAGS;
849 animationTime &= ~ICO_SYC_WIN_SURF_FLAGS;
851 ICO_TRA("CicoSCWindowController::lower Enter"
852 "(surfaceid=08x animation=%s type=%x animationTime=%d)",
853 surfaceid, animation, type, animationTime);
855 // find window information in window list
856 CicoSCWindow *window = findWindow(surfaceid);
857 if (NULL == window) {
858 ICO_WRN("not found window information");
859 ICO_TRA("CicoSCWindowController::lower Leave(ENOENT)");
860 return ICO_SYC_ENOENT;
863 // set animation request to Multi Window Manager
864 if ((NULL != animation) && (animation[0] != '\0')) {
865 CicoSCWlWinMgrIF::setAnimation(window->surfaceid,
866 (type & ICO_SYC_WIN_SURF_ONESHOT) ?
867 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW |
868 ICO_WINDOW_MGR_ANIMATION_TYPE_ONESHOT :
869 ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW,
870 animation, animationTime);
873 // set lower request to Multi Window Manager
874 raiselower(window, false);
875 if (ilm_commitChanges() != ILM_SUCCESS) {
876 ICO_ERR("CicoSCWindowController::lower ilm_commitChanges() Error");
880 CicoSCWayland::getInstance()->flushDisplay();
882 ICO_TRA("CicoSCWindowController::lower Leave(EOK)");
886 //--------------------------------------------------------------------------
888 * @brief set window(surface) animation
890 * @param [in] surfaceid wayland surface id
891 * @param [in] target target(pointer and/or keyboard)
892 * @param [in] type set animation target
893 * @param [in] animation animation information
894 * @param [in] time animation time
896 * @return ICO_SYC_EOK on success, other on error
897 * @retval ICO_SYC_EOK success
898 * @retval ICO_SYC_ESRCH error(not initialized)
899 * @retval ICO_SYC_ENOENT error(layer dose not exist)
901 //--------------------------------------------------------------------------
903 CicoSCWindowController::setWindowAnimation(int surfaceid, int type,
904 const char *animation, int time)
906 CicoSCWindow *window = NULL;
908 ICO_TRA("CicoSCWindowController::setWindowAnimation Enter"
909 "(surfaceid=%08x, type=%x, animation=<%s>, time=%d)",
910 surfaceid, type, animation ? animation : "(null)", time);
912 // find window information in window list
913 window = findWindow(surfaceid);
914 if (NULL == window) {
915 ICO_WRN("not found window information");
916 ICO_TRA("CicoSCWindowController::setWindowAnimation Leave(ENOENT)");
917 return ICO_SYC_ENOENT;
920 // set animation request to Multi Window Manager
921 CicoSCWlWinMgrIF::setAnimation(surfaceid, type, animation, time);
924 CicoSCWayland::getInstance()->flushDisplay();
926 ICO_TRA("CicoSCWindowController::setWindowAnimation Leave(EOK)");
930 //--------------------------------------------------------------------------
932 * @brief set window layer
934 * @param [in] surfaceid wayland surface id
935 * @param [in] layer layer id
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(window or layer dose not exist)
942 //--------------------------------------------------------------------------
944 CicoSCWindowController::setWindowLayer(int surfaceid, int layerid)
946 ICO_TRA("CicoSCWindowController::setWindowLayer Enter"
947 "(surfaceid=%08x layerid=%x)", surfaceid, layerid);
949 // find window information in window list
950 CicoSCWindow* window = findWindow(surfaceid);
951 if (NULL == window) {
952 ICO_WRN("not found window information");
953 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT)");
954 return ICO_SYC_ENOENT;
956 if (window->layerid == layerid) {
957 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(same layer %d)", layerid);
961 // find new layer information in layer list
962 CicoSCLayer* layer = findLayer(window->displayid, layerid);
964 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(ENOENT[disp=%d,layer=%d])",
965 window->displayid, layerid);
966 return ICO_SYC_ENOENT;
969 // find old layer information and remove surface if need
970 CicoSCLayer* oldlayer = findLayer(window->displayid, window->layerid);
972 if (ilm_layerRemoveSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
973 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerRemoveSurface(%d,%08x)"
974 " Error", window->layerid, window->surfaceid);
976 // must need ilm_commitChanges() after ilm_layerRemoveSurface()
977 if (ilm_commitChanges() != ILM_SUCCESS) {
978 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
981 oldlayer->removeSurface(window->surfaceid);
983 const int *oldsurfs = oldlayer->getSurfaces(&noldsurf);
984 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)oldsurfs, noldsurf)
986 ICO_ERR("CicoSCWindowController::setWindowLayer "
987 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, noldsurf);
989 if (ilm_commitChanges() != ILM_SUCCESS) {
990 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges Error");
994 // update window attr
995 window->layerid = layerid;
997 // set window layer request
998 if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
999 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_layerAddSurface(%d,%08x) Error",
1000 window->layerid, window->surfaceid);
1002 if (ilm_commitChanges() != ILM_SUCCESS) {
1003 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
1006 // add surface to new layer
1007 layer->addSurface(window->surfaceid, true);
1009 const int *surfs = layer->getSurfaces(&nsurf);
1010 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
1012 ICO_ERR("CicoSCWindowController::setWindowLayer "
1013 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
1015 if (ilm_commitChanges() != ILM_SUCCESS) {
1016 ICO_ERR("CicoSCWindowController::setWindowLayer ilm_commitChanges() Error");
1020 CicoSCWayland::getInstance()->flushDisplay();
1022 ICO_TRA("CicoSCWindowController::setWindowLayer Leave(EOK)");
1026 //--------------------------------------------------------------------------
1030 * @param [in] displayid display id
1031 * @param [in] layerid layer id
1033 * @return ICO_SYC_EOK on success, other on error
1034 * @retval ICO_SYC_EOK success
1035 * @retval ICO_SYC_ESRCH error(not initialized)
1036 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1038 //--------------------------------------------------------------------------
1040 CicoSCWindowController::showLayer(int displayid, int layerid)
1042 ICO_TRA("CicoSCWindowController::showLayer Enter"
1043 "(displayid=%d layerid=%d)", displayid, layerid);
1045 // find layer information in layer list
1046 CicoSCLayer* layer = findLayer(displayid, layerid);
1047 if (NULL == layer) {
1048 ICO_WRN("not found layer information");
1049 ICO_TRA("CicoSCWindowController::showLayer Leave(ENOENT)");
1050 return ICO_SYC_ENOENT;
1053 CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_SHOW);
1056 CicoSCWayland::getInstance()->flushDisplay();
1058 ICO_TRA("CicoSCWindowController::showLayer Leave(EOK)");
1062 //--------------------------------------------------------------------------
1066 * @param [in] displayid display id
1067 * @param [in] layerid layer id
1069 * @return ICO_SYC_EOK on success, other on error
1070 * @retval ICO_SYC_EOK success
1071 * @retval ICO_SYC_ESRCH error(not initialized)
1072 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1074 //--------------------------------------------------------------------------
1076 CicoSCWindowController::hideLayer(int displayid, int layerid)
1078 ICO_TRA("CicoSCWindowController::hideLayer Enter"
1079 "displayid=%d layerid=%d)",
1080 displayid, layerid);
1082 // find layer information in layer list
1083 CicoSCLayer* layer = findLayer(displayid, layerid);
1084 if (NULL == layer) {
1085 ICO_WRN("not found layer information");
1086 ICO_TRA("CicoSCWindowController::hideLayer Leave(ENOENT)");
1087 return ICO_SYC_ENOENT;
1090 CicoSCWlWinMgrIF::setLayerVisible(layerid, ICO_SYC_LAYER_VISIBLE_HIDE);
1093 CicoSCWayland::getInstance()->flushDisplay();
1095 ICO_TRA("CicoSCWindowController::hideVisible Leave(EOK)");
1099 //--------------------------------------------------------------------------
1101 * @brief active window(surface)
1103 * @param [in] surfaceid wayland surface id
1104 * @param [in] target target(pointer and/or keyboard)
1106 * @return ICO_SYC_EOK on success, other on error
1107 * @retval ICO_SYC_EOK success
1108 * @retval ICO_SYC_ESRCH error(not initialized)
1109 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1111 //--------------------------------------------------------------------------
1113 CicoSCWindowController::active(int surfaceid, int target)
1115 CicoSCWindow *window = NULL;
1117 ICO_TRA("CicoSCWindowController::active Enter"
1118 "(surfaceid=%08x, target=%08x)", surfaceid, target);
1120 // find window information in window list
1122 window = findWindow(surfaceid);
1123 if (NULL == window) {
1124 ICO_WRN("not found window information");
1125 ICO_TRA("CicoSCWindowController::active Leave(ENOENT)");
1126 return ICO_SYC_ENOENT;
1134 // set active request to Multi Window Manager
1135 CicoSCWlWinMgrIF::setActive(surfaceid, target);
1138 CicoSCWayland::getInstance()->flushDisplay();
1140 // update visible attr
1142 window->raise = true;
1145 // update active window
1146 map<unsigned int, CicoSCWindow*>::iterator itr;
1147 itr = m_windowList.begin();
1148 for (; itr != m_windowList.end(); ++itr) {
1149 CicoSCWindow* window = itr->second;
1150 if ((surfaceid != 0) && (window->surfaceid == surfaceid)) {
1151 window->active = target;
1158 window->active &= ~target;
1163 ICO_TRA("CicoSCWindowController::active Leave(EOK)");
1167 //--------------------------------------------------------------------------
1169 * @brief set surface map get
1171 * @param [in] surfaceid wayland surface id
1172 * @param [in] filepath surface image pixel file path
1174 * @return ICO_SYC_EOK on success, other on error(currently EOK only)
1175 * @retval ICO_SYC_EOK success
1177 //--------------------------------------------------------------------------
1179 CicoSCWindowController::setmapGet(int surfaceid, const char *filepath)
1181 ICO_TRA("CicoSCWindowController::setmapGet Enter");
1183 CicoSCWlWinMgrIF::setmapGet(surfaceid, filepath);
1184 CicoSCWayland::getInstance()->flushDisplay();
1186 ICO_TRA("CicoSCWindowController::setmapGet Leave(EOK)");
1190 //--------------------------------------------------------------------------
1192 * @brief map surface
1194 * @param [in] surfaceid wayland surface id
1195 * @param [in] framerate surface change frame rate(frames par sec)
1196 * @param [in] filepath surface image pixel file path
1198 * @return ICO_SYC_EOK on success, other on error
1199 * @retval ICO_SYC_EOK success
1200 * @retval ICO_SYC_ESRCH error(not initialized)
1201 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1203 //--------------------------------------------------------------------------
1205 CicoSCWindowController::mapSurface(int surfaceid, int framerate, const char *filepath)
1207 ICO_TRA("CicoSCWindowController::mapSurface Enter(%08x,%d,%s)",
1208 surfaceid, framerate, filepath ? filepath : "(null)");
1210 // find window information in window list
1211 CicoSCWindow *window = findWindow(surfaceid);
1212 if (NULL == window) {
1213 ICO_WRN("not found window information");
1214 ICO_TRA("CicoSCWindowController::mapSurface Leave(ENOENT)");
1215 return ICO_SYC_ENOENT;
1218 CicoSCWlWinMgrIF::mapSurface(surfaceid, framerate, filepath);
1219 CicoSCWayland::getInstance()->flushDisplay();
1221 ICO_TRA("CicoSCWindowController::mapSurface Leave(EOK)");
1225 //--------------------------------------------------------------------------
1227 * @brief unmap surface
1229 * @param [in] surfaceid wayland surface id
1231 * @return ICO_SYC_EOK on success, other on error
1232 * @retval ICO_SYC_EOK success
1233 * @retval ICO_SYC_ESRCH error(not initialized)
1234 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1236 //--------------------------------------------------------------------------
1238 CicoSCWindowController::unmapSurface(int surfaceid)
1240 ICO_TRA("CicoSCWindowController::unmapSurface Enter(%08x)", surfaceid);
1242 // find window information in window list
1243 CicoSCWindow *window = findWindow(surfaceid);
1244 if (NULL == window) {
1245 ICO_WRN("not found window information");
1246 ICO_TRA("CicoSCWindowController::unmapSurface Leave(ENOENT)");
1247 return ICO_SYC_ENOENT;
1250 CicoSCWlWinMgrIF::unmapSurface(surfaceid);
1251 CicoSCWayland::getInstance()->flushDisplay();
1253 ICO_TRA("CicoSCWindowController::unmapSurface Leave(EOK)");
1257 //--------------------------------------------------------------------------
1259 * @brief get displayed window by display zone id
1261 * @param [in] zoneid display zone id
1263 * @return surface id on success, -1 on not displayed
1265 //--------------------------------------------------------------------------
1267 CicoSCWindowController::getDisplayedWindow(int zoneid)
1269 const CicoSCDisplayZone* zone = findDisplayZone(zoneid);
1274 if (NULL == zone->displayedWindow) {
1278 return zone->displayedWindow->surfaceid;
1281 //--------------------------------------------------------------------------
1283 * @brief set surface attributes
1285 * @param [in] surfaceid surface id
1287 * @retval ICO_SYC_EOK success
1288 * @retval ICO_SYC_ESRCH error(not initialized)
1289 * @retval ICO_SYC_ENOENT error(layer dose not exist)
1291 //--------------------------------------------------------------------------
1293 CicoSCWindowController::setAttributes(int surfaceid)
1295 ICO_TRA("CicoSCWindowController::setAttributes Enter"
1296 "(surfaceid=%08x)", surfaceid);
1298 // find window information in window list
1299 CicoSCWindow *window = findWindow(surfaceid);
1300 if (NULL == window) {
1301 ICO_WRN("not found window information");
1302 ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1303 return ICO_SYC_ENOENT;
1307 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1309 ICO_WRN("not found zone information");
1310 ICO_TRA("CicoSCWindowController::setAttributes Leave(ENOENT)");
1311 return ICO_SYC_ENOENT;
1314 uint32_t attributes = 0;
1315 if (true == zone->aspectFixed) {
1316 attributes |= ICO_SYC_WIN_ASPECT_FIXED;
1317 if (true == zone->aspectAlignLeft) {
1318 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_LEFT;
1320 if (true == zone->aspectAlignRight) {
1321 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_RIGHT;
1323 if (true == zone->aspectAlignTop) {
1324 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_TOP;
1326 if (true == zone->aspectAlignBottom) {
1327 attributes |= ICO_SYC_WIN_ASPECT_ALIGN_BOTTOM;
1330 ICO_TRA("CicoSCWindowController::setAttributes Leave(EOK)");
1334 //--------------------------------------------------------------------------
1336 * @brief wayland surface active callback
1338 * @param [in] data user data(unused)
1339 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1340 * @param [in] surfaceid ico_window_mgr surface Id
1341 * @param [in] select select device(unused)
1342 * (0=not active/1=pointer/2=touch)
1344 //--------------------------------------------------------------------------
1346 CicoSCWindowController::activeCB(void *data,
1347 struct ico_window_mgr *ico_window_mgr,
1351 ICO_TRA("CicoSCWindowController::activeCB Enter"
1352 "(surfaceid=%08x select=%d)", surfaceid, select);
1354 CicoSCWindow *window = findWindow(surfaceid);
1355 if (NULL == window) {
1356 ICO_WRN("not found window information");
1357 ICO_TRA("CicoSCWindowController::activeCB Leave(not found window)");
1362 ICO_TRA("CicoSCWindowController::activeCB Leave(not active)");
1366 if (0 != window->active) {
1367 ICO_TRA("CicoSCWindowController::activeCB Leave(already active)");
1372 CicoSCMessage *message = new CicoSCMessage();
1373 message->addRootObject("command", MSG_CMD_CHANGE_ACTIVE);
1374 message->addRootObject("appid", window->appid);
1375 message->addRootObject("pid", window->pid);
1376 message->addArgObject("surface", window->surfaceid);
1377 message->addArgObject("winname", window->name);
1378 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1380 ICO_TRA("CicoSCWindowController::activeCB Leave");
1383 //--------------------------------------------------------------------------
1385 * @brief surface map event callback
1387 * @param [in] data user data(unused)
1388 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1389 * @param [in] event event
1390 * @param [in] surfaceid surface Id
1391 * @param [in] type surface type (EGL buffer/Shared memory)
1392 * @param [in] width surface width
1393 * @param [in] height surface height
1394 * @param [in] stride surface buffer(frame buffer) stride
1395 * @param [in] format surface buffer format
1397 //--------------------------------------------------------------------------
1399 CicoSCWindowController::mapSurfaceCB(void *data,
1400 struct ico_window_mgr *ico_window_mgr,
1411 ICO_TRA("CicoSCWindowController::mapSurfaceCB Enter(ev=%d surf=%x "
1412 "type=%d w/h=%d/%d stride=%d form=%x)",
1413 event, surfaceid, type, width, height, stride, format);
1415 CicoSCWindow *window = findWindow(surfaceid);
1416 if (NULL == window) {
1420 // convert event to command
1422 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS:
1423 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE:
1424 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP:
1425 command = MSG_CMD_MAP_THUMB;
1427 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP:
1428 case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR:
1429 command = MSG_CMD_UNMAP_THUMB;
1432 ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave(Unknown event(%d))", event);
1437 CicoSCMessage *message = new CicoSCMessage();
1438 message->addRootObject("command", command);
1439 message->addRootObject("appid", window->appid);
1440 message->addArgObject("surface", window->surfaceid);
1441 message->addArgObject("attr", type);
1442 message->addArgObject("width", width);
1443 message->addArgObject("height", height);
1444 message->addArgObject("stride", stride);
1445 message->addArgObject("format", format);
1446 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1448 ICO_TRA("CicoSCWindowController::mapSurfaceCB Leave");
1451 //--------------------------------------------------------------------------
1453 * @brief surface update event callback
1455 * @param [in] data user data(unused)
1456 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1457 * @param [in] surfaceid surface Id
1458 * @param [in] visible visibility
1459 * @param [in] srcwidth application buffer width
1460 * @param [in] srcheight application buffer height
1463 * @param [in] width width
1464 * @param [in] height height
1466 //--------------------------------------------------------------------------
1468 CicoSCWindowController::updateSurfaceCB(void *data,
1469 struct ico_window_mgr *ico_window_mgr,
1479 ICO_TRA("CicoSCWindowController::updateSurfaceCB: Enter(%08x %d,%d,%d,%d,%d,%d,%d)",
1480 surfaceid, visible, srcwidth, srcheight, x, y, width, height);
1482 CicoSCWindow *window = findWindow(surfaceid);
1483 if (NULL == window) {
1484 ICO_WRN("CicoSCWindowController::updateSurfaceCB: not found window(%08x)",
1486 ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
1491 window->visible = visible;
1492 window->srcwidth = srcwidth;
1493 window->srcheight = srcheight;
1496 window->width = width;
1497 window->height = height;
1498 window->nodeid = window->layerid / ICO_SC_LAYERID_SCREENBASE;
1500 // notify to homescreen
1501 CicoSCMessage *message = new CicoSCMessage();
1502 message->addRootObject("command", MSG_CMD_CHANGE_ATTR);
1503 message->addRootObject("appid", window->appid);
1504 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1506 message->addArgObject("zone", zone->fullname);
1509 message->addArgObject("zone", "");
1511 message->addArgObject("surface", window->surfaceid);
1512 message->addArgObject("winname", window->name);
1513 message->addArgObject("node", window->nodeid);
1514 message->addArgObject("layer", window->layerid);
1515 message->addArgObject("pos_x", window->x);
1516 message->addArgObject("pos_y", window->y);
1517 message->addArgObject("width", window->width);
1518 message->addArgObject("height", window->height);
1519 message->addArgObject("raise", window->raise ? 1 : 0);
1520 message->addArgObject("visible", window->visible ? 1 : 0);
1521 message->addArgObject("active", window->active ? 1 : 0);
1522 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1524 ICO_TRA("CicoSCWindowController::updateSurfaceCB: Leave");
1527 //--------------------------------------------------------------------------
1529 * @brief wayland surface destroy callback
1531 * @param [in] data user data(unused)
1532 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
1533 * @param [in] surfaceid ico_window_mgr surface Id
1535 //--------------------------------------------------------------------------
1537 CicoSCWindowController::destroySurfaceCB(void *data,
1538 struct ico_window_mgr *ico_window_mgr,
1541 ICO_TRA("CicoSCWindowController::destroySurfaceCB: Enter(%08x)", surfaceid);
1543 CicoSCWindow *window = findWindow(surfaceid);
1544 if (NULL == window) {
1545 ICO_WRN("not found window(%08x)", surfaceid);
1546 ICO_TRA("CicoSCWindowController::destroySurfaceCB Leave");
1550 // delete surface from layer
1551 CicoSCLayer* layer = findLayer(window->displayid, window->layerid);
1552 if (NULL == layer) {
1553 ICO_TRA("CicoSCWindowController::destroySurfaceCB: surf.%08x not exist in layer.%d",
1554 surfaceid, window->layerid);
1557 layer->removeSurface(surfaceid);
1561 CicoSCMessage *message = new CicoSCMessage();
1562 message->addRootObject("command", MSG_CMD_DESTROY);
1563 message->addRootObject("appid", window->appid);
1564 message->addRootObject("pid", window->pid);
1565 message->addArgObject("surface", window->surfaceid);
1566 message->addArgObject("winname", window->name);
1567 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1569 // TODO delete window in application
1570 if (NULL != m_resMgr) {
1572 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1574 cmd.cmdid = MSG_CMD_DESTORY_RES;
1575 cmd.appid = window->appid;
1576 cmd.pid = window->pid;
1579 opt->dispres = true;
1580 opt->winname = window->name;
1581 opt->surfaceid = window->surfaceid;
1584 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1586 opt->dispzone = zone->fullname;
1589 opt->soundres = true;
1590 opt->soundname = window->appid;
1592 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1593 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1594 if (NULL != defconf) {
1595 const CicoSCSoundZoneConf *zoneconf =
1596 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1597 if (NULL != zoneconf) {
1598 opt->soundzone = zoneconf->fullname;
1601 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1603 // delete window in list
1604 m_windowList.erase(window->surfaceid);
1607 ICO_TRA("CicoSCWindowController::destroySurfaceCB: Leave");
1610 //--------------------------------------------------------------------------
1612 * @brief wayland update surface name callback
1614 * @param [in] surfaceid surface Id
1615 * @param [in] winname surface name (title)
1617 //--------------------------------------------------------------------------
1619 CicoSCWindowController::updateWinnameCB(uint32_t surfaceid,
1620 const char *winname)
1622 ICO_TRA("CicoSCWindowController::updateWinnameCB: Enter(%08x,<%s>)",
1623 surfaceid, winname ? winname : "(null)");
1625 CicoSCWindow *window = findWindow(surfaceid);
1626 if (NULL == window) {
1627 ICO_WRN("CicoSCWindowController::updateWinnameCB: not found window(%08x)",
1629 ICO_TRA("CicoSCWindowController::updateWinnameCB Leave");
1633 window->name = winname;
1636 CicoSCMessage *message = new CicoSCMessage();
1637 message->addRootObject("command", MSG_CMD_NAME);
1638 message->addRootObject("appid", window->appid);
1639 message->addRootObject("pid", window->pid);
1640 message->addArgObject("surface", window->surfaceid);
1641 message->addArgObject("winname", window->name);
1642 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1644 ICO_TRA("CicoSCWindowController::updateWinnameCB: Leave");
1647 //--------------------------------------------------------------------------
1649 * @brief wayland display attribute callback
1651 * @param [in] data user data(unused)
1652 * @param [in] wl_output wayland wl_output interface
1653 * @param [in] x display upper-left X coordinate
1654 * @param [in] y display upper-left Y coordinate
1655 * @param [in] physical_width display physical width
1656 * @param [in] physical_height display physical height
1657 * @param [in] subpixel display sub pixel
1658 * @param [in] make display maker
1659 * @param [in] model display model
1660 * @param [in] transform transform
1662 //--------------------------------------------------------------------------
1664 CicoSCWindowController::outputGeometryCB(void *data,
1665 struct wl_output *wl_output,
1668 int32_t physical_width,
1669 int32_t physical_height,
1675 ICO_TRA("CicoSCWindowController::outputGeometryCB Enter"
1676 "(x=%d y=%d physical_width=%d physical_height=%d "
1677 "subpixel=%d make=%s model=%s transform=%d)",
1678 x, y, physical_width, physical_height,
1679 subpixel, make, model, transform);
1681 ++m_physicalDisplayTotal;
1682 if (0 == m_displayList.size()) {
1683 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1684 "(display is zero)");
1688 if (m_displayList.size() < m_physicalDisplayTotal) {
1689 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave"
1690 "(display total unmatch)");
1694 CicoSCDisplay* display = m_displayList.at(m_physicalDisplayTotal-1);
1695 switch (transform) {
1696 case WL_OUTPUT_TRANSFORM_90:
1697 case WL_OUTPUT_TRANSFORM_270:
1698 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
1699 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
1700 display->pWidth = physical_height;
1701 display->pHeight = physical_width;
1702 display->orientation = CicoSCDisplay::ORIENTATION_VERTICAL;
1704 case WL_OUTPUT_TRANSFORM_NORMAL:
1705 case WL_OUTPUT_TRANSFORM_180:
1706 case WL_OUTPUT_TRANSFORM_FLIPPED:
1707 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
1709 display->pWidth = physical_width;
1710 display->pHeight = physical_height;
1711 display->orientation = CicoSCDisplay::ORIENTATION_HORIZONTAL;
1716 ICO_TRA("CicoSCWindowController::outputGeometryCB Leave");
1719 //--------------------------------------------------------------------------
1721 * @brief wayland display mode callback
1723 * @param [in] data user data(unused)
1724 * @param [in] wl_output wayland wl_output interface
1725 * @param [in] flags flags
1726 * @param [in] width display width
1727 * @param [in] height display height
1728 * @param [in] refresh display refresh rate
1730 //--------------------------------------------------------------------------
1732 CicoSCWindowController::outputModeCB(void *data,
1733 struct wl_output *wl_output,
1739 ICO_TRA("CicoSCWindowController::outputModeCB Enter"
1740 "(flags=%d width=%d height=%d refresh=%d)",
1741 flags, width, height, refresh);
1743 if (0 == m_displayList.size()) {
1744 ICO_TRA("CicoSCWindowController::outputModeCB Leave(display is zero)");
1748 CicoSCDisplay* display = m_displayList.at(0);
1749 if (flags & WL_OUTPUT_MODE_CURRENT) {
1750 if (display->orientation == CicoSCDisplay::ORIENTATION_VERTICAL) {
1751 display->pWidth = height;
1752 display->pHeight = width;
1755 display->pWidth = width;
1756 display->pHeight = height;
1761 ICO_TRA("CicoSCWindowController::outputModeCB Leave");
1764 //--------------------------------------------------------------------------
1766 * @brief wayland genivi ivi-shell surface create callback
1768 * @param [in] data user data
1769 * @param [in] ivi_controller wayland ivi-controller plugin interface
1770 * @param [in] id_surface surface id
1772 //--------------------------------------------------------------------------
1774 CicoSCWindowController::createSurfaceCB(void *data,
1775 struct ivi_controller *ivi_controller,
1776 uint32_t id_surface)
1779 struct ilmSurfaceProperties SurfaceProperties;
1781 ICO_TRA("CicoSCWindowController::createSurfaceCB Enter"
1782 "(surfaceid=%08x)", id_surface);
1784 if (ilm_getPropertiesOfSurface(id_surface, &SurfaceProperties) != ILM_SUCCESS) {
1785 ICO_ERR("CicoSCWindowController::createSurfaceCB: ilm_getPropertiesOfSurface(%x) Error",
1789 ICO_TRA("createSurfaceCB: surface=%08x w/h=%d/%d->%d/%d",
1790 id_surface, SurfaceProperties.sourceWidth, SurfaceProperties.sourceHeight,
1791 SurfaceProperties.destWidth, SurfaceProperties.destHeight);
1793 CicoSCWindow* window = new CicoSCWindow();
1794 window->surfaceid = id_surface;
1795 window->name = CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(id_surface, &pid);
1797 window->displayid = 0; // currently fixed 0
1798 window->raise = 1; // created surface is top of layer
1799 window->srcwidth = SurfaceProperties.sourceWidth;
1800 window->srcheight = SurfaceProperties.sourceHeight;
1801 window->width = SurfaceProperties.destWidth;
1802 window->height = SurfaceProperties.destHeight;
1803 window->layerid = 0;
1805 CicoSCLifeCycleController* appctrl;
1806 appctrl = CicoSCLifeCycleController::getInstance();
1807 const CicoAilItems* ailItem = NULL;
1808 const CicoAulItems* aulitem = appctrl->findAUL(window->pid);
1809 if (NULL == aulitem) {
1810 /* client does not exist in AppCore, search parent process */
1811 ICO_DBG("application information not found. search parent process");
1818 char procpath[PATH_MAX];
1820 while ((cpid > 1) && (aulitem == NULL)) {
1821 snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", cpid);
1823 fd = open(procpath, O_RDONLY);
1826 size = read(fd, procpath, sizeof(procpath));
1829 if (size <= 0) break;
1830 ppid_line = strstr(procpath, "PPid");
1832 if (ppid_line == NULL) break;
1834 sscanf(ppid_line, "PPid: %d", &ppid);
1835 if (ppid <= 1) break;
1836 ICO_DBG("application pid=%d parent=%d", cpid, ppid);
1838 aulitem = appctrl->findAUL(cpid);
1841 if (NULL != aulitem) {
1842 window->appid = aulitem->m_appid;
1843 ICO_DBG("appid=%s", window->appid.c_str());
1844 ailItem = appctrl->findAIL(window->appid.c_str());
1846 window->layerid = ailItem->m_layer;
1847 window->zoneid = ailItem->m_displayZone;
1848 window->nodeid = ailItem->m_nodeID;
1849 if ((window->displayid >= 0) && (window->zoneid >= 0)) {
1851 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1853 window->zone = zone->fullname;
1854 window->x = zone->x;
1855 window->y = zone->y;
1856 window->width = zone->width;
1857 window->height = zone->height;
1863 ICO_WRN("ail item not found.");
1864 ICO_TRA("CicoSCWindowController::createSurfaceCB Leave(ENOENT)");
1868 if (ilm_surfaceSetDestinationRectangle(window->surfaceid, window->x, window->y,
1869 window->width, window->height) != ILM_SUCCESS) {
1870 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1871 "ilm_surfaceSetDestinationRectangle(%08x) Error", window->surfaceid);
1873 else if (ilm_surfaceSetSourceRectangle(window->surfaceid, 0, 0,
1874 window->width, window->height) != ILM_SUCCESS) {
1875 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1876 "ilm_surfaceSetSourceRectangle(%08x) Error", window->surfaceid);
1878 else if (ilm_surfaceSetOrientation(window->surfaceid, ILM_ZERO) != ILM_SUCCESS) {
1879 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1880 "ilm_surfaceSetOrientation(%08x) Error", window->surfaceid);
1882 else if (ilm_commitChanges() != ILM_SUCCESS) {
1883 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1886 CicoSCLayer *layer = findLayer(window->displayid, window->layerid);
1888 if (ilm_layerAddSurface(window->layerid, window->surfaceid) != ILM_SUCCESS) {
1889 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_layerAddSurface(%d,%08x) "
1890 "Error", window->layerid, window->surfaceid);
1892 if (ilm_commitChanges() != ILM_SUCCESS) {
1893 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1896 layer->addSurface(window->surfaceid, true);
1898 const int *surfs = layer->getSurfaces(&nsurf);
1899 if (ilm_layerSetRenderOrder(window->layerid, (t_ilm_layer *)surfs, nsurf)
1901 ICO_ERR("CicoSCWindowController::createSurfaceCB: "
1902 "ilm_layerSetRenderOrder(%d,,%d) Error", window->layerid, nsurf);
1904 if (ilm_commitChanges() != ILM_SUCCESS) {
1905 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1908 // must set surfaceOpacity after surfcaeAddLayer
1909 if (ilm_surfaceSetOpacity(window->surfaceid , (t_ilm_float)1.0f) != ILM_SUCCESS) {
1910 ICO_ERR("CicoSCWindowController::createSurfaceCB "
1911 "ilm_surfaceSetOpacity(%08x) Error", window->surfaceid);
1913 else if (ilm_commitChanges() != ILM_SUCCESS) {
1914 ICO_ERR("CicoSCWindowController::createSurfaceCB ilm_commitChanges() Error");
1917 appctrl->enterAUL(window->appid.c_str(), window->pid, window);
1919 // dump log window information
1922 m_windowList[window->surfaceid] = window;
1924 // set surface attributes
1925 setAttributes(window->surfaceid);
1928 CicoSCMessage *message = new CicoSCMessage();
1929 message->addRootObject("command", MSG_CMD_CREATE);
1930 message->addRootObject("appid", window->appid);
1931 message->addRootObject("pid", window->pid);
1932 message->addArgObject("surface", window->surfaceid);
1933 message->addArgObject("winname", window->name);
1934 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
1936 if (0 == window->appid.compare(ICO_SC_APPID_DEFAULT_ONS)) {
1937 CicoSCMessageRes *msgOS = new CicoSCMessageRes();
1938 msgOS->addRootObject("command", MSG_CMD_WINDOW_ID_RES);
1939 msgOS->addRootObject("appid", window->appid);
1940 msgOS->addRootObject("pid", window->pid);
1941 msgOS->addWinObject(MSG_PRMKEY_ECU, "");
1942 msgOS->addWinObject(MSG_PRMKEY_DISPLAY, "");
1943 msgOS->addWinObject(MSG_PRMKEY_LAYER, "");
1944 msgOS->addWinObject(MSG_PRMKEY_LAYOUT, "");
1945 msgOS->addWinObject(MSG_PRMKEY_AREA, "");
1946 msgOS->addWinObject(MSG_PRMKEY_DISPATCHAPP, "");
1947 msgOS->addWinObject(MSG_PRMKEY_ROLE, window->name);
1948 msgOS->addWinObject(MSG_PRMKEY_RESOURCEID, window->surfaceid);
1949 CicoSCServer::getInstance()->sendMessage(window->appid,
1950 (CicoSCMessage*)msgOS);
1953 if (NULL != m_resMgr) {
1955 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
1957 cmd.cmdid = MSG_CMD_CREATE_RES;
1958 cmd.appid = window->appid;
1959 cmd.pid = window->pid;
1962 opt->dispres = true;
1963 opt->winname = window->name;
1964 opt->surfaceid = window->surfaceid;
1967 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
1969 opt->dispzone = zone->fullname;
1973 opt->soundres = true;
1974 opt->soundname = window->appid;
1976 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
1977 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
1978 if (NULL != defconf) {
1979 const CicoSCSoundZoneConf *zoneconf =
1980 sysconf->findSoundZoneConfbyId(defconf->soundzone);
1981 if (NULL != zoneconf) {
1982 opt->soundzone = zoneconf->fullname;
1986 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
1989 show(window->surfaceid, NULL, 0);
1991 ICO_TRA("CicoSCWindowController::createSurfaceCB Leave");
1994 //--------------------------------------------------------------------------
1996 * @brief genivi ivi-shell layer propaty callback
1998 * @param [in] layer layer id
1999 * @param [in] LayerProperties layer properties
2000 * @param [in] mask change properties
2002 //--------------------------------------------------------------------------
2004 CicoSCWindowController::wlGeniviLayerNotification(t_ilm_layer layer,
2005 struct ilmLayerProperties *LayerProperties,
2006 t_ilm_notification_mask mask)
2008 ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Enter(%x,,%x)", layer, mask);
2010 if (mask & ILM_NOTIFICATION_VISIBILITY) {
2011 // change layer visibility, send message to HomeScreen
2012 CicoSCMessage *message = new CicoSCMessage();
2013 message->addRootObject("command", MSG_CMD_CHANGE_LAYER_ATTR);
2014 message->addRootObject("appid", "");
2015 message->addArgObject("layer", layer);
2016 message->addArgObject("visible", LayerProperties->visibility ? 1 : 0);
2017 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
2019 ICO_TRA("CicoSCWindowController::wlGeniviLayerNotification Leave");
2022 //--------------------------------------------------------------------------
2024 * @brief setup Genivi ivi-shell layer managerment system finctions
2028 //--------------------------------------------------------------------------
2030 CicoSCWindowController::initializeGeniviLMS(void)
2032 t_ilm_uint NumberOfScreens = 0;
2033 t_ilm_layer *pLayerId, *ppLayerId;
2034 t_ilm_int LayerNumber;
2035 t_ilm_uint *pScreenIds;
2036 struct ilmScreenProperties ScreenProperties;
2037 int idxs, idx1, idx2;
2038 int DisplayId, LayerId;
2039 const CicoSCDisplayConf *DisplayConf;
2040 const CicoSCLayerConf *LayerConf;
2042 // get all screen id
2043 if ((ilm_getScreenIDs(&NumberOfScreens, &pScreenIds) != ILM_SUCCESS) ||
2044 (NumberOfScreens <= 0)) {
2045 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2046 "ilm_getScreenIDs() Error(num=%d)", NumberOfScreens);
2049 ICO_TRA("initializeGeniviLMS: Screens=%d.%x %x", NumberOfScreens, pScreenIds[0],
2050 NumberOfScreens >= 2 ? pScreenIds[1] : 0);
2051 if ((int)NumberOfScreens > CicoSystemConfig::getInstance()->getNumberofDisplay()) {
2052 ICO_WRN("CicoSCWindowController::initializeGeniviLMS # of screens physical=%d config=%d",
2053 NumberOfScreens, CicoSystemConfig::getInstance()->getNumberofDisplay());
2054 NumberOfScreens = (t_ilm_uint)CicoSystemConfig::getInstance()->getNumberofDisplay();
2056 #if 1 /* At present, GENIVI (ivi-controller) is processing only one Display */
2057 for (idxs = (int)NumberOfScreens - 1; idxs >= 0; idxs--)
2059 for (idxs = 0; idxs < (int)NumberOfScreens; idxs++)
2062 if (ilm_getPropertiesOfScreen(pScreenIds[idxs], &ScreenProperties) != ILM_SUCCESS) {
2063 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2064 "ilm_getPropertiesOfScreen(%d.%x) Error", idxs, pScreenIds[idxs]);
2067 // It is referred to as Center when there is only one display
2068 if (NumberOfScreens == 1) {
2069 DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyType(ICO_NODETYPE_CENTER);
2072 DisplayId = CicoSystemConfig::getInstance()->getDisplayIdbyNo((int)pScreenIds[idxs]);
2074 ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
2075 "Screen[%d.%x] w/h=%d/%d layers=%d DisplayId=%d",
2076 idxs, pScreenIds[idxs], ScreenProperties.screenWidth,
2077 ScreenProperties.screenHeight, ScreenProperties.layerCount, DisplayId);
2079 if ((DisplayId < 0) ||
2080 ((DisplayConf = CicoSystemConfig::getInstance()->findDisplayConfbyId(DisplayId))
2082 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2083 "ScreenId.%x not found", pScreenIds[idxs]);
2086 // set genivi layers
2087 for (idx1 = 0; ; idx1++) {
2088 LayerConf = CicoSystemConfig::getInstance()->
2089 findLayerConfbyIdx(DisplayId, idx1);
2090 if (! LayerConf) break;
2092 pLayerId = (t_ilm_layer *)malloc(sizeof(t_ilm_layer) * idx1);
2093 ppLayerId = pLayerId;
2096 for (idx1 = 0; ; idx1++) {
2097 LayerConf = CicoSystemConfig::getInstance()->
2098 findLayerConfbyIdx(DisplayId, idx1);
2099 if (! LayerConf) break;
2101 LayerId = LayerConf->id + DisplayId * ICO_SC_LAYERID_SCREENBASE;
2102 for (idx2 = 0; idx2 < LayerNumber; idx2++) {
2103 if (LayerId == (int)pLayerId[idx2]) break;
2105 if (idx2 < LayerNumber) {
2106 ICO_TRA("CicoSCWindowController::initializeGeniviLMS: "
2107 "layer.%d exist, Skip", LayerId);
2111 if (ilm_layerCreateWithDimension((t_ilm_layer *)&LayerId,
2112 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
2113 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2114 "ilm_layerCreateWithDimension(%d,%d,%d) Error",
2115 LayerId, DisplayConf->width, DisplayConf->height);
2117 else if (ilm_commitChanges() != ILM_SUCCESS) {
2118 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2119 "ilm_commitChanges() Error");
2121 else if (ilm_layerSetOpacity(LayerId, (t_ilm_float)1.0f) != ILM_SUCCESS) {
2122 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2123 "ilm_layerSetOpacity(%d) Error", LayerId);
2125 else if (ilm_layerSetSourceRectangle(LayerId, 0, 0,
2126 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
2127 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2128 "ilm_layerSetSourceRectangle(%d) Error", LayerId);
2130 else if (ilm_layerSetDestinationRectangle(LayerId, 0, 0,
2131 DisplayConf->width, DisplayConf->height) != ILM_SUCCESS) {
2132 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2133 "ilm_layerSetDestinationRectangle(%d) Error", LayerId);
2135 else if (ilm_layerSetOrientation(LayerId, ILM_ZERO) != ILM_SUCCESS) {
2136 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2137 "ilm_layerSetOrientation(%d) Error", LayerId);
2140 if (ilm_commitChanges() != ILM_SUCCESS) {
2141 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2142 "ilm_commitChanges() Error");
2144 // SystemController default is layer visible
2145 if ((ilm_layerSetVisibility(LayerId, 1) != ILM_SUCCESS) ||
2146 (ilm_commitChanges() != ILM_SUCCESS)) {
2147 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2148 "ilm_layerSetVisibility() Error");
2150 ICO_TRA("initializeGeniviLMS: layer=%d created(%d,%d)",
2151 LayerId, DisplayConf->width, DisplayConf->height);
2152 *ppLayerId = LayerId;
2157 if (LayerNumber > 0) {
2158 ICO_TRA("initializeGeniviLMS: layers %d.%d %d %d %d set to screen %x",
2159 LayerNumber, pLayerId[0], pLayerId[1], pLayerId[2], pLayerId[3],
2161 if (ilm_displaySetRenderOrder(pScreenIds[idxs], pLayerId, LayerNumber)
2163 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2164 "ilm_displaySetRenderOrder(%d) Error", LayerNumber);
2166 else if (ilm_commitChanges() != ILM_SUCCESS) {
2167 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2168 "ilm_commitChanges() Error");
2170 ppLayerId = pLayerId;
2171 for (idx2 = 0; idx2 < LayerNumber; idx2++) {
2172 if (ilm_layerAddNotification(*ppLayerId, wlGeniviLayerNotification)
2174 ICO_ERR("CicoSCWindowController::initializeGeniviLMS "
2175 "ilm_layerAddNotification(%d) Error", *ppLayerId);
2186 //==========================================================================
2188 //==========================================================================
2190 //--------------------------------------------------------------------------
2192 * @brief find window object by surfaceid
2194 * @param [in] surfaceid wayland surface id
2196 //--------------------------------------------------------------------------
2198 CicoSCWindowController::findWindow(int surfaceid)
2200 map<unsigned int, CicoSCWindow*>::iterator itr;
2201 itr = m_windowList.find(surfaceid);
2202 if (m_windowList.end() == itr) {
2203 ICO_TRA("not found window object. surfaceid=%08x", surfaceid);
2210 //--------------------------------------------------------------------------
2212 * @brief find window object by surfaceid
2214 * @param [in] surfaceid wayland surface id
2216 //--------------------------------------------------------------------------
2218 CicoSCWindowController::findLayer(int displayid, int layerid)
2220 vector<CicoSCDisplay*>::iterator itr;
2221 itr = m_displayList.begin();
2222 for (; itr != m_displayList.end(); ++itr) {
2223 if ((*itr)->displayid != displayid) {
2226 vector<CicoSCLayer*>::iterator itr2;
2227 itr2 = (*itr)->layerList.begin();
2228 for (; itr2 != (*itr)->layerList.end(); ++itr2) {
2229 if ((*itr2)->layerid == layerid) {
2237 //--------------------------------------------------------------------------
2239 * @brief find display zone by id
2241 //--------------------------------------------------------------------------
2242 const CicoSCDisplayZone *
2243 CicoSCWindowController::findDisplayZone(int zoneid)
2245 vector<CicoSCDisplay*>::iterator itr;
2246 itr = m_displayList.begin();
2247 for (; itr != m_displayList.end(); ++itr) {
2248 std::map<unsigned int, CicoSCDisplayZone*>::iterator itr2;
2249 itr2 = (*itr)->zoneList.find(zoneid);
2250 if ((*itr)->zoneList.end() != itr2) {
2251 return itr2->second;
2257 //--------------------------------------------------------------------------
2259 * @brief handle command
2261 * @param [in] cmd control command
2263 //--------------------------------------------------------------------------
2265 CicoSCWindowController::handleCommand(const CicoSCCommand * cmd)
2267 // ICO_TRA("CicoSCWindowController::handleCommand Enter(%d)", cmd->cmdid);
2269 CicoSCCmdWinCtrlOpt *opt = static_cast<CicoSCCmdWinCtrlOpt*>(cmd->opt);
2271 switch (cmd->cmdid) {
2273 ICO_DBG("command: MSG_CMD_SHOW");
2274 if (opt->animationTime & ICO_SYC_WIN_SURF_NORESCTL) {
2275 /* show command but not resource control (for HomeScreen) */
2276 (void)show(opt->surfaceid,
2277 opt->animation.c_str(),
2278 opt->animationTime);
2281 /* show command (normal) */
2282 (void)notifyResourceManager(opt->surfaceid,
2285 opt->animation.c_str(),
2286 opt->animationTime);
2290 ICO_DBG("command: MSG_CMD_HIDE");
2291 (void)hide(opt->surfaceid, opt->animation.c_str(), opt->animationTime);
2295 ICO_DBG("command: MSG_CMD_MOVE");
2296 CicoSCWindow *window = findWindow(opt->surfaceid);
2297 if (NULL == window) {
2300 if (true == opt->zone.empty()) {
2301 (void)setGeometry(opt->surfaceid, opt->nodeid, opt->layerid,
2302 opt->x, opt->y, opt->width, opt->height,
2303 opt->animation.c_str(), opt->animationTime,
2304 opt->animation.c_str(), opt->animationTime);
2306 else if (opt->zone == window->zone) {
2307 (void)setGeometry(opt->surfaceid, opt->zone.c_str(), opt->layerid,
2308 opt->animation.c_str(), opt->animationTime,
2309 opt->animation.c_str(), opt->animationTime);
2312 (void)notifyResourceManager(opt->surfaceid,
2315 opt->animation.c_str(),
2316 opt->animationTime);
2320 case MSG_CMD_ANIMATION:
2321 ICO_DBG("command: MSG_CMD_ANIMATION");
2322 (void)setWindowAnimation(opt->surfaceid, opt->animationType,
2323 opt->animation.c_str(), opt->animationTime);
2325 case MSG_CMD_CHANGE_ACTIVE:
2326 ICO_DBG("command: MSG_CMD_CHANGE_ACTIVE");
2327 (void)active(opt->surfaceid, opt->active);
2329 case MSG_CMD_CHANGE_LAYER:
2330 ICO_DBG("command: MSG_CMD_CHANGE_LAYER");
2331 (void)setWindowLayer(opt->surfaceid, opt->layerid);
2333 case MSG_CMD_MAP_GET:
2334 ICO_DBG("command: MSG_CMD_MAP_GET");
2335 (void)setmapGet(opt->surfaceid, opt->animation.c_str());
2337 case MSG_CMD_MAP_THUMB:
2338 ICO_DBG("command: MSG_CMD_MAP_THUMB");
2339 (void)mapSurface(opt->surfaceid, opt->framerate, opt->animation.c_str());
2341 case MSG_CMD_UNMAP_THUMB:
2342 ICO_DBG("command: MSG_CMD_UNMAP_THUMB");
2343 (void)unmapSurface(opt->surfaceid);
2345 case MSG_CMD_SHOW_LAYER:
2346 ICO_DBG("command: MSG_CMD_SHOW_LAYER");
2347 (void)showLayer(opt->displayid, opt->layerid);
2349 case MSG_CMD_HIDE_LAYER:
2350 ICO_DBG("command: MSG_CMD_HIDE_LAYER");
2351 (void)hideLayer(opt->displayid, opt->layerid);
2354 ICO_WRN("command: Unknown(0x%08x)", cmd->cmdid);
2358 // ICO_TRA("CicoSCWindowController::handleCommand Leave");
2362 CicoSCWindowController::notifyResourceManager(int surfaceid,
2365 const char *animation,
2368 ICO_TRA("CicoSCWindowController::notifyResourceManager Enter"
2369 "(surfaceid=%08x zone=%s layerid=%d "
2370 "animation=%s animationTime=%d)",
2371 surfaceid, zone, layerid, animation, animationTime);
2373 // find window information in window list
2374 CicoSCWindow *window = findWindow(surfaceid);
2375 if (NULL == window) {
2376 ICO_WRN("not found window information");
2377 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2378 return ICO_SYC_ENOENT;
2382 CicoSCCmdResCtrlOpt *opt = new CicoSCCmdResCtrlOpt();
2384 cmd.cmdid = MSG_CMD_ACQUIRE_RES;
2385 cmd.appid = window->appid;
2386 cmd.pid = window->pid;
2389 opt->dispres = true;
2390 opt->winname = window->name;
2391 opt->layerid = layerid;
2392 opt->surfaceid = window->surfaceid;
2393 opt->animation = animation ? animation : "";
2394 opt->animationTime = animationTime;
2397 const CicoSCDisplayZone* zone = findDisplayZone(window->zoneid);
2399 opt->dispzone = zone->fullname;
2402 ICO_WRN("not found zone information");
2403 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(ENOENT)");
2404 return ICO_SYC_ENOENT;
2408 opt->dispzone = zone;
2411 opt->soundres = true;
2412 opt->soundname = window->appid;
2414 CicoSystemConfig *sysconf = CicoSystemConfig::getInstance();
2415 const CicoSCDefaultConf *defconf = sysconf->getDefaultConf();
2416 if (NULL != defconf) {
2417 const CicoSCSoundZoneConf *zoneconf =
2418 sysconf->findSoundZoneConfbyId(defconf->soundzone);
2419 if (NULL != zoneconf) {
2420 opt->soundzone = zoneconf->fullname;
2425 m_resMgr->handleCommand((const CicoSCCommand&)cmd, true);
2427 ICO_TRA("CicoSCWindowController::notifyResourceManager Leave(EOK)");
2432 CicoSCWindowController::findWindowObj(int32_t pid, uint32_t surfaceid) const
2434 const CicoSCWindow* r = NULL;
2435 map<unsigned int, CicoSCWindow*>::const_iterator itr = m_windowList.begin();
2436 for (; itr != m_windowList.end(); ++itr) {
2437 const CicoSCWindow* tmp = itr->second;
2438 if ((pid == tmp->pid) && (surfaceid == (uint32_t)tmp->surfaceid)) {
2440 break; // break of for itr
2443 ICO_TRA("return %x", r);
2447 const CicoSCResourceManager*
2448 CicoSCWindowController::getResourceManager(void) const
2452 // vim:set expandtab ts=4 sw=4: