Revert "Corresponding to TizenIVI3.0 M14.3, GENIVI-LayerManagement was used instead...
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCWlWinMgrIF.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 //==========================================================================
11 /**
12  *  @file   CicoSCWlWinMgrIF.h
13  *
14  *  @brief  This file is definition of CicoSCWlWinMgrIF class
15  */
16 //==========================================================================
17 #ifndef __CICO_SC_WL_WINMGR_IF_H__
18 #define __CICO_SC_WL_WINMGR_IF_H__
19
20 #include <wayland-client.h>
21 #include <ilm/ilm_client.h>
22 #include <ilm/ilm_control.h>
23 #include <ico-uxf-weston-plugin/ico_window_mgr-client-protocol.h>
24 #include <weston/ivi-controller-client-protocol.h>
25 #include <weston/ivi-application-client-protocol.h>
26
27 #include "ico_syc_type.h"
28 #include "CicoSCWaylandIF.h"
29 #include "CicoSCWindow.h"
30
31 //--------------------------------------------------------------------------
32 /**
33  *  @brief  This class is wayland interface of multi window manager
34  */
35 //--------------------------------------------------------------------------
36 struct creation_surface_wait    {
37     struct creation_surface_wait    *next;
38     int32_t     pid;
39     uint32_t    id_surface;
40     struct wl_surface *surface;
41     int32_t     busy;
42     char        title[ICO_SYC_MAX_WINNAME_LEN];
43 };
44 #define SCWINMGR_GENIVI_BUSY_NONE       0
45 #define SCWINMGR_GENIVI_BUSY_REQSURF    1
46 #define SCWINMGR_GENIVI_BUSY_REQBIND    2
47 #define SCWINMGR_GENIVI_BUSY_WAIT       3
48
49 class CicoSCWlWinMgrIF : public CicoSCWaylandIF {
50 public:
51     virtual void initInterface(void               *data,
52                                struct wl_registry *registry,
53                                uint32_t           name,
54                                const char         *interface,
55                                uint32_t           version);
56
57     virtual void activeCB(void *data,
58                           struct ico_window_mgr *ico_window_mgr,
59                           uint32_t surfaceid,
60                           int32_t select);
61
62     virtual void mapSurfaceCB(void *data,
63                               struct ico_window_mgr *ico_window_mgr,
64                               int32_t event,
65                               uint32_t surfaceid,
66                               uint32_t type,
67                               int32_t width,
68                               int32_t height,
69                               int32_t stride,
70                               uint32_t format);
71
72     virtual void updateSurfaceCB(void *data,
73                                  struct ico_window_mgr *ico_window_mgr,
74                                  uint32_t surfaceid,
75                                  int visible,
76                                  int srcwidth,
77                                  int srcheight,
78                                  int x,
79                                  int y,
80                                  int width,
81                                  int height);
82
83     virtual void destroySurfaceCB(void *data,
84                                   struct ico_window_mgr *ico_window_mgr,
85                                   uint32_t surfaceid);
86
87     virtual void updateWinnameCB(uint32_t surfaceid,
88                                  const char *winname);
89     //
90     virtual void outputGeometryCB(void             *data,
91                                   struct wl_output *wl_output,
92                                   int32_t          x,
93                                   int32_t          y,
94                                   int32_t          physical_width,
95                                   int32_t          physical_height,
96                                   int32_t          subpixel,
97                                   const char       *make,
98                                   const char       *model,
99                                   int32_t          transform);
100
101     virtual void outputModeCB(void              *data,
102                               struct wl_output  *wl_output,
103                               uint32_t          flags,
104                               int32_t           width,
105                               int32_t           height,
106                               int32_t           refresh);
107
108     virtual void createSurfaceCB(void           *data,
109                                  struct ivi_controller *ivi_controller,
110                                  uint32_t id_surface);
111
112     static void wlIviCtrlRemoveSurface(uint32_t id_surface);
113
114 protected:
115     // default constructor
116     CicoSCWlWinMgrIF();
117
118     // destructor
119     virtual ~CicoSCWlWinMgrIF();
120
121     // assignment operator
122     CicoSCWlWinMgrIF& operator=(const CicoSCWlWinMgrIF &object);
123
124     // copy constructor
125     CicoSCWlWinMgrIF(const CicoSCWlWinMgrIF &object);
126
127     // wrapper function ico_window_mgr_set_window_layer
128     void setWindowLayer(uint32_t surfaceid, uint32_t layer, uint32_t oldlayer);
129
130     // wrapper function ico_window_mgr_set_positionsize
131     void setPositionsize(uint32_t surfaceid, uint32_t node,
132                          int32_t x, int32_t y, int32_t width, int32_t height);
133
134     // wrapper function ico_window_mgr_set_visible
135     void setVisible(uint32_t surfaceid, int32_t visible);
136
137     // wrapper function of ico_window_mgr_set_animation
138     void setAnimation(uint32_t surfaceid, int32_t type,
139                       const char *animation, int32_t time);
140
141     // wrapper function of ico_window_mgr_set_active
142     void setActive(uint32_t surfaceid, int32_t active);
143
144     // wrapper function of ico_window_mgr_set_layer_visible
145     void setLayerVisible(uint32_t layer, int32_t visible);
146
147     // wrapper function of ilm_takeSurfaceScreenshot
148     void setmapGet(int surfaceid, const char *filepath);
149
150     // wrapper function of ico_window_mgr_map_surface
151     void mapSurface(uint32_t surfaceid, int32_t framerate, const char *filepath);
152
153     // wrapper function of ico_window_mgr_unmap_surface
154     void unmapSurface(uint32_t surfaceid);
155
156     static const char *wlIviCtrlGetSurfaceWaiting(uint32_t id_surface, int *pid);
157
158 private:
159     // ico_window_mgr(Multi Window Manager) callback functions
160     static void wlActiveCB(void *data,
161                            struct ico_window_mgr *ico_window_mgr,
162                            uint32_t surfaceid,
163                            int32_t active);
164
165     static void wlMapSurfaceCB(void *data,
166                                struct ico_window_mgr *ico_window_mgr,
167                                int32_t event,
168                                uint32_t surfaceid,
169                                uint32_t type,
170                                int32_t width,
171                                int32_t height,
172                                int32_t stride,
173                                uint32_t format);
174
175     static void wlUpdateSurfaceCB(void *data,
176                                   struct ico_window_mgr *ico_window_mgr,
177                                   uint32_t surfaceid,
178                                   int layer,
179                                   int srcwidth,
180                                   int srcheight,
181                                   int x,
182                                   int y,
183                                   int width,
184                                   int height);
185
186     static void wlDestroySurfaceCB(void *data,
187                                    struct ico_window_mgr *ico_window_mgr,
188                                    uint32_t surfaceid);
189     //
190     static void wlOutputGeometryCB(void             *data,
191                                    struct wl_output *wl_output,
192                                    int32_t          x,
193                                    int32_t          y,
194                                    int32_t          physical_width,
195                                    int32_t          physical_height,
196                                    int32_t          subpixel,
197                                    const char       *make,
198                                    const char       *model,
199                                    int32_t          transform);
200
201     static void wlOutputModeCB(void             *data,
202                                struct wl_output *wl_output,
203                                uint32_t         flags,
204                                int32_t          width,
205                                int32_t          height,
206                                int32_t          refresh);
207
208     static void wlIviAppNativeShellInfoCB(void          *data,
209                                           struct ivi_application *ivi_application,
210                                           int32_t       pid,
211                                           const char    *title);
212     static void wlIviCtrlScreenCB(void                  *data,
213                                   struct ivi_controller *ivi_controller,
214                                   uint32_t              id_screen,
215                                   struct ivi_controller_screen *screen);
216
217     static void wlIviCtrlLayerCB(void                   *data,
218                                  struct ivi_controller  *ivi_controller,
219                                  uint32_t               id_layer);
220
221     static void wlIviCtrlSurfaceCB(void                 *data,
222                                    struct ivi_controller *ivi_controller,
223                                    uint32_t             id_surface);
224
225     static void wlIviCtrlErrorCB(void                   *data,
226                                  struct ivi_controller  *ivi_controller,
227                                  int32_t                object_id,
228                                  int32_t                object_type,
229                                  int32_t                error_code,
230                                  const char             *error_text);
231
232     static void wlIviCtrlNativeHandleCB(void            *data,
233                                         struct ivi_controller *ivi_controller,
234                                         struct wl_surface *surface);
235
236 protected:
237     // ico_window_mgr listener
238     struct ico_window_mgr_listener m_listener;
239
240     // wayland output listener
241     struct wl_output_listener m_wlOutputListener;
242
243     // genivi ivi-application listener
244     struct ivi_application_listener m_ivi_app_listener;
245
246     // genivi ivi-controller listener
247     struct ivi_controller_listener m_ivi_ctrl_listener;
248
249     // Wayland's Window Manager PlugIn instance
250     static struct ico_window_mgr *m_winmgr;
251
252     // Wayland's genivi ivi_application instance
253     static struct ivi_application *m_ivi_app;
254
255     // Wayland's genivi ivi_controller instance
256     static struct ivi_controller *m_ivi_ctrl;
257
258     // Wayland's genivi ivi_controller_surface instance
259     static struct ivi_controller_surface *m_ivi_ctrl_surf;
260
261     // wayland output instance
262     static struct wl_output *m_wloutput;
263
264     // surface id for wayland/weston applications
265     static int m_id_surface;
266
267     // creation surface title name
268     static struct creation_surface_wait *m_wait_surface_creation;
269     static struct creation_surface_wait *m_free_surface_creation;
270 };
271 #endif  // __CICO_SC_WL_WINMGR_IF_H__
272 // vim:set expandtab ts=4 sw=4: