f390bcb1c311980b12766be83a6cce0ddfff02fe
[profile/ivi/ico-uxf-weston-plugin.git] / src / ico_window_mgr_private.h
1 /*
2  * Copyright © 2010-2011 Intel Corporation
3  * Copyright © 2008-2011 Kristian Høgsberg
4  * Copyright © 2013-2014 TOYOTA MOTOR CORPORATION.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and
7  * its documentation for any purpose is hereby granted without fee, provided
8  * that the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of the copyright holders not be used in
11  * advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission.  The copyright holders make
13  * no representations about the suitability of this software for any
14  * purpose.  It is provided "as is" without express or implied warranty.
15  *
16  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23  */
24 /**
25  * @brief   Public functions in ico_window_mgr Weston plugin
26  *
27  * @date    Jul-26-2013
28  */
29
30 #ifndef _ICO_WINDOW_MGR_PRIVATE_H_
31 #define _ICO_WINDOW_MGR_PRIVATE_H_
32
33 /* Manager management table             */
34 struct uifw_manager {
35     struct wl_resource *resource;           /* Manager resource                     */
36     int         manager;                    /* Manager(=event send flag)            */
37     struct wl_list link;                    /* link to next manager                 */
38 };
39
40 /* Cleint management table              */
41 struct uifw_client  {
42     struct wl_client *client;               /* Wayland client                       */
43     int         pid;                        /* ProcessId (pid)                      */
44     char        appid[ICO_IVI_APPID_LENGTH];/* ApplicationId(from AppCore AUL)      */
45     struct uifw_manager *mgr;               /* Manager table (if manager)           */
46     char        manager;                    /* Manager flag (Need send event)       */
47     char        fixed_appid;                /* ApplicationId fix flag(and counter)  */
48     char        noconfigure;                /* no need configure event              */
49     char        privilege;                  /* privilege aplication                 */
50     char        *shmbuf;                    /* shared memory for surface image      */
51     int         bufsize;                    /* shared memory buffer size            */
52     int         bufnum;                     /* number of shared memory buffer       */
53     struct wl_list  surface_link;           /* surface list of same client          */
54     struct wl_list  link;                   /* client list                          */
55     uint32_t    api_access_control;         /* api permission flags                 */
56 };
57
58 /* Node information                     */
59 struct uifw_node_table {
60     uint16_t    node;                       /* node Id                              */
61     uint16_t    displayno;                  /* weston display number                */
62     struct weston_output *output;           /* weston output                        */
63     int         disp_x;                     /* display frame buffer X-coordinate    */
64     int         disp_y;                     /* display frame buffer Y-coordinate    */
65     int         disp_width;                 /* display width                        */
66     int         disp_height;                /* display height                       */
67 };
68
69 /* Layer management table               */
70 struct  uifw_win_layer  {
71     uint32_t    layer;                      /* Layer Id                             */
72     char        visible;                    /* visibility                           */
73     char        layertype;                  /* layer type                           */
74     char        res[2];                     /* (unused)                             */
75     struct wl_list surface_list;            /* Surface list                         */
76     struct wl_list link;                    /* Link pointer for layer list          */
77 };
78
79 /* Surface map table                    */
80 struct uifw_win_surface;
81 struct uifw_surface_map {
82     struct uifw_win_surface *usurf;         /* UIFW surface                         */
83     struct uifw_client      *uclient;       /* UIFW client                          */
84     struct weston_buffer    *curbuf;        /* current buffer                       */
85     uint32_t    eglname;                    /* EGL buffer name                      */
86     uint32_t    format;                     /* format                               */
87     uint16_t    type;                       /* buffer type(currently only EGL buffer)*/
88     uint16_t    width;                      /* width                                */
89     uint16_t    height;                     /* height                               */
90     uint16_t    stride;                     /* stride                               */
91     uint16_t    framerate;                  /* update frame rate (frame/sec)        */
92     uint16_t    interval;                   /* interval time (ms)                   */
93     uint32_t    lasttime;                   /* last event time (ms)                 */
94     char        initflag;                   /* map event send flag(0=no/1=yes)      */
95     char        eventque;                   /* send event queue flag                */
96     char        res[2];                     /* (unused)                             */
97     struct wl_list  map_link;               /* surface map list                     */
98     struct wl_list  surf_link;              /* surface map list from UIFW surface   */
99 };
100
101 /* UIFW surface                         */
102 struct shell_surface;
103 struct uifw_win_surface {
104     uint32_t    surfaceid;                  /* UIFW SurfaceId                       */
105     struct uifw_node_table *node_tbl;       /* Node manager of ico_window_mgr       */
106     struct uifw_win_layer *win_layer;       /* surface layer                        */
107     struct uifw_win_layer *old_layer;       /* saved surface layer for change full screen*/
108     struct weston_surface *surface;         /* Weston surface                       */
109     struct shell_surface  *shsurf;          /* Shell(IVI-Shell) surface             */
110     struct uifw_client    *uclient;         /* Client                               */
111     struct weston_transform transform;      /* transform matrix                     */
112     float       scalex;                     /* surface transform scale of X         */
113     float       scaley;                     /* surface transform scale of Y         */
114     int         x;                          /* X-coordinate                         */
115     int         y;                          /* Y-coordinate                         */
116     short       xadd;                       /* X-coordinate delta                   */
117     short       yadd;                       /* Y-coordinate delta                   */
118     uint16_t    width;                      /* Width                                */
119     uint16_t    height;                     /* Height                               */
120     uint16_t    client_width;               /* Widht that a client(App) required    */
121     uint16_t    client_height;              /* Height that a client(App) required   */
122     uint16_t    conf_width;                 /* Width that notified to client        */
123     uint16_t    conf_height;                /* Height that notified to client       */
124     uint32_t    attributes;                 /* surface attributes                   */
125     char        winname[ICO_IVI_WINNAME_LENGTH];/* Window name                      */
126     char        disable;                    /* can not display                      */
127     char        visible;                    /* visibility                           */
128     char        raise;                      /* raise(top of the layer)              */
129     char        created;                    /* sended created event to manager      */
130     char        mapped;                     /* end of map                           */
131     char        restrain_configure;         /* restrant configure event             */
132     char        set_transform;              /* surface transform flag               */
133     char        layertype;                  /* surface layer type                   */
134     char        old_layertype;              /* surface old layer type               */
135     char        res[3];                     /* (unused)                             */
136     struct  _uifw_win_surface_animation {   /* wndow animation                      */
137         struct weston_animation animation;  /* weston animation control             */
138         uint16_t    type;                   /* current animation type               */
139         uint16_t    anima;                  /* curremt animation Id                 */
140         uint16_t    next_anima;             /* next animation Id                    */
141         uint16_t    hide_anima;             /* animation Id for hide                */
142         uint16_t    hide_time;              /* animation time(ms) for hide          */
143         uint16_t    show_anima;             /* animation Id for show                */
144         uint16_t    show_time;              /* animation time(ms) for show          */
145         uint16_t    move_anima;             /* animation Id for move                */
146         uint16_t    move_time;              /* animation time(ms) for move          */
147         uint16_t    resize_anima;           /* animation Id for resize              */
148         uint16_t    resize_time;            /* animation time(ms) for resize        */
149         uint16_t    time;                   /* current animation time(ms)           */
150         uint16_t    pos_x;                  /* start/end X-coordinate               */
151         uint16_t    pos_y;                  /* start/end Y-coordinate               */
152         uint16_t    pos_width;              /* start/end width                      */
153         uint16_t    pos_height;             /* start/end height                     */
154         short       current;                /* animation current percentage         */
155         char        state;                  /* animation state                      */
156         char        visible;                /* need hide(1)/show(2) at end of animation*/
157         char        restrain_configure;     /* restrain surface resize              */
158         char        ahalf;                  /* after half                           */
159         char        no_configure;           /* no send configure to client          */
160         char        res;                    /* (unused)                             */
161         uint32_t    starttime;              /* start time(ms)                       */
162         void        *animadata;             /* animation data                       */
163     }           animation;
164     struct wl_list  ivi_layer;              /* surface list of same layer           */
165     struct wl_list  client_link;            /* surface list of same client          */
166     struct wl_list  surf_map;               /* surface map list                     */
167     struct wl_list  input_region;           /* surface input region list            */
168     struct uifw_win_surface *next_idhash;   /* UIFW SurfaceId hash list             */
169     struct uifw_win_surface *next_wshash;   /* Weston SurfaceId hash list           */
170 };
171
172 /* access control                       */
173 #define ICO_UIFW_MAX_SUBJECT_NAME    64
174 struct ico_uifw_api_permit  {
175     char     subject[ICO_UIFW_MAX_SUBJECT_NAME];    /* subject smack label  */
176     uint32_t api_permit;                            /* api permission flags */
177 };
178
179 /* animation operation                  */
180 /* default animation                    */
181 #define ICO_WINDOW_MGR_ANIMATION_NONE           0   /* no animation                 */
182
183 /* return code of animation hook function*/
184 #define ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA    -1  /* no animation                 */
185 #define ICO_WINDOW_MGR_ANIMATION_RET_ANIMA      0   /* animation                    */
186 #define ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL 1   /* animation but no control     */
187
188 /* animation state                      */
189 #define ICO_WINDOW_MGR_ANIMATION_STATE_NONE     0   /* not animation                */
190 #define ICO_WINDOW_MGR_ANIMATION_STATE_SHOW     1   /* show(in) animation           */
191 #define ICO_WINDOW_MGR_ANIMATION_STATE_HIDE     2   /* hide(out) animation          */
192 #define ICO_WINDOW_MGR_ANIMATION_STATE_MOVE     3   /* move animation               */
193 #define ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE   4   /* resize animation             */
194
195 /* extended(plugin) animation operation */
196 #define ICO_WINDOW_MGR_ANIMATION_NAME       0       /* convert animation name to Id */
197 #define ICO_WINDOW_MGR_ANIMATION_DESTROY   99       /* surface destroy              */
198 #define ICO_WINDOW_MGR_ANIMATION_OPNONE     0       /* no animation                 */
199 #define ICO_WINDOW_MGR_ANIMATION_OPHIDE     1       /* change to hide               */
200 #define ICO_WINDOW_MGR_ANIMATION_OPSHOW     2       /* change to show               */
201 #define ICO_WINDOW_MGR_ANIMATION_OPMOVE     3       /* surface move                 */
202 #define ICO_WINDOW_MGR_ANIMATION_OPRESIZE   4       /* surface resize               */
203 #define ICO_WINDOW_MGR_ANIMATION_OPCANCEL   9       /* animation cancel             */
204 #define ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS 11       /* change to hide with position */
205 #define ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS 12       /* change to show with position */
206
207 /* Prototype for function               */
208                                             /* find uifw_client table               */
209 struct uifw_client *ico_window_mgr_find_uclient(struct wl_client *client);
210                                             /* surface visible control              */
211 void ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible);
212                                             /* get client applicationId             */
213 char *ico_window_mgr_get_appid(struct wl_client* client);
214                                             /* get display coordinate               */
215 void ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y);
216                                             /* change weston surface                */
217 void ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, int x, int y,
218                                        int width, int height);
219                                             /* surface change                       */
220 void ico_window_mgr_change_surface(struct uifw_win_surface *usurf,
221                                    const int to, const int manager);
222                                             /* check active keyboard surface        */
223 int ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf);
224                                             /* get UIFW client table                */
225 struct uifw_client *ico_window_mgr_get_uclient(const char *appid);
226                                             /* get UIFW surface table               */
227 struct uifw_win_surface *ico_window_mgr_get_usurf(const uint32_t surfaceid);
228                                             /* get UIFW surface table               */
229 struct uifw_win_surface *ico_window_mgr_get_usurf_client(const uint32_t surfaceid,
230                                                          struct wl_client *client);
231                                             /* get application surface              */
232 struct uifw_win_surface *ico_window_mgr_get_client_usurf(const char *target);
233                                             /* rebuild surface layer list           */
234 void ico_window_mgr_restack_layer(struct uifw_win_surface *usurf);
235                                             /* touch layer control for input manager*/
236 void ico_window_mgr_touch_layer(int omit);
237                                             /* chek surface visibility              */
238 int ico_window_mgr_is_visible(struct uifw_win_surface *usurf);
239                                             /* set active surface                   */
240 void ico_window_mgr_active_surface(struct weston_surface *surface);
241                                             /* get buffer width                     */
242 int ico_ivi_surface_buffer_width(struct weston_surface *es);
243                                             /* get buffer height                    */
244 int ico_ivi_surface_buffer_height(struct weston_surface *es);
245                                             /* get buffer size                      */
246 void ico_ivi_surface_buffer_size(struct weston_surface *es, int *width, int *height);
247                                             /* get surface primary view             */
248 struct weston_view *ico_ivi_get_primary_view(struct uifw_win_surface *usurf);
249                                             /* set window animation hook            */
250 void ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data));
251                                             /* set surface attribute change hook    */
252 void ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf));
253                                             /* set surface destory hook             */
254 void ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf));
255                                             /* set input region set/unset hook      */
256 void ico_window_mgr_set_hook_inputregion(void (*hook_inputregion)(
257                         int set, struct uifw_win_surface *usurf, int32_t x, int32_t y,
258                         int32_t width, int32_t height, int32_t hotspot_x, int32_t hotspot_y,
259                         int32_t cursor_x, int32_t cursor_y, int32_t cursor_width,
260                         int32_t cursor_height, uint32_t attr));
261
262 #endif  /*_ICO_WINDOW_MGR_PRIVATE_H_*/