Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
#include "ecore_xcb_private.h"
|
2011-07-14 08:35:42 -07:00
|
|
|
#ifdef ECORE_XCB_CURSOR
|
|
|
|
# include <xcb/render.h>
|
|
|
|
# include <xcb/xcb_renderutil.h>
|
|
|
|
#endif
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
|
2011-07-14 08:35:42 -07:00
|
|
|
/* local function prototypes */
|
2011-08-23 09:39:52 -07:00
|
|
|
#ifdef ECORE_XCB_CURSOR
|
|
|
|
static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format_get(void);
|
|
|
|
#endif
|
2011-10-20 22:40:59 -07:00
|
|
|
static void _ecore_xcb_cursor_default_size_get(void);
|
|
|
|
static void _ecore_xcb_cursor_dpi_size_get(void);
|
|
|
|
static void _ecore_xcb_cursor_guess_size(void);
|
2011-07-14 08:35:42 -07:00
|
|
|
#ifdef ECORE_XCB_CURSOR
|
2011-10-20 22:40:59 -07:00
|
|
|
static Ecore_X_Cursor _ecore_xcb_cursor_image_load_cursor(xcb_image_t *img,
|
|
|
|
int hot_x,
|
|
|
|
int hot_y);
|
2011-07-14 08:35:42 -07:00
|
|
|
#endif
|
2011-08-23 09:39:52 -07:00
|
|
|
static void _ecore_xcb_cursor_image_destroy(xcb_image_t *img);
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
|
2011-07-14 08:35:42 -07:00
|
|
|
/* local variables */
|
2011-08-23 09:39:52 -07:00
|
|
|
static int _ecore_xcb_cursor_size = 0;
|
|
|
|
static Eina_Bool _ecore_xcb_cursor = EINA_FALSE;
|
2011-07-14 08:35:42 -07:00
|
|
|
#ifdef ECORE_XCB_CURSOR
|
2011-09-20 00:17:55 -07:00
|
|
|
static uint32_t _ecore_xcb_cursor_format_id = 0;
|
|
|
|
// static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format = NULL;
|
2011-07-14 08:35:42 -07:00
|
|
|
#endif
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
void
|
|
|
|
_ecore_xcb_cursor_init(void)
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
{
|
2011-07-14 08:35:42 -07:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-08-23 09:39:52 -07:00
|
|
|
/* NB: No-op */
|
2011-07-14 08:35:42 -07:00
|
|
|
}
|
2010-08-02 11:54:27 -07:00
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
void
|
|
|
|
_ecore_xcb_cursor_finalize(void)
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
{
|
2011-07-14 08:35:42 -07:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
#ifdef ECORE_XCB_CURSOR
|
|
|
|
_ecore_xcb_cursor = _ecore_xcb_render_argb_get();
|
2011-07-25 22:54:01 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
/* find render pict format */
|
2011-10-20 22:40:59 -07:00
|
|
|
if (_ecore_xcb_cursor_format_id <= 0)
|
2011-09-20 00:17:55 -07:00
|
|
|
_ecore_xcb_cursor_format_id = _ecore_xcb_cursor_format_get()->id;
|
2011-08-23 09:39:52 -07:00
|
|
|
#endif
|
|
|
|
|
2011-07-25 22:54:01 -07:00
|
|
|
/* try to grab cursor size from XDefaults */
|
|
|
|
_ecore_xcb_cursor_default_size_get();
|
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
/* if that failed, try to get it from Xft Dpi setting */
|
|
|
|
if (_ecore_xcb_cursor_size == 0)
|
2011-07-25 22:54:01 -07:00
|
|
|
_ecore_xcb_cursor_dpi_size_get();
|
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
/* if that failed, try to guess from display size */
|
|
|
|
if (_ecore_xcb_cursor_size == 0)
|
2011-07-25 22:54:01 -07:00
|
|
|
_ecore_xcb_cursor_guess_size();
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
/* NB: Would normally add theme stuff here, but E cursor does not support
|
|
|
|
* xcursor themes. Delay parsing that stuff out until such time if/when the
|
2011-07-25 22:54:01 -07:00
|
|
|
* user selects to use X Cursor, rather than E cursor */
|
2011-07-14 08:35:42 -07:00
|
|
|
}
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_x_cursor_color_supported_get(void)
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
{
|
2011-07-14 08:35:42 -07:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
return _ecore_xcb_cursor;
|
|
|
|
}
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
EAPI Ecore_X_Cursor
|
|
|
|
ecore_x_cursor_new(Ecore_X_Window win,
|
|
|
|
int *pixels,
|
|
|
|
int w,
|
|
|
|
int h,
|
|
|
|
int hot_x,
|
|
|
|
int hot_y)
|
2011-07-14 08:35:42 -07:00
|
|
|
{
|
|
|
|
Ecore_X_Cursor cursor = 0;
|
|
|
|
xcb_image_t *img;
|
|
|
|
|
2011-09-08 14:51:08 -07:00
|
|
|
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-09-20 02:12:02 -07:00
|
|
|
CHECK_XCB_CONN;
|
2011-07-14 08:35:42 -07:00
|
|
|
|
Here is ecore_x with XCB backend.
* The XCB backend is disabled by default during the
configuration. To enable it, add --enable-ecore-x-xcb. See the
messages that configure displays when it finishes.
* The way XCB is detected, and used in src/lib/ecore_x/Makefile.am
should be improved
* Any program that uses ecore_evas does not need to be modified.
Any program that uses ecore_x may need some changes. That is,
adding some functions (_prefetch and _fetch ones). No other
change is needed. See the documention of any _get functions, as
these are the ones that need those functions.
* There are some missing parts, especially everything that involves
the keyboard, as porting Xlib functions related to strings (utf8
stuff, XKeysymToString, etc...) is an horror. So keyboard events
are not working yet.
* I tried to write as much documentation as I could. But there is
certainly some missing doc here and there.
there are certainly other things that I have forgotten.
Improvements of that backend:
* the creation of an ecore_evas is faster. Especially when done over
an ssh connection (on my computer, 7-10s with Xlib, 1.5s with XCB,
over an ssh)
* A Window Manager should be more responsive. But it's not tomorrow
that e17 will use it :)
Have fun !
SVN revision: 29500
2007-04-13 10:15:19 -07:00
|
|
|
#ifdef ECORE_XCB_CURSOR
|
2011-10-20 22:40:59 -07:00
|
|
|
if (_ecore_xcb_cursor)
|
2011-07-14 08:35:42 -07:00
|
|
|
{
|
2011-10-20 22:40:59 -07:00
|
|
|
img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
|
|
|
|
32, NULL, (w * h * sizeof(int)),
|
2011-08-23 09:39:52 -07:00
|
|
|
(uint8_t *)pixels);
|
|
|
|
cursor = _ecore_xcb_cursor_image_load_cursor(img, hot_x, hot_y);
|
|
|
|
_ecore_xcb_cursor_image_destroy(img);
|
|
|
|
return cursor;
|
2011-07-14 08:35:42 -07:00
|
|
|
}
|
2011-08-23 09:39:52 -07:00
|
|
|
else
|
|
|
|
#endif
|
2011-10-20 22:40:59 -07:00
|
|
|
{
|
|
|
|
Ecore_X_GC gc;
|
|
|
|
xcb_pixmap_t pmap, mask;
|
|
|
|
uint32_t *pix;
|
|
|
|
uint8_t fr = 0x00, fg = 0x00, fb = 0x00;
|
|
|
|
uint8_t br = 0xff, bg = 0xff, bb = 0xff;
|
|
|
|
uint32_t brightest = 0, darkest = 255 * 3;
|
|
|
|
uint16_t x, y;
|
|
|
|
const uint32_t dither[2][2] =
|
|
|
|
{
|
|
|
|
{0, 2},
|
|
|
|
{3, 1}
|
|
|
|
};
|
|
|
|
|
|
|
|
img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
|
|
|
|
1, NULL, ~0, NULL);
|
|
|
|
if (img->data) free(img->data);
|
|
|
|
img->data = malloc(img->size);
|
|
|
|
|
|
|
|
pmap = xcb_generate_id(_ecore_xcb_conn);
|
|
|
|
xcb_create_pixmap(_ecore_xcb_conn, 1, pmap, win, w, h);
|
|
|
|
mask = xcb_generate_id(_ecore_xcb_conn);
|
|
|
|
xcb_create_pixmap(_ecore_xcb_conn, 1, mask, win, w, h);
|
|
|
|
|
|
|
|
pix = (uint32_t *)pixels;
|
|
|
|
for (y = 0; y < h; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < w; x++)
|
|
|
|
{
|
|
|
|
uint8_t r, g, b, a;
|
|
|
|
|
|
|
|
a = (pix[0] >> 24) & 0xff;
|
|
|
|
r = (pix[0] >> 16) & 0xff;
|
|
|
|
g = (pix[0] >> 8) & 0xff;
|
|
|
|
b = (pix[0]) & 0xff;
|
|
|
|
if (a > 0)
|
|
|
|
{
|
|
|
|
if ((uint32_t)(r + g + b) > brightest)
|
|
|
|
{
|
|
|
|
brightest = r + g + b;
|
|
|
|
br = r;
|
|
|
|
bg = g;
|
|
|
|
bb = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((uint32_t)(r + g + b) < darkest)
|
|
|
|
{
|
|
|
|
darkest = r + g + b;
|
|
|
|
fr = r;
|
|
|
|
fg = g;
|
|
|
|
fb = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pix = (uint32_t *)pixels;
|
|
|
|
for (y = 0; y < h; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < w; x++)
|
|
|
|
{
|
|
|
|
uint32_t v;
|
|
|
|
uint8_t r, g, b;
|
|
|
|
int32_t d1, d2;
|
|
|
|
|
|
|
|
r = (pix[0] >> 16) & 0xff;
|
|
|
|
g = (pix[0] >> 8) & 0xff;
|
|
|
|
b = (pix[0]) & 0xff;
|
|
|
|
d1 =
|
|
|
|
((r - fr) * (r - fr)) +
|
|
|
|
((g - fg) * (g - fg)) +
|
|
|
|
((b - fb) * (b - fb));
|
|
|
|
d2 =
|
|
|
|
((r - br) * (r - br)) +
|
|
|
|
((g - bg) * (g - bg)) +
|
|
|
|
((b - bb) * (b - bb));
|
|
|
|
if (d1 + d2)
|
|
|
|
{
|
|
|
|
v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
|
|
|
|
if (v > dither[x & 0x1][y & 0x1])
|
|
|
|
v = 1;
|
|
|
|
else
|
|
|
|
v = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
v = 0;
|
|
|
|
|
|
|
|
xcb_image_put_pixel(img, x, y, v);
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gc = ecore_x_gc_new(pmap, 0, NULL);
|
|
|
|
xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc, w, h,
|
|
|
|
0, 0, 0, img->depth, img->size, img->data);
|
|
|
|
ecore_x_gc_free(gc);
|
|
|
|
|
|
|
|
pix = (uint32_t *)pixels;
|
|
|
|
for (y = 0; y < h; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < w; x++)
|
|
|
|
{
|
|
|
|
uint32_t v;
|
|
|
|
|
|
|
|
v = (((pix[0] >> 24) & 0xff) * 5) / 256;
|
|
|
|
if (v > dither[x & 0x1][y & 0x1])
|
|
|
|
v = 1;
|
|
|
|
else
|
|
|
|
v = 0;
|
|
|
|
|
|
|
|
xcb_image_put_pixel(img, x, y, v);
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gc = ecore_x_gc_new(mask, 0, NULL);
|
|
|
|
xcb_put_image(_ecore_xcb_conn, img->format, mask, gc, w, h,
|
|
|
|
0, 0, 0, img->depth, img->size, img->data);
|
|
|
|
ecore_x_gc_free(gc);
|
|
|
|
|
|
|
|
if (img->data) free(img->data);
|
|
|
|
_ecore_xcb_cursor_image_destroy(img);
|
|
|
|
|
|
|
|
cursor = xcb_generate_id(_ecore_xcb_conn);
|
|
|
|
xcb_create_cursor(_ecore_xcb_conn, cursor, pmap, mask,
|
|
|
|
fr << 8 | fr, fg << 8 | fg, fb << 8 | fb,
|
|
|
|
br << 8 | br, bg << 8 | bg, bb << 8 | bb,
|
|
|
|
hot_x, hot_y);
|
|
|
|
|
|
|
|
xcb_free_pixmap(_ecore_xcb_conn, pmap);
|
|
|
|
xcb_free_pixmap(_ecore_xcb_conn, mask);
|
|
|
|
|
|
|
|
return cursor;
|
|
|
|
}
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_x_cursor_free(Ecore_X_Cursor c)
|
2011-08-23 09:39:52 -07:00
|
|
|
{
|
2011-09-08 14:51:08 -07:00
|
|
|
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-10-20 22:40:59 -07:00
|
|
|
CHECK_XCB_CONN;
|
2011-08-23 09:39:52 -07:00
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
xcb_free_cursor(_ecore_xcb_conn, c);
|
2011-08-23 09:39:52 -07:00
|
|
|
}
|
|
|
|
|
2011-08-23 09:43:18 -07:00
|
|
|
/*
|
|
|
|
* Returns the cursor for the given shape.
|
|
|
|
* Note that the return value must not be freed with
|
|
|
|
* ecore_x_cursor_free()!
|
|
|
|
*/
|
2011-10-20 22:40:59 -07:00
|
|
|
EAPI Ecore_X_Cursor
|
|
|
|
ecore_x_cursor_shape_get(int shape)
|
2011-08-23 09:39:52 -07:00
|
|
|
{
|
|
|
|
Ecore_X_Cursor cursor = 0;
|
|
|
|
xcb_font_t font;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-09-20 02:12:02 -07:00
|
|
|
CHECK_XCB_CONN;
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
font = xcb_generate_id(_ecore_xcb_conn);
|
|
|
|
xcb_open_font(_ecore_xcb_conn, font, strlen("cursor"), "cursor");
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
cursor = xcb_generate_id(_ecore_xcb_conn);
|
|
|
|
/* FIXME: Add request check ?? */
|
2011-10-20 22:40:59 -07:00
|
|
|
xcb_create_glyph_cursor(_ecore_xcb_conn, cursor, font, font,
|
2011-08-23 09:39:52 -07:00
|
|
|
shape, shape + 1, 0, 0, 0, 65535, 65535, 65535);
|
|
|
|
|
|
|
|
xcb_close_font(_ecore_xcb_conn, font);
|
2011-07-14 08:35:42 -07:00
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_x_cursor_size_set(int size)
|
2011-08-23 09:39:52 -07:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
_ecore_xcb_cursor_size = size;
|
|
|
|
/* NB: May need to adjust size of current cursors here */
|
|
|
|
}
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
EAPI int
|
|
|
|
ecore_x_cursor_size_get(void)
|
2011-08-23 09:39:52 -07:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
return _ecore_xcb_cursor_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local functions */
|
|
|
|
#ifdef ECORE_XCB_CURSOR
|
|
|
|
static xcb_render_pictforminfo_t *
|
2011-10-20 22:40:59 -07:00
|
|
|
_ecore_xcb_cursor_format_get(void)
|
2011-08-23 09:39:52 -07:00
|
|
|
{
|
|
|
|
const xcb_render_query_pict_formats_reply_t *reply;
|
|
|
|
xcb_render_pictforminfo_t *ret = NULL;
|
|
|
|
|
2011-09-20 02:12:02 -07:00
|
|
|
CHECK_XCB_CONN;
|
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
reply = xcb_render_util_query_formats(_ecore_xcb_conn);
|
2011-10-20 22:40:59 -07:00
|
|
|
if (reply)
|
|
|
|
ret = xcb_render_util_find_standard_format(reply,
|
2011-08-23 09:39:52 -07:00
|
|
|
XCB_PICT_STANDARD_ARGB_32);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2011-10-20 22:40:59 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
#endif
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
static void
|
|
|
|
_ecore_xcb_cursor_default_size_get(void)
|
2011-07-25 22:54:01 -07:00
|
|
|
{
|
2011-09-08 14:51:08 -07:00
|
|
|
char *s = NULL;
|
|
|
|
int v = 0;
|
2011-08-23 09:39:52 -07:00
|
|
|
|
2011-09-08 14:51:08 -07:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-07-25 22:54:01 -07:00
|
|
|
|
2011-09-08 14:51:08 -07:00
|
|
|
s = getenv("XCURSOR_SIZE");
|
2011-10-20 22:40:59 -07:00
|
|
|
if (!s)
|
2011-09-08 14:51:08 -07:00
|
|
|
{
|
|
|
|
_ecore_xcb_xdefaults_init();
|
|
|
|
v = _ecore_xcb_xdefaults_int_get("Xcursor", "size");
|
|
|
|
_ecore_xcb_xdefaults_shutdown();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
v = atoi(s);
|
|
|
|
if (v) _ecore_xcb_cursor_size = ((v * 16) / 72);
|
2011-07-25 22:54:01 -07:00
|
|
|
}
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
static void
|
|
|
|
_ecore_xcb_cursor_dpi_size_get(void)
|
2011-07-25 22:54:01 -07:00
|
|
|
{
|
2011-09-08 14:51:08 -07:00
|
|
|
int v = 0;
|
2011-08-23 09:39:52 -07:00
|
|
|
|
2011-09-08 14:51:08 -07:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-07-25 22:54:01 -07:00
|
|
|
|
2011-09-08 14:51:08 -07:00
|
|
|
_ecore_xcb_xdefaults_init();
|
|
|
|
v = _ecore_xcb_xdefaults_int_get("Xft", "dpi");
|
|
|
|
if (v) _ecore_xcb_cursor_size = ((v * 16) / 72);
|
|
|
|
_ecore_xcb_xdefaults_shutdown();
|
2011-07-25 22:54:01 -07:00
|
|
|
}
|
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
static void
|
|
|
|
_ecore_xcb_cursor_guess_size(void)
|
2011-07-25 22:54:01 -07:00
|
|
|
{
|
|
|
|
int w = 0, h = 0, s = 0;
|
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2011-07-25 22:54:01 -07:00
|
|
|
ecore_x_screen_size_get(_ecore_xcb_screen, &w, &h);
|
|
|
|
if (h < w) s = h;
|
|
|
|
else s = w;
|
|
|
|
_ecore_xcb_cursor_size = (s / 48);
|
|
|
|
}
|
|
|
|
|
2011-07-14 08:35:42 -07:00
|
|
|
#ifdef ECORE_XCB_CURSOR
|
2011-10-20 22:40:59 -07:00
|
|
|
static Ecore_X_Cursor
|
|
|
|
_ecore_xcb_cursor_image_load_cursor(xcb_image_t *img,
|
|
|
|
int hot_x,
|
|
|
|
int hot_y)
|
2011-07-14 08:35:42 -07:00
|
|
|
{
|
2011-08-23 09:39:52 -07:00
|
|
|
Ecore_X_Cursor cursor = 0;
|
2011-07-14 08:35:42 -07:00
|
|
|
Ecore_X_GC gc;
|
2011-08-23 09:39:52 -07:00
|
|
|
xcb_pixmap_t pmap;
|
|
|
|
xcb_render_picture_t pict;
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-09-20 02:12:02 -07:00
|
|
|
CHECK_XCB_CONN;
|
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
pmap = xcb_generate_id(_ecore_xcb_conn);
|
2011-10-20 22:40:59 -07:00
|
|
|
xcb_create_pixmap(_ecore_xcb_conn, img->depth, pmap,
|
|
|
|
((xcb_screen_t *)_ecore_xcb_screen)->root,
|
2011-08-23 09:39:52 -07:00
|
|
|
img->width, img->height);
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
gc = ecore_x_gc_new(pmap, 0, NULL);
|
2011-10-20 22:40:59 -07:00
|
|
|
xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc,
|
|
|
|
img->width, img->height, 0, 0, 0, img->depth,
|
2011-08-23 09:39:52 -07:00
|
|
|
img->size, img->data);
|
2011-07-14 08:35:42 -07:00
|
|
|
ecore_x_gc_free(gc);
|
|
|
|
|
|
|
|
pict = xcb_generate_id(_ecore_xcb_conn);
|
2011-10-20 22:40:59 -07:00
|
|
|
xcb_render_create_picture(_ecore_xcb_conn, pict, pmap,
|
2011-09-20 00:17:55 -07:00
|
|
|
_ecore_xcb_cursor_format_id, 0, NULL);
|
2011-08-23 09:39:52 -07:00
|
|
|
xcb_free_pixmap(_ecore_xcb_conn, pmap);
|
2011-07-14 08:35:42 -07:00
|
|
|
|
|
|
|
cursor = xcb_generate_id(_ecore_xcb_conn);
|
|
|
|
xcb_render_create_cursor(_ecore_xcb_conn, cursor, pict, hot_x, hot_y);
|
|
|
|
xcb_render_free_picture(_ecore_xcb_conn, pict);
|
|
|
|
|
|
|
|
return cursor;
|
|
|
|
}
|
2011-10-20 22:40:59 -07:00
|
|
|
|
2011-08-23 09:39:52 -07:00
|
|
|
#endif
|
2011-07-14 08:35:42 -07:00
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
static void
|
|
|
|
_ecore_xcb_cursor_image_destroy(xcb_image_t *img)
|
2011-07-14 08:35:42 -07:00
|
|
|
{
|
2011-09-20 02:12:02 -07:00
|
|
|
CHECK_XCB_CONN;
|
2011-08-23 09:39:52 -07:00
|
|
|
if (img) xcb_image_destroy(img);
|
2011-07-14 08:35:42 -07:00
|
|
|
}
|
2011-10-20 22:40:59 -07:00
|
|
|
|