3a1bb5b78902ac0d28b945853b5d04698910d393
[framework/uifw/ecore.git] / src / lib / ecore_x / xcb / ecore_xcb_drawable.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #include "ecore_xcb_private.h"
6 #include <xcb/xcb.h>
7
8
9 /**
10  * @defgroup Ecore_X_Drawable_Group X Drawable Functions
11  *
12  * Functions that operate on drawables.
13  */
14
15
16 /**
17  * Sends the GetGeometry request.
18  * @param drawable Drawable whose characteristics are sought.
19  * @ingroup Ecore_X_Drawable_Group
20  */
21 EAPI void
22 ecore_x_drawable_geometry_get_prefetch(Ecore_X_Drawable drawable)
23 {
24    xcb_get_geometry_cookie_t cookie;
25
26    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, drawable);
27    _ecore_xcb_cookie_cache(cookie.sequence);
28 }
29
30
31 /**
32  * Gets the reply of the GetGeometry request sent by ecore_x_atom_get_prefetch().
33  * @ingroup Ecore_X_Drawable_Group
34  */
35 EAPI void
36 ecore_x_drawable_geometry_get_fetch(void)
37 {
38    xcb_get_geometry_cookie_t cookie;
39    xcb_get_geometry_reply_t *reply;
40
41    cookie.sequence = _ecore_xcb_cookie_get();
42    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
43    _ecore_xcb_reply_cache(reply);
44 }
45
46
47 /**
48  * Retrieves the geometry of the given drawable.
49  * @param drawable Unused.
50  * @param x        Pointer to an integer into which the X position is to be stored.
51  * @param y        Pointer to an integer into which the Y position is to be stored.
52  * @param width    Pointer to an integer into which the width is to be stored.
53  * @param height   Pointer to an integer into which the height is to be stored.
54  *
55  * To use this function, you must call before, and in order,
56  * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
57  * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
58  * @ingroup Ecore_X_Drawable_Group
59  */
60 EAPI void
61 ecore_x_drawable_geometry_get(Ecore_X_Drawable drawable __UNUSED__,
62                               int             *x,
63                               int             *y,
64                               int             *width,
65                               int             *height)
66 {
67    xcb_get_geometry_reply_t *reply;
68
69    reply = _ecore_xcb_reply_get();
70    if (!reply)
71      {
72         if (x) *x = 0;
73         if (y) *y = 0;
74         if (width) *width = 0;
75         if (height) *height = 0;
76         return;
77      }
78
79    if (x) *x = reply->x;
80    if (y) *y = reply->y;
81    if (width) *width = reply->width;
82    if (height) *height = reply->height;
83 }
84
85
86 /**
87  * Retrieves the width of the border of the given drawable.
88  * @param  drawable Unused.
89  * @return          The border width of the given drawable.
90  *
91  * To use this function, you must call before, and in order,
92  * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
93  * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
94  * @ingroup Ecore_X_Drawable_Group
95  */
96 EAPI int
97 ecore_x_drawable_border_width_get(Ecore_X_Drawable drawable __UNUSED__)
98 {
99    xcb_get_geometry_reply_t *reply;
100
101    reply = _ecore_xcb_reply_get();
102    if (!reply)
103      return 0;
104
105    return reply->border_width;
106 }
107
108
109 /**
110  * Retrieves the depth of the given drawable.
111  * @param  drawable Unused.
112  * @return          The depth of the given drawable.
113  *
114  * To use this function, you must call before, and in order,
115  * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
116  * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
117  * @ingroup Ecore_X_Drawable_Group
118  */
119 EAPI int
120 ecore_x_drawable_depth_get(Ecore_X_Drawable drawable __UNUSED__)
121 {
122    xcb_get_geometry_reply_t *reply;
123
124    reply = _ecore_xcb_reply_get();
125    if (!reply)
126      return 0;
127
128    return reply->depth;
129 }