eolian: rename is_ref API to is_ptr to match syntax
[platform/upstream/efl.git] / src / lib / ecore_x / ecore_x_drawable.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif /* ifdef HAVE_CONFIG_H */
4
5 #include "ecore_x_private.h"
6
7 /**
8  * @defgroup Ecore_X_Drawable_Group X Drawable Functions
9  * @ingroup Ecore_X_Group
10  *
11  * Functions that operate on drawables.
12  */
13
14 /**
15  * Retrieves the geometry of the given drawable.
16  * @param d The given drawable.
17  * @param x Pointer to an integer into which the X position is to be stored.
18  * @param y Pointer to an integer into which the Y position is to be stored.
19  * @param w Pointer to an integer into which the width is to be stored.
20  * @param h Pointer to an integer into which the height is to be stored.
21  * @ingroup Ecore_X_Drawable_Group
22  */
23 EAPI void
24 ecore_x_drawable_geometry_get(Ecore_X_Drawable d,
25                               int *x,
26                               int *y,
27                               int *w,
28                               int *h)
29 {
30    Window dummy_win;
31    int ret_x, ret_y;
32    unsigned int ret_w, ret_h, dummy_border, dummy_depth;
33
34    LOGFN(__FILE__, __LINE__, __FUNCTION__);
35    EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
36    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &ret_x, &ret_y,
37                      &ret_w, &ret_h, &dummy_border, &dummy_depth))
38      {
39         ret_x = 0;
40         ret_y = 0;
41         ret_w = 0;
42         ret_h = 0;
43      }
44
45    if (x)
46      *x = ret_x;
47
48    if (y)
49      *y = ret_y;
50
51    if (w)
52      *w = (int)ret_w;
53
54    if (h)
55      *h = (int)ret_h;
56    if (_ecore_xlib_sync) ecore_x_sync();
57 }
58
59 /**
60  * Retrieves the width of the border of the given drawable.
61  * @param  d The given drawable.
62  * @return The border width of the given drawable.
63  * @ingroup Ecore_X_Drawable_Group
64  */
65 EAPI int
66 ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
67 {
68    Window dummy_win;
69    int dummy_x, dummy_y;
70    unsigned int dummy_w, dummy_h, border_ret, dummy_depth;
71
72    LOGFN(__FILE__, __LINE__, __FUNCTION__);
73    EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
74    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
75                      &dummy_w, &dummy_h, &border_ret, &dummy_depth))
76      border_ret = 0;
77    if (_ecore_xlib_sync) ecore_x_sync();
78    return (int)border_ret;
79 }
80
81 /**
82  * Retrieves the depth of the given drawable.
83  * @param  d The given drawable.
84  * @return The depth of the given drawable.
85  * @ingroup Ecore_X_Drawable_Group
86  */
87 EAPI int
88 ecore_x_drawable_depth_get(Ecore_X_Drawable d)
89 {
90    Window dummy_win;
91    int dummy_x, dummy_y;
92    unsigned int dummy_w, dummy_h, dummy_border, depth_ret;
93
94    LOGFN(__FILE__, __LINE__, __FUNCTION__);
95    EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
96    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
97                      &dummy_w, &dummy_h, &dummy_border, &depth_ret))
98      depth_ret = 0;
99    if (_ecore_xlib_sync) ecore_x_sync();
100    return (int)depth_ret;
101 }
102
103 /**
104  * Fill the specified rectangle on a drawable.
105  * @param d The given drawable.
106  * @param gc The graphic context that controls the fill rules.
107  * @param x The X coordinate of the top-left corner of the rectangle.
108  * @param y The Y coordinate of the top-left corner of the rectangle.
109  * @param width The width of the rectangle.
110  * @param height The height of the rectangle.
111  */
112 EAPI void
113 ecore_x_drawable_rectangle_fill(Ecore_X_Drawable d,
114                                 Ecore_X_GC gc,
115                                 int x,
116                                 int y,
117                                 int width,
118                                 int height)
119 {
120    LOGFN(__FILE__, __LINE__, __FUNCTION__);
121    EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
122    XFillRectangle(_ecore_x_disp, d, gc, x, y, width, height);
123    if (_ecore_xlib_sync) ecore_x_sync();
124 }
125