Ecore_X(cb): Remove extra calls to ecore_x_flush. Move main loop
[framework/uifw/ecore.git] / src / lib / ecore_x / xcb / ecore_xcb_drawable.c
1 #include "ecore_xcb_private.h"
2
3 /**
4  * @defgroup Ecore_X_Drawable_Group X Drawable Functions
5  *
6  * Functions that operate on drawables.
7  */
8
9 /**
10  * Fill the specified rectangle on a drawable.
11  * @param d The given drawable.
12  * @param gc The graphic context that controls the fill rules.
13  * @param x The X coordinate of the top-left corner of the rectangle.
14  * @param y The Y coordinate of the top-left corner of the rectangle.
15  * @param width The width of the rectangle.
16  * @param height The height of the rectangle.
17  */
18 EAPI void 
19 ecore_x_drawable_rectangle_fill(Ecore_X_Drawable draw, Ecore_X_GC gc, int x, int y, int w, int h) 
20 {
21    xcb_rectangle_t rect;
22
23    LOGFN(__FILE__, __LINE__, __FUNCTION__);
24
25    rect.x = x;
26    rect.y = y;
27    rect.width = w;
28    rect.height = h;
29    xcb_poly_fill_rectangle(_ecore_xcb_conn, draw, gc, 1, 
30                            (const xcb_rectangle_t *)&rect);
31 //   ecore_x_flush();
32 }
33
34 /**
35  * Retrieves the geometry of the given drawable.
36  * @param d The given drawable.
37  * @param x Pointer to an integer into which the X position is to be stored.
38  * @param y Pointer to an integer into which the Y position is to be stored.
39  * @param w Pointer to an integer into which the width is to be stored.
40  * @param h Pointer to an integer into which the height is to be stored.
41  * @ingroup Ecore_X_Drawable_Group
42  */
43 EAPI void 
44 ecore_x_drawable_geometry_get(Ecore_X_Drawable draw, int *x, int *y, int *w, int *h) 
45 {
46    xcb_get_geometry_cookie_t cookie;
47    xcb_get_geometry_reply_t *reply;
48
49    LOGFN(__FILE__, __LINE__, __FUNCTION__);
50
51    if (x) *x = 0;
52    if (y) *y = 0;
53    if (w) *w = 0;
54    if (h) *h = 0;
55    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
56    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
57    if (!reply) return;
58    if (x) *x = reply->x;
59    if (y) *y = reply->y;
60    if (w) *w = (int)reply->width;
61    if (h) *h = (int)reply->height;
62    free(reply);
63 }
64
65 /**
66  * Retrieves the width of the border of the given drawable.
67  * @param  d The given drawable.
68  * @return The border width of the given drawable.
69  * @ingroup Ecore_X_Drawable_Group
70  */
71 EAPI int 
72 ecore_x_drawable_border_width_get(Ecore_X_Drawable d) 
73 {
74    xcb_get_geometry_cookie_t cookie;
75    xcb_get_geometry_reply_t *reply;
76    int ret = 0;
77
78    LOGFN(__FILE__, __LINE__, __FUNCTION__);
79
80    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d);
81    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
82    if (!reply) return 0;
83    ret = (int)reply->border_width;
84    free(reply);
85    return ret;
86 }
87
88 /**
89  * Retrieves the depth of the given drawable.
90  * @param  d The given drawable.
91  * @return The depth of the given drawable.
92  * @ingroup Ecore_X_Drawable_Group
93  */
94 EAPI int 
95 ecore_x_drawable_depth_get(Ecore_X_Drawable d) 
96 {
97    xcb_get_geometry_cookie_t cookie;
98    xcb_get_geometry_reply_t *reply;
99    int ret = 0;
100
101    LOGFN(__FILE__, __LINE__, __FUNCTION__);
102
103    cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d);
104    reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
105    if (!reply) return 0;
106    ret = (int)reply->depth;
107    free(reply);
108    return ret;
109 }