summaryrefslogtreecommitdiff
path: root/src/lib/ecore_x
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-01 23:04:47 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-03 22:22:54 +0900
commit4ed2e01591e1575800d9aa871f76a5f7559060b3 (patch)
treee2ff598e015fecd3f26a9c717a2bae1334e1bb1d /src/lib/ecore_x
parentf399e77a92fc6d2cf92ab097eebc984a039bf223 (diff)
remove xcb support in ecore_x and evas engines as per mailing list
as per mailing list discussion about dropping xcb support now. it hasn't been complete for a long time, thus not recommented for being turned on. as we are moving to a wayland world xcbmakes even less sense. as agreed, time to clean up a bit and remove a distraction as well as not well tested code. this also updates po's too. @feature
Diffstat (limited to 'src/lib/ecore_x')
-rw-r--r--src/lib/ecore_x/Ecore_X.h10
-rw-r--r--src/lib/ecore_x/ecore_x.c (renamed from src/lib/ecore_x/xlib/ecore_x.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_atoms.c (renamed from src/lib/ecore_x/xlib/ecore_x_atoms.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_composite.c (renamed from src/lib/ecore_x/xlib/ecore_x_composite.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_cursor.c (renamed from src/lib/ecore_x/xlib/ecore_x_cursor.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_damage.c (renamed from src/lib/ecore_x/xlib/ecore_x_damage.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_dnd.c (renamed from src/lib/ecore_x/xlib/ecore_x_dnd.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_dpms.c (renamed from src/lib/ecore_x/xlib/ecore_x_dpms.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_drawable.c (renamed from src/lib/ecore_x/xlib/ecore_x_drawable.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_e.c (renamed from src/lib/ecore_x/xlib/ecore_x_e.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_error.c (renamed from src/lib/ecore_x/xlib/ecore_x_error.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_events.c (renamed from src/lib/ecore_x/xlib/ecore_x_events.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_fixes.c (renamed from src/lib/ecore_x/xlib/ecore_x_fixes.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_gc.c (renamed from src/lib/ecore_x/xlib/ecore_x_gc.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_gesture.c (renamed from src/lib/ecore_x/xlib/ecore_x_gesture.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_icccm.c (renamed from src/lib/ecore_x/xlib/ecore_x_icccm.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_image.c (renamed from src/lib/ecore_x/xlib/ecore_x_image.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_keygrab.c (renamed from src/lib/ecore_x/xlib/ecore_x_keygrab.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_mwm.c (renamed from src/lib/ecore_x/xlib/ecore_x_mwm.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_netwm.c (renamed from src/lib/ecore_x/xlib/ecore_x_netwm.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_pixmap.c (renamed from src/lib/ecore_x/xlib/ecore_x_pixmap.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_present.c (renamed from src/lib/ecore_x/xlib/ecore_x_present.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_private.h (renamed from src/lib/ecore_x/xlib/ecore_x_private.h)0
-rw-r--r--src/lib/ecore_x/ecore_x_randr.c (renamed from src/lib/ecore_x/xlib/ecore_x_randr.c)2
-rw-r--r--src/lib/ecore_x/ecore_x_region.c (renamed from src/lib/ecore_x/xlib/ecore_x_region.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_screensaver.c (renamed from src/lib/ecore_x/xlib/ecore_x_screensaver.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_selection.c (renamed from src/lib/ecore_x/xlib/ecore_x_selection.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_sync.c (renamed from src/lib/ecore_x/xlib/ecore_x_sync.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_test.c (renamed from src/lib/ecore_x/xlib/ecore_x_test.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_vsync.c (renamed from src/lib/ecore_x/xlib/ecore_x_vsync.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_window.c (renamed from src/lib/ecore_x/xlib/ecore_x_window.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_window_prop.c (renamed from src/lib/ecore_x/xlib/ecore_x_window_prop.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_window_shape.c (renamed from src/lib/ecore_x/xlib/ecore_x_window_shape.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_xi2.c (renamed from src/lib/ecore_x/xlib/ecore_x_xi2.c)0
-rw-r--r--src/lib/ecore_x/ecore_x_xinerama.c (renamed from src/lib/ecore_x/xlib/ecore_x_xinerama.c)0
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb.c1605
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_atoms.c155
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_composite.c291
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_cursor.c400
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_damage.c156
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_dnd.c720
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_dpms.c354
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_drawable.c124
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_e.c2266
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_error.c116
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_events.c2831
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_extensions.c156
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_gc.c173
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_gesture.c203
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_icccm.c1259
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_image.c782
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_input.c295
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_keygrab.c442
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_keymap.c534
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_mwm.c105
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_netwm.c1590
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_pixmap.c129
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_present.c200
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_private.h448
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_randr.c4323
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_region.c159
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_render.c225
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_screensaver.c404
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_selection.c1111
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_shape.c50
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_sync.c338
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_textlist.c509
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_vsync.c375
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window.c2255
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window_prop.c689
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c410
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window_shape.c791
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c120
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xfixes.c745
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xinerama.c139
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xtest.c215
76 files changed, 3 insertions, 28201 deletions
diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h
index 7337ae2..e732fb9 100644
--- a/src/lib/ecore_x/Ecore_X.h
+++ b/src/lib/ecore_x/Ecore_X.h
@@ -72,8 +72,8 @@ EAPI extern Ecore_X_Version *ecore_x_version;
72 * @li @ref Ecore_X_Window_Parent_Group 72 * @li @ref Ecore_X_Window_Parent_Group
73 * @li @ref Ecore_X_Window_Shape 73 * @li @ref Ecore_X_Window_Shape
74 * 74 *
75 * When using the XLib backend, setting the ECORE_X_SYNC environment variable 75 * The ECORE_X_SYNC environment variable will cause X calls to be run
76 * will cause X calls to be run synchronously for easier debugging. 76 * synchronously for easier debugging.
77 */ 77 */
78 78
79typedef unsigned int Ecore_X_ID; 79typedef unsigned int Ecore_X_ID;
@@ -89,11 +89,7 @@ typedef struct _Ecore_X_Icon
89#endif // ifndef _ECORE_X_WINDOW_PREDEF 89#endif // ifndef _ECORE_X_WINDOW_PREDEF
90typedef void *Ecore_X_Visual; 90typedef void *Ecore_X_Visual;
91typedef Ecore_X_ID Ecore_X_Drawable; 91typedef Ecore_X_ID Ecore_X_Drawable;
92#ifdef HAVE_ECORE_X_XCB
93typedef Ecore_X_ID Ecore_X_GC;
94#else // ifdef HAVE_ECORE_X_XCB
95typedef void *Ecore_X_GC; 92typedef void *Ecore_X_GC;
96#endif /* HAVE_ECORE_X_XCB */
97typedef Ecore_X_ID Ecore_X_Colormap; 93typedef Ecore_X_ID Ecore_X_Colormap;
98typedef Ecore_X_ID Ecore_X_Time; 94typedef Ecore_X_ID Ecore_X_Time;
99typedef Ecore_X_ID Ecore_X_Cursor; 95typedef Ecore_X_ID Ecore_X_Cursor;
@@ -1118,7 +1114,7 @@ struct Ecore_X_Event_Present_Idle
1118}; /**< @since 1.9 */ 1114}; /**< @since 1.9 */
1119 1115
1120EAPI extern int ECORE_X_EVENT_ANY; /**< low level event dependent on 1116EAPI extern int ECORE_X_EVENT_ANY; /**< low level event dependent on
1121 backend in use, if Xlib will be XEvent, if XCB will be xcb_generic_event_t. 1117 backend in use, will be XEvent.
1122 @warning avoid using it. 1118 @warning avoid using it.
1123 */ 1119 */
1124EAPI extern int ECORE_X_EVENT_MOUSE_IN; 1120EAPI extern int ECORE_X_EVENT_MOUSE_IN;
diff --git a/src/lib/ecore_x/xlib/ecore_x.c b/src/lib/ecore_x/ecore_x.c
index ae8b5bd..ae8b5bd 100644
--- a/src/lib/ecore_x/xlib/ecore_x.c
+++ b/src/lib/ecore_x/ecore_x.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_atoms.c b/src/lib/ecore_x/ecore_x_atoms.c
index 5276238..5276238 100644
--- a/src/lib/ecore_x/xlib/ecore_x_atoms.c
+++ b/src/lib/ecore_x/ecore_x_atoms.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_composite.c b/src/lib/ecore_x/ecore_x_composite.c
index 913839f..913839f 100644
--- a/src/lib/ecore_x/xlib/ecore_x_composite.c
+++ b/src/lib/ecore_x/ecore_x_composite.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_cursor.c b/src/lib/ecore_x/ecore_x_cursor.c
index 46ac42e..46ac42e 100644
--- a/src/lib/ecore_x/xlib/ecore_x_cursor.c
+++ b/src/lib/ecore_x/ecore_x_cursor.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_damage.c b/src/lib/ecore_x/ecore_x_damage.c
index c5906b4..c5906b4 100644
--- a/src/lib/ecore_x/xlib/ecore_x_damage.c
+++ b/src/lib/ecore_x/ecore_x_damage.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_dnd.c b/src/lib/ecore_x/ecore_x_dnd.c
index d673094..d673094 100644
--- a/src/lib/ecore_x/xlib/ecore_x_dnd.c
+++ b/src/lib/ecore_x/ecore_x_dnd.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_dpms.c b/src/lib/ecore_x/ecore_x_dpms.c
index a44825c..a44825c 100644
--- a/src/lib/ecore_x/xlib/ecore_x_dpms.c
+++ b/src/lib/ecore_x/ecore_x_dpms.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_drawable.c b/src/lib/ecore_x/ecore_x_drawable.c
index e0edbe2..e0edbe2 100644
--- a/src/lib/ecore_x/xlib/ecore_x_drawable.c
+++ b/src/lib/ecore_x/ecore_x_drawable.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_e.c b/src/lib/ecore_x/ecore_x_e.c
index 742d9d6..742d9d6 100644
--- a/src/lib/ecore_x/xlib/ecore_x_e.c
+++ b/src/lib/ecore_x/ecore_x_e.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_error.c b/src/lib/ecore_x/ecore_x_error.c
index ad3d322..ad3d322 100644
--- a/src/lib/ecore_x/xlib/ecore_x_error.c
+++ b/src/lib/ecore_x/ecore_x_error.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/ecore_x_events.c
index 0049fca..0049fca 100644
--- a/src/lib/ecore_x/xlib/ecore_x_events.c
+++ b/src/lib/ecore_x/ecore_x_events.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_fixes.c b/src/lib/ecore_x/ecore_x_fixes.c
index 012e458..012e458 100644
--- a/src/lib/ecore_x/xlib/ecore_x_fixes.c
+++ b/src/lib/ecore_x/ecore_x_fixes.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_gc.c b/src/lib/ecore_x/ecore_x_gc.c
index 6b8168b..6b8168b 100644
--- a/src/lib/ecore_x/xlib/ecore_x_gc.c
+++ b/src/lib/ecore_x/ecore_x_gc.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_gesture.c b/src/lib/ecore_x/ecore_x_gesture.c
index 15a9efd..15a9efd 100644
--- a/src/lib/ecore_x/xlib/ecore_x_gesture.c
+++ b/src/lib/ecore_x/ecore_x_gesture.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_icccm.c b/src/lib/ecore_x/ecore_x_icccm.c
index d335fd2..d335fd2 100644
--- a/src/lib/ecore_x/xlib/ecore_x_icccm.c
+++ b/src/lib/ecore_x/ecore_x_icccm.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_image.c b/src/lib/ecore_x/ecore_x_image.c
index 016323c..016323c 100644
--- a/src/lib/ecore_x/xlib/ecore_x_image.c
+++ b/src/lib/ecore_x/ecore_x_image.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_keygrab.c b/src/lib/ecore_x/ecore_x_keygrab.c
index 4ed762d..4ed762d 100644
--- a/src/lib/ecore_x/xlib/ecore_x_keygrab.c
+++ b/src/lib/ecore_x/ecore_x_keygrab.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_mwm.c b/src/lib/ecore_x/ecore_x_mwm.c
index c2d298b..c2d298b 100644
--- a/src/lib/ecore_x/xlib/ecore_x_mwm.c
+++ b/src/lib/ecore_x/ecore_x_mwm.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_netwm.c b/src/lib/ecore_x/ecore_x_netwm.c
index 83615e7..83615e7 100644
--- a/src/lib/ecore_x/xlib/ecore_x_netwm.c
+++ b/src/lib/ecore_x/ecore_x_netwm.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_pixmap.c b/src/lib/ecore_x/ecore_x_pixmap.c
index 30903c1..30903c1 100644
--- a/src/lib/ecore_x/xlib/ecore_x_pixmap.c
+++ b/src/lib/ecore_x/ecore_x_pixmap.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_present.c b/src/lib/ecore_x/ecore_x_present.c
index eb190b7..eb190b7 100644
--- a/src/lib/ecore_x/xlib/ecore_x_present.c
+++ b/src/lib/ecore_x/ecore_x_present.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_private.h b/src/lib/ecore_x/ecore_x_private.h
index 07c09fb..07c09fb 100644
--- a/src/lib/ecore_x/xlib/ecore_x_private.h
+++ b/src/lib/ecore_x/ecore_x_private.h
diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c b/src/lib/ecore_x/ecore_x_randr.c
index 03da850..f2288cc 100644
--- a/src/lib/ecore_x/xlib/ecore_x_randr.c
+++ b/src/lib/ecore_x/ecore_x_randr.c
@@ -1966,8 +1966,6 @@ ecore_x_randr_crtc_info_free(Ecore_X_Randr_Crtc_Info *info)
1966 * @param mode The mode added to the output. 1966 * @param mode The mode added to the output.
1967 * @return @c EINA_FALSE if output or mode equal Ecore_X_Randr_None, else 1967 * @return @c EINA_FALSE if output or mode equal Ecore_X_Randr_None, else
1968 * @c EINA_TRUE. 1968 * @c EINA_TRUE.
1969 * Additionally, if xcb backend is used, the success of the addition is
1970 * reported back directly.
1971 * @since 1.2.0 1969 * @since 1.2.0
1972 */ 1970 */
1973EAPI Eina_Bool 1971EAPI Eina_Bool
diff --git a/src/lib/ecore_x/xlib/ecore_x_region.c b/src/lib/ecore_x/ecore_x_region.c
index 01f1fa7..01f1fa7 100644
--- a/src/lib/ecore_x/xlib/ecore_x_region.c
+++ b/src/lib/ecore_x/ecore_x_region.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_screensaver.c b/src/lib/ecore_x/ecore_x_screensaver.c
index 8c186ea..8c186ea 100644
--- a/src/lib/ecore_x/xlib/ecore_x_screensaver.c
+++ b/src/lib/ecore_x/ecore_x_screensaver.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_selection.c b/src/lib/ecore_x/ecore_x_selection.c
index ff0480d..ff0480d 100644
--- a/src/lib/ecore_x/xlib/ecore_x_selection.c
+++ b/src/lib/ecore_x/ecore_x_selection.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_sync.c b/src/lib/ecore_x/ecore_x_sync.c
index 0c7f546..0c7f546 100644
--- a/src/lib/ecore_x/xlib/ecore_x_sync.c
+++ b/src/lib/ecore_x/ecore_x_sync.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_test.c b/src/lib/ecore_x/ecore_x_test.c
index f552910..f552910 100644
--- a/src/lib/ecore_x/xlib/ecore_x_test.c
+++ b/src/lib/ecore_x/ecore_x_test.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_vsync.c b/src/lib/ecore_x/ecore_x_vsync.c
index ee43406..ee43406 100644
--- a/src/lib/ecore_x/xlib/ecore_x_vsync.c
+++ b/src/lib/ecore_x/ecore_x_vsync.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_window.c b/src/lib/ecore_x/ecore_x_window.c
index 444538a..444538a 100644
--- a/src/lib/ecore_x/xlib/ecore_x_window.c
+++ b/src/lib/ecore_x/ecore_x_window.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_window_prop.c b/src/lib/ecore_x/ecore_x_window_prop.c
index 043e50e..043e50e 100644
--- a/src/lib/ecore_x/xlib/ecore_x_window_prop.c
+++ b/src/lib/ecore_x/ecore_x_window_prop.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_window_shape.c b/src/lib/ecore_x/ecore_x_window_shape.c
index 987aa07..987aa07 100644
--- a/src/lib/ecore_x/xlib/ecore_x_window_shape.c
+++ b/src/lib/ecore_x/ecore_x_window_shape.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_xi2.c b/src/lib/ecore_x/ecore_x_xi2.c
index 089c2a7..089c2a7 100644
--- a/src/lib/ecore_x/xlib/ecore_x_xi2.c
+++ b/src/lib/ecore_x/ecore_x_xi2.c
diff --git a/src/lib/ecore_x/xlib/ecore_x_xinerama.c b/src/lib/ecore_x/ecore_x_xinerama.c
index 4a591f9..4a591f9 100644
--- a/src/lib/ecore_x/xlib/ecore_x_xinerama.c
+++ b/src/lib/ecore_x/ecore_x_xinerama.c
diff --git a/src/lib/ecore_x/xcb/ecore_xcb.c b/src/lib/ecore_x/xcb/ecore_xcb.c
deleted file mode 100644
index 9e08aef..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb.c
+++ /dev/null
@@ -1,1605 +0,0 @@
1#include "ecore_xcb_private.h"
2#include <X11/Xlib-xcb.h>
3#include <dlfcn.h>
4
5/* local function prototypes */
6static int _ecore_xcb_shutdown(Eina_Bool close_display);
7static Eina_Bool _ecore_xcb_fd_handle(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED);
8static Eina_Bool _ecore_xcb_fd_handle_buff(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED);
9static Eina_Bool _ecore_xcb_idle_enter(void *data EINA_UNUSED);
10
11/* local variables */
12static int _ecore_xcb_init_count = 0;
13static int _ecore_xcb_grab_count = 0;
14static Ecore_Fd_Handler *_ecore_xcb_fd_handler = NULL;
15static xcb_generic_event_t *_ecore_xcb_event_buffered = NULL;
16static Ecore_Idle_Enterer *_ecore_xcb_idle_enterer = NULL;
17
18static Ecore_X_Version _version = { VMAJ, VMIN, VMIC, VREV };
19EAPI Ecore_X_Version *ecore_x_version = &_version;
20
21/* external variables */
22int _ecore_xcb_log_dom = -1;
23Ecore_X_Display *_ecore_xcb_display = NULL;
24Ecore_X_Connection *_ecore_xcb_conn = NULL;
25Ecore_X_Screen *_ecore_xcb_screen = NULL;
26Ecore_X_Atom _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_NUM];
27double _ecore_xcb_double_click_time = 0.25;
28
29/**
30 * @defgroup Ecore_X_Init_Group X Library Init and Shutdown Functions
31 * @ingroup Ecore_X_Group
32 *
33 * Functions that start and shut down the Ecore X Library.
34 */
35
36static int
37_ecore_x_init(const char *name, Ecore_X_Display *display)
38{
39 char *gl = NULL;
40 uint32_t mask, list[1];
41
42 /* check if we have initialized already */
43 if (++_ecore_xcb_init_count != 1)
44 return _ecore_xcb_init_count;
45
46 LOGFN(__FILE__, __LINE__, __FUNCTION__);
47
48 /* try to initialize eina */
49 if (!eina_init()) return --_ecore_xcb_init_count;
50
51 /* setup ecore_xcb log domain */
52 _ecore_xcb_log_dom =
53 eina_log_domain_register("ecore_x", ECORE_XCB_DEFAULT_LOG_COLOR);
54 if (_ecore_xcb_log_dom < 0)
55 {
56 EINA_LOG_ERR("Cannot create Ecore Xcb log domain");
57 eina_shutdown();
58 return --_ecore_xcb_init_count;
59 }
60
61 /* try to initialize ecore */
62 if (!ecore_init())
63 {
64 /* unregister log domain */
65 eina_log_domain_unregister(_ecore_xcb_log_dom);
66 _ecore_xcb_log_dom = -1;
67 eina_shutdown();
68 return --_ecore_xcb_init_count;
69 }
70
71 /* try to initialize ecore_event */
72 if (!ecore_event_init())
73 {
74 /* unregister log domain */
75 eina_log_domain_unregister(_ecore_xcb_log_dom);
76 _ecore_xcb_log_dom = -1;
77 ecore_shutdown();
78 eina_shutdown();
79 return --_ecore_xcb_init_count;
80 }
81
82 /* NB: XLib has XInitThreads */
83
84 /* check for env var which says we are not going to use GL @ all
85 *
86 * NB: This is done because if someone wants a 'pure' xcb implementation
87 * of ecore_x, all they need do is export this variable in the environment
88 * and ecore_x will not use xlib stuff at all.
89 *
90 * The upside is you can get pure xcb-based ecore_x (w/ all the speed), but
91 * there is a down-side here in that you cannot get OpenGL without XLib :(
92 */
93 if ((gl = getenv("ECORE_X_NO_XLIB")))
94 {
95 /* we found the env var that says 'Yes, we are not ever gonna try
96 * OpenGL so it is safe to not use XLib at all' */
97
98 /* try to connect to the display server */
99 _ecore_xcb_conn = xcb_connect(name, NULL);
100 }
101 else
102 {
103 /* env var was not specified, so we will assume that the user
104 * may want opengl @ some point. connect this way for opengl to work */
105 void *libxcb, *libxlib;
106 Display *(*_real_display)(const char *display);
107 xcb_connection_t *(*_real_connection)(Display * dpy);
108 void (*_real_queue)(Display *dpy, enum XEventQueueOwner owner);
109 int (*_real_close)(Display *dpy);
110#ifdef EVAS_FRAME_QUEUING
111 Status (*_real_threads)(void);
112#endif
113
114 /* want to dlopen here to avoid actual library linkage */
115 libxlib = dlopen("libX11.so", (RTLD_LAZY | RTLD_GLOBAL));
116 if (!libxlib)
117 libxlib = dlopen("libX11.so.6", (RTLD_LAZY | RTLD_GLOBAL));
118 if (!libxlib)
119 libxlib = dlopen("libX11.so.6.3.0", (RTLD_LAZY | RTLD_GLOBAL));
120 if (!libxlib)
121 {
122 ERR("Could not dlsym to libX11");
123 /* unregister log domain */
124 eina_log_domain_unregister(_ecore_xcb_log_dom);
125 _ecore_xcb_log_dom = -1;
126 ecore_event_shutdown();
127 ecore_shutdown();
128 eina_shutdown();
129 return --_ecore_xcb_init_count;
130 }
131
132 libxcb = dlopen("libX11-xcb.so", (RTLD_LAZY | RTLD_GLOBAL));
133 if (!libxcb)
134 libxcb = dlopen("libX11-xcb.so.1", (RTLD_LAZY | RTLD_GLOBAL));
135 if (!libxcb)
136 libxcb = dlopen("libX11-xcb.so.1.0.0", (RTLD_LAZY | RTLD_GLOBAL));
137 if (!libxcb)
138 {
139 ERR("Could not dlsym to libX11-xcb");
140 /* unregister log domain */
141 eina_log_domain_unregister(_ecore_xcb_log_dom);
142 _ecore_xcb_log_dom = -1;
143 ecore_event_shutdown();
144 ecore_shutdown();
145 eina_shutdown();
146 return --_ecore_xcb_init_count;
147 }
148
149 _real_display = dlsym(libxlib, "XOpenDisplay");
150 _real_close = dlsym(libxlib, "XCloseDisplay");
151 _real_connection = dlsym(libxcb, "XGetXCBConnection");
152 _real_queue = dlsym(libxcb, "XSetEventQueueOwner");
153#ifdef EVAS_FRAME_QUEUING
154 _real_threads = dlsym(libxlib, "XInitThreads");
155#endif
156
157 if (_real_display)
158 {
159#ifdef EVAS_FRAME_QUEUING
160 if (_real_threads) _real_threads();
161#endif
162 _ecore_xcb_display = display ? display : _real_display(name);
163 if (!_ecore_xcb_display)
164 {
165 ERR("Could not open Display via XLib");
166 /* unregister log domain */
167 eina_log_domain_unregister(_ecore_xcb_log_dom);
168 _ecore_xcb_log_dom = -1;
169 ecore_event_shutdown();
170 ecore_shutdown();
171 eina_shutdown();
172 return --_ecore_xcb_init_count;
173 }
174 if (_real_connection)
175 _ecore_xcb_conn = _real_connection(_ecore_xcb_display);
176 if (!_ecore_xcb_conn)
177 {
178 ERR("Could not get XCB Connection from XLib");
179
180 if (_real_close) _real_close(_ecore_xcb_display);
181
182 /* unregister log domain */
183 eina_log_domain_unregister(_ecore_xcb_log_dom);
184 _ecore_xcb_log_dom = -1;
185 ecore_event_shutdown();
186 ecore_shutdown();
187 eina_shutdown();
188 return --_ecore_xcb_init_count;
189 }
190 if (_real_queue)
191 _real_queue(_ecore_xcb_display, XCBOwnsEventQueue);
192 }
193 }
194
195 if (xcb_connection_has_error(_ecore_xcb_conn))
196 {
197 CRI("XCB Connection has error");
198 eina_log_domain_unregister(_ecore_xcb_log_dom);
199 _ecore_xcb_log_dom = -1;
200 ecore_event_shutdown();
201 ecore_shutdown();
202 eina_shutdown();
203 return --_ecore_xcb_init_count;
204 }
205
206 /* grab the default screen */
207 _ecore_xcb_screen =
208 xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data;
209
210 /* NB: This method of init/finalize extensions first, then atoms
211 * Does end up being 2 round trips to X, BUT if we do extensions init then
212 * atoms init first, and call the 'finalize' functions later, we end up
213 * being slower, so it's a trade-off. This current method clocks in
214 * around 0.003 for fetching atoms VS 0.010 for init both then finalize */
215
216 /* prefetch extension data */
217 _ecore_xcb_extensions_init();
218
219 /* finalize extensions */
220 _ecore_xcb_extensions_finalize();
221
222 /* set keyboard autorepeat */
223 mask = XCB_KB_AUTO_REPEAT_MODE;
224 list[0] = XCB_AUTO_REPEAT_MODE_ON;
225 xcb_change_keyboard_control(_ecore_xcb_conn, mask, list);
226
227 /* setup xcb events */
228 _ecore_xcb_events_init();
229
230 /* setup xcb keymasks */
231 _ecore_xcb_keymap_init();
232
233 /* finalize xcb keymasks */
234 _ecore_xcb_keymap_finalize();
235
236 /* prefetch atoms */
237 _ecore_xcb_atoms_init();
238
239 /* finalize atoms */
240 _ecore_xcb_atoms_finalize();
241
242 /* icccm_init: dummy function */
243 ecore_x_icccm_init();
244
245 /* setup netwm */
246 ecore_x_netwm_init();
247
248 /* old e hints init: dummy function */
249 ecore_x_e_init();
250
251 _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] =
252 ECORE_X_ATOM_WM_DELETE_WINDOW;
253 _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] =
254 ECORE_X_ATOM_WM_TAKE_FOCUS;
255 _ecore_xcb_atoms_wm_protocol[ECORE_X_NET_WM_PROTOCOL_PING] =
256 ECORE_X_ATOM_NET_WM_PING;
257 _ecore_xcb_atoms_wm_protocol[ECORE_X_NET_WM_PROTOCOL_SYNC_REQUEST] =
258 ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
259
260 /* setup selection */
261 _ecore_xcb_selection_init();
262
263 /* setup dnd */
264 _ecore_xcb_dnd_init();
265
266 _ecore_xcb_idle_enterer =
267 ecore_idle_enterer_add(_ecore_xcb_idle_enter, NULL);
268
269 /* setup ecore fd handler */
270 _ecore_xcb_fd_handler =
271 ecore_main_fd_handler_add(xcb_get_file_descriptor(_ecore_xcb_conn),
272 ECORE_FD_READ, _ecore_xcb_fd_handle,
273 _ecore_xcb_conn, _ecore_xcb_fd_handle_buff,
274 _ecore_xcb_conn);
275
276 if (!_ecore_xcb_fd_handler)
277 return _ecore_xcb_shutdown(EINA_TRUE);
278
279 return _ecore_xcb_init_count;
280}
281
282/**
283 * Initialize the X display connection to the given display.
284 *
285 * @param name Display target name. If @c NULL, the default display is
286 * assumed.
287 * @return The number of times the library has been initialized without
288 * being shut down. 0 is returned if an error occurs.
289 * @ingroup Ecore_X_Init_Group
290 */
291EAPI int
292ecore_x_init(const char *name)
293{
294 return _ecore_x_init(name, NULL);
295}
296
297EAPI int
298ecore_x_init_from_display(Ecore_X_Display *display)
299{
300 EINA_SAFETY_ON_NULL_RETURN_VAL(display, 0);
301 return _ecore_x_init(NULL, display);
302}
303
304/**
305 * Shuts down the Ecore X library.
306 *
307 * In shutting down the library, the X display connection is terminated
308 * and any event handlers for it are removed.
309 *
310 * @return The number of times the library has been initialized without
311 * being shut down.
312 * @ingroup Ecore_X_Init_Group
313 */
314EAPI int
315ecore_x_shutdown(void)
316{
317 return _ecore_xcb_shutdown(EINA_TRUE);
318}
319
320/**
321 * Shuts down the Ecore X library.
322 *
323 * As ecore_x_shutdown, except do not close Display, only connection.
324 *
325 * @return The number of times the library has been initialized without
326 * being shut down. 0 is returned if an error occurs.
327 * @ingroup Ecore_X_Init_Group
328 */
329EAPI int
330ecore_x_disconnect(void)
331{
332 return _ecore_xcb_shutdown(EINA_FALSE);
333}
334
335/**
336 * @defgroup Ecore_X_Flush_Group X Synchronization Functions
337 * @ingroup Ecore_X_Group
338 *
339 * Functions that ensure that all commands that have been issued by the
340 * Ecore X library have been sent to the server.
341 */
342
343/**
344 * Sends all X commands in the X Display buffer.
345 * @ingroup Ecore_X_Flush_Group
346 */
347EAPI void
348ecore_x_flush(void)
349{
350// LOGFN(__FILE__, __LINE__, __FUNCTION__);
351
352 CHECK_XCB_CONN;
353 xcb_flush(_ecore_xcb_conn);
354}
355
356/**
357 * Retrieves the Ecore_X_Screen handle used for the current X connection.
358 * @return The current default screen.
359 * @ingroup Ecore_X_Display_Attr_Group
360 */
361EAPI Ecore_X_Screen *
362ecore_x_default_screen_get(void)
363{
364 LOGFN(__FILE__, __LINE__, __FUNCTION__);
365
366 return (Ecore_X_Screen *)_ecore_xcb_screen;
367}
368
369EAPI Ecore_X_Connection *
370ecore_x_connection_get(void)
371{
372 LOGFN(__FILE__, __LINE__, __FUNCTION__);
373
374 CHECK_XCB_CONN;
375 return (Ecore_X_Connection *)_ecore_xcb_conn;
376}
377
378/**
379 * Return the last event time
380 */
381EAPI Ecore_X_Time
382ecore_x_current_time_get(void)
383{
384 return _ecore_xcb_events_last_time_get();
385}
386
387/**
388 * Flushes the command buffer and waits until all requests have been
389 * processed by the server.
390 * @ingroup Ecore_X_Flush_Group
391 */
392EAPI void
393ecore_x_sync(void)
394{
395 LOGFN(__FILE__, __LINE__, __FUNCTION__);
396
397 CHECK_XCB_CONN;
398 free(xcb_get_input_focus_reply(_ecore_xcb_conn,
399 xcb_get_input_focus_unchecked(_ecore_xcb_conn),
400 NULL));
401}
402
403EAPI void
404ecore_x_grab(void)
405{
406 LOGFN(__FILE__, __LINE__, __FUNCTION__);
407
408 CHECK_XCB_CONN;
409 _ecore_xcb_grab_count++;
410 if (_ecore_xcb_grab_count == 1)
411 xcb_grab_server(_ecore_xcb_conn);
412}
413
414EAPI void
415ecore_x_ungrab(void)
416{
417 LOGFN(__FILE__, __LINE__, __FUNCTION__);
418
419 CHECK_XCB_CONN;
420 _ecore_xcb_grab_count--;
421 if (_ecore_xcb_grab_count < 0) _ecore_xcb_grab_count = 0;
422 if (_ecore_xcb_grab_count == 0)
423 xcb_ungrab_server(_ecore_xcb_conn);
424}
425
426/**
427 * Send client message with given type and format 32.
428 *
429 * @param win The window the message is sent to.
430 * @param type The client message type.
431 * @param mask The mask of the message to be sent.
432 * @param d0 The client message data item 1
433 * @param d1 The client message data item 2
434 * @param d2 The client message data item 3
435 * @param d3 The client message data item 4
436 * @param d4 The client message data item 5
437 *
438 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise.
439 */
440EAPI Eina_Bool
441ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type,
442 Ecore_X_Event_Mask mask,
443 long d0, long d1, long d2, long d3, long d4)
444{
445 xcb_client_message_event_t ev;
446 xcb_void_cookie_t cookie;
447 xcb_generic_error_t *err;
448
449 LOGFN(__FILE__, __LINE__, __FUNCTION__);
450 CHECK_XCB_CONN;
451
452 memset(&ev, 0, sizeof(xcb_client_message_event_t));
453
454 ev.response_type = XCB_CLIENT_MESSAGE;
455 ev.format = 32;
456 ev.window = win;
457 ev.type = type;
458 ev.data.data32[0] = (uint32_t)d0;
459 ev.data.data32[1] = (uint32_t)d1;
460 ev.data.data32[2] = (uint32_t)d2;
461 ev.data.data32[3] = (uint32_t)d3;
462 ev.data.data32[4] = (uint32_t)d4;
463
464 cookie = xcb_send_event(_ecore_xcb_conn, 0, win, mask, (const char *)&ev);
465
466 err = xcb_request_check(_ecore_xcb_conn, cookie);
467 if (err)
468 {
469 DBG("Problem Sending Event");
470 DBG("\tType: %d", type);
471 DBG("\tWin: %d", win);
472 _ecore_xcb_error_handle(err);
473 free(err);
474 return EINA_FALSE;
475 }
476
477 return EINA_TRUE;
478}
479
480/**
481 * Send client message with given type and format 8.
482 *
483 * @param win The window the message is sent to.
484 * @param type The client message type.
485 * @param data Data to be sent.
486 * @param len Number of data bytes, max @c 20.
487 *
488 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise.
489 */
490EAPI Eina_Bool
491ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type,
492 const void *data, int len)
493{
494 xcb_client_message_event_t ev;
495 xcb_void_cookie_t cookie;
496 xcb_generic_error_t *err;
497
498 LOGFN(__FILE__, __LINE__, __FUNCTION__);
499 CHECK_XCB_CONN;
500
501 memset(&ev, 0, sizeof(xcb_client_message_event_t));
502
503 ev.response_type = XCB_CLIENT_MESSAGE;
504 ev.format = 8;
505 ev.window = win;
506 ev.type = type;
507 if (len > 20)
508 len = 20;
509 if (data && len > 0)
510 memcpy(ev.data.data8, data, len);
511 if (len < 20)
512 memset(ev.data.data8 + len, 0, 20 - len);
513
514 cookie = xcb_send_event(_ecore_xcb_conn, 0, win,
515 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
516
517 err = xcb_request_check(_ecore_xcb_conn, cookie);
518 if (err)
519 {
520 DBG("Problem Sending Event");
521 DBG("\tType: %d", type);
522 DBG("\tWin: %d", win);
523 _ecore_xcb_error_handle(err);
524 free(err);
525 return EINA_FALSE;
526 }
527
528 return EINA_TRUE;
529}
530
531EAPI Eina_Bool
532ecore_x_mouse_down_send(Ecore_X_Window win, int x, int y, int b)
533{
534 xcb_translate_coordinates_cookie_t cookie;
535 xcb_translate_coordinates_reply_t *reply;
536 xcb_button_press_event_t ev;
537 xcb_void_cookie_t vcookie;
538 xcb_generic_error_t *err;
539 Ecore_X_Window root = 0;
540
541 LOGFN(__FILE__, __LINE__, __FUNCTION__);
542 CHECK_XCB_CONN;
543
544 root = ecore_x_window_root_get(win);
545 cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y);
546 reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
547 if (!reply) return EINA_FALSE;
548
549 memset(&ev, 0, sizeof(xcb_button_press_event_t));
550
551 ev.response_type = XCB_BUTTON_PRESS;
552 ev.event = win;
553 ev.child = win;
554 ev.root = root;
555 ev.event_x = x;
556 ev.event_y = y;
557 ev.same_screen = 1;
558 ev.state = 1 << b;
559 ev.detail = b; // xcb uses detail for button
560 ev.root_x = reply->dst_x;
561 ev.root_y = reply->dst_y;
562 ev.time = ecore_x_current_time_get();
563 free(reply);
564
565 vcookie = xcb_send_event(_ecore_xcb_conn, 1, win,
566 XCB_EVENT_MASK_BUTTON_PRESS, (const char *)&ev);
567
568 err = xcb_request_check(_ecore_xcb_conn, vcookie);
569 if (err)
570 {
571 _ecore_xcb_error_handle(err);
572 free(err);
573 return EINA_FALSE;
574 }
575
576 return EINA_TRUE;
577}
578
579EAPI Eina_Bool
580ecore_x_mouse_up_send(Ecore_X_Window win, int x, int y, int b)
581{
582 xcb_translate_coordinates_cookie_t cookie;
583 xcb_translate_coordinates_reply_t *reply;
584 xcb_button_release_event_t ev;
585 xcb_void_cookie_t vcookie;
586 xcb_generic_error_t *err;
587 Ecore_X_Window root = 0;
588
589 LOGFN(__FILE__, __LINE__, __FUNCTION__);
590 CHECK_XCB_CONN;
591
592 root = ecore_x_window_root_get(win);
593 cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y);
594 reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
595 if (!reply) return EINA_FALSE;
596
597 memset(&ev, 0, sizeof(xcb_button_release_event_t));
598
599 ev.response_type = XCB_BUTTON_RELEASE;
600 ev.event = win;
601 ev.child = win;
602 ev.root = root;
603 ev.event_x = x;
604 ev.event_y = y;
605 ev.same_screen = 1;
606 ev.state = 0;
607 ev.root_x = reply->dst_x;
608 ev.root_y = reply->dst_y;
609 ev.detail = b; // xcb uses detail for button
610 ev.time = ecore_x_current_time_get();
611 free(reply);
612
613 vcookie = xcb_send_event(_ecore_xcb_conn, 1, win,
614 XCB_EVENT_MASK_BUTTON_RELEASE, (const char *)&ev);
615
616 err = xcb_request_check(_ecore_xcb_conn, vcookie);
617 if (err)
618 {
619 _ecore_xcb_error_handle(err);
620 free(err);
621 return EINA_FALSE;
622 }
623
624 return EINA_TRUE;
625}
626
627EAPI Eina_Bool
628ecore_x_mouse_move_send(Ecore_X_Window win, int x, int y)
629{
630 xcb_translate_coordinates_cookie_t cookie;
631 xcb_translate_coordinates_reply_t *reply;
632 xcb_motion_notify_event_t ev;
633 xcb_void_cookie_t vcookie;
634 xcb_generic_error_t *err;
635 Ecore_X_Window root = 0;
636
637 LOGFN(__FILE__, __LINE__, __FUNCTION__);
638 CHECK_XCB_CONN;
639
640 root = ecore_x_window_root_get(win);
641 cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y);
642 reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
643 if (!reply) return EINA_FALSE;
644
645 memset(&ev, 0, sizeof(xcb_motion_notify_event_t));
646
647 ev.response_type = XCB_MOTION_NOTIFY;
648 ev.event = win;
649 ev.child = win;
650 ev.root = root;
651 ev.event_x = x;
652 ev.event_y = y;
653 ev.same_screen = 1;
654 ev.state = 0;
655 ev.detail = 0; // xcb uses 'detail' for is_hint
656 ev.root_x = reply->dst_x;
657 ev.root_y = reply->dst_y;
658 ev.time = ecore_x_current_time_get();
659 free(reply);
660
661 vcookie = xcb_send_event(_ecore_xcb_conn, 1, win,
662 XCB_EVENT_MASK_POINTER_MOTION, (const char *)&ev);
663
664 err = xcb_request_check(_ecore_xcb_conn, vcookie);
665 if (err)
666 {
667 _ecore_xcb_error_handle(err);
668 free(err);
669 return EINA_FALSE;
670 }
671
672 return EINA_TRUE;
673}
674
675EAPI Eina_Bool
676ecore_x_mouse_in_send(Ecore_X_Window win, int x, int y)
677{
678 xcb_translate_coordinates_cookie_t cookie;
679 xcb_translate_coordinates_reply_t *reply;
680 xcb_enter_notify_event_t ev;
681 xcb_void_cookie_t vcookie;
682 xcb_generic_error_t *err;
683 Ecore_X_Window root = 0;
684
685 LOGFN(__FILE__, __LINE__, __FUNCTION__);
686 CHECK_XCB_CONN;
687
688 root = ecore_x_window_root_get(win);
689 cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y);
690 reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
691 if (!reply) return EINA_FALSE;
692
693 memset(&ev, 0, sizeof(xcb_enter_notify_event_t));
694
695 ev.response_type = XCB_ENTER_NOTIFY;
696 ev.event = win;
697 ev.child = win;
698 ev.root = root;
699 ev.event_x = x;
700 ev.event_y = y;
701 ev.same_screen_focus = 1;
702 ev.mode = XCB_NOTIFY_MODE_NORMAL;
703 ev.detail = XCB_NOTIFY_DETAIL_NONLINEAR;
704 /* ev.focus = 0; */
705 ev.state = 0;
706 ev.root_x = reply->dst_x;
707 ev.root_y = reply->dst_y;
708 ev.time = ecore_x_current_time_get();
709 free(reply);
710
711 vcookie = xcb_send_event(_ecore_xcb_conn, 1, win,
712 XCB_EVENT_MASK_ENTER_WINDOW, (const char *)&ev);
713
714 err = xcb_request_check(_ecore_xcb_conn, vcookie);
715 if (err)
716 {
717 _ecore_xcb_error_handle(err);
718 free(err);
719 return EINA_FALSE;
720 }
721
722 return EINA_TRUE;
723}
724
725EAPI Eina_Bool
726ecore_x_mouse_out_send(Ecore_X_Window win, int x, int y)
727{
728 xcb_translate_coordinates_cookie_t cookie;
729 xcb_translate_coordinates_reply_t *reply;
730 xcb_leave_notify_event_t ev;
731 xcb_void_cookie_t vcookie;
732 xcb_generic_error_t *err;
733 Ecore_X_Window root = 0;
734
735 LOGFN(__FILE__, __LINE__, __FUNCTION__);
736 CHECK_XCB_CONN;
737
738 root = ecore_x_window_root_get(win);
739 cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y);
740 reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL);
741 if (!reply) return EINA_FALSE;
742
743 memset(&ev, 0, sizeof(xcb_leave_notify_event_t));
744
745 ev.response_type = XCB_LEAVE_NOTIFY;
746 ev.event = win;
747 ev.child = win;
748 ev.root = root;
749 ev.event_x = x;
750 ev.event_y = y;
751 ev.same_screen_focus = 1;
752 ev.mode = XCB_NOTIFY_MODE_NORMAL;
753 ev.detail = XCB_NOTIFY_DETAIL_NONLINEAR;
754 /* ev.focus = 0; */
755 ev.state = 0;
756 ev.root_x = reply->dst_x;
757 ev.root_y = reply->dst_y;
758 ev.time = ecore_x_current_time_get();
759 free(reply);
760
761 vcookie = xcb_send_event(_ecore_xcb_conn, 1, win,
762 XCB_EVENT_MASK_LEAVE_WINDOW, (const char *)&ev);
763
764 err = xcb_request_check(_ecore_xcb_conn, vcookie);
765 if (err)
766 {
767 _ecore_xcb_error_handle(err);
768 free(err);
769 return EINA_FALSE;
770 }
771
772 return EINA_TRUE;
773}
774
775EAPI Eina_Bool
776ecore_x_keyboard_grab(Ecore_X_Window win)
777{
778 xcb_grab_keyboard_cookie_t cookie;
779 xcb_grab_keyboard_reply_t *reply;
780
781 LOGFN(__FILE__, __LINE__, __FUNCTION__);
782 CHECK_XCB_CONN;
783
784 cookie =
785 xcb_grab_keyboard_unchecked(_ecore_xcb_conn, 0, win, XCB_CURRENT_TIME,
786 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
787 reply = xcb_grab_keyboard_reply(_ecore_xcb_conn, cookie, NULL);
788 if (!reply) return EINA_FALSE;
789 free(reply);
790 return EINA_TRUE;
791}
792
793EAPI void
794ecore_x_keyboard_ungrab(void)
795{
796 LOGFN(__FILE__, __LINE__, __FUNCTION__);
797 CHECK_XCB_CONN;
798
799 xcb_ungrab_keyboard(_ecore_xcb_conn, XCB_CURRENT_TIME);
800}
801
802EAPI void
803ecore_x_pointer_xy_get(Ecore_X_Window win, int *x, int *y)
804{
805 xcb_query_pointer_cookie_t cookie;
806 xcb_query_pointer_reply_t *reply;
807
808// LOGFN(__FILE__, __LINE__, __FUNCTION__);
809 CHECK_XCB_CONN;
810
811// if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
812
813 if (x) *x = -1;
814 if (y) *y = -1;
815
816 cookie = xcb_query_pointer_unchecked(_ecore_xcb_conn, win);
817 reply = xcb_query_pointer_reply(_ecore_xcb_conn, cookie, NULL);
818 if (!reply) return;
819 if (x) *x = reply->win_x;
820 if (y) *y = reply->win_y;
821 free(reply);
822}
823
824EAPI Eina_Bool
825ecore_x_pointer_control_set(int accel_num, int accel_denom, int threshold)
826{
827 xcb_void_cookie_t vcookie;
828 xcb_generic_error_t *err;
829
830 LOGFN(__FILE__, __LINE__, __FUNCTION__);
831 CHECK_XCB_CONN;
832
833 vcookie =
834 xcb_change_pointer_control_checked(_ecore_xcb_conn,
835 accel_num, accel_denom, threshold,
836 1, 1);
837 err = xcb_request_check(_ecore_xcb_conn, vcookie);
838 if (err)
839 {
840 _ecore_xcb_error_handle(err);
841 free(err);
842 return EINA_FALSE;
843 }
844
845 return EINA_TRUE;
846}
847
848EAPI Eina_Bool
849ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int *threshold)
850{
851 xcb_get_pointer_control_cookie_t cookie;
852 xcb_get_pointer_control_reply_t *reply;
853
854 LOGFN(__FILE__, __LINE__, __FUNCTION__);
855 CHECK_XCB_CONN;
856
857 if (accel_num) *accel_num = 0;
858 if (accel_denom) *accel_denom = 0;
859 if (threshold) *threshold = 0;
860
861 cookie = xcb_get_pointer_control_unchecked(_ecore_xcb_conn);
862 reply = xcb_get_pointer_control_reply(_ecore_xcb_conn, cookie, NULL);
863 if (!reply) return EINA_FALSE;
864
865 if (accel_num) *accel_num = reply->acceleration_numerator;
866 if (accel_denom) *accel_denom = reply->acceleration_denominator;
867 if (threshold) *threshold = reply->threshold;
868 free(reply);
869
870 return EINA_TRUE;
871}
872
873EAPI Eina_Bool
874ecore_x_pointer_mapping_set(unsigned char *map, int nmap)
875{
876 xcb_set_pointer_mapping_cookie_t cookie;
877 xcb_set_pointer_mapping_reply_t *reply;
878 Eina_Bool ret = EINA_FALSE;
879
880 LOGFN(__FILE__, __LINE__, __FUNCTION__);
881 CHECK_XCB_CONN;
882
883 cookie = xcb_set_pointer_mapping_unchecked(_ecore_xcb_conn, nmap, map);
884 reply = xcb_set_pointer_mapping_reply(_ecore_xcb_conn, cookie, NULL);
885 if (!reply) return EINA_FALSE;
886
887 if (reply->status == XCB_MAPPING_STATUS_SUCCESS)
888 ret = EINA_TRUE;
889
890 free(reply);
891 return ret;
892}
893
894EAPI Eina_Bool
895ecore_x_pointer_mapping_get(unsigned char *map, int nmap)
896{
897 xcb_get_pointer_mapping_cookie_t cookie;
898 xcb_get_pointer_mapping_reply_t *reply;
899
900 LOGFN(__FILE__, __LINE__, __FUNCTION__);
901 CHECK_XCB_CONN;
902
903 if (map) *map = 0;
904 nmap = 0;
905
906 cookie = xcb_get_pointer_mapping_unchecked(_ecore_xcb_conn);
907 reply = xcb_get_pointer_mapping_reply(_ecore_xcb_conn, cookie, NULL);
908 if (!reply) return EINA_FALSE;
909
910 nmap = xcb_get_pointer_mapping_map_length(reply);
911 if (nmap <= 0)
912 {
913 free(reply);
914 return EINA_FALSE;
915 }
916
917 if (map)
918 {
919 uint8_t *tmp;
920 int i = 0;
921
922 tmp = xcb_get_pointer_mapping_map(reply);
923 for (i = 0; i < nmap; i++)
924 map[i] = tmp[i];
925 }
926
927 free(reply);
928 return EINA_TRUE;
929}
930
931EAPI Eina_Bool
932ecore_x_pointer_grab(Ecore_X_Window win)
933{
934 xcb_grab_pointer_cookie_t cookie;
935 xcb_grab_pointer_reply_t *reply;
936 uint16_t mask;
937 Eina_Bool ret = EINA_FALSE;
938
939 LOGFN(__FILE__, __LINE__, __FUNCTION__);
940 CHECK_XCB_CONN;
941
942 mask = (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
943 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
944 XCB_EVENT_MASK_POINTER_MOTION);
945
946 cookie = xcb_grab_pointer_unchecked(_ecore_xcb_conn, 0, win, mask,
947 XCB_GRAB_MODE_ASYNC,
948 XCB_GRAB_MODE_ASYNC,
949 XCB_NONE, XCB_NONE, XCB_CURRENT_TIME);
950 reply = xcb_grab_pointer_reply(_ecore_xcb_conn, cookie, NULL);
951 if (!reply) return EINA_FALSE;
952
953 ret = (reply->status == XCB_GRAB_STATUS_SUCCESS) ? EINA_TRUE : EINA_FALSE;
954
955 free(reply);
956 return ret;
957}
958
959EAPI Eina_Bool
960ecore_x_pointer_confine_grab(Ecore_X_Window win)
961{
962 xcb_grab_pointer_cookie_t cookie;
963 xcb_grab_pointer_reply_t *reply;
964 uint16_t mask;
965 Eina_Bool ret = EINA_FALSE;
966
967 LOGFN(__FILE__, __LINE__, __FUNCTION__);
968 CHECK_XCB_CONN;
969
970 mask = (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
971 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
972 XCB_EVENT_MASK_POINTER_MOTION);
973
974 cookie = xcb_grab_pointer_unchecked(_ecore_xcb_conn, 0, win, mask,
975 XCB_GRAB_MODE_ASYNC,
976 XCB_GRAB_MODE_ASYNC,
977 win, XCB_NONE, XCB_CURRENT_TIME);
978 reply = xcb_grab_pointer_reply(_ecore_xcb_conn, cookie, NULL);
979 if (!reply) return EINA_FALSE;
980
981 ret = (reply->status == XCB_GRAB_STATUS_SUCCESS) ? EINA_TRUE : EINA_FALSE;
982
983 free(reply);
984 return ret;
985}
986
987EAPI void
988ecore_x_pointer_ungrab(void)
989{
990 LOGFN(__FILE__, __LINE__, __FUNCTION__);
991 CHECK_XCB_CONN;
992
993 xcb_ungrab_pointer(_ecore_xcb_conn, XCB_CURRENT_TIME);
994}
995
996EAPI Eina_Bool
997ecore_x_pointer_warp(Ecore_X_Window win, int x, int y)
998{
999 xcb_void_cookie_t vcookie;
1000 xcb_generic_error_t *err;
1001
1002 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1003 CHECK_XCB_CONN;
1004
1005 vcookie =
1006 xcb_warp_pointer_checked(_ecore_xcb_conn, XCB_NONE, win, 0, 0, 0, 0, x, y);
1007 err = xcb_request_check(_ecore_xcb_conn, vcookie);
1008 if (err)
1009 {
1010 _ecore_xcb_error_handle(err);
1011 free(err);
1012 return EINA_FALSE;
1013 }
1014
1015 return EINA_TRUE;
1016}
1017
1018/**
1019 * Invoke the standard system beep to alert users
1020 *
1021 * @param percent The volume at which the bell rings. Must be in the range
1022 * [-100,+100]. If percent >= 0, the final volume will be:
1023 * base - [(base * percent) / 100] + percent
1024 * Otherwise, it's calculated as:
1025 * base + [(base * percent) / 100]
1026 * where @c base is the bell's base volume as set by XChangeKeyboardControl(3).
1027 *
1028 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1029 */
1030EAPI Eina_Bool
1031ecore_x_bell(int percent)
1032{
1033 xcb_void_cookie_t cookie;
1034 xcb_generic_error_t *err;
1035
1036 CHECK_XCB_CONN;
1037
1038 // FIXME: Use unchecked version after development is ironed out
1039 cookie = xcb_bell_checked(_ecore_xcb_conn, percent);
1040 err = xcb_request_check(_ecore_xcb_conn, cookie);
1041 if (err)
1042 {
1043 _ecore_xcb_error_handle(err);
1044 free(err);
1045 return EINA_FALSE;
1046 }
1047
1048 return EINA_TRUE;
1049}
1050
1051EAPI void
1052ecore_x_display_size_get(Ecore_X_Display *dsp EINA_UNUSED, int *w, int *h)
1053{
1054 xcb_screen_t *screen;
1055
1056 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1057 CHECK_XCB_CONN;
1058
1059 /* grab the default screen */
1060 screen = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data;
1061 if (w) *w = screen->width_in_pixels;
1062 if (h) *h = screen->height_in_pixels;
1063}
1064
1065EAPI unsigned long
1066ecore_x_display_black_pixel_get(Ecore_X_Display *dsp EINA_UNUSED)
1067{
1068 xcb_screen_t *screen;
1069
1070 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1071 CHECK_XCB_CONN;
1072
1073 /* grab the default screen */
1074 screen = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data;
1075 return screen->black_pixel;
1076}
1077
1078EAPI unsigned long
1079ecore_x_display_white_pixel_get(Ecore_X_Display *dsp EINA_UNUSED)
1080{
1081 xcb_screen_t *screen;
1082
1083 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1084 CHECK_XCB_CONN;
1085
1086 /* grab the default screen */
1087 screen = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data;
1088 return screen->white_pixel;
1089}
1090
1091EAPI void
1092ecore_x_pointer_last_xy_get(int *x, int *y)
1093{
1094 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1095
1096 if (x) *x = _ecore_xcb_event_last_root_x;
1097 if (y) *y = _ecore_xcb_event_last_root_y;
1098}
1099
1100EAPI void
1101ecore_x_focus_reset(void)
1102{
1103 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1104 CHECK_XCB_CONN;
1105
1106 xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT,
1107 ((xcb_screen_t *)_ecore_xcb_screen)->root,
1108 XCB_CURRENT_TIME);
1109// ecore_x_flush();
1110}
1111
1112EAPI void
1113ecore_x_events_allow_all(void)
1114{
1115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1116 CHECK_XCB_CONN;
1117
1118 xcb_allow_events(_ecore_xcb_conn, XCB_ALLOW_ASYNC_BOTH, XCB_CURRENT_TIME);
1119// ecore_x_flush();
1120}
1121
1122/**
1123 * Kill a specific client
1124 *
1125 * You can kill a specific client owning window @p win
1126 *
1127 * @param win Window of the client to be killed
1128 */
1129EAPI void
1130ecore_x_kill(Ecore_X_Window win)
1131{
1132 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1133 CHECK_XCB_CONN;
1134
1135 xcb_kill_client(_ecore_xcb_conn, win);
1136// ecore_x_flush();
1137}
1138
1139/**
1140 * Kill all clients with subwindows under a given window.
1141 *
1142 * You can kill all clients connected to the X server by using
1143 * @ref ecore_x_window_root_list to get a list of root windows, and
1144 * then passing each root window to this function.
1145 *
1146 * @param root The window whose children will be killed.
1147 */
1148EAPI void
1149ecore_x_killall(Ecore_X_Window root)
1150{
1151 int screens = 0, i = 0;
1152
1153 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1154 CHECK_XCB_CONN;
1155
1156 ecore_x_grab();
1157
1158 screens = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem;
1159
1160 /* Traverse window tree starting from root, and drag each
1161 * before the firing squad */
1162 for (i = 0; i < screens; ++i)
1163 {
1164 xcb_query_tree_cookie_t cookie;
1165 xcb_query_tree_reply_t *reply;
1166
1167 cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, root);
1168 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1169 if (reply)
1170 {
1171 xcb_window_t *wins = NULL;
1172 int tree_c_len, j = 0;
1173
1174 wins = xcb_query_tree_children(reply);
1175 tree_c_len = xcb_query_tree_children_length(reply);
1176 for (j = 0; j < tree_c_len; j++)
1177 xcb_kill_client(_ecore_xcb_conn, wins[j]);
1178 free(reply);
1179 }
1180 }
1181
1182 ecore_x_ungrab();
1183 ecore_x_sync(); // needed
1184}
1185
1186/**
1187 * Return the screen DPI
1188 *
1189 * This is a simplistic call to get DPI. It does not account for differing
1190 * DPI in the x amd y axes nor does it account for multihead or xinerama and
1191 * xrander where different parts of the screen may have differen DPI etc.
1192 *
1193 * @return the general screen DPI (dots/pixels per inch).
1194 */
1195EAPI int
1196ecore_x_dpi_get(void)
1197{
1198 uint16_t mw = 0, w = 0;
1199
1200 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1201
1202 mw = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters;
1203 if (mw <= 0) return 75;
1204 w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
1205 return (((w * 254) / mw) + 5) / 10;
1206}
1207
1208/**
1209 * @defgroup Ecore_X_Display_Attr_Group X Display Attributes
1210 * @ingroup Ecore_X_Group
1211 *
1212 * Functions that set and retrieve X display attributes.
1213 */
1214
1215/**
1216 * Retrieves the Ecore_X_Display handle used for the current X connection.
1217 * @return The current X display.
1218 * @ingroup Ecore_X_Display_Attr_Group
1219 */
1220EAPI Ecore_X_Display *
1221ecore_x_display_get(void)
1222{
1223 char *gl = NULL;
1224
1225 CHECK_XCB_CONN;
1226
1227 /* if we have the 'dont use xlib' env var, then we are not using
1228 * XLib and thus cannot return a real XDisplay.
1229 *
1230 * NB: This may break EFL in some places and needs lots of testing !!! */
1231 if ((gl = getenv("ECORE_X_NO_XLIB")))
1232 return (Ecore_X_Display *)_ecore_xcb_conn;
1233 else /* we can safely return an XDisplay var */
1234 return (Ecore_X_Display *)_ecore_xcb_display;
1235}
1236
1237/**
1238 * Retrieves the X display file descriptor.
1239 * @return The current X display file descriptor.
1240 * @ingroup Ecore_X_Display_Attr_Group
1241 */
1242EAPI int
1243ecore_x_fd_get(void)
1244{
1245 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1246 CHECK_XCB_CONN;
1247 return xcb_get_file_descriptor(_ecore_xcb_conn);
1248}
1249
1250EAPI void
1251ecore_x_passive_grab_replay_func_set(Eina_Bool (*func)(void *data, int type, void *event),
1252 void *data)
1253{
1254 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1255
1256 _ecore_xcb_window_grab_replay_func = func;
1257 _ecore_xcb_window_grab_replay_data = data;
1258}
1259
1260/**
1261 * Retrieves the size of an Ecore_X_Screen.
1262 * @param screen the handle to the screen to query.
1263 * @param w where to return the width. May be NULL. Returns 0 on errors.
1264 * @param h where to return the height. May be NULL. Returns 0 on errors.
1265 * @ingroup Ecore_X_Display_Attr_Group
1266 * @see ecore_x_default_screen_get()
1267 *
1268 * @since 1.1
1269 */
1270EAPI void
1271ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h)
1272{
1273 xcb_screen_t *s;
1274
1275 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1276
1277 if (w) *w = 0;
1278 if (h) *h = 0;
1279 if (!(s = (xcb_screen_t *)screen)) return;
1280 if (w) *w = s->width_in_pixels;
1281 if (h) *h = s->height_in_pixels;
1282}
1283
1284/**
1285 * Retrieves the count of screens.
1286 *
1287 * @return The count of screens.
1288 * @ingroup Ecore_X_Display_Attr_Group
1289 *
1290 * @since 1.1
1291 */
1292EAPI int
1293ecore_x_screen_count_get(void)
1294{
1295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1296 CHECK_XCB_CONN;
1297
1298 return xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn));
1299}
1300
1301/**
1302 * Retrieves the index number of the given screen.
1303 *
1304 * @param screen The screen for which index will be gotten.
1305 * @return The index number of the screen.
1306 * @ingroup Ecore_X_Display_Attr_Group
1307 *
1308 * @since 1.1
1309 */
1310EAPI int
1311ecore_x_screen_index_get(const Ecore_X_Screen *screen)
1312{
1313 xcb_screen_iterator_t iter;
1314 int i = 0;
1315
1316 CHECK_XCB_CONN;
1317
1318 iter =
1319 xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
1320 for (; iter.rem; xcb_screen_next(&iter))
1321 {
1322 if (iter.data == (xcb_screen_t *)screen)
1323 return i;
1324 i++;
1325 }
1326
1327 return 0;
1328}
1329
1330/**
1331 * Retrieves the screen based on index number.
1332 *
1333 * @param idx The index that will be used to retrieve the screen.
1334 * @return The Ecore_X_Screen at this index.
1335 * @ingroup Ecore_X_Display_Attr_Group
1336 *
1337 * @since 1.1
1338 */
1339EAPI Ecore_X_Screen *
1340ecore_x_screen_get(int idx)
1341{
1342 xcb_screen_iterator_t iter;
1343 int i = 0;
1344
1345 CHECK_XCB_CONN;
1346
1347 iter =
1348 xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
1349 for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
1350 if (i == idx) return iter.data;
1351
1352 return NULL;
1353}
1354
1355EAPI unsigned int
1356ecore_x_visual_id_get(Ecore_X_Visual visual)
1357{
1358 return ((xcb_visualtype_t *)visual)->visual_id;
1359}
1360
1361/**
1362 * Retrieve the default Visual.
1363 *
1364 * @param disp The Display to get the Default Visual from
1365 * @param screen The Screen.
1366 *
1367 * @return The default visual.
1368 * @since 1.1.0
1369 */
1370EAPI Ecore_X_Visual
1371ecore_x_default_visual_get(Ecore_X_Display *disp EINA_UNUSED, Ecore_X_Screen *screen)
1372{
1373 xcb_screen_t *s;
1374 xcb_depth_iterator_t diter;
1375 xcb_visualtype_iterator_t viter;
1376
1377 CHECK_XCB_CONN;
1378
1379 s = (xcb_screen_t *)screen;
1380 diter = xcb_screen_allowed_depths_iterator(s);
1381 for (; diter.rem; xcb_depth_next(&diter))
1382 {
1383 viter = xcb_depth_visuals_iterator(diter.data);
1384 for (; viter.rem; xcb_visualtype_next(&viter))
1385 {
1386 if (viter.data->visual_id == s->root_visual)
1387 return viter.data;
1388 }
1389 }
1390 return 0;
1391}
1392
1393/**
1394 * Retrieve the default Colormap.
1395 *
1396 * @param disp The Display to get the Default Colormap from
1397 * @param screen The Screen.
1398 *
1399 * @return The default colormap.
1400 * @since 1.1.0
1401 */
1402EAPI Ecore_X_Colormap
1403ecore_x_default_colormap_get(Ecore_X_Display *disp EINA_UNUSED, Ecore_X_Screen *screen)
1404{
1405 xcb_screen_t *s;
1406
1407 s = (xcb_screen_t *)screen;
1408 return s->default_colormap;
1409}
1410
1411/**
1412 * Retrieve the default depth.
1413 *
1414 * @param disp The Display to get the Default Depth from
1415 * @param screen The Screen.
1416 *
1417 * @return The default depth.
1418 * @since 1.1.0
1419 */
1420EAPI int
1421ecore_x_default_depth_get(Ecore_X_Display *disp EINA_UNUSED, Ecore_X_Screen *screen)
1422{
1423 xcb_screen_t *s;
1424
1425 s = (xcb_screen_t *)screen;
1426 return s->root_depth;
1427}
1428
1429EAPI void
1430ecore_x_xkb_select_group(int group EINA_UNUSED)
1431{
1432 // XXX: implement me */
1433}
1434
1435/**
1436 * Sets the timeout for a double and triple clicks to be flagged.
1437 *
1438 * This sets the time between clicks before the double_click flag is
1439 * set in a button down event. If 3 clicks occur within double this
1440 * time, the triple_click flag is also set.
1441 *
1442 * @param t The time in seconds
1443 * @ingroup Ecore_X_Display_Attr_Group
1444 */
1445EAPI void
1446ecore_x_double_click_time_set(double t)
1447{
1448 if (t < 0.0) t = 0.0;
1449 _ecore_xcb_double_click_time = t;
1450}
1451
1452/**
1453 * Retrieves the double and triple click flag timeout.
1454 *
1455 * See @ref ecore_x_double_click_time_set for more information.
1456 *
1457 * @return The timeout for double clicks in seconds.
1458 * @ingroup Ecore_X_Display_Attr_Group
1459 */
1460EAPI double
1461ecore_x_double_click_time_get(void)
1462{
1463 return _ecore_xcb_double_click_time;
1464}
1465
1466/* local function prototypes */
1467static int
1468_ecore_xcb_shutdown(Eina_Bool close_display)
1469{
1470 if (--_ecore_xcb_init_count != 0)
1471 return _ecore_xcb_init_count;
1472
1473 if (!_ecore_xcb_conn)
1474 return _ecore_xcb_init_count;
1475
1476 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1477 CHECK_XCB_CONN;
1478
1479 ecore_idle_enterer_del(_ecore_xcb_idle_enterer);
1480 _ecore_xcb_idle_enterer = NULL;
1481
1482 if (_ecore_xcb_fd_handler)
1483 ecore_main_fd_handler_del(_ecore_xcb_fd_handler);
1484
1485 /* disconnect from display server */
1486 if (close_display)
1487 xcb_disconnect(_ecore_xcb_conn);
1488 else
1489 {
1490 close(xcb_get_file_descriptor(_ecore_xcb_conn));
1491 _ecore_xcb_conn = NULL;
1492 }
1493
1494 /* shutdown events */
1495 _ecore_xcb_events_shutdown();
1496
1497 /* shutdown input extension */
1498 _ecore_xcb_input_shutdown();
1499
1500 /* shutdown gesture extension */
1501 _ecore_xcb_gesture_shutdown();
1502
1503 /* shutdown selection */
1504 _ecore_xcb_selection_shutdown();
1505
1506 /* shutdown dnd */
1507 _ecore_xcb_dnd_shutdown();
1508
1509 /* shutdown netwm */
1510 ecore_x_netwm_shutdown();
1511
1512 /* shutdown keymap */
1513 _ecore_xcb_keymap_shutdown();
1514
1515 /* shutdown ecore_event */
1516 ecore_event_shutdown();
1517
1518 /* shutdown ecore */
1519 ecore_shutdown();
1520
1521 /* unregister log domain */
1522 eina_log_domain_unregister(_ecore_xcb_log_dom);
1523 _ecore_xcb_log_dom = -1;
1524
1525 /* shutdown eina */
1526 eina_shutdown();
1527
1528 return _ecore_xcb_init_count;
1529}
1530
1531static Eina_Bool
1532_ecore_xcb_fd_handle(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
1533{
1534 xcb_connection_t *conn;
1535 xcb_generic_event_t *ev = NULL;
1536
1537 conn = (xcb_connection_t *)data;
1538
1539 if (_ecore_xcb_event_buffered)
1540 {
1541 _ecore_xcb_events_handle(_ecore_xcb_event_buffered);
1542 free(_ecore_xcb_event_buffered);
1543 _ecore_xcb_event_buffered = NULL;
1544 }
1545
1546// xcb_flush(conn);
1547
1548 while ((ev = xcb_poll_for_event(conn)))
1549 {
1550 /* NB: Ecore Xlib uses filterevent for xim, but xcb does not support
1551 * xim, so no need for it here */
1552
1553 /* check for errors first */
1554 if (xcb_connection_has_error(conn))
1555 {
1556 xcb_generic_error_t *err;
1557
1558 err = (xcb_generic_error_t *)ev;
1559 _ecore_xcb_io_error_handle(err);
1560 }
1561 else
1562 {
1563 /* FIXME: Filter event for XIM */
1564 _ecore_xcb_events_handle(ev);
1565 free(ev);
1566 }
1567 }
1568
1569 return ECORE_CALLBACK_RENEW;
1570}
1571
1572static Eina_Bool
1573_ecore_xcb_fd_handle_buff(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
1574{
1575 xcb_connection_t *conn;
1576 xcb_generic_event_t *ev = NULL;
1577
1578 conn = (xcb_connection_t *)data;
1579 ev = xcb_poll_for_event(conn);
1580 if (ev)
1581 {
1582 /* check for errors first */
1583 if (xcb_connection_has_error(conn))
1584 {
1585 xcb_generic_error_t *err;
1586
1587 err = (xcb_generic_error_t *)ev;
1588 _ecore_xcb_io_error_handle(err);
1589 return ECORE_CALLBACK_CANCEL;
1590 }
1591 _ecore_xcb_event_buffered = ev;
1592 return ECORE_CALLBACK_RENEW;
1593 }
1594 return ECORE_CALLBACK_CANCEL;
1595}
1596
1597static Eina_Bool
1598_ecore_xcb_idle_enter(void *data EINA_UNUSED)
1599{
1600 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1601 CHECK_XCB_CONN;
1602
1603 xcb_flush(_ecore_xcb_conn);
1604 return ECORE_CALLBACK_RENEW;
1605}
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_atoms.c b/src/lib/ecore_x/xcb/ecore_xcb_atoms.c
deleted file mode 100644
index ba31df7..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb_atoms.c
+++ /dev/null
@@ -1,155 +0,0 @@
1#include "ecore_xcb_private.h"
2#include "ecore_x_atoms_decl.h"
3
4/* NB: Increment if you add new atoms */
5#define ECORE_X_ATOMS_COUNT 199
6
7/* local function prototypes */
8
9/* local variables */
10static xcb_intern_atom_cookie_t cookies[ECORE_X_ATOMS_COUNT];
11
12#define MYMIN(X, Y) (((X) < (Y)) ? (X) : (Y))
13
14void
15_ecore_xcb_atoms_init(void)
16{
17 int i = 0, num = 0;
18
19 LOGFN(__FILE__, __LINE__, __FUNCTION__);
20 CHECK_XCB_CONN;
21
22 num = (sizeof(atom_items) / sizeof(Atom_Item));
23 num = MYMIN(num, ECORE_X_ATOMS_COUNT);
24 for (i = 0; i < num; i++)
25 {
26 cookies[i] =
27 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
28 strlen(atom_items[i].name), atom_items[i].name);
29 }
30}
31
32void
33_ecore_xcb_atoms_finalize(void)
34{
35 int i = 0, num = 0;
36
37 LOGFN(__FILE__, __LINE__, __FUNCTION__);
38 CHECK_XCB_CONN;
39
40 num = (sizeof(atom_items) / sizeof(Atom_Item));
41 num = MYMIN(num, ECORE_X_ATOMS_COUNT);
42 for (i = 0; i < num; i++)
43 {
44 xcb_intern_atom_reply_t *reply = NULL;
45
46 if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
47 continue;
48 *(atom_items[i].atom) = reply->atom;
49 free(reply);
50 }
51}
52
53/**
54 * @defgroup Ecore_X_Atom_Group X Atom Functions
55 * @ingroup Ecore_X_Group
56 *
57 * Functions that operate on atoms
58 */
59
60/**
61 * Retrieves the atom value associated to a name.
62 *
63 * @param name Unused.
64 * @return Associated atom value.
65 *
66 * Retrieves the atom value associated to a name. The reply is the
67 * returned value of the function ecore_xcb_intern_atom_reply(). If
68 * @p reply is @c NULL, the NULL atom is returned. Otherwise, the atom
69 * associated to the name is returned.
70 *
71 * @ingroup Ecore_X_Atom_Group
72 */
73EAPI Ecore_X_Atom
74ecore_x_atom_get(const char *name)
75{
76 xcb_intern_atom_cookie_t cookie;
77 xcb_intern_atom_reply_t *reply;
78 Ecore_X_Atom a;
79
80 LOGFN(__FILE__, __LINE__, __FUNCTION__);
81 CHECK_XCB_CONN;
82
83 cookie = xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(name), name);
84 reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookie, NULL);
85 if (!reply) return XCB_ATOM_NONE;
86 a = reply->atom;
87 free(reply);
88 return a;
89}
90
91/**
92 * Retrieves the name of the given atom.
93 *
94 * @param atom
95 * @return The name of the atom.
96 *
97 * @ingroup Ecore_X_Atom_Group
98 */
99EAPI char *
100ecore_x_atom_name_get(Ecore_X_Atom atom)
101{
102 xcb_get_atom_name_cookie_t cookie;
103 xcb_get_atom_name_reply_t *reply;
104 char *name;
105 int len = 0;
106
107 LOGFN(__FILE__, __LINE__, __FUNCTION__);
108 CHECK_XCB_CONN;
109
110 cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom);
111 reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
112 if (!reply) return NULL;
113 len = xcb_get_atom_name_name_length(reply);
114 name = (char *)malloc(sizeof(char) * (len + 1));
115 if (!name)
116 {
117 free(reply);
118 return NULL;
119 }
120 memcpy(name, xcb_get_atom_name_name(reply), len);
121 name[len] = '\0';
122
123 free(reply);
124 return name;
125}
126
127EAPI void
128ecore_x_atoms_get(const char **names,
129 int num,
130 Ecore_X_Atom *atoms)
131{
132 xcb_intern_atom_cookie_t cookies[num];
133 int i = 0;
134
135 LOGFN(__FILE__, __LINE__, __FUNCTION__);
136 CHECK_XCB_CONN;
137
138 num = MYMIN(num, ECORE_X_ATOMS_COUNT);
139 for (i = 0; i < num; i++)
140 {
141 cookies[i] =
142 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
143 strlen(names[i]), names[i]);
144 }
145 for (i = 0; i < num; i++)
146 {
147 xcb_intern_atom_reply_t *reply = NULL;
148
149 if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
150 continue;
151 atoms[i] = reply->atom;
152 free(reply);
153 }
154}
155
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_composite.c b/src/lib/ecore_x/xcb/ecore_xcb_composite.c
deleted file mode 100644
index b614d3c..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb_composite.c
+++ /dev/null
@@ -1,291 +0,0 @@
1#include "ecore_xcb_private.h"
2#ifdef ECORE_XCB_COMPOSITE
3# include <xcb/composite.h>
4#endif
5
6/* local variables */
7static Eina_Bool _composite_avail = EINA_FALSE;
8
9void
10_ecore_xcb_composite_init(void)
11{
12 LOGFN(__FILE__, __LINE__, __FUNCTION__);
13
14#ifdef ECORE_XCB_COMPOSITE
15 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_composite_id);
16#endif
17}
18
19void
20_ecore_xcb_composite_finalize(void)
21{
22#ifdef ECORE_XCB_COMPOSITE
23 const xcb_query_extension_reply_t *ext_reply;
24#endif
25
26 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27
28#ifdef ECORE_XCB_COMPOSITE
29 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_composite_id);
30 if ((ext_reply) && (ext_reply->present))
31 {
32 xcb_composite_query_version_cookie_t cookie;
33 xcb_composite_query_version_reply_t *reply;
34
35 cookie =
36 xcb_composite_query_version_unchecked(_ecore_xcb_conn,
37 XCB_COMPOSITE_MAJOR_VERSION,
38 XCB_COMPOSITE_MINOR_VERSION);
39 reply =
40 xcb_composite_query_version_reply(_ecore_xcb_conn, cookie, NULL);
41 if (reply)
42 {
43// if ((reply->major_version >= XCB_COMPOSITE_MAJOR_VERSION) &&
44 if (reply->minor_version >= XCB_COMPOSITE_MINOR_VERSION)
45 {
46# ifdef ECORE_XCB_RENDER
47 if (_ecore_xcb_render_avail_get())
48 {
49# ifdef ECORE_XCB_XFIXES
50 if (_ecore_xcb_xfixes_avail_get())
51 _composite_avail = EINA_TRUE;
52# endif
53 }
54# endif
55 }
56
57 free(reply);
58 }
59 }
60#endif
61}
62
63/**
64 * @defgroup Ecore_X_Composite_Group X Composite Extension Functions
65 * @ingroup Ecore_X_Group
66 *
67 * Functions related to the X Composite Extension
68 */
69
70/**
71 * Return whether the Composite Extension is available
72 *
73 * @return @c EINA_TRUE is the Composite Extension is available, @c EINA_FALSE
74 * if not.
75 *
76 * @ingroup Ecore_X_Composite_Group
77 */
78EAPI Eina_Bool
79ecore_x_composite_query(void)
80{
81 LOGFN(__FILE__, __LINE__, __FUNCTION__);
82 return _composite_avail;
83}
84
85EAPI void
86ecore_x_composite_redirect_window(Ecore_X_Window win,
87 Ecore_X_Composite_Update_Type type)
88{
89 LOGFN(__FILE__, __LINE__, __FUNCTION__);
90 CHECK_XCB_CONN;
91
92 if (!_composite_avail) return;
93
94#ifdef ECORE_XCB_COMPOSITE
95 uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
96
97 switch (type)
98 {
99 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
100 update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
101 break;
102
103 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
104 update = XCB_COMPOSITE_REDIRECT_MANUAL;
105 break;
106 }
107 xcb_composite_redirect_window(_ecore_xcb_conn, win, update);
108// ecore_x_flush();
109#endif
110}
111
112EAPI void
113ecore_x_composite_redirect_subwindows(Ecore_X_Window win,
114 Ecore_X_Composite_Update_Type type)
115{
116 LOGFN(__FILE__, __LINE__, __FUNCTION__);
117 CHECK_XCB_CONN;
118
119 if (!_composite_avail) return;
120
121#ifdef ECORE_XCB_COMPOSITE
122 uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
123
124 switch (type)
125 {
126 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
127 update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
128 break;
129
130 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
131 update = XCB_COMPOSITE_REDIRECT_MANUAL;
132 break;
133 }
134 xcb_composite_redirect_subwindows(_ecore_xcb_conn, win, update);
135// ecore_x_flush();
136#endif
137}
138
139EAPI void
140ecore_x_composite_unredirect_window(Ecore_X_Window win,
141 Ecore_X_Composite_Update_Type type)
142{
143 LOGFN(__FILE__, __LINE__, __FUNCTION__);
144 CHECK_XCB_CONN;
145
146 if (!_composite_avail) return;
147
148#ifdef ECORE_XCB_COMPOSITE
149 uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
150
151 switch (type)
152 {
153 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
154 update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
155 break;
156
157 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
158 update = XCB_COMPOSITE_REDIRECT_MANUAL;
159 break;
160 }
161 xcb_composite_unredirect_window(_ecore_xcb_conn, win, update);
162// ecore_x_flush();
163#endif
164}
165
166EAPI void
167ecore_x_composite_unredirect_subwindows(Ecore_X_Window win,
168 Ecore_X_Composite_Update_Type type)
169{
170 LOGFN(__FILE__, __LINE__, __FUNCTION__);
171 CHECK_XCB_CONN;
172
173 if (!_composite_avail) return;
174
175#ifdef ECORE_XCB_COMPOSITE
176 uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
177
178 switch (type)
179 {
180 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
181 update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
182 break;
183
184 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
185 update = XCB_COMPOSITE_REDIRECT_MANUAL;
186 break;
187 }
188 xcb_composite_unredirect_subwindows(_ecore_xcb_conn, win, update);
189// ecore_x_flush();
190#endif
191}
192
193EAPI Ecore_X_Pixmap
194ecore_x_composite_name_window_pixmap_get(Ecore_X_Window win)
195{
196#ifdef ECORE_XCB_COMPOSITE
197 Ecore_X_Pixmap pmap = XCB_NONE;
198#endif
199
200 LOGFN(__FILE__, __LINE__, __FUNCTION__);
201 CHECK_XCB_CONN;
202
203 if (!_composite_avail) return XCB_NONE;
204
205#ifdef ECORE_XCB_COMPOSITE
206 pmap = xcb_generate_id(_ecore_xcb_conn);
207 xcb_composite_name_window_pixmap(_ecore_xcb_conn, win, pmap);
208// ecore_x_flush();
209#endif
210
211 return pmap;
212}
213
214EAPI void
215ecore_x_composite_window_events_disable(Ecore_X_Window win)
216{
217 LOGFN(__FILE__, __LINE__, __FUNCTION__);
218 CHECK_XCB_CONN;
219
220 if (!_composite_avail) return;
221
222#ifdef ECORE_XCB_SHAPE
223 ecore_x_window_shape_input_rectangle_set(win, -1, -1, 1, 1);
224// ecore_x_flush();
225#else
226 return;
227 win = 0;
228#endif
229}
230
231EAPI void
232ecore_x_composite_window_events_enable(Ecore_X_Window win)
233{
234 LOGFN(__FILE__, __LINE__, __FUNCTION__);
235 CHECK_XCB_CONN;
236
237 if (!_composite_avail) return;
238
239#ifdef ECORE_XCB_SHAPE
240 ecore_x_window_shape_input_rectangle_set(win, 0, 0, 65535, 65535);
241// ecore_x_flush();
242#else
243 return;
244 win = 0;
245#endif
246}
247
248EAPI Ecore_X_Window
249ecore_x_composite_render_window_enable(Ecore_X_Window root)
250{
251 Ecore_X_Window win = 0;
252#ifdef ECORE_XCB_COMPOSITE
253 xcb_composite_get_overlay_window_cookie_t cookie;
254 xcb_composite_get_overlay_window_reply_t *reply;
255#endif
256
257 LOGFN(__FILE__, __LINE__, __FUNCTION__);
258 CHECK_XCB_CONN;
259
260 if (!_composite_avail) return 0;
261
262#ifdef ECORE_XCB_COMPOSITE
263 cookie = xcb_composite_get_overlay_window_unchecked(_ecore_xcb_conn, root);
264 reply =
265 xcb_composite_get_overlay_window_reply(_ecore_xcb_conn, cookie, NULL);
266 if (!reply) return win;
267
268 win = reply->overlay_win;
269 free(reply);
270
271 ecore_x_composite_window_events_disable(win);
272// ecore_x_flush();
273#endif
274
275 return win;
276}
277
278EAPI void
279ecore_x_composite_render_window_disable(Ecore_X_Window win)
280{
281 LOGFN(__FILE__, __LINE__, __FUNCTION__);
282 CHECK_XCB_CONN;
283
284 if (!_composite_avail) return;
285
286#ifdef ECORE_XCB_COMPOSITE
287 xcb_composite_release_overlay_window(_ecore_xcb_conn, win);
288// ecore_x_flush();
289#endif
290}
291
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_cursor.c b/src/lib/ecore_x/xcb/ecore_xcb_cursor.c
deleted file mode 100644
index 755df04..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb_cursor.c
+++ /dev/null
@@ -1,400 +0,0 @@
1#include "ecore_xcb_private.h"
2#ifdef ECORE_XCB_CURSOR
3# include <xcb/render.h>
4# include <xcb/xcb_renderutil.h>
5#endif
6
7/* local function prototypes */
8#ifdef ECORE_XCB_CURSOR
9static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format_get(void);
10#endif
11static void _ecore_xcb_cursor_default_size_get(void);
12static void _ecore_xcb_cursor_dpi_size_get(void);
13static void _ecore_xcb_cursor_guess_size(void);
14#ifdef ECORE_XCB_CURSOR
15static Ecore_X_Cursor _ecore_xcb_cursor_image_load_cursor(xcb_image_t *img,
16 int hot_x,
17 int hot_y);
18#endif
19static void _ecore_xcb_cursor_image_destroy(xcb_image_t *img);
20
21/* local variables */
22static int _ecore_xcb_cursor_size = 0;
23static Eina_Bool _ecore_xcb_cursor = EINA_FALSE;
24#ifdef ECORE_XCB_CURSOR
25static uint32_t _ecore_xcb_cursor_format_id = 0;
26// static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format = NULL;
27#endif
28
29void
30_ecore_xcb_cursor_init(void)
31{
32 LOGFN(__FILE__, __LINE__, __FUNCTION__);
33 /* NB: No-op */
34}
35
36void
37_ecore_xcb_cursor_finalize(void)
38{
39 LOGFN(__FILE__, __LINE__, __FUNCTION__);
40
41#ifdef ECORE_XCB_CURSOR
42 _ecore_xcb_cursor = _ecore_xcb_render_argb_get();
43
44 /* find render pict format */
45 if (_ecore_xcb_cursor_format_id <= 0)
46 _ecore_xcb_cursor_format_id = _ecore_xcb_cursor_format_get()->id;
47#endif
48
49 /* try to grab cursor size from XDefaults */
50 _ecore_xcb_cursor_default_size_get();
51
52 /* if that failed, try to get it from Xft Dpi setting */
53 if (_ecore_xcb_cursor_size == 0)
54 _ecore_xcb_cursor_dpi_size_get();
55
56 /* if that failed, try to guess from display size */
57 if (_ecore_xcb_cursor_size == 0)
58 _ecore_xcb_cursor_guess_size();
59
60 /* NB: Would normally add theme stuff here, but E cursor does not support
61 * xcursor themes. Delay parsing that stuff out until such time if/when the
62 * user selects to use X Cursor, rather than E cursor */
63}
64
65EAPI Eina_Bool
66ecore_x_cursor_color_supported_get(void)
67{
68 LOGFN(__FILE__, __LINE__, __FUNCTION__);
69
70 return _ecore_xcb_cursor;
71}
72
73EAPI Ecore_X_Cursor
74ecore_x_cursor_new(Ecore_X_Window win,
75 int *pixels,
76 int w,
77 int h,
78 int hot_x,
79 int hot_y)
80{
81 Ecore_X_Cursor cursor = 0;
82 xcb_image_t *img;
83
84// LOGFN(__FILE__, __LINE__, __FUNCTION__);
85 CHECK_XCB_CONN;
86
87#ifdef ECORE_XCB_CURSOR
88 if (_ecore_xcb_cursor)
89 {
90 img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
91 32, NULL, (w * h * sizeof(int)),
92 (uint8_t *)pixels);
93 cursor = _ecore_xcb_cursor_image_load_cursor(img, hot_x, hot_y);
94 _ecore_xcb_cursor_image_destroy(img);
95 return cursor;
96 }
97 else
98#endif
99 {
100 Ecore_X_GC gc;
101 xcb_pixmap_t pmap, mask;
102 uint32_t *pix;
103 uint8_t fr = 0x00, fg = 0x00, fb = 0x00;
104 uint8_t br = 0xff, bg = 0xff, bb = 0xff;
105 uint32_t brightest = 0, darkest = 255 * 3;
106 uint16_t x, y;
107 const uint32_t dither[2][2] =
108 {
109 {0, 2},
110 {3, 1}
111 };
112
113 img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
114 1, NULL, ~0, NULL);
115 if (img->data) free(img->data);
116 img->data = malloc(img->size);
117
118 pmap = xcb_generate_id(_ecore_xcb_conn);
119 xcb_create_pixmap(_ecore_xcb_conn, 1, pmap, win, w, h);
120 mask = xcb_generate_id(_ecore_xcb_conn);
121 xcb_create_pixmap(_ecore_xcb_conn, 1, mask, win, w, h);
122
123 pix = (uint32_t *)pixels;
124 for (y = 0; y < h; y++)
125 {
126 for (x = 0; x < w; x++)
127 {
128 uint8_t r, g, b, a;
129
130 a = (pix[0] >> 24) & 0xff;
131 r = (pix[0] >> 16) & 0xff;
132 g = (pix[0] >> 8) & 0xff;
133 b = (pix[0]) & 0xff;
134 if (a > 0)
135 {
136 if ((uint32_t)(r + g + b) > brightest)
137 {
138 brightest = r + g + b;
139 br = r;
140 bg = g;
141 bb = b;
142 }
143
144 if ((uint32_t)(r + g + b) < darkest)
145 {
146 darkest = r + g + b;
147 fr = r;
148 fg = g;
149 fb = b;
150 }
151 }
152 pix++;
153 }
154 }
155
156 pix = (uint32_t *)pixels;
157 for (y = 0; y < h; y++)
158 {
159 for (x = 0; x < w; x++)
160 {
161 uint32_t v;
162 uint8_t r, g, b;
163 int32_t d1, d2;
164
165 r = (pix[0] >> 16) & 0xff;
166 g = (pix[0] >> 8) & 0xff;
167 b = (pix[0]) & 0xff;
168 d1 =
169 ((r - fr) * (r - fr)) +
170 ((g - fg) * (g - fg)) +
171 ((b - fb) * (b - fb));
172 d2 =
173 ((r - br) * (r - br)) +
174 ((g - bg) * (g - bg)) +
175 ((b - bb) * (b - bb));
176 if (d1 + d2)
177 {
178 v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
179 if (v > dither[x & 0x1][y & 0x1])
180 v = 1;
181 else
182 v = 0;
183 }
184 else
185 v = 0;
186
187 xcb_image_put_pixel(img, x, y, v);
188 pix++;
189 }
190 }
191
192 gc = ecore_x_gc_new(pmap, 0, NULL);
193 xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc, w, h,
194 0, 0, 0, img->depth, img->size, img->data);
195 ecore_x_gc_free(gc);
196
197 pix = (uint32_t *)pixels;
198 for (y = 0; y < h; y++)
199 {
200 for (x = 0; x < w; x++)
201 {
202 uint32_t v;
203
204 v = (((pix[0] >> 24) & 0xff) * 5) / 256;
205 if (v > dither[x & 0x1][y & 0x1])
206 v = 1;
207 else
208 v = 0;
209
210 xcb_image_put_pixel(img, x, y, v);
211 pix++;
212 }
213 }
214
215 gc = ecore_x_gc_new(mask, 0, NULL);
216 xcb_put_image(_ecore_xcb_conn, img->format, mask, gc, w, h,
217 0, 0, 0, img->depth, img->size, img->data);
218 ecore_x_gc_free(gc);
219
220 if (img->data) free(img->data);
221 _ecore_xcb_cursor_image_destroy(img);
222
223 cursor = xcb_generate_id(_ecore_xcb_conn);
224 xcb_create_cursor(_ecore_xcb_conn, cursor, pmap, mask,
225 fr << 8 | fr, fg << 8 | fg, fb << 8 | fb,
226 br << 8 | br, bg << 8 | bg, bb << 8 | bb,
227 hot_x, hot_y);
228
229 xcb_free_pixmap(_ecore_xcb_conn, pmap);
230 xcb_free_pixmap(_ecore_xcb_conn, mask);
231
232 return cursor;
233 }
234
235 return 0;
236}
237
238EAPI void
239ecore_x_cursor_free(Ecore_X_Cursor c)
240{
241// LOGFN(__FILE__, __LINE__, __FUNCTION__);
242 CHECK_XCB_CONN;
243
244 xcb_free_cursor(_ecore_xcb_conn, c);
245}
246
247/*
248 * Returns the cursor for the given shape.
249 * Note that the return value must not be freed with
250 * ecore_x_cursor_free()!
251 */
252EAPI Ecore_X_Cursor
253ecore_x_cursor_shape_get(int shape)
254{
255 Ecore_X_Cursor cursor = 0;
256 xcb_font_t font;
257
258 LOGFN(__FILE__, __LINE__, __FUNCTION__);
259 CHECK_XCB_CONN;
260
261 font = xcb_generate_id(_ecore_xcb_conn);
262 xcb_open_font(_ecore_xcb_conn, font, strlen("cursor"), "cursor");
263
264 cursor = xcb_generate_id(_ecore_xcb_conn);
265 /* FIXME: Add request check ?? */
266 xcb_create_glyph_cursor(_ecore_xcb_conn, cursor, font, font,
267 shape, shape + 1, 0, 0, 0, 65535, 65535, 65535);
268
269 xcb_close_font(_ecore_xcb_conn, font);
270 return cursor;
271}
272
273EAPI void
274ecore_x_cursor_size_set(int size)
275{
276 LOGFN(__FILE__, __LINE__, __FUNCTION__);
277
278 _ecore_xcb_cursor_size = size;
279 /* NB: May need to adjust size of current cursors here */
280}
281
282EAPI int
283ecore_x_cursor_size_get(void)
284{
285 LOGFN(__FILE__, __LINE__, __FUNCTION__);
286
287 return _ecore_xcb_cursor_size;
288}
289
290/* local functions */
291#ifdef ECORE_XCB_CURSOR
292static xcb_render_pictforminfo_t *
293_ecore_xcb_cursor_format_get(void)
294{
295 const xcb_render_query_pict_formats_reply_t *reply;
296 xcb_render_pictforminfo_t *ret = NULL;
297
298 CHECK_XCB_CONN;
299
300 reply = xcb_render_util_query_formats(_ecore_xcb_conn);
301 if (reply)
302 ret = xcb_render_util_find_standard_format(reply,
303 XCB_PICT_STANDARD_ARGB_32);
304
305 return ret;
306}
307
308#endif
309
310static void
311_ecore_xcb_cursor_default_size_get(void)
312{
313 char *s = NULL;
314 int v = 0;
315
316 LOGFN(__FILE__, __LINE__, __FUNCTION__);
317
318 s = getenv("XCURSOR_SIZE");
319 if (!s)
320 {
321 _ecore_xcb_xdefaults_init();
322 v = _ecore_xcb_xdefaults_int_get("Xcursor", "size");
323 _ecore_xcb_xdefaults_shutdown();
324 }
325 else
326 v = atoi(s);
327 if (v) _ecore_xcb_cursor_size = ((v * 16) / 72);
328}
329
330static void
331_ecore_xcb_cursor_dpi_size_get(void)
332{
333 int v = 0;
334
335 LOGFN(__FILE__, __LINE__, __FUNCTION__);
336
337 _ecore_xcb_xdefaults_init();
338 v = _ecore_xcb_xdefaults_int_get("Xft", "dpi");
339 if (v) _ecore_xcb_cursor_size = ((v * 16) / 72);
340 _ecore_xcb_xdefaults_shutdown();
341}
342
343static void
344_ecore_xcb_cursor_guess_size(void)
345{
346 int w = 0, h = 0, s = 0;
347
348 LOGFN(__FILE__, __LINE__, __FUNCTION__);
349
350 ecore_x_screen_size_get(_ecore_xcb_screen, &w, &h);
351 if (h < w) s = h;
352 else s = w;
353 _ecore_xcb_cursor_size = (s / 48);
354}
355
356#ifdef ECORE_XCB_CURSOR
357static Ecore_X_Cursor
358_ecore_xcb_cursor_image_load_cursor(xcb_image_t *img,
359 int hot_x,
360 int hot_y)
361{
362 Ecore_X_Cursor cursor = 0;
363 Ecore_X_GC gc;
364 xcb_pixmap_t pmap;
365 xcb_render_picture_t pict;
366
367 CHECK_XCB_CONN;
368
369 pmap = xcb_generate_id(_ecore_xcb_conn);
370 xcb_create_pixmap(_ecore_xcb_conn, img->depth, pmap,
371 ((xcb_screen_t *)_ecore_xcb_screen)->root,
372 img->width, img->height);
373
374 gc = ecore_x_gc_new(pmap, 0, NULL);
375 xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc,
376 img->width, img->height, 0, 0, 0, img->depth,
377 img->size, img->data);
378 ecore_x_gc_free(gc);
379
380 pict = xcb_generate_id(_ecore_xcb_conn);
381 xcb_render_create_picture(_ecore_xcb_conn, pict, pmap,
382 _ecore_xcb_cursor_format_id, 0, NULL);
383 xcb_free_pixmap(_ecore_xcb_conn, pmap);
384
385 cursor = xcb_generate_id(_ecore_xcb_conn);
386 xcb_render_create_cursor(_ecore_xcb_conn, cursor, pict, hot_x, hot_y);
387 xcb_render_free_picture(_ecore_xcb_conn, pict);
388
389 return cursor;
390}
391
392#endif
393
394static void
395_ecore_xcb_cursor_image_destroy(xcb_image_t *img)
396{
397 CHECK_XCB_CONN;
398 if (img) xcb_image_destroy(img);
399}
400
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_damage.c b/src/lib/ecore_x/xcb/ecore_xcb_damage.c
deleted file mode 100644
index fdb7a2a..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb_damage.c
+++ /dev/null
@@ -1,156 +0,0 @@
1#include "ecore_xcb_private.h"
2# ifdef ECORE_XCB_DAMAGE
3# include <xcb/damage.h>
4# endif
5
6/* local variables */
7static Eina_Bool _damage_avail = EINA_FALSE;
8
9/* external variables */
10int _ecore_xcb_event_damage = -1;
11
12void
13_ecore_xcb_damage_init(void)
14{
15 LOGFN(__FILE__, __LINE__, __FUNCTION__);
16
17#ifdef ECORE_XCB_DAMAGE
18 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_damage_id);
19#endif
20}
21
22void
23_ecore_xcb_damage_finalize(void)
24{
25#ifdef ECORE_XCB_DAMAGE
26 const xcb_query_extension_reply_t *ext_reply;
27#endif
28
29 LOGFN(__FILE__, __LINE__, __FUNCTION__);
30
31#ifdef ECORE_XCB_DAMAGE
32 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_damage_id);
33 if ((ext_reply) && (ext_reply->present))
34 {
35 xcb_damage_query_version_cookie_t cookie;
36 xcb_damage_query_version_reply_t *reply;
37
38 cookie =
39 xcb_damage_query_version_unchecked(_ecore_xcb_conn,
40 XCB_DAMAGE_MAJOR_VERSION,
41 XCB_DAMAGE_MINOR_VERSION);
42 reply = xcb_damage_query_version_reply(_ecore_xcb_conn, cookie, NULL);
43 if (reply)
44 {
45 _damage_avail = EINA_TRUE;
46 free(reply);
47 }
48
49 if (_damage_avail)
50 _ecore_xcb_event_damage = ext_reply->first_event;
51 }
52#endif
53}
54
55/**
56 * @defgroup Ecore_X_Damage_Group X Damage Extension Functions
57 * @ingroup Ecore_X_Group
58 *
59 * Functions related to the X Damage Extension.
60 */
61
62EAPI Eina_Bool
63ecore_x_damage_query(void)
64{
65 return _damage_avail;
66}
67
68/**
69 * Create a damage object
70 *
71 * @param drawable The drawable to monitor
72 * @param level The level of the damage report
73 * @return The damage object
74 *
75 * Creates a damage object to monitor changes to @p drawable,
76 * with the level @p level.
77 *
78 * @ingroup Ecore_X_Damage_Group
79 */
80EAPI Ecore_X_Damage
81ecore_x_damage_new(Ecore_X_Drawable drawable,
82 Ecore_X_Damage_Report_Level level)
83{
84 Ecore_X_Damage damage = 0;
85
86 LOGFN(__FILE__, __LINE__, __FUNCTION__);
87 CHECK_XCB_CONN;
88
89 if (!_damage_avail) return 0;
90
91#ifdef ECORE_XCB_DAMAGE
92 damage = xcb_generate_id(_ecore_xcb_conn);
93 xcb_damage_create(_ecore_xcb_conn, damage, drawable, level);
94// ecore_x_flush();
95#endif
96
97 return damage;
98}
99
100/**
101 * Destroy a damage object
102 *
103 * @param damage The damage object to destroy
104 *
105 * Destroys the damage object @p damage
106 *
107 * @ingroup Ecore_X_Damage_Group
108 */
109EAPI void
110ecore_x_damage_free(Ecore_X_Damage damage)
111{
112 LOGFN(__FILE__, __LINE__, __FUNCTION__);
113 CHECK_XCB_CONN;
114
115 if (!_damage_avail) return;
116
117#ifdef ECORE_XCB_DAMAGE
118 xcb_damage_destroy(_ecore_xcb_conn, damage);
119// ecore_x_flush();
120#endif
121}
122
123/**
124 * Synchronously modifies the region
125 *
126 * @param damage The damage object to destroy
127 * @param repair The repair region
128 * @param parts The parts region
129 *
130 * Synchronously modifies the regions in the following manner:
131 * If @p repair is @c XCB_NONE:
132 * 1) parts = damage
133 * 2) damage = \<empty\>
134 * Otherwise:
135 * 1) parts = damage INTERSECT repair
136 * 2) damage = damage - parts
137 * 3) Generate DamageNotify for remaining damage areas
138 *
139 * @ingroup Ecore_X_Damage_Group
140 */
141EAPI void
142ecore_x_damage_subtract(Ecore_X_Damage damage,
143 Ecore_X_Region repair,
144 Ecore_X_Region parts)
145{
146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
147 CHECK_XCB_CONN;
148
149 if (!_damage_avail) return;
150
151#ifdef ECORE_XCB_DAMAGE
152 xcb_damage_subtract(_ecore_xcb_conn, damage, repair, parts);
153// ecore_x_flush();
154#endif
155}
156
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c
deleted file mode 100644
index 974ec0e..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c
+++ /dev/null
@@ -1,720 +0,0 @@
1#include "ecore_xcb_private.h"
2
3/* local structures */
4typedef struct _Version_Cache_Item
5{
6 Ecore_X_Window win;
7 int ver;
8} Version_Cache_Item;
9
10/* local function prototypes */
11static Eina_Bool _ecore_xcb_dnd_converter_copy(char *target EINA_UNUSED,
12 void *data,
13 int size,
14 void **data_ret,
15 int *size_ret,
16 Ecore_X_Atom *tprop EINA_UNUSED,
17 int *count EINA_UNUSED);
18
19/* local variables */
20static int _ecore_xcb_dnd_init_count = 0;
21static Ecore_X_DND_Source *_source = NULL;
22static Ecore_X_DND_Target *_target = NULL;
23static Version_Cache_Item *_version_cache = NULL;
24static int _version_cache_num = 0, _version_cache_alloc = 0;
25static void (*_posupdatecb)(void *,
26 Ecore_X_Xdnd_Position *);
27static void *_posupdatedata;
28
29/* external variables */
30EAPI int ECORE_X_EVENT_XDND_ENTER = 0;
31EAPI int ECORE_X_EVENT_XDND_POSITION = 0;
32EAPI int ECORE_X_EVENT_XDND_STATUS = 0;
33EAPI int ECORE_X_EVENT_XDND_LEAVE = 0;
34EAPI int ECORE_X_EVENT_XDND_DROP = 0;
35EAPI int ECORE_X_EVENT_XDND_FINISHED = 0;
36
37void
38_ecore_xcb_dnd_init(void)
39{
40 LOGFN(__FILE__, __LINE__, __FUNCTION__);
41
42 if (!_ecore_xcb_dnd_init_count)
43 {
44 _source = calloc(1, sizeof(Ecore_X_DND_Source));
45 if (!_source) return;
46 _source->version = ECORE_X_DND_VERSION;
47 _source->win = XCB_NONE;
48 _source->dest = XCB_NONE;
49 _source->state = ECORE_X_DND_SOURCE_IDLE;
50 _source->prev.window = 0;
51
52 _target = calloc(1, sizeof(Ecore_X_DND_Target));
53 if (!_target)
54 {
55 free(_source);
56 _source = NULL;
57 return;
58 }
59 _target->win = XCB_NONE;
60 _target->source = XCB_NONE;
61 _target->state = ECORE_X_DND_TARGET_IDLE;
62
63 ECORE_X_EVENT_XDND_ENTER = ecore_event_type_new();
64 ECORE_X_EVENT_XDND_POSITION = ecore_event_type_new();
65 ECORE_X_EVENT_XDND_STATUS = ecore_event_type_new();
66 ECORE_X_EVENT_XDND_LEAVE = ecore_event_type_new();
67 ECORE_X_EVENT_XDND_DROP = ecore_event_type_new();
68 ECORE_X_EVENT_XDND_FINISHED = ecore_event_type_new();
69 }
70 _ecore_xcb_dnd_init_count++;
71}
72
73void
74_ecore_xcb_dnd_shutdown(void)
75{
76 LOGFN(__FILE__, __LINE__, __FUNCTION__);
77
78 _ecore_xcb_dnd_init_count--;
79 if (_ecore_xcb_dnd_init_count > 0) return;
80 if (_source) free(_source);
81 _source = NULL;
82 if (_target) free(_target);
83 _target = NULL;
84 _ecore_xcb_dnd_init_count = 0;
85}
86
87EAPI void
88ecore_x_dnd_send_status(Eina_Bool will_accept,
89 Eina_Bool suppress,
90 Ecore_X_Rectangle rect,
91 Ecore_X_Atom action)
92{
93 xcb_client_message_event_t ev;
94
95 LOGFN(__FILE__, __LINE__, __FUNCTION__);
96 CHECK_XCB_CONN;
97
98 if (_target->state == ECORE_X_DND_TARGET_IDLE) return;
99
100 memset(&ev, 0, sizeof(xcb_client_message_event_t));
101
102 _target->will_accept = will_accept;
103
104 ev.response_type = XCB_CLIENT_MESSAGE;
105 ev.type = ECORE_X_ATOM_XDND_STATUS;
106 ev.format = 32;
107 ev.window = _target->source;
108 ev.data.data32[0] = _target->win;
109 ev.data.data32[1] = 0;
110 if (will_accept) ev.data.data32[1] |= 0x1UL;
111 if (!suppress) ev.data.data32[1] |= 0x2UL;
112
113 ev.data.data32[2] = rect.x;
114 ev.data.data32[2] <<= 16;
115 ev.data.data32[2] |= rect.y;
116 ev.data.data32[3] = rect.width;
117 ev.data.data32[3] <<= 16;
118 ev.data.data32[3] |= rect.height;
119
120 if (will_accept)
121 ev.data.data32[4] = action;
122 else
123 ev.data.data32[4] = XCB_NONE;
124 _target->accepted_action = action;
125
126 xcb_send_event(_ecore_xcb_conn, 0, _target->source,
127 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
128// ecore_x_flush();
129}
130
131EAPI void
132ecore_x_dnd_aware_set(Ecore_X_Window win,
133 Eina_Bool on)
134{
135 Ecore_X_Atom prop_data = ECORE_X_DND_VERSION;
136
137 LOGFN(__FILE__, __LINE__, __FUNCTION__);
138
139 if (on)
140 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_AWARE,
141 ECORE_X_ATOM_ATOM, 32, &prop_data, 1);
142 else
143 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_AWARE);
144}
145
146EAPI int
147ecore_x_dnd_version_get(Ecore_X_Window win)
148{
149 unsigned char *data;
150 int num = 0;
151 Version_Cache_Item *t;
152
153 LOGFN(__FILE__, __LINE__, __FUNCTION__);
154
155 if (_source->state == ECORE_X_DND_SOURCE_DRAGGING)
156 {
157 if (_version_cache)
158 {
159 int i = 0;
160
161 for (i = 0; i < _version_cache_num; i++)
162 {
163 if (_version_cache[i].win == win)
164 return _version_cache[i].ver;
165 }
166 }
167 }
168
169 if (ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_AWARE,
170 ECORE_X_ATOM_ATOM, 32, &data, &num))
171 {
172 int version = 0;
173
174 version = (int)*data;
175 free(data);
176 if (_source->state == ECORE_X_DND_SOURCE_DRAGGING)
177 {
178 _version_cache_num++;
179 if (_version_cache_num > _version_cache_alloc)
180 _version_cache_alloc += 16;
181 t = realloc(_version_cache,
182 _version_cache_alloc * sizeof(Version_Cache_Item));
183 if (!t) return 0;
184 _version_cache = t;
185 _version_cache[_version_cache_num - 1].win = win;
186 _version_cache[_version_cache_num - 1].ver = version;
187 }
188 return version;
189 }
190
191 if (_source->state == ECORE_X_DND_SOURCE_DRAGGING)
192 {
193 _version_cache_num++;
194 if (_version_cache_num > _version_cache_alloc)
195 _version_cache_alloc += 16;
196 t = realloc(_version_cache,
197 _version_cache_alloc * sizeof(Version_Cache_Item));
198 if (!t) return 0;
199 _version_cache = t;
200 _version_cache[_version_cache_num - 1].win = win;
201 _version_cache[_version_cache_num - 1].ver = 0;
202 }
203
204 return 0;
205}
206
207EAPI Eina_Bool
208ecore_x_dnd_type_isset(Ecore_X_Window win,
209 const char *type)
210{
211 int num = 0, i = 0;
212 Eina_Bool ret = EINA_FALSE;
213 unsigned char *data;
214 Ecore_X_Atom *atoms, atom;
215
216 LOGFN(__FILE__, __LINE__, __FUNCTION__);
217 CHECK_XCB_CONN;
218
219 if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_TYPE_LIST,
220 ECORE_X_ATOM_ATOM, 32, &data, &num))
221 return ret;
222
223 atom = ecore_x_atom_get(type);
224 atoms = (Ecore_X_Atom *)data;
225 for (i = 0; i < num; ++i)
226 {
227 if (atom == atoms[i])
228 {
229 ret = EINA_TRUE;
230 break;
231 }
232 }
233
234 free(data);
235 return ret;
236}
237
238EAPI void
239ecore_x_dnd_type_set(Ecore_X_Window win,
240 const char *type,
241 Eina_Bool on)
242{
243 Ecore_X_Atom atom, *oldset = NULL, *newset = NULL;
244 int i = 0, j = 0, num = 0;
245 unsigned char *data = NULL, *old_data = NULL;
246
247 LOGFN(__FILE__, __LINE__, __FUNCTION__);
248 CHECK_XCB_CONN;
249
250 atom = ecore_x_atom_get(type);
251 ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_TYPE_LIST,
252 ECORE_X_ATOM_ATOM, 32, &old_data, &num);
253 oldset = (Ecore_X_Atom *)old_data;
254 if (on)
255 {
256 if (ecore_x_dnd_type_isset(win, type))
257 {
258 free(old_data);
259 return;
260 }
261 newset = calloc(num + 1, sizeof(Ecore_X_Atom));
262 if (!newset) return;
263 data = (unsigned char *)newset;
264 for (i = 0; i < num; i++)
265 newset[i + 1] = oldset[i];
266 newset[0] = atom;
267 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
268 ECORE_X_ATOM_ATOM, 32, data, num + 1);
269 }
270 else
271 {
272 if (!ecore_x_dnd_type_isset(win, type))
273 {
274 free(old_data);
275 return;
276 }
277 newset = calloc(num - 1, sizeof(Ecore_X_Atom));
278 if (!newset)
279 {
280 free(old_data);
281 return;
282 }
283 data = (unsigned char *)newset;
284 for (i = 0; i < num; i++)
285 if (oldset[i] != atom)
286 newset[j++] = oldset[i];
287 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
288 ECORE_X_ATOM_ATOM, 32, data, num - 1);
289 }
290 free(oldset);
291 free(newset);
292}
293
294EAPI void
295ecore_x_dnd_types_set(Ecore_X_Window win,
296 const char **types,
297 unsigned int num_types)
298{
299 Ecore_X_Atom *newset = NULL;
300 unsigned int i;
301 unsigned char *data = NULL;
302
303 LOGFN(__FILE__, __LINE__, __FUNCTION__);
304 CHECK_XCB_CONN;
305
306 if (!num_types)
307 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_TYPE_LIST);
308 else
309 {
310 newset = calloc(num_types, sizeof(Ecore_X_Atom));
311 if (!newset) return;
312
313 data = (unsigned char *)newset;
314 for (i = 0; i < num_types; i++)
315 {
316 newset[i] = ecore_x_atom_get(types[i]);
317 ecore_x_selection_converter_atom_add(newset[i],
318 _ecore_xcb_dnd_converter_copy);
319 }
320 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
321 ECORE_X_ATOM_ATOM, 32, data,
322 num_types);
323 free(newset);
324 }
325}
326
327EAPI void
328ecore_x_dnd_actions_set(Ecore_X_Window win,
329 Ecore_X_Atom *actions,
330 unsigned int num_actions)
331{
332 unsigned int i;
333 unsigned char *data = NULL;
334
335 LOGFN(__FILE__, __LINE__, __FUNCTION__);
336 CHECK_XCB_CONN;
337
338 if (!num_actions)
339 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_ACTION_LIST);
340 else
341 {
342 data = (unsigned char *)actions;
343 for (i = 0; i < num_actions; i++)
344 ecore_x_selection_converter_atom_add(actions[i],
345 _ecore_xcb_dnd_converter_copy);
346 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_ACTION_LIST,
347 ECORE_X_ATOM_ATOM, 32, data,
348 num_actions);
349 }
350}
351
352/**
353 * The DND position update cb is called Ecore_X sends a DND position to a
354 * client.
355 *
356 * It essentially mirrors some of the data sent in the position message.
357 * Generally this cb should be set just before position update is called.
358 * Please note well you need to look after your own data pointer if someone
359 * trashes you position update cb set.
360 *
361 * It is considered good form to clear this when the dnd event finishes.
362 *
363 * @param cb Callback to updated each time ecore_x sends a position update.
364 * @param data User data.
365 */
366EAPI void
367ecore_x_dnd_callback_pos_update_set(void (*cb)(void *, Ecore_X_Xdnd_Position *data),
368 const void *data)
369{
370 _posupdatecb = cb;
371 _posupdatedata = (void *)data;
372}
373
374static Eina_Bool
375_ecore_x_dnd_begin(Ecore_X_Window source, Eina_Bool self, unsigned char *data, int size)
376{
377 LOGFN(__FILE__, __LINE__, __FUNCTION__);
378
379 if (!ecore_x_dnd_version_get(source)) return EINA_FALSE;
380
381 /* Take ownership of XdndSelection */
382 if (!ecore_x_selection_xdnd_set(source, data, size)) return EINA_FALSE;
383
384 if (_version_cache)
385 {
386 free(_version_cache);
387 _version_cache = NULL;
388 _version_cache_num = 0;
389 _version_cache_alloc = 0;
390 }
391
392 ecore_x_window_shadow_tree_flush();
393
394 _source->win = source;
395 if (!self) ecore_x_window_ignore_set(_source->win, 1);
396 _source->state = ECORE_X_DND_SOURCE_DRAGGING;
397 _source->time = _ecore_xcb_events_last_time_get();
398 _source->prev.window = 0;
399
400 /* Default Accepted Action: move */
401 _source->action = ECORE_X_ATOM_XDND_ACTION_MOVE;
402 _source->accepted_action = XCB_NONE;
403 _source->dest = XCB_NONE;
404
405 return EINA_TRUE;
406}
407
408static Eina_Bool
409_ecore_x_dnd_drop(Eina_Bool self)
410{
411 xcb_client_message_event_t ev;
412 Eina_Bool status = EINA_FALSE;
413
414 LOGFN(__FILE__, __LINE__, __FUNCTION__);
415 CHECK_XCB_CONN;
416
417 memset(&ev, 0, sizeof(xcb_client_message_event_t));
418
419 if (_source->dest)
420 {
421 ev.response_type = XCB_CLIENT_MESSAGE;
422 ev.format = 32;
423 ev.window = _source->dest;
424
425 if (_source->will_accept)
426 {
427 ev.type = ECORE_X_ATOM_XDND_DROP;
428 ev.data.data32[0] = _source->win;
429 ev.data.data32[1] = 0;
430 ev.data.data32[2] = _source->time;
431
432 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
433 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
434// ecore_x_flush();
435 _source->state = ECORE_X_DND_SOURCE_DROPPED;
436 status = EINA_TRUE;
437 }
438 else
439 {
440 ev.type = ECORE_X_ATOM_XDND_LEAVE;
441 ev.data.data32[0] = _source->win;
442 ev.data.data32[1] = 0;
443
444 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
445 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
446// ecore_x_flush();
447 _source->state = ECORE_X_DND_SOURCE_IDLE;
448 }
449 }
450 else
451 {
452 ecore_x_selection_xdnd_clear();
453 _source->state = ECORE_X_DND_SOURCE_IDLE;
454 }
455
456 if (!self) ecore_x_window_ignore_set(_source->win, 0);
457 _source->prev.window = 0;
458
459 return status;
460}
461
462EAPI Eina_Bool
463ecore_x_dnd_begin(Ecore_X_Window source,
464 unsigned char *data,
465 int size)
466{
467 return _ecore_x_dnd_begin(source, EINA_FALSE, data, size);
468}
469
470EAPI Eina_Bool
471ecore_x_dnd_drop(void)
472{
473 return _ecore_x_dnd_drop(EINA_FALSE);
474}
475
476EAPI Eina_Bool
477ecore_x_dnd_self_begin(Ecore_X_Window source,
478 unsigned char *data,
479 int size)
480{
481 return _ecore_x_dnd_begin(source, EINA_TRUE, data, size);
482}
483
484EAPI Eina_Bool
485ecore_x_dnd_self_drop(void)
486{
487 return _ecore_x_dnd_drop(EINA_TRUE);
488}
489
490EAPI void
491ecore_x_dnd_send_finished(void)
492{
493 xcb_client_message_event_t ev;
494
495 LOGFN(__FILE__, __LINE__, __FUNCTION__);
496 CHECK_XCB_CONN;
497
498 if (_target->state == ECORE_X_DND_TARGET_IDLE) return;
499
500 memset(&ev, 0, sizeof(xcb_client_message_event_t));
501
502 ev.response_type = XCB_CLIENT_MESSAGE;
503 ev.format = 32;
504 ev.type = ECORE_X_ATOM_XDND_FINISHED;
505 ev.window = _target->source;
506 ev.data.data32[0] = _target->win;
507 ev.data.data32[1] = 0;
508 ev.data.data32[2] = 0;
509 if (_target->will_accept)
510 {
511 ev.data.data32[1] |= 0x1UL;
512 ev.data.data32[2] = _target->accepted_action;
513 }
514
515 xcb_send_event(_ecore_xcb_conn, 0, _target->source,
516 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
517// ecore_x_flush();
518 _target->state = ECORE_X_DND_TARGET_IDLE;
519}
520
521EAPI void
522ecore_x_dnd_source_action_set(Ecore_X_Atom action)
523{
524 LOGFN(__FILE__, __LINE__, __FUNCTION__);
525
526 _source->action = action;
527 if (_source->prev.window)
528 _ecore_xcb_dnd_drag(_source->prev.window,
529 _source->prev.x, _source->prev.y);
530}
531
532Ecore_X_DND_Source *
533_ecore_xcb_dnd_source_get(void)
534{
535 return _source;
536}
537
538Ecore_X_DND_Target *
539_ecore_xcb_dnd_target_get(void)
540{
541 return _target;
542}
543
544void
545_ecore_xcb_dnd_drag(Ecore_X_Window root,
546 int x,
547 int y)
548{
549 xcb_client_message_event_t ev;
550 Ecore_X_Window win, *skip;
551 Ecore_X_Xdnd_Position pos;
552 int num = 0;
553
554 LOGFN(__FILE__, __LINE__, __FUNCTION__);
555 CHECK_XCB_CONN;
556
557 if (_source->state != ECORE_X_DND_SOURCE_DRAGGING) return;
558
559 memset(&ev, 0, sizeof(xcb_client_message_event_t));
560
561 ev.response_type = XCB_CLIENT_MESSAGE;
562 ev.format = 32;
563
564 skip = ecore_x_window_ignore_list(&num);
565 win = ecore_x_window_shadow_tree_at_xy_with_skip_get(root, x, y, skip, num);
566 while ((win) && !(ecore_x_dnd_version_get(win)))
567 win = ecore_x_window_shadow_parent_get(root, win);
568
569 if ((_source->dest) && (win != _source->dest))
570 {
571 ev.window = _source->dest;
572 ev.type = ECORE_X_ATOM_XDND_LEAVE;
573 ev.data.data32[0] = _source->win;
574 ev.data.data32[1] = 0;
575
576 xcb_send_event(_ecore_xcb_conn, 0, _source->dest,
577 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
578// ecore_x_flush();
579 _source->suppress = 0;
580 }
581
582 if (win)
583 {
584 int x1, x2, y1, y2;
585
586 _source->version = MIN(ECORE_X_DND_VERSION,
587 ecore_x_dnd_version_get(win));
588 if (win != _source->dest)
589 {
590 int i = 0;
591 unsigned char *data;
592 Ecore_X_Atom *types;
593
594 ecore_x_window_prop_property_get(_source->win,
595 ECORE_X_ATOM_XDND_TYPE_LIST,
596 ECORE_X_ATOM_ATOM, 32,
597 &data, &num);
598 types = (Ecore_X_Atom *)data;
599 ev.window = win;
600 ev.type = ECORE_X_ATOM_XDND_ENTER;
601 ev.data.data32[0] = _source->win;
602 ev.data.data32[1] = 0;
603 if (num > 3)
604 ev.data.data32[1] |= 0x1UL;
605 else
606 ev.data.data32[1] &= 0xfffffffeUL;
607 ev.data.data32[1] |= ((unsigned long)_source->version) << 24;
608
609 for (i = 2; i < 5; i++)
610 ev.data.data32[i] = 0;
611 for (i = 0; i < MIN(num, 3); ++i)
612 ev.data.data32[i + 2] = types[i];
613 free(data);
614
615 xcb_send_event(_ecore_xcb_conn, 0, win,
616 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
617// ecore_x_flush();
618 _source->await_status = 0;
619 _source->will_accept = 0;
620 }
621
622 x1 = _source->rectangle.x;
623 x2 = _source->rectangle.x + _source->rectangle.width;
624 y1 = _source->rectangle.y;
625 y2 = _source->rectangle.y + _source->rectangle.height;
626
627 if ((!_source->await_status) || (!_source->suppress) ||
628 ((x < x1) || (x > x2) || (y < y1) || (y > y2)))
629 {
630 ev.window = win;
631 ev.type = ECORE_X_ATOM_XDND_POSITION;
632 ev.data.data32[0] = _source->win;
633 ev.data.data32[1] = 0;
634 ev.data.data32[2] = ((x << 16) & 0xffff0000) | (y & 0xffff);
635 ev.data.data32[3] = _source->time;
636 ev.data.data32[4] = _source->action;
637
638 xcb_send_event(_ecore_xcb_conn, 0, win,
639 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
640// ecore_x_flush();
641 _source->await_status = 1;
642 }
643 }
644
645 if (_posupdatecb)
646 {
647 pos.position.x = x;
648 pos.position.y = y;
649 pos.win = win;
650 pos.prev = _source->dest;
651 _posupdatecb(_posupdatedata, &pos);
652 }
653
654 _source->prev.x = x;
655 _source->prev.y = y;
656 _source->prev.window = root;
657 _source->dest = win;
658}
659
660EAPI Ecore_X_Atom
661ecore_x_dnd_source_action_get(void)
662{
663 return _source->action;
664}
665
666/* local functions */
667static Eina_Bool
668_ecore_xcb_dnd_converter_copy(char *target EINA_UNUSED,
669 void *data,
670 int size,
671 void **data_ret,
672 int *size_ret,
673 Ecore_X_Atom *tprop EINA_UNUSED,
674 int *count EINA_UNUSED)
675{
676 Ecore_Xcb_Textproperty text_prop;
677 Ecore_Xcb_Encoding_Style style = XcbTextStyle;
678 char *mystr;
679
680 LOGFN(__FILE__, __LINE__, __FUNCTION__);
681
682 if ((!data) || (!size)) return EINA_FALSE;
683
684 mystr = calloc(1, size + 1);
685 if (!mystr) return EINA_FALSE;
686
687 memcpy(mystr, data, size);
688 if (_ecore_xcb_mb_textlist_to_textproperty(&mystr, 1, style, &text_prop))
689 {
690 int len;
691
692 len = strlen((char *)text_prop.value) + 1;
693 if (!(*data_ret = malloc(len)))
694 {
695 free(mystr);
696 return EINA_FALSE;
697 }
698 memcpy(*data_ret, text_prop.value, len);
699 *size_ret = len;
700 free(text_prop.value);
701 free(mystr);
702 return EINA_TRUE;
703 }
704 else
705 {
706 free(mystr);
707 return EINA_FALSE;
708 }
709}
710
711EAPI Eina_Bool
712ecore_x_dnd_abort(Ecore_X_Window xwin_source)
713{
714 if (xwin_source == _source->win)
715 {
716 _source->will_accept = 0;
717 return ecore_x_dnd_self_drop();
718 }
719 else return EINA_FALSE;
720}
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dpms.c b/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
deleted file mode 100644
index 95360e3..0000000
--- a/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
+++ /dev/null
@@ -1,354 +0,0 @@
1#include "ecore_xcb_private.h"
2#ifdef ECORE_XCB_DAMAGE
3# include <xcb/dpms.h>
4#endif
5
6/* local variables */
7static Eina_Bool _dpms_avail = EINA_FALSE;
8
9void
10_ecore_xcb_dpms_init(void)
11{
12 LOGFN(__FILE__, __LINE__, __FUNCTION__);
13
14#ifdef ECORE_XCB_DPMS
15 xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_dpms_id);
16#endif
17}
18
19void
20_ecore_xcb_dpms_finalize(void)
21{
22#ifdef ECORE_XCB_DPMS
23 const xcb_query_extension_reply_t *ext_reply;
24#endif
25
26 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27
28#ifdef ECORE_XCB_DPMS
29 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_dpms_id);
30 if ((ext_reply) && (ext_reply->present))
31 {
32 xcb_dpms_get_version_cookie_t cookie;
33 xcb_dpms_get_version_reply_t *reply;
34
35 cookie =
36 xcb_dpms_get_version_unchecked(_ecore_xcb_conn,
37 XCB_DPMS_MAJOR_VERSION,
38 XCB_DPMS_MINOR_VERSION);
39 reply = xcb_dpms_get_version_reply(_ecore_xcb_conn, cookie, NULL);
40 if (reply)
41 {
42 if (reply->server_major_version >= 1)
43 _dpms_avail = EINA_TRUE;
44 free(reply);
45 }
46 }
47#endif
48}
49
50/**
51 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
52 * @ingroup Ecore_X_Group
53 *
54 * Functions related to the X DPMS Extension
55 */
56
57/**
58 * Checks if the DPMS extension is available or not.
59 *
60 * @return @c EINA_TRUE if the DPMS extension is available,
61 * @c EINA_FALSE otherwise.
62 *
63 * Return @c EINA_TRUE if the X server supports the DPMS Extension version 1.0,
64 * @c EINA_FALSE otherwise.
65 *
66 * @ingroup Ecore_X_DPMS_Group
67 */
68EAPI Eina_Bool
69ecore_x_dpms_query(void)
70{
71// LOGFN(__FILE__, __LINE__, __FUNCTION__);
72
73 return _dpms_avail;
74}
75
76/**
77 * Checks if the X server is capable of DPMS.
78 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
79 * @ingroup Ecore_X_DPMS_Group
80 */
81EAPI Eina_Bool
82ecore_x_dpms_capable_get(void)
83{
84 Eina_Bool ret = EINA_FALSE;
85#ifdef ECORE_XCB_DPMS
86 xcb_dpms_capable_cookie_t cookie;
87 xcb_dpms_capable_reply_t *reply;
88#endif
89
90 LOGFN(__FILE__, __LINE__, __FUNCTION__);
91 CHECK_XCB_CONN;
92
93 if (!_dpms_avail) return EINA_FALSE;
94
95#ifdef ECORE_XCB_DPMS
96 cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn);
97 reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL);
98 if (reply)
99 {
100 ret = reply->capable;
101 free(reply);
102 }
103#endif
104
105 return ret;
106}
107
108/**
109 * Checks the DPMS state of the display.
110 * @return @c EINA_TRUE if DPMS is enabled, @c EINA_FALSE otherwise.
111 * @ingroup Ecore_X_DPMS_Group
112 */
113EAPI Eina_Bool
114ecore_x_dpms_enabled_get(void)
115{
116 Eina_Bool ret = EINA_FALSE;
117#ifdef ECORE_XCB_DPMS
118 xcb_dpms_info_cookie_t cookie;
119 xcb_dpms_info_reply_t *reply;
120#endif
121
122 LOGFN(__FILE__, __LINE__, __FUNCTION__);
123 CHECK_XCB_CONN;
124
125 if (!_dpms_avail) return EINA_FALSE;
126
127#ifdef ECORE_XCB_DPMS
128 cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
129 reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
130 if (!reply) return EINA_FALSE;
131 if (reply->state) ret = EINA_TRUE;
132 free(reply);
133#endif
134
135 return ret;
136}
137
138/**
139 * Sets the DPMS state of the display.
140 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
141 * @ingroup Ecore_X_DPMS_Group
142 */
143EAPI void
144ecore_x_dpms_enabled_set(int enabled)
145{
146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
147 CHECK_XCB_CONN;
148
149 if (!_dpms_avail) return;
150
151#ifdef ECORE_XCB_DPMS
152 if (enabled)
153 xcb_dpms_enable(_ecore_xcb_conn);
154 else
155 xcb_dpms_disable(_ecore_xcb_conn);
156#endif
157}
158
159/**
160 * Gets the timeouts. The values are in unit of seconds.
161 * @param standby Amount of time of inactivity before standby mode will be invoked.
162 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
163 * @param off Amount of time of inactivity before the monitor is shut off.
164 * @ingroup Ecore_X_DPMS_Group
165 */
166EAPI void
167ecore_x_dpms_timeouts_get(unsigned int *standby,
168 unsigned int *suspend,
169 unsigned int *off)
170{
171#ifdef ECORE_XCB_DPMS
172 xcb_dpms_get_timeouts_cookie_t cookie;
173 xcb_dpms_get_timeouts_reply_t *reply;
174#endif
175
176 LOGFN(__FILE__, __LINE__, __FUNCTION__);
177 CHECK_XCB_CONN;
178
179 if (standby) *standby = 0;
180 if (suspend) *suspend = 0;
181 if (off) *off = 0;
182
183 if (!_dpms_avail) return;
184
185#ifdef ECORE_XCB_DPMS
186 cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn);
187 reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL);
188 if (!reply) return;
189 if (standby) *standby = reply->standby_timeout;
190 if (suspend) *suspend = reply->suspend_timeout;
191 if (off) *off = reply->off_timeout;
192 free(reply);
193#endif
194}
195
196/**
197 * Sets the timeouts. The values are in unit of seconds.
198 *
199 * @param standby Amount of time of inactivity before standby mode will be invoked.
200 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
201 * @param off Amount of time of inactivity before the monitor is shut off.
202 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
203 * @ingroup Ecore_X_DPMS_Group
204 */
205EAPI Eina_Bool
206ecore_x_dpms_timeouts_set(unsigned int standby,
207 unsigned int suspend,
208 unsigned int off)
209{
210 LOGFN(__FILE__, __LINE__, __FUNCTION__);
211 CHECK_XCB_CONN;
212
213 if (!_dpms_avail) return EINA_FALSE;
214
215#ifdef ECORE_XCB_DPMS
216 // FIXME: Add request check
217 xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off);
218 return EINA_TRUE;
219#endif
220
221 return EINA_FALSE;
222}
223
224/**
225 * Returns the amount of time of inactivity before standby mode is invoked.
226 * @return The standby timeout value.
227 * @ingroup Ecore_X_DPMS_Group
228 */
229EAPI unsigned int
230ecore_x_dpms_timeout_standby_get(void)
231{
232 unsigned int standby = 0;
233
234 LOGFN(__FILE__, __LINE__, __FUNCTION__);
235
236 ecore_x_dpms_timeouts_get(&standby, NULL, NULL);
237 return standby;
238}
239
240/**
241 * Returns the amount of time of inactivity before the second level of
242 * power saving is invoked.
243 * @return The suspend timeout value.
244 * @ingroup Ecore_X_DPMS_Group
245 */
246EAPI unsigned int
247ecore_x_dpms_timeout_suspend_get(void)
248{
249 unsigned int suspend = 0;
250
251 LOGFN(__FILE__, __LINE__, __FUNCTION__);
252