summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorChristopher Michael <cpmichael1@comcast.net>2011-08-23 16:39:52 +0000
committerChristopher Michael <cpmichael1@comcast.net>2011-08-23 16:39:52 +0000
commit4d6e04c51246e227b14eadbcc68b9fa1c8af6bdf (patch)
tree97cc0a511b53c246bcf0c5f473e9246dd1f59808 /legacy
parentb28995b31decce58397be9173c5ce0730a0580fd (diff)
Ecore_X(cb): Rework cursor code to be more like the Xlib version.
SVN revision: 62727
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c488
-rw-r--r--legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c5
-rw-r--r--legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h3
3 files changed, 222 insertions, 274 deletions
diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c
index bcb602a920..46a881a980 100644
--- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c
+++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c
@@ -1,37 +1,33 @@
1#include "ecore_xcb_private.h" 1#include "ecore_xcb_private.h"
2# include <xcb/xproto.h>
3# include <xcb/xcb_image.h>
4#ifdef ECORE_XCB_CURSOR 2#ifdef ECORE_XCB_CURSOR
5# include <xcb/render.h> 3# include <xcb/render.h>
6# include <xcb/xcb_renderutil.h> 4# include <xcb/xcb_renderutil.h>
7#endif 5#endif
8 6
9/* local function prototypes */ 7/* local function prototypes */
10static xcb_image_t *_ecore_xcb_cursor_image_create(int w, int h, int *pixels); 8#ifdef ECORE_XCB_CURSOR
11static Ecore_X_Cursor _ecore_xcb_cursor_image_load_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, int *pixels, xcb_image_t *img); 9static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format_get(void);
10#endif
12static void _ecore_xcb_cursor_default_size_get(void); 11static void _ecore_xcb_cursor_default_size_get(void);
13static void _ecore_xcb_cursor_dpi_size_get(void); 12static void _ecore_xcb_cursor_dpi_size_get(void);
14static void _ecore_xcb_cursor_guess_size(void); 13static void _ecore_xcb_cursor_guess_size(void);
15#ifdef ECORE_XCB_CURSOR 14#ifdef ECORE_XCB_CURSOR
16static Ecore_X_Cursor _ecore_xcb_cursor_image_load_argb_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, xcb_image_t *img); 15static Ecore_X_Cursor _ecore_xcb_cursor_image_load_cursor(xcb_image_t *img, int hot_x, int hot_y);
17static xcb_render_pictforminfo_t *_ecore_xcb_cursor_find_image_format(void);
18#endif 16#endif
17static void _ecore_xcb_cursor_image_destroy(xcb_image_t *img);
19 18
20/* local variables */ 19/* local variables */
20static int _ecore_xcb_cursor_size = 0;
21static Eina_Bool _ecore_xcb_cursor = EINA_FALSE;
21#ifdef ECORE_XCB_CURSOR 22#ifdef ECORE_XCB_CURSOR
22static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format = NULL; 23static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format = NULL;
23#endif 24#endif
24static int _ecore_xcb_cursor_size = 0;
25static Eina_Bool _ecore_xcb_cursor = EINA_FALSE;
26 25
27void 26void
28_ecore_xcb_cursor_init(void) 27_ecore_xcb_cursor_init(void)
29{ 28{
30 LOGFN(__FILE__, __LINE__, __FUNCTION__); 29 LOGFN(__FILE__, __LINE__, __FUNCTION__);
31 30 /* NB: No-op */
32#ifdef ECORE_XCB_CURSOR
33 /* NB: noop */
34#endif
35} 31}
36 32
37void 33void
@@ -42,53 +38,24 @@ _ecore_xcb_cursor_finalize(void)
42#ifdef ECORE_XCB_CURSOR 38#ifdef ECORE_XCB_CURSOR
43 _ecore_xcb_cursor = _ecore_xcb_render_argb_get(); 39 _ecore_xcb_cursor = _ecore_xcb_render_argb_get();
44 40
41 /* find render pict format */
42 _ecore_xcb_cursor_format = _ecore_xcb_cursor_format_get();
43#endif
44
45 /* try to grab cursor size from XDefaults */ 45 /* try to grab cursor size from XDefaults */
46 _ecore_xcb_cursor_default_size_get(); 46 _ecore_xcb_cursor_default_size_get();
47 47
48 /* if that failed, try to get it from xft dpi setting */ 48 /* if that failed, try to get it from Xft Dpi setting */
49 if (_ecore_xcb_cursor_size == 0) 49 if (_ecore_xcb_cursor_size == 0)
50 _ecore_xcb_cursor_dpi_size_get(); 50 _ecore_xcb_cursor_dpi_size_get();
51 51
52 /* If that fails, try to guess from display size */ 52 /* if that failed, try to guess from display size */
53 if (_ecore_xcb_cursor_size == 0) 53 if (_ecore_xcb_cursor_size == 0)
54 _ecore_xcb_cursor_guess_size(); 54 _ecore_xcb_cursor_guess_size();
55 55
56 /* NB: Would normally add theme stuff here, but E cursor does not support 56 /* NB: Would normally add theme stuff here, but E cursor does not support
57 * xcursor themes. Delay parsing that stuff out until such time if/when the 57 * xcursor themes. Delay parsing that stuff out until such time if/when the
58 * user selects to use X Cursor, rather than E cursor */ 58 * user selects to use X Cursor, rather than E cursor */
59#endif
60}
61
62/*
63 * Returns the cursor for the given shape.
64 * Note that the return value must not be freed with
65 * ecore_x_cursor_free()!
66 */
67EAPI Ecore_X_Cursor
68ecore_x_cursor_shape_get(int shape)
69{
70 Ecore_X_Cursor cursor = 0;
71 xcb_font_t font;
72
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
74
75 font = xcb_generate_id(_ecore_xcb_conn);
76 xcb_open_font(_ecore_xcb_conn, font, strlen("cursor"), "cursor");
77
78 cursor = xcb_generate_id(_ecore_xcb_conn);
79 xcb_create_glyph_cursor(_ecore_xcb_conn, cursor, font, font,
80 shape, shape + 1, 0, 0, 0, 65535, 65535, 65535);
81 xcb_close_font(_ecore_xcb_conn, font);
82
83 return cursor;
84}
85
86EAPI void
87ecore_x_cursor_free(Ecore_X_Cursor cursor)
88{
89 LOGFN(__FILE__, __LINE__, __FUNCTION__);
90
91 xcb_free_cursor(_ecore_xcb_conn, cursor);
92} 59}
93 60
94EAPI Eina_Bool 61EAPI Eina_Bool
@@ -107,233 +74,224 @@ ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int
107 74
108 LOGFN(__FILE__, __LINE__, __FUNCTION__); 75 LOGFN(__FILE__, __LINE__, __FUNCTION__);
109 76
110 if (_ecore_xcb_cursor) // argb
111 {
112 if ((img = _ecore_xcb_cursor_image_create(w, h, pixels)))
113 {
114#ifdef ECORE_XCB_CURSOR 77#ifdef ECORE_XCB_CURSOR
115 cursor =
116 _ecore_xcb_cursor_image_load_argb_cursor(win, w, h,
117 hot_x, hot_y, img);
118#else
119 cursor =
120 _ecore_xcb_cursor_image_load_cursor(win, w, h,
121 hot_x, hot_y, pixels, img);
122#endif
123 }
124 else
125 DBG("Failed to create new cursor image");
126 }
127 else
128 {
129 if ((img = _ecore_xcb_cursor_image_create(w, h, pixels)))
130 {
131 cursor =
132 _ecore_xcb_cursor_image_load_cursor(win, w, h,
133 hot_x, hot_y, pixels, img);
134 }
135 else
136 DBG("Failed to create new cursor image");
137 }
138
139 if (cursor)
140 {
141 uint32_t mask, list;
142
143 mask = XCB_CW_CURSOR;
144 list = cursor;
145 xcb_change_window_attributes(_ecore_xcb_conn, win, mask, &list);
146 ecore_x_flush();
147 }
148
149 return cursor;
150}
151
152EAPI void
153ecore_x_cursor_size_set(int size)
154{
155 LOGFN(__FILE__, __LINE__, __FUNCTION__);
156
157 // NB: size_set only needed for non-argb cursors
158 _ecore_xcb_cursor_size = size;
159}
160
161EAPI int
162ecore_x_cursor_size_get(void)
163{
164 LOGFN(__FILE__, __LINE__, __FUNCTION__);
165
166 return _ecore_xcb_cursor_size;
167}
168
169/* local functions */
170static xcb_image_t *
171_ecore_xcb_cursor_image_create(int w, int h, int *pixels)
172{
173 // NB: May be able to use shm here, but the image NEEDS to be in
174 // native format
175 if (_ecore_xcb_cursor) 78 if (_ecore_xcb_cursor)
176 { 79 {
177#ifdef ECORE_XCB_CURSOR 80 img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
178 return xcb_image_create_native(_ecore_xcb_conn, w, h, 81 32, NULL, (w * h * sizeof(int)),
179 XCB_IMAGE_FORMAT_Z_PIXMAP, 82 (uint8_t *)pixels);
180 32, pixels, (w * h * sizeof(int)), 83 cursor = _ecore_xcb_cursor_image_load_cursor(img, hot_x, hot_y);
181 (uint8_t *)pixels); 84 _ecore_xcb_cursor_image_destroy(img);
182#else 85 return cursor;
183 return xcb_image_create_native(_ecore_xcb_conn, w, h,
184 XCB_IMAGE_FORMAT_Z_PIXMAP,
185 1, pixels, (w * h * sizeof(int)),
186 (uint8_t *)pixels);
187#endif
188 }
189 else
190 {
191 return xcb_image_create_native(_ecore_xcb_conn, w, h,
192 XCB_IMAGE_FORMAT_Z_PIXMAP, 1,
193 NULL, ~0, NULL);
194 } 86 }
195} 87 else
196 88#endif
197static Ecore_X_Cursor
198_ecore_xcb_cursor_image_load_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, int *pixels, xcb_image_t *img)
199{
200 xcb_pixmap_t pixmap, mask;
201 Ecore_X_Cursor cursor;
202 Ecore_X_GC gc;
203 uint32_t *pix;
204 uint8_t fr = 0x00, fg = 0x00, fb = 0x00;
205 uint8_t br = 0xff, bg = 0xff, bb = 0xff;
206 uint32_t brightest = 0, darkest = 255 * 3;
207 uint16_t x, y;
208 const uint32_t dither[2][2] =
209 {
210 {0, 2},
211 {3, 1}
212 };
213
214 pixmap = xcb_generate_id(_ecore_xcb_conn);
215 xcb_create_pixmap(_ecore_xcb_conn, 1, pixmap, win, w, h);
216
217 mask = xcb_generate_id(_ecore_xcb_conn);
218 xcb_create_pixmap(_ecore_xcb_conn, 1, mask, win, w, h);
219
220 img->data = malloc(img->size);
221
222 pix = (uint32_t *)pixels;
223 for (y = 0; y < h; y++)
224 { 89 {
225 for (x = 0; x < w; x++) 90 Ecore_X_GC gc;
91 xcb_pixmap_t pmap, mask;
92 uint32_t *pix;
93 uint8_t fr = 0x00, fg = 0x00, fb = 0x00;
94 uint8_t br = 0xff, bg = 0xff, bb = 0xff;
95 uint32_t brightest = 0, darkest = 255 * 3;
96 uint16_t x, y;
97 const uint32_t dither[2][2] =
226 { 98 {
227 uint8_t r, g, b, a; 99 {0, 2},
228 100 {3, 1}
229 a = (pix[0] >> 24) & 0xff; 101 };
230 r = (pix[0] >> 16) & 0xff; 102
231 g = (pix[0] >> 8) & 0xff; 103 img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
232 b = (pix[0]) & 0xff; 104 1, NULL, ~0, NULL);
233 if (a > 0) 105 if (img->data) free(img->data);
106 img->data = malloc(img->size);
107
108 pmap = xcb_generate_id(_ecore_xcb_conn);
109 xcb_create_pixmap(_ecore_xcb_conn, 1, pmap, win, w, h);
110 mask = xcb_generate_id(_ecore_xcb_conn);
111 xcb_create_pixmap(_ecore_xcb_conn, 1, mask, win, w, h);
112
113 pix = (uint32_t *)pixels;
114 for (y = 0; y < h; y++)
115 {
116 for (x = 0; x < w; x++)
234 { 117 {
235 if ((uint32_t)(r + g + b) > brightest) 118 uint8_t r, g, b, a;
119
120 a = (pix[0] >> 24) & 0xff;
121 r = (pix[0] >> 16) & 0xff;
122 g = (pix[0] >> 8) & 0xff;
123 b = (pix[0]) & 0xff;
124 if (a > 0)
236 { 125 {
237 brightest = r + g + b; 126 if ((uint32_t)(r + g + b) > brightest)
238 br = r; 127 {
239 bg = g; 128 brightest = r + g + b;
240 bb = b; 129 br = r;
130 bg = g;
131 bb = b;
132 }
133
134 if ((uint32_t)(r + g + b) < darkest)
135 {
136 darkest = r + g + b;
137 fr = r;
138 fg = g;
139 fb = b;
140 }
241 } 141 }
142 pix++;
143 }
144 }
242 145
243 if ((uint32_t)(r + g + b) < darkest) 146 pix = (uint32_t *)pixels;
147 for (y = 0; y < h; y++)
148 {
149 for (x = 0; x < w; x++)
150 {
151 uint32_t v;
152 uint8_t r, g, b;
153 int32_t d1, d2;
154
155 r = (pix[0] >> 16) & 0xff;
156 g = (pix[0] >> 8) & 0xff;
157 b = (pix[0]) & 0xff;
158 d1 =
159 ((r - fr) * (r - fr)) +
160 ((g - fg) * (g - fg)) +
161 ((b - fb) * (b - fb));
162 d2 =
163 ((r - br) * (r - br)) +
164 ((g - bg) * (g - bg)) +
165 ((b - bb) * (b - bb));
166 if (d1 + d2)
244 { 167 {
245 darkest = r + g + b; 168 v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
246 fr = r; 169 if (v > dither[x & 0x1][y & 0x1])
247 fg = g; 170 v = 1;
248 fb = b; 171 else
172 v = 0;
249 } 173 }
174 else
175 v = 0;
176
177 xcb_image_put_pixel(img, x, y, v);
178 pix++;
250 } 179 }
251 pix++;
252 } 180 }
253 }
254 181
255 pix = (uint32_t *)pixels; 182 gc = ecore_x_gc_new(pmap, 0, NULL);
256 for (y = 0; y < h; y++) 183 xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc, w, h,
257 { 184 0, 0, 0, img->depth, img->size, img->data);
258 for (x = 0; x < w; x++) 185 ecore_x_gc_free(gc);
186
187 pix = (uint32_t *)pixels;
188 for (y = 0; y < h; y++)
259 { 189 {
260 uint32_t v; 190 for (x = 0; x < w; x++)
261 uint8_t r, g, b;
262 int32_t d1, d2;
263
264 r = (pix[0] >> 16) & 0xff;
265 g = (pix[0] >> 8) & 0xff;
266 b = (pix[0]) & 0xff;
267 d1 =
268 ((r - fr) * (r - fr)) +
269 ((g - fg) * (g - fg)) +
270 ((b - fb) * (b - fb));
271 d2 =
272 ((r - br) * (r - br)) +
273 ((g - bg) * (g - bg)) +
274 ((b - bb) * (b - bb));
275 if (d1 + d2)
276 { 191 {
277 v = (((d2 * 255) / (d1 + d2)) * 5) / 256; 192 uint32_t v;
193
194 v = (((pix[0] >> 24) & 0xff) * 5) / 256;
278 if (v > dither[x & 0x1][y & 0x1]) 195 if (v > dither[x & 0x1][y & 0x1])
279 v = 1; 196 v = 1;
280 else 197 else
281 v = 0; 198 v = 0;
282 }
283 else
284 v = 0;
285 199
286 xcb_image_put_pixel(img, x, y, v); 200 xcb_image_put_pixel(img, x, y, v);
287 pix++; 201 pix++;
202 }
288 } 203 }
289 }
290 204
291 // img->depth was 1 205 gc = ecore_x_gc_new(mask, 0, NULL);
292 gc = ecore_x_gc_new(pixmap, 0, NULL); 206 xcb_put_image(_ecore_xcb_conn, img->format, mask, gc, w, h,
293 xcb_put_image(_ecore_xcb_conn, XCB_IMAGE_FORMAT_Z_PIXMAP, 207 0, 0, 0, img->depth, img->size, img->data);
294 pixmap, gc, w, h, 0, 0, 0, img->depth, img->size, img->data); 208 ecore_x_gc_free(gc);
295 ecore_x_gc_free(gc);
296 209
297 pix = (uint32_t *)pixels; 210 if (img->data) free(img->data);
298 for (y = 0; y < h; y++) 211 _ecore_xcb_cursor_image_destroy(img);
299 {
300 for (x = 0; x < w; x++)
301 {
302 uint32_t v;
303 212
304 v = (((pix[0] >> 24) & 0xff) * 5) / 256; 213 cursor = xcb_generate_id(_ecore_xcb_conn);
305 if (v > dither[x & 0x1][y & 0x1]) 214 xcb_create_cursor(_ecore_xcb_conn, cursor, pmap, mask,
306 v = 1; 215 fr << 8 | fr, fg << 8 | fg, fb << 8 | fb,
307 else 216 br << 8 | br, bg << 8 | bg, bb << 8 | bb,
308 v = 0; 217 hot_x, hot_y);
309 218
310 xcb_image_put_pixel(img, x, y, v); 219 xcb_free_pixmap(_ecore_xcb_conn, pmap);
311 pix++; 220 xcb_free_pixmap(_ecore_xcb_conn, mask);
312 } 221
222 return cursor;
313 } 223 }
314 224
315 // img->depth was 1 225 return 0;
316 gc = ecore_x_gc_new(mask, 0, NULL); 226}
317 xcb_put_image(_ecore_xcb_conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
318 mask, gc, w, h, 0, 0, 0, img->depth, img->size, img->data);
319 ecore_x_gc_free(gc);
320 227
321 cursor = xcb_generate_id(_ecore_xcb_conn); 228EAPI void
322 xcb_create_cursor(_ecore_xcb_conn, cursor, pixmap, mask, 229ecore_x_cursor_free(Ecore_X_Cursor c)
323 fr << 8 | fr, fg << 8 | fg, fb << 8 | fb, 230{
324 br << 8 | br, bg << 8 | bg, bb << 8 | bb, 231 LOGFN(__FILE__, __LINE__, __FUNCTION__);
325 hot_x, hot_y); 232
233 xcb_free_cursor(_ecore_xcb_conn, c);
234}
235
236EAPI Ecore_X_Cursor
237ecore_x_cursor_shape_get(int shape)
238{
239 Ecore_X_Cursor cursor = 0;
240 xcb_font_t font;
241
242 LOGFN(__FILE__, __LINE__, __FUNCTION__);
326 243
327 xcb_free_pixmap(_ecore_xcb_conn, pixmap); 244 font = xcb_generate_id(_ecore_xcb_conn);
328 xcb_free_pixmap(_ecore_xcb_conn, mask); 245 xcb_open_font(_ecore_xcb_conn, font, strlen("cursor"), "cursor");
329 246
330 ecore_x_flush(); 247 cursor = xcb_generate_id(_ecore_xcb_conn);
248 /* FIXME: Add request check ?? */
249 xcb_create_glyph_cursor(_ecore_xcb_conn, cursor, font, font,
250 shape, shape + 1, 0, 0, 0, 65535, 65535, 65535);
251
252 xcb_close_font(_ecore_xcb_conn, font);
331 return cursor; 253 return cursor;
332} 254}
333 255
256EAPI void
257ecore_x_cursor_size_set(int size)
258{
259 LOGFN(__FILE__, __LINE__, __FUNCTION__);
260
261 _ecore_xcb_cursor_size = size;
262 /* NB: May need to adjust size of current cursors here */
263}
264
265EAPI int
266ecore_x_cursor_size_get(void)
267{
268 LOGFN(__FILE__, __LINE__, __FUNCTION__);
269
270 return _ecore_xcb_cursor_size;
271}
272
273/* local functions */
274#ifdef ECORE_XCB_CURSOR
275static xcb_render_pictforminfo_t *
276_ecore_xcb_cursor_format_get(void)
277{
278 const xcb_render_query_pict_formats_reply_t *reply;
279 xcb_render_pictforminfo_t *ret = NULL;
280
281 reply = xcb_render_util_query_formats(_ecore_xcb_conn);
282 if (reply)
283 ret = xcb_render_util_find_standard_format(reply,
284 XCB_PICT_STANDARD_ARGB_32);
285
286 return ret;
287}
288#endif
289
334static void 290static void
335_ecore_xcb_cursor_default_size_get(void) 291_ecore_xcb_cursor_default_size_get(void)
336{ 292{
293 LOGFN(__FILE__, __LINE__, __FUNCTION__);
294
337 /* char *v = NULL; */ 295 /* char *v = NULL; */
338 296
339 /* v = getenv("XCURSOR_SIZE"); */ 297 /* v = getenv("XCURSOR_SIZE"); */
@@ -345,6 +303,8 @@ _ecore_xcb_cursor_default_size_get(void)
345static void 303static void
346_ecore_xcb_cursor_dpi_size_get(void) 304_ecore_xcb_cursor_dpi_size_get(void)
347{ 305{
306 LOGFN(__FILE__, __LINE__, __FUNCTION__);
307
348 /* int v = 0; */ 308 /* int v = 0; */
349 309
350 /* v = _ecore_xcb_resource_get_int("Xft", "dpi"); */ 310 /* v = _ecore_xcb_resource_get_int("Xft", "dpi"); */
@@ -356,6 +316,8 @@ _ecore_xcb_cursor_guess_size(void)
356{ 316{
357 int w = 0, h = 0, s = 0; 317 int w = 0, h = 0, s = 0;
358 318
319 LOGFN(__FILE__, __LINE__, __FUNCTION__);
320
359 ecore_x_screen_size_get(_ecore_xcb_screen, &w, &h); 321 ecore_x_screen_size_get(_ecore_xcb_screen, &w, &h);
360 if (h < w) s = h; 322 if (h < w) s = h;
361 else s = w; 323 else s = w;
@@ -364,53 +326,39 @@ _ecore_xcb_cursor_guess_size(void)
364 326
365#ifdef ECORE_XCB_CURSOR 327#ifdef ECORE_XCB_CURSOR
366static Ecore_X_Cursor 328static Ecore_X_Cursor
367_ecore_xcb_cursor_image_load_argb_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, xcb_image_t *img) 329_ecore_xcb_cursor_image_load_cursor(xcb_image_t *img, int hot_x, int hot_y)
368{ 330{
369 xcb_pixmap_t pixmap; 331 Ecore_X_Cursor cursor = 0;
370 xcb_render_picture_t pict;
371 Ecore_X_Cursor cursor;
372 Ecore_X_GC gc; 332 Ecore_X_GC gc;
333 xcb_pixmap_t pmap;
334 xcb_render_picture_t pict;
373 335
374 if (!_ecore_xcb_cursor_format) 336 pmap = xcb_generate_id(_ecore_xcb_conn);
375 _ecore_xcb_cursor_format = _ecore_xcb_cursor_find_image_format(); 337 xcb_create_pixmap(_ecore_xcb_conn, img->depth, pmap,
376 338 ((xcb_screen_t *)_ecore_xcb_screen)->root,
377 pixmap = xcb_generate_id(_ecore_xcb_conn); 339 img->width, img->height);
378 xcb_create_pixmap(_ecore_xcb_conn, 32, pixmap, win, w, h);
379 340
380 // img->depth was 32 341 gc = ecore_x_gc_new(pmap, 0, NULL);
381 gc = ecore_x_gc_new(pixmap, 0, NULL); 342 xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc,
382 xcb_put_image(_ecore_xcb_conn, XCB_IMAGE_FORMAT_Z_PIXMAP, 343 img->width, img->height, 0, 0, 0, img->depth,
383 pixmap, gc, w, h, 0, 0, 0, 344 img->size, img->data);
384 img->depth, img->size, img->data);
385 ecore_x_gc_free(gc); 345 ecore_x_gc_free(gc);
386 346
387 pict = xcb_generate_id(_ecore_xcb_conn); 347 pict = xcb_generate_id(_ecore_xcb_conn);
388 xcb_render_create_picture(_ecore_xcb_conn, pict, pixmap, 348 xcb_render_create_picture(_ecore_xcb_conn, pict, pmap,
389 _ecore_xcb_cursor_format->id, 0, NULL); 349 _ecore_xcb_cursor_format->id, 0, NULL);
390 xcb_free_pixmap(_ecore_xcb_conn, pixmap); 350 xcb_free_pixmap(_ecore_xcb_conn, pmap);
391 351
392 cursor = xcb_generate_id(_ecore_xcb_conn); 352 cursor = xcb_generate_id(_ecore_xcb_conn);
393 xcb_render_create_cursor(_ecore_xcb_conn, cursor, pict, hot_x, hot_y); 353 xcb_render_create_cursor(_ecore_xcb_conn, cursor, pict, hot_x, hot_y);
394 xcb_render_free_picture(_ecore_xcb_conn, pict); 354 xcb_render_free_picture(_ecore_xcb_conn, pict);
395 355
396 ecore_x_flush();
397 return cursor; 356 return cursor;
398} 357}
358#endif
399 359
400static xcb_render_pictforminfo_t * 360static void
401_ecore_xcb_cursor_find_image_format(void) 361_ecore_xcb_cursor_image_destroy(xcb_image_t *img)
402{ 362{
403 const xcb_render_query_pict_formats_reply_t *reply; 363 if (img) xcb_image_destroy(img);
404 xcb_render_pictforminfo_t *ret = NULL;
405
406 reply = xcb_render_util_query_formats(_ecore_xcb_conn);
407 if (reply)
408 {
409 ret = xcb_render_util_find_standard_format(reply,
410 XCB_PICT_STANDARD_ARGB_32);
411// free(reply);
412 }
413
414 return ret;
415} 364}
416#endif
diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c
index bd41f20b3f..10b5659255 100644
--- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c
+++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c
@@ -1,7 +1,6 @@
1#include "ecore_xcb_private.h" 1#include "ecore_xcb_private.h"
2#include <sys/ipc.h> 2#include <sys/ipc.h>
3#include <sys/shm.h> 3#include <sys/shm.h>
4#include <xcb/xcb_image.h>
5#include <xcb/xcb_event.h> 4#include <xcb/xcb_event.h>
6#include <xcb/shm.h> 5#include <xcb/shm.h>
7 6
@@ -19,7 +18,6 @@ struct _Ecore_X_Image
19/* local function prototypes */ 18/* local function prototypes */
20static void _ecore_xcb_image_shm_check(void); 19static void _ecore_xcb_image_shm_check(void);
21static void _ecore_xcb_image_shm_create(Ecore_X_Image *im); 20static void _ecore_xcb_image_shm_create(Ecore_X_Image *im);
22static xcb_image_t *_ecore_xcb_image_create_native(int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data);
23static xcb_format_t *_ecore_xcb_image_find_format(const xcb_setup_t *setup, uint8_t depth); 21static xcb_format_t *_ecore_xcb_image_find_format(const xcb_setup_t *setup, uint8_t depth);
24 22
25/* local variables */ 23/* local variables */
@@ -586,7 +584,6 @@ _ecore_xcb_image_shm_create(Ecore_X_Image *im)
586 if (!im->xim) return; 584 if (!im->xim) return;
587 585
588 im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0666)); 586 im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0666));
589// shmget(IPC_PRIVATE, im->xim->stride * im->xim->height, (IPC_CREAT | 0666));
590 if (im->shminfo.shmid == (uint32_t)-1) 587 if (im->shminfo.shmid == (uint32_t)-1)
591 { 588 {
592 xcb_image_destroy(im->xim); 589 xcb_image_destroy(im->xim);
@@ -618,7 +615,7 @@ _ecore_xcb_image_shm_create(Ecore_X_Image *im)
618 im->bpp = 4; 615 im->bpp = 4;
619} 616}
620 617
621static xcb_image_t * 618xcb_image_t *
622_ecore_xcb_image_create_native(int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data) 619_ecore_xcb_image_create_native(int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data)
623{ 620{
624 static uint8_t dpth = 0; 621 static uint8_t dpth = 0;
diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h
index 5330de23da..95824cabeb 100644
--- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h
+++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h
@@ -13,6 +13,7 @@
13# include <xcb/xcb.h> 13# include <xcb/xcb.h>
14# include <xcb/bigreq.h> 14# include <xcb/bigreq.h>
15# include <xcb/shm.h> 15# include <xcb/shm.h>
16# include <xcb/xcb_image.h>
16 17
17/* EFL includes */ 18/* EFL includes */
18# include "Ecore.h" 19# include "Ecore.h"
@@ -334,4 +335,6 @@ Ecore_X_Window_State _ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom);
334int _ecore_xcb_error_handle(xcb_generic_error_t *err); 335int _ecore_xcb_error_handle(xcb_generic_error_t *err);
335int _ecore_xcb_io_error_handle(xcb_generic_error_t *err); 336int _ecore_xcb_io_error_handle(xcb_generic_error_t *err);
336 337
338xcb_image_t *_ecore_xcb_image_create_native(int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data);
339
337#endif 340#endif