ba98657d58fddec531e93ad4b24af7b9323c7a80
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCWindowController.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   CicoSCWindowController.h
13  *
14  *  @brief  This file is definition of CicoSCWindowController class
15  */
16 //==========================================================================
17 #ifndef __CICO_SC_WINDOW_CONTROLLER_H__
18 #define __CICO_SC_WINDOW_CONTROLLER_H__
19
20 #include <vector>
21 #include <map>
22 #include "ico_syc_private.h"
23
24 using namespace std;
25
26 #include "CicoSCWlWinMgrIF.h"
27
28 #define ICO_SC_APPID_DEFAULT_ONS    "org.tizen.ico.onscreen"
29 #define ICO_SC_LAYERID_SCREENBASE   1000
30
31 #define ICO_SC_WINCHK_TIMER_BASE        20      /* window check timer cycle(ms)     */
32 #define ICO_SC_WINCHK_TIMER_BASE_L      50      /* window check timer slow cycle(ms)*/
33 #define ICO_SC_WINCHK_ANIMATION_TIME    20      /* window check timer cycle(ms)     */
34 #define ICO_SC_WINCHK_CONTENTS_TIME     1000    /* window contents check time(ms)   */
35
36 #define ICO_SC_WINCHK_CONTENTS_CHECK        101
37 #define ICO_SC_WINCHK_ANIMA_FADE            201
38 #define ICO_SC_WINCHK_ANIMA_SLIDETOTOP      211
39 #define ICO_SC_WINCHK_ANIMA_SLIDETOBUTTOM   212
40 #define ICO_SC_WINCHK_ANIMA_SLIDETOLEFT     213
41 #define ICO_SC_WINCHK_ANIMA_SLIDETORIGHT    214
42
43 #define ICO_SC_WINANIMA_SHOW                1
44 #define ICO_SC_WINANIMA_HIDE                2
45
46 #define ICO_SC_WINCONT_CHECK                1
47 #define ICO_SC_WINCONT_WAITFILE             2
48
49 #define ICO_SC_WINCHK_MAP_SURFACE_EVENT_MAP         1
50 #define ICO_SC_WINCHK_MAP_SURFACE_EVENT_UNMAP       2
51 #define ICO_SC_WINCHK_MAP_SURFACE_EVENT_CONTENTS    3
52
53 struct  ico_sc_win_check_t  {
54     struct ico_sc_win_check_t   *next;
55     uint32_t    surfaceid;
56     short       time;
57     short       cycle;
58     short       lapsed;
59     short       timeout;
60     short       function;
61     short       state;
62     short       par;
63     union   {
64         struct  {
65             short       x;
66             short       y;
67             short       width;
68             short       height;
69             short       screen_width;
70             short       screen_height;
71         }           anim;
72         struct  {
73             short       x;
74             short       y;
75             short       width;
76             short       height;
77             char        path[ICO_SYC_MAX_LEN];
78         }           cont;
79     }           u;
80 };
81
82 //==========================================================================
83 //  Forward declaration
84 //==========================================================================
85 class CicoSCCommand;
86 class CicoSCDisplay;
87 class CicoSCLayer;
88 class CicoSCDisplayZone;
89 class CicoSCWindow;
90 class CicoSCResourceManager;
91
92 //--------------------------------------------------------------------------
93 /**
94  *  @brief  This class is controller of window
95  */
96 //--------------------------------------------------------------------------
97 class CicoSCWindowController : public CicoSCWlWinMgrIF
98 {
99 public:
100     // get instance of CicoSCWindowController
101     static CicoSCWindowController* getInstance();
102
103     // default constructor
104     CicoSCWindowController();
105
106     // copy constructor
107     virtual ~CicoSCWindowController();
108
109     int initDB(void);
110
111     void handleCommand(const CicoSCCommand * cmd);
112
113     //
114     void setResourceManager(CicoSCResourceManager *resMgr);
115
116     int show(int         surfaceid,
117              const char  *animation,
118              int         animationTime);
119
120     int hide(int         surfaceid,
121              const char  *animation,
122              int         animationTime);
123
124     int resize(int        surfaceid,
125                int        w,
126                int        h,
127                const char *animation,
128                int        animationTime);
129
130     int move(int        surfaceid,
131              int        nodeid,
132              int        x,
133              int        y,
134              const char *animation,
135              int        animationTime);
136
137     int setGeometry(int        surfaceid,
138                     int        nodeid,
139                     int        layerid,
140                     int        x,
141                     int        y,
142                     int        w,
143                     int        h,
144                     const char *resizeAnimation,
145                     int        resizeAnimationTime,
146                     const char *moveAnimation,
147                     int        moveAnimationTime);
148
149     int setGeometry(int        surfaceid,
150                     const char *zone,
151                     int        layerid,
152                     const char *resizeAnimation,
153                     int        resizeAnimationTime,
154                     const char *moveAnimation,
155                     int        moveAnimationTime);
156
157     int raise(int surfaceid,
158              const char  *animation,
159              int         animationTime);
160
161     int lower(int surfaceid, const char *animation, int animationTime);
162
163     int setWindowLayer(int surfaceid, int layerid);
164
165     int showLayer(int displayid, int layerid);
166
167     int hideLayer(int displayid, int layerid);
168
169     int active(int surfaceid, int target);
170
171     int setmapGet(int surfaceid, const char *filepath);
172
173     int mapSurface(int surfaceid, int framerate, const char *filepath);
174
175     int unmapSurface(int surfaceid);
176
177     int getDisplayedWindow(int zoneid);
178
179     int setAttributes(int surfaceid);
180
181     void initializeGeniviLMS(void);
182
183     static void wlGeniviLayerNotification(t_ilm_layer layer,
184                                           struct ilmLayerProperties *LayerProperties,
185                                           t_ilm_notification_mask mask);
186     //
187     virtual void activeCB(void *data,
188                           uint32_t surfaceid,
189                           int32_t select);
190
191     virtual void mapSurfaceCB(int32_t event,
192                               uint32_t surfaceid,
193                               uint32_t type,
194                               int32_t width,
195                               int32_t height,
196                               int32_t stride,
197                               uint32_t format);
198
199     static void wlGeniviSurfaceNotification(t_ilm_surface surfaceid,
200                                             struct ilmSurfaceProperties *surfprop,
201                                             t_ilm_notification_mask mask);
202
203     virtual void updateSurfaceCB(uint32_t surfaceid,
204                                  struct ilmSurfaceProperties *surfprop);
205
206     virtual void destroySurfaceCB(uint32_t surfaceid);
207
208     virtual void updateWinnameCB(uint32_t surfaceid,
209                                  const char *winname);
210 //
211     virtual void outputGeometryCB(void *data,
212                                   struct wl_output *wl_output,
213                                   int32_t x,
214                                   int32_t y,
215                                   int32_t physical_width,
216                                   int32_t physical_height,
217                                   int32_t subpixel,
218                                   const char *make,
219                                   const char *model,
220                                   int32_t transform);
221
222     virtual void outputModeCB(void *data,
223                               struct wl_output *wl_output,
224                               uint32_t flags,
225                               int32_t width,
226                               int32_t height,
227                               int32_t refresh);
228
229     virtual void createSurfaceCB(void           *data,
230                                  struct ivi_controller *ivi_controller,
231                                  uint32_t id_surface);
232
233     const CicoSCWindow* findWindowObj(int32_t pid, uint32_t surfaceid) const;
234
235     const CicoSCResourceManager* getResourceManager(void) const;
236
237 private:
238     // assignment operator
239     CicoSCWindowController& operator=(const CicoSCWindowController &object);
240
241     // copy constructor
242     CicoSCWindowController(const CicoSCWindowController &object);
243
244     // find window object by surface id
245     CicoSCWindow* findWindow(int surfaceid);
246
247     // find layer object by display id and layer id
248     CicoSCLayer* findLayer(int displayid, int layerid);
249
250     // fine display zone by id
251     const CicoSCDisplayZone * findDisplayZone(int zoneid);
252
253     void raiselower(CicoSCWindow *window, bool raise);
254
255     int notifyResourceManager(int        surfaceid,
256                               const char *zone,
257                               int        layerid,
258                               const char *animation,
259                               int        animationTime);
260
261     // window checker
262     void windowCheckerRemove(uint32_t surfaceid);
263
264     void setWindowAnimation(CicoSCWindow *window, int show,
265                             const char *animation, int time);
266
267     void resetWindowAnimation(CicoSCWindow *window);
268
269     void setWindowMap(CicoSCWindow *window, int framerate, const char *filepath);
270
271     void resetWindowMap(uint32_t surfaceid);
272
273 protected:
274     static Eina_Bool    ico_SCWindowChecker(void *data);
275
276 private:
277     /// my instance
278     static CicoSCWindowController *ms_myInstance;
279
280     // resource manager instance
281     CicoSCResourceManager *m_resMgr;
282
283     // window object list
284     map<unsigned int, CicoSCWindow*> m_windowList;
285
286     // display object list
287     vector<CicoSCDisplay*> m_displayList;
288
289     // total of physical display
290     unsigned int m_physicalDisplayTotal;
291
292 protected:
293     // window check timer
294     static struct ico_sc_win_check_t    *win_check_timer;
295     static struct ico_sc_win_check_t    *win_check_free;
296 };
297 #endif  // __CICO_SC_WINDOW_CONTROLLER_H__
298 // vim:set expandtab ts=4 sw=4: