1 #ifdef E_TYPEDEFS
2 typedef struct _E_Comp E_Comp;
3 
4 #ifdef E_COMP_WL
5 typedef struct _E_Comp_Wl_Client_Data E_Comp_Client_Data;
6 #endif
7 typedef struct _E_Comp_Wl_Data E_Comp_Wl_Data;
8 
9 #ifdef E_COMP_X
10 typedef struct _E_Comp_X_Client_Data E_Comp_Client_Data;
11 #endif
12 typedef struct _E_Comp_X_Data E_Comp_X_Data;
13 
14 #if !defined(E_COMP_WL) && !defined(E_COMP_X)
15 typedef struct _E_Comp_Client_Data E_Comp_Client_Data;
16 #endif
17 
18 typedef struct _E_Comp_Demo_Style_Item E_Comp_Demo_Style_Item;
19 
20 # define E_COMP_TYPE (int) 0xE0b01003
21 
22 # define E_LAYER_COUNT 19
23 # define E_CLIENT_LAYER_COUNT 11
24 
25 typedef enum _E_Layer
26 {
27    E_LAYER_BOTTOM = -100,
28    E_LAYER_BG = -1, // zone bg stuff
29    E_LAYER_DESKTOP = 0, // desktop objects: fileman, gadgets, shelves
30    E_LAYER_DESKTOP_TOP = 10, // raised desktop objects: gadgets
31    E_LAYER_CLIENT_DESKTOP = 100, //shelves
32    E_LAYER_CLIENT_BELOW = 150,
33    E_LAYER_CLIENT_NORMAL = 200,
34    E_LAYER_CLIENT_ABOVE = 250,
35    E_LAYER_CLIENT_EDGE = 300,
36    E_LAYER_CLIENT_FULLSCREEN = 350,
37    E_LAYER_CLIENT_EDGE_FULLSCREEN = 400,
38    E_LAYER_CLIENT_POPUP = 450,
39    E_LAYER_CLIENT_TOP = 500,
40    E_LAYER_CLIENT_DRAG = 550,
41    E_LAYER_CLIENT_PRIO = 600,
42    E_LAYER_POPUP = 999, // popups
43    E_LAYER_MENU = 5000, // menus
44    E_LAYER_DESKLOCK = 9999, // desklock
45    E_LAYER_MAX = 32767 // EVAS_LAYER_MAX
46 } E_Layer;
47 
48 #else
49 # ifndef E_COMP_H
50 #  define E_COMP_H
51 
52 # include "e_comp_cfdata.h"
53 
54 extern E_API int E_EVENT_COMPOSITOR_DISABLE;
55 extern E_API int E_EVENT_COMPOSITOR_ENABLE;
56 extern E_API int E_EVENT_COMPOSITOR_XWAYLAND_INIT;
57 
58 typedef void (*E_Comp_Cb)(void);
59 
60 typedef struct E_Comp_Screen_Iface
61 {
62    /* can screen changes be made at all */
63    Eina_Bool (*available)(void);
64    /* begin listening for screen events */
65    void (*init)(void);
66    /* stop listening for screen events */
67    void (*shutdown)(void);
68    /* gather screen info */
69    E_Randr2 *(*create)(void);
70    /* apply current config */
71    void (*apply)(void);
72    /* set dpms (on, standby, suspend, off) */
73    void (*dpms)(int);
74    /* is key event eaten */
75    Eina_Bool (*key_down)(Ecore_Event_Key *ev);
76    /* is key event eaten */
77    Eina_Bool (*key_up)(Ecore_Event_Key *ev);
78    Eina_Bool relative_motion E_BITFIELD;
79    Eina_Bool backlight_enabled E_BITFIELD;
80 } E_Comp_Screen_Iface;
81 
82 /* struct to hold canvas objects so that abi doesn't break
83  * when new objects are added
84  */
85 typedef struct E_Comp_Canvas
86 {
87    Evas_Object *resize_object; //object to monitor for comp canvas resizes
88    Evas_Object *fps_bg;
89    Evas_Object *fps_fg;
90    Evas_Object *gadget_site; //desktop gadget site
91 } E_Comp_Canvas;
92 
93 struct _E_Comp
94 {
95    E_Object e_obj_inherit;
96    int w, h; //overall size of compositor
97 
98    Ecore_Window  win; // input overlay
99    Ecore_Window  root; //x11 root window
100    Ecore_Evas     *ee; //canvas
101    Ecore_Window  ee_win; //canvas window
102    E_Comp_Canvas *canvas;
103    Evas_Object    *elm; //elm win base
104    Evas           *evas; //canvas
105    Eina_List      *zones; //list of E_Zones
106    E_Pointer      *pointer;
107    Eina_List *clients; //list of all E_Clients
108    unsigned int new_clients; //number of clients with new_client set
109 
110    Eina_List *pre_render_cbs; /* E_Comp_Cb */
111 
112    E_Comp_X_Data *x_comp_data; //x11 compositor-specific data
113    E_Comp_Wl_Data *wl_comp_data; //wl compositor-specific data
114 
115    E_Pixmap_Type comp_type; //for determining X/Wayland primary type
116 
117    struct {
118       Ecore_Window win; //x11 layer stacking window
119       Evas_Object *obj; //layer stacking object
120       //Eina_Inlist *objs; /* E_Comp_Object; NOT to be exposed; seems pointless? */
121       Eina_Inlist *clients; /* E_Client, bottom to top */
122       unsigned int clients_count; //count of clients on layer
123    } layers[E_LAYER_COUNT];
124 
125    struct //autoclose handler for e_comp_object_util_autoclose
126    {
127       Evas_Object *rect; //autoclose blocker rect
128       Evas_Object *obj; //autoclose object
129       Ecore_Event_Handler *key_handler;
130       E_Comp_Object_Autoclose_Cb del_cb; //cb to call on autoclose delete
131       E_Comp_Object_Key_Cb key_cb; //cb to call on key press
132       void *data; //user data
133    } autoclose;
134 
135    E_Comp_Screen_Iface *screen;
136 
137    Eina_List *debug_rects; //used when SHAPE_DEBUG is defined in e_comp.c
138    Eina_List *ignore_wins; //windows to be ignored by the compositor
139 
140    Eina_List      *updates; //E_Clients with render updates
141    Eina_List      *post_updates; //E_Clients awaiting post render flushing
142    Ecore_Animator *render_animator; //animator for fixed time rendering
143    Ecore_Job      *shape_job; //job to update x11 input shapes
144    Ecore_Job      *update_job; //job to trigger render updates
145    Ecore_Timer    *nocomp_delay_timer; //delay before activating nocomp in x11
146    Ecore_Timer    *nocomp_override_timer; //delay before overriding nocomp in x11
147    int             animating; //number of animating comp objects
148    double          frametimes[122]; //used for calculating fps
149    int             frameskip;
150 
151    int             nocomp_override; //number of times nocomp override has been requested
152    Ecore_Window block_win;
153    int             block_count; //number of times block window has been requested
154 
155    Ecore_Window  cm_selection; //FIXME: move to comp_x ?
156    E_Client       *nocomp_ec; //window that triggered nocomp mode
157 
158    unsigned int    input_key_grabs; //number of active compositor key grabs
159    unsigned int    input_mouse_grabs; //number of active compositor mouse grabs
160 
161    E_Comp_Cb        grab_cb; //callback for grabbing the xserver
162    E_Comp_Cb        bindings_grab_cb; //callback for triggering binding input grab
163    E_Comp_Cb        bindings_ungrab_cb; //callback for triggering binding input ungrab
164 
165    Eina_Bool       gl E_BITFIELD; //gl is active
166    Eina_Bool       grabbed E_BITFIELD; //xserver is grabbed
167    Eina_Bool       nocomp E_BITFIELD; //nocomp is active
168    Eina_Bool       nocomp_want E_BITFIELD; //nocomp is pending
169    Eina_Bool       saver E_BITFIELD; //screensaver is active
170    Eina_Bool       shape_queue_blocked E_BITFIELD; //x11 input shape updates are blocked
171 
172    Eina_Bool       rendering E_BITFIELD; // we've received a pre-render callback but no post-render yet.
173    Eina_Bool       updating E_BITFIELD; // running client updates
174 };
175 
176 
177 struct _E_Comp_Demo_Style_Item
178 {
179    Evas_Object *preview;
180    Evas_Object *frame;
181    Evas_Object *livethumb;
182    Evas_Object *layout;
183    Evas_Object *border;
184    Evas_Object *client;
185 };
186 
187 typedef enum
188 {
189    E_COMP_ENGINE_NONE = 0,
190    E_COMP_ENGINE_SW = 1,
191    E_COMP_ENGINE_GL = 2
192 } E_Comp_Engine;
193 
194 extern E_API E_Comp *e_comp;
195 extern E_API E_Comp_X_Data *e_comp_x;
196 extern E_API E_Comp_Wl_Data *e_comp_wl;
197 
198 EINTERN Eina_Bool e_comp_init(void);
199 E_API E_Comp *e_comp_new(void);
200 E_API int e_comp_internal_save(void);
201 EINTERN int e_comp_shutdown(void);
202 E_API void e_comp_render_queue(void);
203 E_API void e_comp_client_post_update_add(E_Client *ec);
204 E_API void e_comp_shape_queue(void);
205 E_API void e_comp_shape_queue_block(Eina_Bool block);
206 E_API E_Comp_Config *e_comp_config_get(void);
207 E_API const Eina_List *e_comp_list(void);
208 E_API void e_comp_shadows_reset(void);
209 E_API Ecore_Window e_comp_top_window_at_xy_get(Evas_Coord x, Evas_Coord y);
210 E_API void e_comp_util_wins_print(void);
211 E_API void e_comp_ignore_win_add(E_Pixmap_Type type, Ecore_Window win);
212 E_API void e_comp_ignore_win_del(E_Pixmap_Type type, Ecore_Window win);
213 E_API Eina_Bool e_comp_ignore_win_find(Ecore_Window win);
214 E_API void e_comp_override_del(void);
215 E_API void e_comp_override_add(void);
216 E_API void e_comp_block_window_add(void);
217 E_API void e_comp_block_window_del(void);
218 E_API E_Comp *e_comp_find_by_window(Ecore_Window win);
219 E_API void e_comp_override_timed_pop(void);
220 E_API unsigned int e_comp_e_object_layer_get(const E_Object *obj);
221 E_API Eina_Bool e_comp_grab_input(Eina_Bool mouse, Eina_Bool kbd);
222 E_API void e_comp_ungrab_input(Eina_Bool mouse, Eina_Bool kbd);
223 E_API void e_comp_gl_set(Eina_Bool set);
224 E_API Eina_Bool e_comp_gl_get(void);
225 
226 E_API void e_comp_button_bindings_grab_all(void);
227 E_API void e_comp_button_bindings_ungrab_all(void);
228 E_API void e_comp_client_redirect_toggle(E_Client *ec);
229 E_API Eina_Bool e_comp_util_object_is_above_nocomp(Evas_Object *obj);
230 
231 EINTERN Evas_Object *e_comp_style_selector_create(Evas *evas, const char **source);
232 E_API E_Config_Dialog *e_int_config_comp(Evas_Object *parent, const char *params);
233 E_API E_Config_Dialog *e_int_config_comp_match(Evas_Object *parent, const char *params);
234 
235 E_API Eina_Bool e_comp_util_kbd_grabbed(void);
236 E_API Eina_Bool e_comp_util_mouse_grabbed(void);
237 
238 E_API void e_comp_clients_rescale(void);
239 
240 static inline Eina_Bool
e_comp_util_client_is_fullscreen(const E_Client * ec)241 e_comp_util_client_is_fullscreen(const E_Client *ec)
242 {
243    if ((!ec->visible) || (ec->input_only))
244      return EINA_FALSE;
245    return ((ec->client.x == 0) && (ec->client.y == 0) &&
246        ((ec->client.w) >= e_comp->w) &&
247        ((ec->client.h) >= e_comp->h) &&
248        (!ec->argb) && (!ec->shaped)
249        );
250 }
251 
252 static inline Eina_Bool
e_comp_util_has_x(void)253 e_comp_util_has_x(void)
254 {
255    return !!e_comp->root;
256 }
257 
258 static inline Eina_Bool
e_comp_util_has_xwayland(void)259 e_comp_util_has_xwayland(void)
260 {
261    return (e_comp->comp_type != E_PIXMAP_TYPE_X) && e_comp_util_has_x();
262 }
263 
264 #endif
265 #endif
266