diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c new file mode 100644 index 0000000..d811b54 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c | |||
@@ -0,0 +1,173 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /** | ||
4 | * Creates a new default graphics context associated with the given | ||
5 | * drawable. | ||
6 | * @param draw Drawable to create graphics context with. If @c 0 is | ||
7 | * given instead, the default root window is used. | ||
8 | * @param value_mask Bitmask values. | ||
9 | * @param value_list List of values. The order of values must be the | ||
10 | * same than the corresponding bitmaks. | ||
11 | * @return The new default graphics context. | ||
12 | */ | ||
13 | EAPI Ecore_X_GC | ||
14 | ecore_x_gc_new(Ecore_X_Drawable drawable, | ||
15 | Ecore_X_GC_Value_Mask value_mask, | ||
16 | const unsigned int *value_list) | ||
17 | { | ||
18 | xcb_gcontext_t gc; | ||
19 | uint32_t vmask = 0; | ||
20 | int i = 0, mask = 0; | ||
21 | |||
22 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
23 | CHECK_XCB_CONN; | ||
24 | |||
25 | if (!drawable) drawable = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
26 | |||
27 | for (i = 0, mask = 1; i <= 22; i++, mask <<= 1) | ||
28 | { | ||
29 | switch (mask & value_mask) | ||
30 | { | ||
31 | case ECORE_X_GC_VALUE_MASK_FUNCTION: | ||
32 | vmask |= XCB_GC_FUNCTION; | ||
33 | break; | ||
34 | |||
35 | case ECORE_X_GC_VALUE_MASK_PLANE_MASK: | ||
36 | vmask |= XCB_GC_PLANE_MASK; | ||
37 | break; | ||
38 | |||
39 | case ECORE_X_GC_VALUE_MASK_FOREGROUND: | ||
40 | vmask |= XCB_GC_FOREGROUND; | ||
41 | break; | ||
42 | |||
43 | case ECORE_X_GC_VALUE_MASK_BACKGROUND: | ||
44 | vmask |= XCB_GC_BACKGROUND; | ||
45 | break; | ||
46 | |||
47 | case ECORE_X_GC_VALUE_MASK_LINE_WIDTH: | ||
48 | vmask |= XCB_GC_LINE_WIDTH; | ||
49 | break; | ||
50 | |||
51 | case ECORE_X_GC_VALUE_MASK_LINE_STYLE: | ||
52 | vmask |= XCB_GC_LINE_STYLE; | ||
53 | break; | ||
54 | |||
55 | case ECORE_X_GC_VALUE_MASK_CAP_STYLE: | ||
56 | vmask |= XCB_GC_CAP_STYLE; | ||
57 | break; | ||
58 | |||
59 | case ECORE_X_GC_VALUE_MASK_JOIN_STYLE: | ||
60 | vmask |= XCB_GC_JOIN_STYLE; | ||
61 | break; | ||
62 | |||
63 | case ECORE_X_GC_VALUE_MASK_FILL_STYLE: | ||
64 | vmask |= XCB_GC_FILL_STYLE; | ||
65 | break; | ||
66 | |||
67 | case ECORE_X_GC_VALUE_MASK_FILL_RULE: | ||
68 | vmask |= XCB_GC_FILL_RULE; | ||
69 | break; | ||
70 | |||
71 | case ECORE_X_GC_VALUE_MASK_TILE: | ||
72 | vmask |= XCB_GC_TILE; | ||
73 | break; | ||
74 | |||
75 | case ECORE_X_GC_VALUE_MASK_STIPPLE: | ||
76 | vmask |= XCB_GC_STIPPLE; | ||
77 | break; | ||
78 | |||
79 | case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_X: | ||
80 | vmask |= XCB_GC_TILE_STIPPLE_ORIGIN_X; | ||
81 | break; | ||
82 | |||
83 | case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_Y: | ||
84 | vmask |= XCB_GC_TILE_STIPPLE_ORIGIN_Y; | ||
85 | break; | ||
86 | |||
87 | case ECORE_X_GC_VALUE_MASK_FONT: | ||
88 | vmask |= XCB_GC_FONT; | ||
89 | break; | ||
90 | |||
91 | case ECORE_X_GC_VALUE_MASK_SUBWINDOW_MODE: | ||
92 | vmask |= XCB_GC_SUBWINDOW_MODE; | ||
93 | break; | ||
94 | |||
95 | case ECORE_X_GC_VALUE_MASK_GRAPHICS_EXPOSURES: | ||
96 | vmask |= XCB_GC_GRAPHICS_EXPOSURES; | ||
97 | break; | ||
98 | |||
99 | case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_X: | ||
100 | vmask |= XCB_GC_CLIP_ORIGIN_X; | ||
101 | break; | ||
102 | |||
103 | case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_Y: | ||
104 | vmask |= XCB_GC_CLIP_ORIGIN_Y; | ||
105 | break; | ||
106 | |||
107 | case ECORE_X_GC_VALUE_MASK_CLIP_MASK: | ||
108 | vmask |= XCB_GC_CLIP_MASK; | ||
109 | break; | ||
110 | |||
111 | case ECORE_X_GC_VALUE_MASK_DASH_OFFSET: | ||
112 | vmask |= XCB_GC_DASH_OFFSET; | ||
113 | break; | ||
114 | |||
115 | case ECORE_X_GC_VALUE_MASK_DASH_LIST: | ||
116 | vmask |= XCB_GC_DASH_LIST; | ||
117 | break; | ||
118 | |||
119 | case ECORE_X_GC_VALUE_MASK_ARC_MODE: | ||
120 | vmask |= XCB_GC_ARC_MODE; | ||
121 | break; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | gc = xcb_generate_id(_ecore_xcb_conn); | ||
126 | xcb_create_gc(_ecore_xcb_conn, gc, drawable, vmask, value_list); | ||
127 | |||
128 | // ecore_x_flush(); | ||
129 | return gc; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * Deletes and frees the given graphics context. | ||
134 | * @param gc The given graphics context. | ||
135 | */ | ||
136 | EAPI void | ||
137 | ecore_x_gc_free(Ecore_X_GC gc) | ||
138 | { | ||
139 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
140 | CHECK_XCB_CONN; | ||
141 | |||
142 | xcb_free_gc(_ecore_xcb_conn, gc); | ||
143 | // ecore_x_flush(); | ||
144 | } | ||
145 | |||
146 | EAPI void | ||
147 | ecore_x_gc_foreground_set(Ecore_X_GC gc, | ||
148 | unsigned long foreground) | ||
149 | { | ||
150 | uint32_t list; | ||
151 | |||
152 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
153 | CHECK_XCB_CONN; | ||
154 | |||
155 | list = foreground; | ||
156 | xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &list); | ||
157 | // ecore_x_flush(); | ||
158 | } | ||
159 | |||
160 | EAPI void | ||
161 | ecore_x_gc_background_set(Ecore_X_GC gc, | ||
162 | unsigned long background) | ||
163 | { | ||
164 | uint32_t list; | ||
165 | |||
166 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
167 | CHECK_XCB_CONN; | ||
168 | |||
169 | list = background; | ||
170 | xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_BACKGROUND, &list); | ||
171 | // ecore_x_flush(); | ||
172 | } | ||
173 | |||