eolian: rename is_ref API to is_ptr to match syntax
[platform/upstream/efl.git] / src / lib / ecore_x / xcb / ecore_xcb_private.h
1 #ifndef __ECORE_XCB_PRIVATE_H__
2 # define __ECORE_XCB_PRIVATE_H__
3
4 //# define LOGFNS 1
5
6 # ifdef HAVE_CONFIG_H
7 #  include "config.h"
8 # endif
9
10 #ifdef STDC_HEADERS
11 # include <stdlib.h>
12 # include <stddef.h>
13 #else
14 # ifdef HAVE_STDLIB_H
15 #  include <stdlib.h>
16 # endif
17 #endif
18
19 # include <unistd.h> // included for close & gethostname functions
20
21 /* generic xcb includes */
22 # include <xcb/xcb.h>
23 # include <xcb/bigreq.h>
24 # include <xcb/shm.h>
25 # include <xcb/xcb_image.h>
26
27 /* EFL includes */
28 # include "Ecore.h"
29 # include "Ecore_Input.h"
30 # include "Ecore_X.h"
31
32 /* logging */
33 extern int _ecore_xcb_log_dom;
34
35 # ifdef ECORE_XCB_DEFAULT_LOG_COLOR
36 #  undef ECORE_XCB_DEFAULT_LOG_COLOR
37 # endif
38 # define ECORE_XCB_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
39
40 # ifdef ERR
41 #  undef ERR
42 # endif
43 # define ERR(...) EINA_LOG_DOM_ERR(_ecore_xcb_log_dom, __VA_ARGS__)
44
45 # ifdef DBG
46 #  undef DBG
47 # endif
48 # define DBG(...) EINA_LOG_DOM_DBG(_ecore_xcb_log_dom, __VA_ARGS__)
49
50 # ifdef INF
51 #  undef INF
52 # endif
53 # define INF(...) EINA_LOG_DOM_INFO(_ecore_xcb_log_dom, __VA_ARGS__)
54
55 # ifdef WRN
56 #  undef WRN
57 # endif
58 # define WRN(...) EINA_LOG_DOM_WARN(_ecore_xcb_log_dom, __VA_ARGS__)
59
60 # ifdef CRI
61 #  undef CRI
62 # endif
63 # define CRI(...)          EINA_LOG_DOM_CRIT(_ecore_xcb_log_dom, __VA_ARGS__)
64
65 # ifdef LOGFNS
66 #  include <stdio.h>
67 #  define LOGFN(fl, ln, fn) printf("-ECORE-XCB: %25s: %5i - %s\n", fl, ln, fn);
68 # else
69 #  define LOGFN(fl, ln, fn)
70 # endif
71
72 # ifndef MAXHOSTNAMELEN
73 #  define MAXHOSTNAMELEN 256
74 # endif
75
76 #define CHECK_XCB_CONN                              \
77   {                                                 \
78      if (!_ecore_xcb_conn || xcb_connection_has_error(_ecore_xcb_conn)) \
79        {                                            \
80           DBG("XCB Connection Has Error !!");       \
81           _ecore_xcb_io_error_handle(NULL);         \
82        }                                            \
83   }
84
85 /* enums */
86 typedef enum _Ecore_Xcb_Encoding_Style Ecore_Xcb_Encoding_Style;
87
88 enum _Ecore_Xcb_Encoding_Style
89 {
90    XcbStringStyle,
91    XcbCompoundTextStyle,
92    XcbTextStyle,
93    XcbStdICCTextStyle,
94    XcbUTF8StringStyle
95 };
96
97 /* structures */
98 typedef struct _Ecore_X_DND_Source          Ecore_X_DND_Source;
99 typedef struct _Ecore_X_DND_Target          Ecore_X_DND_Target;
100 typedef struct _Ecore_X_Selection_Intern    Ecore_X_Selection_Intern;
101 typedef struct _Ecore_X_Selection_Converter Ecore_X_Selection_Converter;
102 typedef struct _Ecore_X_Selection_Parser    Ecore_X_Selection_Parser;
103 typedef struct _Ecore_Xcb_Textproperty      Ecore_Xcb_Textproperty;
104
105 struct _Ecore_X_DND_Source
106 {
107    int            version;
108    Ecore_X_Window win, dest;
109
110    enum
111    {
112       ECORE_X_DND_SOURCE_IDLE,
113       ECORE_X_DND_SOURCE_DRAGGING,
114       ECORE_X_DND_SOURCE_DROPPED,
115       ECORE_X_DND_SOURCE_CONVERTING
116    } state;
117
118    struct
119    {
120       short          x, y;
121       unsigned short width, height;
122    } rectangle;
123
124    struct
125    {
126       Ecore_X_Window window;
127       int            x, y;
128    } prev;
129
130    Ecore_X_Time time;
131
132    Ecore_X_Atom action, accepted_action;
133
134    int          will_accept, suppress;
135    int          await_status;
136 };
137
138 struct _Ecore_X_DND_Target
139 {
140    int            version;
141    Ecore_X_Window win, source;
142
143    enum
144    {
145       ECORE_X_DND_TARGET_IDLE,
146       ECORE_X_DND_TARGET_ENTERED
147    } state;
148
149    struct
150    {
151       int x, y;
152    } pos;
153
154    Ecore_X_Time time;
155
156    Ecore_X_Atom action, accepted_action;
157    int          will_accept;
158 };
159
160 struct _Ecore_X_Selection_Intern
161 {
162    Ecore_X_Window win;
163    Ecore_X_Atom   selection;
164    unsigned char *data;
165    int            length;
166    Ecore_X_Time   time;
167 };
168
169 struct _Ecore_X_Selection_Converter
170 {
171    Ecore_X_Atom                 target;
172    Eina_Bool                    (*convert)(char *target,
173                                            void *data,
174                                            int size,
175                                            void **data_ret,
176                                            int *size_ret,
177                                            Ecore_X_Atom *type,
178                                            int *size_type);
179    Ecore_X_Selection_Converter *next;
180 };
181
182 struct _Ecore_X_Selection_Parser
183 {
184    char                     *target;
185    void                     *(*parse)(const char *target, void *data, int size, int format);
186    Ecore_X_Selection_Parser *next;
187 };
188
189 struct _Ecore_Xcb_Textproperty
190 {
191    char        *value;
192    Ecore_X_Atom encoding;
193    unsigned int format, nitems;
194 };
195
196 /* external variables */
197 extern Ecore_X_Connection *_ecore_xcb_conn;
198 extern Ecore_X_Screen *_ecore_xcb_screen;
199 extern double _ecore_xcb_double_click_time;
200 extern int16_t _ecore_xcb_event_last_root_x;
201 extern int16_t _ecore_xcb_event_last_root_y;
202
203 /* external variables for extension events */
204 extern int _ecore_xcb_event_damage;
205 extern int _ecore_xcb_event_randr;
206 extern int _ecore_xcb_event_screensaver;
207 extern int _ecore_xcb_event_shape;
208 extern int _ecore_xcb_event_sync;
209 extern int _ecore_xcb_event_xfixes;
210 extern int _ecore_xcb_event_input;
211 extern int _ecore_xcb_event_gesture;
212
213 extern Ecore_X_Atom _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_NUM];
214
215 extern int _ecore_xcb_button_grabs_num;
216 extern int _ecore_xcb_key_grabs_num;
217 extern Ecore_X_Window *_ecore_xcb_button_grabs;
218 extern Ecore_X_Window *_ecore_xcb_key_grabs;
219 extern Eina_Bool (*_ecore_xcb_window_grab_replay_func)(void *data,
220                                                        int type,
221                                                        void *event);
222 extern void *_ecore_xcb_window_grab_replay_data;
223
224 /* private function prototypes */
225 void _ecore_xcb_error_handler_init(void);
226 void _ecore_xcb_error_handler_shutdown(void);
227
228 void _ecore_xcb_atoms_init(void);
229 void _ecore_xcb_atoms_finalize(void);
230
231 void _ecore_xcb_extensions_init(void);
232 void _ecore_xcb_extensions_finalize(void);
233
234 void _ecore_xcb_shape_init(void);
235 void _ecore_xcb_shape_finalize(void);
236
237 void _ecore_xcb_screensaver_init(void);
238 void _ecore_xcb_screensaver_finalize(void);
239
240 void _ecore_xcb_sync_init(void);
241 void _ecore_xcb_sync_finalize(void);
242 void _ecore_xcb_sync_magic_send(int val,
243                                 Ecore_X_Window win);
244
245 void                _ecore_xcb_render_init(void);
246 void                _ecore_xcb_render_finalize(void);
247 Eina_Bool           _ecore_xcb_render_argb_get(void);
248 Eina_Bool           _ecore_xcb_render_anim_get(void);
249 Eina_Bool           _ecore_xcb_render_avail_get(void);
250
251 Eina_Bool           _ecore_xcb_render_visual_supports_alpha(Ecore_X_Visual visual);
252 uint32_t            _ecore_xcb_render_find_visual_id(int type,
253                                                      Eina_Bool check_alpha);
254 Ecore_X_Visual     *_ecore_xcb_render_visual_get(int visual_id);
255
256 void                _ecore_xcb_randr_init(void);
257 void                _ecore_xcb_randr_finalize(void);
258
259 void _ecore_xcb_gesture_init(void);
260 void _ecore_xcb_gesture_finalize(void);
261 void _ecore_xcb_gesture_shutdown(void);
262
263 void                _ecore_xcb_xfixes_init(void);
264 void                _ecore_xcb_xfixes_finalize(void);
265 Eina_Bool           _ecore_xcb_xfixes_avail_get(void);
266
267 void                _ecore_xcb_damage_init(void);
268 void                _ecore_xcb_damage_finalize(void);
269
270 void                _ecore_xcb_composite_init(void);
271 void                _ecore_xcb_composite_finalize(void);
272
273 void                _ecore_xcb_present_init(void);
274 void                _ecore_xcb_present_finalize(void);
275 void                _ecore_xcb_event_handle_present_event(xcb_ge_event_t *ev);
276 extern int _ecore_xcb_event_xpresent;
277
278 void                _ecore_xcb_dpms_init(void);
279 void                _ecore_xcb_dpms_finalize(void);
280
281 void                _ecore_xcb_cursor_init(void);
282 void                _ecore_xcb_cursor_finalize(void);
283
284 void                _ecore_xcb_xinerama_init(void);
285 void                _ecore_xcb_xinerama_finalize(void);
286
287 void                _ecore_xcb_dnd_init(void);
288 void                _ecore_xcb_dnd_shutdown(void);
289 Ecore_X_DND_Source *_ecore_xcb_dnd_source_get(void);
290 Ecore_X_DND_Target *_ecore_xcb_dnd_target_get(void);
291 void                _ecore_xcb_dnd_drag(Ecore_X_Window root,
292                                         int x,
293                                         int y);
294
295 void  _ecore_xcb_selection_init(void);
296 void  _ecore_xcb_selection_shutdown(void);
297 void *_ecore_xcb_selection_parse(const char *target,
298                                  void *data,
299                                  int size,
300                                  int format);
301 char                     *_ecore_xcb_selection_target_get(Ecore_X_Atom target);
302 Ecore_X_Selection_Intern *_ecore_xcb_selection_get(Ecore_X_Atom selection);
303
304 # ifdef HAVE_ICONV
305 Eina_Bool _ecore_xcb_utf8_textlist_to_textproperty(char **list,
306                                                    int count,
307                                                    Ecore_Xcb_Encoding_Style style,
308                                                    Ecore_Xcb_Textproperty *ret);
309 # endif
310 Eina_Bool _ecore_xcb_mb_textlist_to_textproperty(char **list,
311                                                  int count,
312                                                  Ecore_Xcb_Encoding_Style style,
313                                                  Ecore_Xcb_Textproperty *ret);
314 Eina_Bool _ecore_xcb_textlist_to_textproperty(const char *type,
315                                               char **list,
316                                               int count,
317                                               Ecore_Xcb_Encoding_Style style,
318                                               Ecore_Xcb_Textproperty *ret);
319
320 # ifdef HAVE_ICONV
321 Eina_Bool _ecore_xcb_utf8_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop,
322                                                    char ***list_ret,
323                                                    int *count_ret);
324 # endif
325 Eina_Bool _ecore_xcb_mb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop,
326                                                  char ***list_ret,
327                                                  int *count_ret);
328 Eina_Bool _ecore_xcb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop,
329                                               const char *type,
330                                               char ***list_ret,
331                                               int *count_ret);
332
333 void         _ecore_xcb_events_init(void);
334 void         _ecore_xcb_events_shutdown(void);
335 void         _ecore_xcb_events_handle(xcb_generic_event_t *ev);
336 Ecore_X_Time _ecore_xcb_events_last_time_get(void);
337 unsigned int _ecore_xcb_events_modifiers_get(unsigned int state);
338 void         _ecore_xcb_event_mouse_move(uint16_t timestamp,
339                                          uint16_t modifiers,
340                                          int16_t x,
341                                          int16_t y,
342                                          int16_t root_x,
343                                          int16_t root_y,
344                                          xcb_window_t event_win,
345                                          xcb_window_t win,
346                                          xcb_window_t root_win,
347                                          uint8_t same_screen,
348                                          int dev,
349                                          double radx,
350                                          double rady,
351                                          double pressure,
352                                          double angle,
353                                          int16_t mx,
354                                          int16_t my,
355                                          int16_t mrx,
356                                          int16_t mry);
357 Ecore_Event_Mouse_Button *_ecore_xcb_event_mouse_button(int event,
358                                                         uint16_t timestamp,
359                                                         uint16_t modifiers,
360                                                         xcb_button_t buttons,
361                                                         int16_t x,
362                                                         int16_t y,
363                                                         int16_t root_x,
364                                                         int16_t root_y,
365                                                         xcb_window_t event_win,
366                                                         xcb_window_t win,
367                                                         xcb_window_t root_win,
368                                                         uint8_t same_screen,
369                                                         int dev,
370                                                         double radx,
371                                                         double rady,
372                                                         double pressure,
373                                                         double angle,
374                                                         int16_t mx,
375                                                         int16_t my,
376                                                         int16_t mrx,
377                                                         int16_t mry);
378
379 void           _ecore_xcb_keymap_init(void);
380 void           _ecore_xcb_keymap_finalize(void);
381 void           _ecore_xcb_keymap_shutdown(void);
382 void           _ecore_xcb_keymap_refresh(xcb_mapping_notify_event_t *event);
383 xcb_keysym_t   _ecore_xcb_keymap_keycode_to_keysym(xcb_keycode_t keycode,
384                                                    int col);
385 xcb_keycode_t *_ecore_xcb_keymap_keysym_to_keycode(xcb_keysym_t keysym);
386 char          *_ecore_xcb_keymap_keysym_to_string(xcb_keysym_t keysym);
387 xcb_keycode_t  _ecore_xcb_keymap_string_to_keycode(const char *key);
388 int            _ecore_xcb_keymap_lookup_string(xcb_keycode_t keycode,
389                                                int state,
390                                                char *buffer,
391                                                int bytes,
392                                                xcb_keysym_t *sym);
393
394 void _ecore_xcb_input_init(void);
395 void _ecore_xcb_input_finalize(void);
396 void _ecore_xcb_input_shutdown(void);
397 # ifdef ECORE_XCB_XINPUT
398 void _ecore_xcb_input_handle_event(xcb_generic_event_t *event);
399 # else
400 void _ecore_xcb_input_handle_event(xcb_generic_event_t *event);
401 # endif
402
403 void           _ecore_xcb_dri_init(void);
404 void           _ecore_xcb_dri_finalize(void);
405
406 void           _ecore_xcb_xtest_init(void);
407 void           _ecore_xcb_xtest_finalize(void);
408
409 Ecore_X_Window _ecore_xcb_window_root_of_screen_get(int screen);
410 void           _ecore_xcb_window_prop_string_utf8_set(Ecore_X_Window win,
411                                                       Ecore_X_Atom atom,
412                                                       const char *str);
413 Ecore_X_Visual _ecore_xcb_window_visual_get(Ecore_X_Window win);
414 void           _ecore_xcb_window_button_grab_remove(Ecore_X_Window win);
415 void           _ecore_xcb_window_key_grab_remove(Ecore_X_Window win);
416 void           _ecore_xcb_window_grab_allow_events(Ecore_X_Window event_win,
417                                                    Ecore_X_Window child_win,
418                                                    int type,
419                                                    void *event,
420                                                    Ecore_X_Time timestamp);
421
422 int                  _ecore_xcb_netwm_startup_info_begin(Ecore_X_Window win,
423                                                          uint8_t data);
424 int                  _ecore_xcb_netwm_startup_info(Ecore_X_Window win,
425                                                    uint8_t data);
426 Ecore_X_Window_State _ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom);
427
428 int                  _ecore_xcb_error_handle(xcb_generic_error_t *err);
429 int                  _ecore_xcb_io_error_handle(xcb_generic_error_t *err);
430
431 xcb_image_t         *_ecore_xcb_image_create_native(int w,
432                                                     int h,
433                                                     xcb_image_format_t format,
434                                                     uint8_t depth,
435                                                     void *base,
436                                                     uint32_t bytes,
437                                                     uint8_t *data);
438
439 void  _ecore_xcb_xdefaults_init(void);
440 void  _ecore_xcb_xdefaults_shutdown(void);
441 char *_ecore_xcb_xdefaults_string_get(const char *prog,
442                                       const char *param);
443 int   _ecore_xcb_xdefaults_int_get(const char *prog,
444                                    const char *param);
445
446 void _ecore_xcb_modifiers_get(void);
447
448 #endif