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 CicoSCWlWinMgrIF.cpp
14 * @brief This file implementation of CicoSCWlInputMgrIF class
16 //==========================================================================
20 #include <sys/types.h>
24 #include "ico_syc_type.h"
25 #include "CicoSCWlWinMgrIF.h"
26 #include "CicoSCWayland.h"
28 #include "CicoSystemConfig.h"
30 #include "CicoSCWindowController.h"
32 //==========================================================================
34 //==========================================================================
35 struct ico_window_mgr *CicoSCWlWinMgrIF::m_winmgr = NULL;
36 struct ivi_application *CicoSCWlWinMgrIF::m_ivi_app = NULL;
37 struct ivi_controller *CicoSCWlWinMgrIF::m_ivi_ctrl = NULL;
38 struct wl_output *CicoSCWlWinMgrIF::m_wloutput = NULL;
40 int CicoSCWlWinMgrIF::m_id_surface = 0;
42 struct creation_surface_wait *CicoSCWlWinMgrIF::m_wait_surface_creation = NULL;
43 struct creation_surface_wait *CicoSCWlWinMgrIF::m_free_surface_creation = NULL;
45 //--------------------------------------------------------------------------
47 * @brief default constructor
49 //--------------------------------------------------------------------------
50 CicoSCWlWinMgrIF::CicoSCWlWinMgrIF()
52 // ico_window_mgr listener
53 m_listener.window_active = wlActiveCB;
54 m_listener.map_surface = wlMapSurfaceCB;
55 m_listener.update_surface = wlUpdateSurfaceCB;
56 m_listener.destroy_surface = wlDestroySurfaceCB;
58 // genivi ivi_application listener
59 m_ivi_app_listener.wl_shell_info = wlIviAppNativeShellInfoCB;
61 // genivi ivi_controller listener
62 m_ivi_ctrl_listener.screen = wlIviCtrlScreenCB;
63 m_ivi_ctrl_listener.layer = wlIviCtrlLayerCB;
64 m_ivi_ctrl_listener.surface = wlIviCtrlSurfaceCB;
65 m_ivi_ctrl_listener.error = wlIviCtrlErrorCB;
66 m_ivi_ctrl_listener.native_handle = wlIviCtrlNativeHandleCB;
68 // wayland output listener
69 m_wlOutputListener.geometry = wlOutputGeometryCB;
70 m_wlOutputListener.mode = wlOutputModeCB;
73 //--------------------------------------------------------------------------
77 //--------------------------------------------------------------------------
78 CicoSCWlWinMgrIF::~CicoSCWlWinMgrIF()
82 //--------------------------------------------------------------------------
84 * @brief initialize ico_window_mgr interfaces
86 * @param [in] data user data
87 * @param [in] registry wayland registry
88 * @param [in] name wayland display id
89 * @parma [in] interface wayland interface name
90 * @parma [in] version wayland interface version number
92 //--------------------------------------------------------------------------
94 CicoSCWlWinMgrIF::initInterface(void *data,
95 struct wl_registry *registry,
97 const char *interface,
100 ICO_TRA("CicoSCWlWinMgrIF::initInterface Enter(interface=%s)", interface);
102 // check interface name
103 if (0 == strcmp(interface, ICO_WL_WIN_MGR_IF)) {
104 // get interface instance
105 ICO_DBG("called: wl_registry_bind");
106 void *wlProxy = wl_registry_bind(registry,
108 &ico_window_mgr_interface,
110 if (NULL == wlProxy) {
111 ICO_WRN("interface(%s) wl_registry_bind failed.",
113 ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
118 m_winmgr = (struct ico_window_mgr *)wlProxy;
119 ico_window_mgr_add_listener(m_winmgr,
123 else if (0 == strcmp(interface, ICO_WL_IVI_APPLICATION_IF)) {
124 // get interface instance
125 ICO_DBG("called: wl_registry_bind for ivi_application");
126 void *wlProxy = wl_registry_bind(registry,
128 &ivi_application_interface,
130 if (NULL == wlProxy) {
131 ICO_WRN("interface(%s) wl_registry_bind failed.",
133 ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
136 m_ivi_app = (struct ivi_application *)wlProxy;
137 ivi_application_add_listener(m_ivi_app,
141 else if (0 == strcmp(interface, ICO_WL_IVI_CONTROLLER_IF)) {
142 // get interface instance
143 ICO_DBG("called: wl_registry_bind for ivi_controller");
144 void *wlProxy = wl_registry_bind(registry,
146 &ivi_controller_interface,
148 if (NULL == wlProxy) {
149 ICO_WRN("interface(%s) wl_registry_bind failed.",
151 ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
154 m_ivi_ctrl = (struct ivi_controller *)wlProxy;
155 ivi_controller_add_listener(m_ivi_ctrl,
156 &m_ivi_ctrl_listener,
159 else if (0 == strcmp(interface, ICO_WL_OUTPUT_IF)) {
160 // get interface instance
161 ICO_DBG("called: wl_registry_bind");
162 void *wlProxy = wl_registry_bind(registry,
164 &wl_output_interface,
166 if (NULL == wlProxy) {
167 ICO_WRN("interface(%s) wl_registry_bind failed.",
169 ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(binding failed)");
173 m_wloutput = (struct wl_output*)wlProxy;
174 wl_output_add_listener(m_wloutput,
179 ICO_WRN("unmatch interface");
180 ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave(unmatch interface)");
184 if((NULL != m_winmgr) && (NULL != m_wloutput)) {
185 m_initialized = true;
188 ICO_TRA("CicoSCWlWinMgrIF::initInterface Leave");
191 //--------------------------------------------------------------------------
193 * @brief wrapper function of ilm_layerAddSurface
195 * @param [in] surfaceid wayland surface id
196 * @param [in] layer layer id
197 * @param [in] oldlayer old layer id(if 0xffffffff, no old layer)
199 //--------------------------------------------------------------------------
201 CicoSCWlWinMgrIF::setWindowLayer(uint32_t surfaceid, uint32_t layer, uint32_t oldlayer)
203 // set window layer request to Multi Window Manager
204 ICO_DBG("CicoSCWlWinMgrIF::setWindowLayer: "
205 "surfaceid=%08x layer=%d->%d", surfaceid, oldlayer, layer);
207 if (oldlayer == layer) {
208 ICO_DBG("CicoSCWlWinMgrIF::setWindowLayer: new layer same as old, NOP");
212 // remove original layer
213 if (oldlayer <= 0x7fffffff) {
214 ICO_TRA("CicoSCWlWinMgrIF::setWindowLayer: remove surface %08x "
215 "from layer(%d)", surfaceid, oldlayer);
216 if (ilm_layerRemoveSurface(oldlayer, surfaceid) != ILM_SUCCESS) {
217 ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_layerRemoveSurface(%d,%08x) "
218 "Error", oldlayer, surfaceid);
220 // must need ilm_commitChanges() after ilm_layerRemoveSurface()
221 if (ilm_commitChanges() != ILM_SUCCESS) {
222 ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_commitChanges Error");
226 ICO_TRA("CicoSCWlWinMgrIF::setWindowLayer: surface %08x has no old layer(%d)",
227 surfaceid, oldlayer);
231 if (ilm_layerAddSurface(layer, surfaceid) != ILM_SUCCESS) {
232 ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_layerAddSurface(%d,%08x) Error",
235 if (ilm_commitChanges() != ILM_SUCCESS) {
236 ICO_ERR("CicoSCWlWinMgrIF::setWindowLayer ilm_commitChanges Error");
240 //--------------------------------------------------------------------------
242 * @brief wrapper function of ilm_surfaceSetDestinationRectangle
244 * @param [in] surfaceid wayland surface id
245 * @param [in] layer number of layer
251 //--------------------------------------------------------------------------
253 CicoSCWlWinMgrIF::setPositionsize(uint32_t surfaceid, uint32_t node,
254 int32_t x, int32_t y, int32_t width, int32_t height)
256 // set position size request to Multi Window Manager
257 ICO_DBG("called: ilm_surfaceSetDestinationRectangle"
258 "(surfaceid=%08x node=%d x=%d y=%d w=%d h=%d)",
259 surfaceid, node, x, y, width, height);
261 if (ilm_surfaceSetDestinationRectangle(surfaceid, x, y, width, height)
263 ICO_ERR("CicoSCWlWinMgrIF::setPositionsize ilm_surfaceSetDestinationRectangle"
264 "(%08x,%d,%d,%d,%d) Error", surfaceid, x, y, width, height);
266 else if (ilm_surfaceSetSourceRectangle(surfaceid, 0, 0, width, height)
268 ICO_ERR("CicoSCWlWinMgrIF::setPositionsize ilm_surfaceSetSourceRectangle"
269 "(%08x,0,0,%d,%d) Error", surfaceid, width, height);
271 else if (ilm_commitChanges() != ILM_SUCCESS) {
272 ICO_ERR("CicoSCWlWinMgrIF::setPositionsize ilm_commitChanges() Error");
276 //--------------------------------------------------------------------------
278 * @brief wrapper function of ilm_surfaceSetVisibility
280 * @param [in] surfaceid wayland surface id
281 * @param [in] visible visible state
283 //--------------------------------------------------------------------------
285 CicoSCWlWinMgrIF::setVisible(uint32_t surfaceid, int32_t visible)
287 // set visible request to Multi Window Manager
288 ICO_DBG("called: ilm_surfaceSetVisibility(surfaceid=%08x visible=%d)",
290 if ((visible == ICO_SYC_WIN_VISIBLE_SHOW) || (visible == ICO_SYC_WIN_VISIBLE_HIDE)) {
291 ilm_surfaceSetVisibility(surfaceid, visible);
292 if (ilm_commitChanges() != ILM_SUCCESS) {
293 ICO_ERR("CicoSCWlWinMgrIF::setVisible: ilm_commitChanges() Error");
298 //--------------------------------------------------------------------------
300 * @brief wrapper function of ico_window_mgr_set_animation
302 * @param [in] surfaceid wayland surface id
303 * @param [in] type transition type
304 * @param [in] animation name of animation
305 * @param [in] time time of animation
307 //--------------------------------------------------------------------------
309 CicoSCWlWinMgrIF::setAnimation(uint32_t surfaceid, int32_t type,
310 const char *animation, int32_t time)
312 ICO_DBG("called: ico_window_mgr_set_animation"
313 "(surfaceid=%08x type=%d anima=%s time=%d)",
314 surfaceid, type, animation, time);
315 ico_window_mgr_set_animation(m_winmgr, surfaceid, type, animation, time);
316 // need wayland flush for GENIVI layer management
317 CicoSCWayland::getInstance()->flushDisplay();
320 //--------------------------------------------------------------------------
322 * @brief wrapper function of ilm_SetKeyboardFocusOn
324 * @param [in] surfaceid wayland surface id
325 * @param [in] active flags or active device(unused)
327 //--------------------------------------------------------------------------
329 CicoSCWlWinMgrIF::setActive(uint32_t surfaceid, int32_t active)
331 ICO_DBG("called: ilm_SetKeyboardFocusOn"
332 "(surfaceid=%08x active=%d)", surfaceid, active);
333 if ((ilm_SetKeyboardFocusOn(surfaceid) != ILM_SUCCESS) ||
334 (ilm_commitChanges() != ILM_SUCCESS)) {
335 ICO_ERR("CicoSCWlWinMgrIF::setActive ilm_SetKeyboardFocusOn(%08x) Error", surfaceid);
339 //--------------------------------------------------------------------------
341 * @brief wrapper function of ilm_layerSetVisibility
343 * @param [in] surfaceid wayland surface id
344 * @param [in] layer id of layer
345 * @param [in] visible visible state
347 //--------------------------------------------------------------------------
349 CicoSCWlWinMgrIF::setLayerVisible(uint32_t layer, int32_t visible)
351 ICO_DBG("called: ilm_layerSetVisibility"
352 "(layer=%d visible=%d)", layer, visible);
353 if ((ilm_layerSetVisibility(layer, visible) != ILM_SUCCESS) ||
354 (ilm_commitChanges() != ILM_SUCCESS)) {
355 ICO_ERR("CicoSCWlWinMgrIF::setLayerVisible ilm_layerSetVisibility(%d,%d) Error",
360 //--------------------------------------------------------------------------
362 * @brief wrapper function of ilm_takeSurfaceScreenshot
364 * @param [in] surface id of wayland surface
365 * @param [in] filepath surface image pixel file path
367 //--------------------------------------------------------------------------
369 CicoSCWlWinMgrIF::setmapGet(int surfaceid, const char *filepath)
371 ICO_DBG("called: ilm_takeSurfaceScreenshot(filepath=%s,, surface=%08x)",
372 filepath ? filepath : "(null)", surfaceid);
373 if ((ilm_takeSurfaceScreenshot(filepath, surfaceid) != ILM_SUCCESS) ||
374 (ilm_commitChanges() != ILM_SUCCESS)) {
375 ICO_ERR("CicoSCWlWinMgrIF::setmapGet ilm_takeSurfaceScreenshot(%s,%x) Error",
376 filepath ? filepath : "(null)", surfaceid);
380 //--------------------------------------------------------------------------
382 * @brief wrapper function of ico_window_mgr_map_surface
384 * @param [in] surface id of wayland surface
385 * @param [in] framerate interval of changed notify[frame per second]
386 * @param [in] filepath surface image pixel file path
388 //--------------------------------------------------------------------------
390 CicoSCWlWinMgrIF::mapSurface(uint32_t surfaceid, int32_t framerate, const char *filepath)
392 ICO_DBG("called: ico_window_mgr_map_surface(surfaceid=%08x framerate=%d file=%s)",
393 surfaceid, framerate, filepath ? filepath : "(null)");
394 // currently GENIVI genivi-shell not support contents change, so use ico_window_mgr
395 if ((filepath != NULL) && (*filepath != 0) && (*filepath != ' ')) {
396 ico_window_mgr_map_surface(m_winmgr, surfaceid, framerate, filepath);
399 ico_window_mgr_map_surface(m_winmgr, surfaceid, framerate, " ");
403 //--------------------------------------------------------------------------
405 * @brief wrapper function of ico_window_mgr_unmap_surface
407 * @param [in] surface id of wayland surface
409 //--------------------------------------------------------------------------
411 CicoSCWlWinMgrIF::unmapSurface(uint32_t surfaceid)
413 ICO_DBG("called: ico_window_mgr_unmap_surface"
414 "(surfaceid=%08x)", surfaceid);
415 // currently GENIVI genivi-shell not support contents change, so use ico_window_mgr
416 ico_window_mgr_unmap_surface(m_winmgr, surfaceid);
419 //--------------------------------------------------------------------------
421 * @brief get creation surface window name(title) and pid
423 * @param [in] id_surface surface id
424 * @param [out] pid application process id
426 //--------------------------------------------------------------------------
428 CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(uint32_t id_surface, int *pid)
430 struct creation_surface_wait *tp = m_wait_surface_creation;
433 if (tp->id_surface == id_surface) {
434 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(%x) pid=%d title=<%s>",
435 id_surface, tp->pid, tp->title);
441 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlGetSurfaceWaiting(%x) dose not exist", id_surface);
445 //--------------------------------------------------------------------------
447 * @brief remove surface window
449 * @param [in] id_surface surface id
451 //--------------------------------------------------------------------------
453 CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(uint32_t id_surface)
455 struct creation_surface_wait *tp = m_wait_surface_creation;
456 struct creation_surface_wait *bp = NULL;
459 if (tp->id_surface == id_surface) {
464 m_wait_surface_creation = tp->next;
466 tp->next = m_free_surface_creation;
467 m_free_surface_creation = tp;
469 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(%x) removed", id_surface);
475 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlRemoveSurface(%x) dose not exist", id_surface);
478 //--------------------------------------------------------------------------
480 * @brief wayland surface active callback
482 * @param [in] data user data(unused)
483 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
484 * @param [in] surfaceid ico_window_mgr surface Id
485 * @param [in] select select device(unused)
486 * (0=not active/1=pointer/2=touch)
488 //--------------------------------------------------------------------------
490 CicoSCWlWinMgrIF::activeCB(void *data,
491 struct ico_window_mgr *ico_window_mgr,
495 ICO_WRN("CicoSCWlWinMgrIF::activeCB called.");
498 //--------------------------------------------------------------------------
500 * @brief surface map event callback
502 * @param [in] data user data(unused)
503 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
504 * @param [in] event event
505 * @param [in] surfaceid surface Id
506 * @param [in] type surface buffer type(EGL buffer/Shared memory)
507 * @param [in] width surface width
508 * @param [in] height surface height
509 * @param [in] stride surface buffer(frame buffer) stride
510 * @param [in] format surface buffer format
512 //--------------------------------------------------------------------------
514 CicoSCWlWinMgrIF::mapSurfaceCB(void *data,
515 struct ico_window_mgr *ico_window_mgr,
524 ICO_WRN("CicoSCWlWinMgrIF::mapSurfaceCB called.");
527 //--------------------------------------------------------------------------
529 * @brief surface update event callback
531 * @param [in] data user data(unused)
532 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
533 * @param [in] surfaceid surface Id
534 * @param [in] visible visibility
535 * @param [in] srcwidth application buffer width
536 * @param [in] srcheight application buffer height
539 * @param [in] width width
540 * @param [in] height height
542 //--------------------------------------------------------------------------
544 CicoSCWlWinMgrIF::updateSurfaceCB(void *data,
545 struct ico_window_mgr *ico_window_mgr,
555 ICO_WRN("CicoSCWlWinMgrIF::updateSurfaceCB called.");
558 //--------------------------------------------------------------------------
560 * @brief wayland surface destroy callback
562 * @param [in] data user data(unused)
563 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
564 * @param [in] surfaceid surface Id
566 //--------------------------------------------------------------------------
568 CicoSCWlWinMgrIF::destroySurfaceCB(void *data,
569 struct ico_window_mgr *ico_window_mgr,
572 ICO_WRN("CicoSCWlWinMgrIF::destroySurfaceCB called.");
575 //--------------------------------------------------------------------------
577 * @brief wayland update surface name callback
579 * @param [in] surfaceid surface Id
580 * @param [in] winname surface name (title)
582 //--------------------------------------------------------------------------
584 CicoSCWlWinMgrIF::updateWinnameCB(uint32_t surfaceid,
587 ICO_WRN("CicoSCWlWinMgrIF::updateWinnameCB called.");
590 //--------------------------------------------------------------------------
592 * @brief wayland display attribute callback
594 * @param [in] data user data(unused)
595 * @param [in] wl_output wayland wl_output interface
596 * @param [in] x display upper-left X coordinate
597 * @param [in] y display upper-left Y coordinate
598 * @param [in] physical_width display physical width
599 * @param [in] physical_height display physical height
600 * @param [in] subpixel display sub pixel
601 * @param [in] make display maker
602 * @param [in] model display model
603 * @param [in] transform transform
605 //--------------------------------------------------------------------------
607 CicoSCWlWinMgrIF::outputGeometryCB(void *data,
608 struct wl_output *wl_output,
611 int32_t physical_width,
612 int32_t physical_height,
618 ICO_WRN("CicoSCWlWinMgrIF::outputGeometryCB called.");
621 //--------------------------------------------------------------------------
623 * @brief wayland display mode callback
625 * @param [in] data user data(unused)
626 * @param [in] wl_output wayland wl_output interface
627 * @param [in] flags flags
628 * @param [in] width display width
629 * @param [in] height display height
630 * @param [in] refresh display refresh rate
632 //--------------------------------------------------------------------------
634 CicoSCWlWinMgrIF::outputModeCB(void *data,
635 struct wl_output *wl_output,
641 ICO_WRN("CicoSCWlWinMgrIF::outputModeCB called.");
644 //--------------------------------------------------------------------------
646 * @brief wayland genivi ivi-surface create callback
648 * @param [in] data user data(unused)
649 * @param [in] ivi_controller wayland ivi-controller plugin interface
650 * @param [in] id_surface surface id
652 //--------------------------------------------------------------------------
654 CicoSCWlWinMgrIF::createSurfaceCB(void *data,
655 struct ivi_controller *ivi_controller,
658 ICO_WRN("CicoSCWlWinMgrIF::createSurfaceCB called.");
661 //==========================================================================
663 //==========================================================================
665 //--------------------------------------------------------------------------
667 * @brief wayland surface active callback
669 * @param [in] data user data(unused)
670 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
671 * @param [in] surfaceid ico_window_mgr surface Id
672 * @param [in] select select device(unused)
673 * (0=not active/1=pointer/2=touch)
675 //--------------------------------------------------------------------------
677 CicoSCWlWinMgrIF::wlActiveCB(void *data,
678 struct ico_window_mgr *ico_window_mgr,
682 // ICO_TRA("CicoSCWlWinMgrIF::wlActiveCB Enter");
685 ICO_WRN("wlActiveCB: data is null");
688 static_cast<CicoSCWlWinMgrIF*>(data)->activeCB(data, ico_window_mgr,
690 // ICO_TRA("CicoSCWlWinMgrIF::wlActiveCB Leave");
693 //--------------------------------------------------------------------------
695 * @brief surface map event callback
697 * @param [in] data user data
698 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
699 * @param [in] event event
700 * @param [in] surfaceid surface Id
701 * @param [IN] type buffer type(fixed ICO_WINDOW_MGR_MAP_TYPE_EGL)
702 * @param [in] width surface width
703 * @param [in] height surface height
704 * @param [in] stride surface buffer(frame buffer) stride
705 * @param [in] format surface buffer format
707 //--------------------------------------------------------------------------
709 CicoSCWlWinMgrIF::wlMapSurfaceCB(void *data,
710 struct ico_window_mgr *ico_window_mgr,
719 // ICO_TRA("CicoSCWlWinMgrIF::wlMapSurfaceCB Enter");
722 ICO_WRN("wlMapSurfaceCB: data is null");
725 static_cast<CicoSCWlWinMgrIF*>(data)->mapSurfaceCB(data, ico_window_mgr,
730 // ICO_TRA("CicoSCWlWinMgrIF::wlMapSurfaceCB Leave");
733 //--------------------------------------------------------------------------
735 * @brief surface update event callback
737 * @param [in] data user data
738 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
739 * @param [in] surfaceid surface Id
740 * @param [in] visible visibility
741 * @param [in] srcwidth application buffer width
742 * @param [in] srcheight application buffer height
745 * @param [in] width width
746 * @param [in] height height
748 //--------------------------------------------------------------------------
750 CicoSCWlWinMgrIF::wlUpdateSurfaceCB(void *data,
751 struct ico_window_mgr *ico_window_mgr,
761 // ICO_TRA("CicoSCWlWinMgrIF::wlUpdateSurfaceCB Enter");
764 ICO_WRN("wlUpdateSurfaceCB: data is null");
767 static_cast<CicoSCWlWinMgrIF*>(data)->updateSurfaceCB(data, ico_window_mgr,
770 x, y, width, height);
771 // ICO_TRA("CicoSCWlWinMgrIF::wlUpdateSurfaceCB Leave");
774 //--------------------------------------------------------------------------
776 * @brief surface destroy event callback
778 * @param [in] data user data
779 * @param [in] ico_window_mgr wayland ico_window_mgr plugin interface
780 * @param [in] surfaceid surface Id
782 //--------------------------------------------------------------------------
784 CicoSCWlWinMgrIF::wlDestroySurfaceCB(void *data,
785 struct ico_window_mgr *ico_window_mgr,
788 // ICO_TRA("CicoSCWlWinMgrIF::wlDestroySurfaceCB Enter");
791 ICO_WRN("wlDestroySurfaceCB: data is null");
794 wlIviCtrlRemoveSurface(surfaceid);
796 static_cast<CicoSCWlWinMgrIF*>(data)->destroySurfaceCB(data, ico_window_mgr,
798 // ICO_TRA("CicoSCWlWinMgrIF::wlDestroySurfaceCB Leave");
801 //--------------------------------------------------------------------------
803 * @brief wayland display attribute callback
805 * @param [in] data user data(unused)
806 * @param [in] wl_output wayland wl_output interface
807 * @param [in] x display upper-left X coordinate
808 * @param [in] y display upper-left Y coordinate
809 * @param [in] physical_width display physical width
810 * @param [in] physical_height display physical height
811 * @param [in] subpixel display sub pixel
812 * @param [in] make display maker
813 * @param [in] model display model
814 * @param [in] transform transform
816 //--------------------------------------------------------------------------
818 CicoSCWlWinMgrIF::wlOutputGeometryCB(void *data,
819 struct wl_output *wl_output,
822 int32_t physical_width,
823 int32_t physical_height,
829 // ICO_TRA("CicoSCWlWinMgrIF::wlOutputGeometryCB Enter");
832 ICO_WRN("wlOutputGeometryCB: data is null");
835 static_cast<CicoSCWlWinMgrIF*>(data)->outputGeometryCB(data, wl_output,
843 // ICO_TRA("CicoSCWlWinMgrIF::wlOutputGeometryCB Leave");
846 //--------------------------------------------------------------------------
848 * @brief wayland display mode callback
850 * @param [in] data user data(unused)
851 * @param [in] wl_output wayland wl_output interface
852 * @param [in] flags flags
853 * @param [in] width display width
854 * @param [in] height display height
855 * @param [in] refresh display refresh rate
857 //--------------------------------------------------------------------------
859 CicoSCWlWinMgrIF::wlOutputModeCB(void *data,
860 struct wl_output *wl_output,
866 // ICO_TRA("CicoSCWlWinMgrIF::wlOutputModeCB Enter");
869 ICO_WRN("wlOutputGeometryCB: data is null");
872 static_cast<CicoSCWlWinMgrIF*>(data)->outputModeCB(data, wl_output, flags,
873 width, height, refresh);
874 // ICO_TRA("CicoSCWlWinMgrIF::wlOutputModeCB Leave");
877 //--------------------------------------------------------------------------
879 * @brief wayland ivi-shell ivi-application protocol create wl_surface callback
881 * @param [in] data user data(unused)
882 * @param [in] ivi_application wayland ivi-application interface
883 * @param [in] pid application process id
884 * @param [in] title surface title name
886 //--------------------------------------------------------------------------
888 CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB(void *data,
889 struct ivi_application *ivi_application,
890 int32_t pid, const char *title)
892 struct creation_surface_wait *tp;
893 struct creation_surface_wait *tp2;
895 ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Enter(%d,<%s>)",
896 pid, title ? title : "(null)");
899 ICO_WRN("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(data is null)");
903 ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(no title)");
907 // if same pid and same title, skip
908 tp = m_wait_surface_creation;
910 if ((tp->pid == pid) && (strcmp(tp->title, title) == 0)) {
911 ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave(same title)");
917 // get native surface info
918 tp = m_free_surface_creation;
920 m_free_surface_creation = tp->next;
923 tp = (struct creation_surface_wait *)malloc(sizeof(struct creation_surface_wait));
925 ICO_ERR("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: out of memory");
929 memset(tp, 0, sizeof(struct creation_surface_wait));
930 tp->next = m_wait_surface_creation;
932 strncpy(tp->title, title, ICO_SYC_MAX_WINNAME_LEN-1);
933 tp->busy = SCWINMGR_GENIVI_BUSY_WAIT;
934 tp2 = m_wait_surface_creation;
936 if (tp2->busy != SCWINMGR_GENIVI_BUSY_NONE) break;
939 m_wait_surface_creation = tp;
941 tp->busy = SCWINMGR_GENIVI_BUSY_REQSURF;
942 ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: "
943 "call ivi_controller_get_native_handle(%d,<%s>)", pid, title);
944 ivi_controller_get_native_handle(m_ivi_ctrl, pid, title);
946 ICO_TRA("CicoSCWlWinMgrIF::wlIviAppNativeShellInfoCB: Leave");
949 //--------------------------------------------------------------------------
951 * @brief wayland ivi-shell ivi-controller protocol create screen callback
953 * @param [in] data user data(unused)
954 * @param [in] ivi_controller wayland ivi-controller interface
955 * @param [in] id_screen screen id
956 * @param [in] screen screen information
958 //--------------------------------------------------------------------------
960 CicoSCWlWinMgrIF::wlIviCtrlScreenCB(void *data,
961 struct ivi_controller *ivi_controller,
963 struct ivi_controller_screen *screen)
965 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlScreenCB: Enter(%x)", id_screen);
968 ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlScreenCB: data is null");
971 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlScreenCB: Leave");
974 //--------------------------------------------------------------------------
976 * @brief wayland ivi-shell ivi-controller protocol create layer callback
978 * @param [in] data user data(unused)
979 * @param [in] ivi_controller wayland ivi-controller interface
980 * @param [in] id_layer layer id
982 //--------------------------------------------------------------------------
984 CicoSCWlWinMgrIF::wlIviCtrlLayerCB(void *data,
985 struct ivi_controller *ivi_controller,
988 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlLayerCB: Enter(%x)", id_layer);
991 ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlLayerCB: data is null");
994 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlLayerCB: Leave");
997 //--------------------------------------------------------------------------
999 * @brief wayland ivi-shell ivi-controller protocol create surface callback
1001 * @param [in] data user data(unused)
1002 * @param [in] ivi_controller wayland ivi-controller interface
1003 * @param [in] id_surface surface id
1005 //--------------------------------------------------------------------------
1007 CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB(void *data,
1008 struct ivi_controller *ivi_controller,
1009 uint32_t id_surface)
1011 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB: Enter(%x)", id_surface);
1014 ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB: data is null");
1018 static_cast<CicoSCWlWinMgrIF*>(data)->createSurfaceCB(data, ivi_controller, id_surface);
1020 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlSurfaceCB: Leave");
1023 //--------------------------------------------------------------------------
1025 * @brief wayland ivi-shell ivi-controller protocol error callback
1027 * @param [in] data user data(unused)
1028 * @param [in] ivi_controller wayland ivi-controller interface
1029 * @param [in] error_code error code
1030 * @param [in] error_text error message
1032 //--------------------------------------------------------------------------
1034 CicoSCWlWinMgrIF::wlIviCtrlErrorCB(void *data,
1035 struct ivi_controller *ivi_controller,
1036 int32_t object_id, int32_t object_type,
1037 int32_t error_code, const char *error_text)
1039 struct creation_surface_wait *tp;
1040 struct creation_surface_wait *tp2;
1041 struct creation_surface_wait *deltp;
1043 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: Enter(%d[%d],%d,<%s>)",
1044 object_id, object_type, error_code, error_text ? error_text : "(null)");
1047 ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: data is null");
1051 // search request wait
1052 tp = m_wait_surface_creation;
1056 if (tp->busy == SCWINMGR_GENIVI_BUSY_WAIT) {
1059 else if (tp->busy == SCWINMGR_GENIVI_BUSY_REQSURF) {
1062 else if (tp->busy != SCWINMGR_GENIVI_BUSY_NONE) {
1063 tp->busy = SCWINMGR_GENIVI_BUSY_NONE;
1068 if (m_wait_surface_creation == deltp) {
1069 m_wait_surface_creation = deltp->next;
1072 tp = m_wait_surface_creation;
1073 while(tp->next != deltp) {
1077 tp->next = deltp->next;
1080 deltp->next = m_free_surface_creation;
1081 m_free_surface_creation = deltp;
1084 tp2->busy = SCWINMGR_GENIVI_BUSY_REQSURF;
1085 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: "
1086 "call ivi_controller_get_native_handle(%d,<%s>)", tp2->pid, tp2->title);
1087 ivi_controller_get_native_handle(m_ivi_ctrl, tp2->pid, tp2->title);
1089 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlErrorCB: Leave");
1092 //--------------------------------------------------------------------------
1094 * @brief wayland ivi-shell ivi-controller protocol native handle callback
1096 * @param [in] data user data(unused)
1097 * @param [in] ivi_controller wayland ivi-controller interface
1098 * @param [in] surface weston_surface object
1100 //--------------------------------------------------------------------------
1102 CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB(void *data,
1103 struct ivi_controller *ivi_controller,
1104 struct wl_surface *surface)
1106 struct creation_surface_wait *tp;
1107 struct creation_surface_wait *tp2;
1108 struct creation_surface_wait *tp3;
1109 struct creation_surface_wait *bp;
1110 uint32_t id_surface;
1113 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Enter(surf=%08x)", (int)surface);
1116 ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Leave(data is null)");
1120 // check same surface
1121 tp = m_wait_surface_creation;
1124 if (tp->busy == SCWINMGR_GENIVI_BUSY_REQSURF) break;
1129 ICO_WRN("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Leave(no request)");
1134 tp3 = m_wait_surface_creation;
1136 if ((tp != tp3) && (tp3->pid == tp->pid)) {
1142 if (surface_count == 1) {
1143 // title change, delete old table
1144 id_surface = tp2->id_surface;
1145 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: winname change"
1146 "(%08x,<%s>)", id_surface, tp->title);
1147 strcpy(tp2->title, tp->title);
1149 bp->next = tp->next;
1152 m_wait_surface_creation = tp->next;
1154 tp->next = m_free_surface_creation;
1155 m_free_surface_creation = tp;
1157 static_cast<CicoSCWlWinMgrIF*>(data)->updateWinnameCB(tp2->id_surface, tp2->title);
1160 // create ivi-surface and bind to wl_surface
1162 if (m_id_surface >= 0x00ffffff) m_id_surface = 1;
1163 id_surface = m_id_surface | 0x40000000;
1165 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: "
1166 "call ivi_application_surface_create(%08x)", id_surface);
1167 if (ivi_application_surface_create(m_ivi_app, id_surface, surface) == NULL) {
1168 ICO_ERR("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: "
1169 "ivi_application_surface_create(%08x) Error", id_surface);
1171 bp->next = tp->next;
1174 m_wait_surface_creation = tp->next;
1176 tp->next = m_free_surface_creation;
1177 m_free_surface_creation = tp;
1180 tp->surface = surface;
1181 tp->id_surface = id_surface;
1182 tp->busy = SCWINMGR_GENIVI_BUSY_REQBIND;
1186 // search request wait
1187 tp = m_wait_surface_creation;
1190 if (tp->busy == SCWINMGR_GENIVI_BUSY_WAIT) {
1193 else if (tp->busy != SCWINMGR_GENIVI_BUSY_NONE) {
1198 if ((tp == NULL) && (tp2 != NULL)) {
1199 tp2->busy = SCWINMGR_GENIVI_BUSY_REQSURF;
1200 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: "
1201 "call ivi_controller_get_native_handle(%d,<%s>)", tp2->pid, tp2->title);
1202 ivi_controller_get_native_handle(m_ivi_ctrl, tp2->pid, tp2->title);
1204 ICO_TRA("CicoSCWlWinMgrIF::wlIviCtrlNativeHandleCB: Leave(id_surface=%08x)", id_surface);
1206 // vim:set expandtab ts=4 sw=4: