3 #endif /* ifdef HAVE_CONFIG_H */
7 #include "ecore_x_private.h"
10 ecore_x_cursor_color_supported_get(void)
12 return _ecore_x_xcursor;
16 ecore_x_cursor_new(Ecore_X_Window win,
24 LOGFN(__FILE__, __LINE__, __FUNCTION__);
30 xci = XcursorImageCreate(w, h);
38 for (i = 0; i < (w * h); i++)
42 // a = (pixels[i] >> 24) & 0xff;
43 // r = (((pixels[i] >> 16) & 0xff) * a) / 0xff;
44 // g = (((pixels[i] >> 8 ) & 0xff) * a) / 0xff;
45 // b = (((pixels[i] ) & 0xff) * a) / 0xff;
46 xci->pixels[i] = pixels[i];
47 // (a << 24) | (r << 16) | (g << 8) | (b);
49 c = XcursorImageLoadCursor(_ecore_x_disp, xci);
50 XcursorImageDestroy(xci);
55 #endif /* ifdef ECORE_XCURSOR */
64 int fr, fg, fb, br, bg, bb;
66 int darkest = 255 * 3;
68 const int dither[2][2] =
74 pmap = XCreatePixmap(_ecore_x_disp, win, w, h, 1);
75 mask = XCreatePixmap(_ecore_x_disp, win, w, h, 1);
76 xim = XCreateImage(_ecore_x_disp,
77 DefaultVisual(_ecore_x_disp, 0),
78 1, ZPixmap, 0, NULL, w, h, 32, 0);
79 xim->data = malloc(xim->bytes_per_line * xim->height);
81 fr = 0x00; fg = 0x00; fb = 0x00;
82 br = 0xff; bg = 0xff; bb = 0xff;
83 pix = (unsigned int *)pixels;
84 for (y = 0; y < h; y++)
86 for (x = 0; x < w; x++)
90 a = (pix[0] >> 24) & 0xff;
91 r = (pix[0] >> 16) & 0xff;
92 g = (pix[0] >> 8) & 0xff;
96 if ((r + g + b) > brightest)
98 brightest = r + g + b;
104 if ((r + g + b) < darkest)
117 pix = (unsigned int *)pixels;
118 for (y = 0; y < h; y++)
120 for (x = 0; x < w; x++)
126 r = (pix[0] >> 16) & 0xff;
127 g = (pix[0] >> 8) & 0xff;
130 ((r - fr) * (r - fr)) +
131 ((g - fg) * (g - fg)) +
132 ((b - fb) * (b - fb));
134 ((r - br) * (r - br)) +
135 ((g - bg) * (g - bg)) +
136 ((b - bb) * (b - bb));
139 v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
140 if (v > dither[x & 0x1][y & 0x1])
148 XPutPixel(xim, x, y, v);
152 gc = XCreateGC(_ecore_x_disp, pmap, 0, &gcv);
153 XPutImage(_ecore_x_disp, pmap, gc, xim, 0, 0, 0, 0, w, h);
154 XFreeGC(_ecore_x_disp, gc);
156 pix = (unsigned int *)pixels;
157 for (y = 0; y < h; y++)
159 for (x = 0; x < w; x++)
163 v = (((pix[0] >> 24) & 0xff) * 5) / 256;
164 if (v > dither[x & 0x1][y & 0x1])
169 XPutPixel(xim, x, y, v);
173 gc = XCreateGC(_ecore_x_disp, mask, 0, &gcv);
174 XPutImage(_ecore_x_disp, mask, gc, xim, 0, 0, 0, 0, w, h);
175 XFreeGC(_ecore_x_disp, gc);
182 c1.red = fr << 8 | fr;
183 c1.green = fg << 8 | fg;
184 c1.blue = fb << 8 | fb;
185 c1.flags = DoRed | DoGreen | DoBlue;
188 c2.red = br << 8 | br;
189 c2.green = bg << 8 | bg;
190 c2.blue = bb << 8 | bb;
191 c2.flags = DoRed | DoGreen | DoBlue;
193 c = XCreatePixmapCursor(_ecore_x_disp,
197 XFreePixmap(_ecore_x_disp, pmap);
198 XFreePixmap(_ecore_x_disp, mask);
206 ecore_x_cursor_free(Ecore_X_Cursor c)
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 XFreeCursor(_ecore_x_disp, c);
213 * Returns the cursor for the given shape.
214 * Note that the return value must not be freed with
215 * ecore_x_cursor_free()!
218 ecore_x_cursor_shape_get(int shape)
220 LOGFN(__FILE__, __LINE__, __FUNCTION__);
221 /* Shapes are defined in Ecore_X_Cursor.h */
222 return XCreateFontCursor(_ecore_x_disp, shape);
226 ecore_x_cursor_size_set(int size)
229 LOGFN(__FILE__, __LINE__, __FUNCTION__);
230 XcursorSetDefaultSize(_ecore_x_disp, size);
231 #else /* ifdef ECORE_XCURSOR */
233 #endif /* ifdef ECORE_XCURSOR */
237 ecore_x_cursor_size_get(void)
240 LOGFN(__FILE__, __LINE__, __FUNCTION__);
241 return XcursorGetDefaultSize(_ecore_x_disp);
242 #else /* ifdef ECORE_XCURSOR */
244 #endif /* ifdef ECORE_XCURSOR */