Enlightenment CVS committal Author : doursse Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_x Modified Files: Ecore_X.h Makefile.am ecore_x.c ecore_x_dpms.c ecore_x_private.h Added Files: ecore_x_cursor.c ecore_x_drawable.c Log Message: Move cursor and drawable functions to their own file. DPMS: Add doc, init function, ecore_x_dpms_timeouts_get and rename ecore_x_dpms_capable. As my xorg does not have the dpms extension, someone else has to add its test in configure.in (like other extensions) =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v retrieving revision 1.182 retrieving revision 1.183 diff -u -3 -r1.182 -r1.183 --- Ecore_X.h 13 Feb 2007 16:24:37 -0000 1.182 +++ Ecore_X.h 9 Mar 2007 01:11:09 -0000 1.183 @@ -6,9 +6,9 @@ #define _ECORE_X_H #ifdef EAPI -#undef EAPI +# undef EAPI #endif -#ifdef WIN32 +#ifdef _MSC_VER # ifdef BUILDING_DLL # define EAPI __declspec(dllexport) # else @@ -1173,11 +1173,19 @@ EAPI int ecore_x_mouse_down_send(Ecore_X_Window win, int x, int y, int b); EAPI int ecore_x_mouse_up_send(Ecore_X_Window win, int x, int y, int b); - -/* FIXME: these funcs need categorising */ EAPI void ecore_x_drawable_geometry_get(Ecore_X_Drawable d, int *x, int *y, int *w, int *h); EAPI int ecore_x_drawable_border_width_get(Ecore_X_Drawable d); EAPI int ecore_x_drawable_depth_get(Ecore_X_Drawable d); + +EAPI int ecore_x_cursor_color_supported_get(void); +EAPI Ecore_X_Cursor ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int hot_y); +EAPI void ecore_x_cursor_free(Ecore_X_Cursor c); +EAPI Ecore_X_Cursor ecore_x_cursor_shape_get(int shape); +EAPI void ecore_x_cursor_size_set(int size); +EAPI int ecore_x_cursor_size_get(void); + + +/* FIXME: these funcs need categorising */ EAPI Ecore_X_Window *ecore_x_window_root_list(int *num_ret); EAPI Ecore_X_Window ecore_x_window_root_first_get(void); EAPI int ecore_x_window_manage(Ecore_X_Window win); @@ -1409,13 +1417,6 @@ EAPI void ecore_x_window_save_set_del(Ecore_X_Window win); EAPI Ecore_X_Window *ecore_x_window_children_get(Ecore_X_Window win, int *num); -EAPI int ecore_x_cursor_color_supported_get(void); -EAPI Ecore_X_Cursor ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int hot_y); -EAPI void ecore_x_cursor_free(Ecore_X_Cursor c); -EAPI Ecore_X_Cursor ecore_x_cursor_shape_get(int shape); -EAPI void ecore_x_cursor_size_set(int size); -EAPI int ecore_x_cursor_size_get(void); - EAPI int ecore_x_pointer_grab(Ecore_X_Window win); EAPI int ecore_x_pointer_confine_grab(Ecore_X_Window win); @@ -1530,6 +1531,20 @@ EAPI void ecore_x_damage_subtract(Ecore_X_Damage damage, Ecore_X_Region repair, Ecore_X_Region parts); EAPI int ecore_x_screen_is_composited(int screen); + +EAPI int ecore_x_dpms_query(void); +EAPI int ecore_x_dpms_capable_get(void); +EAPI int ecore_x_dpms_enabled_get(void); +EAPI void ecore_x_dpms_enabled_set(int enabled); +EAPI void ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off); +EAPI int ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off); +EAPI unsigned int ecore_x_dpms_timeout_standby_get(); +EAPI unsigned int ecore_x_dpms_timeout_suspend_get(); +EAPI unsigned int ecore_x_dpms_timeout_off_get(); +EAPI void ecore_x_dpms_timeout_standby_set(unsigned int new_timeout); +EAPI void ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout); +EAPI void ecore_x_dpms_timeout_off_set(unsigned int new_timeout); + #ifdef __cplusplus } =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/Makefile.am,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- Makefile.am 13 Feb 2007 02:29:01 -0000 1.31 +++ Makefile.am 9 Mar 2007 01:11:09 -0000 1.32 @@ -52,6 +52,8 @@ ecore_x_xinerama.c \ ecore_x_screensaver.c \ ecore_x_dpms.c \ +ecore_x_drawable.c \ +ecore_x_cursor.c \ ecore_x_private.h libecore_x_la_LIBADD = \ @@ -100,4 +102,6 @@ ecore_x_xinerama.c \ ecore_x_screensaver.c \ ecore_x_dpms.c \ +ecore_x_drawable.c \ +ecore_x_cursor.c \ ecore_x_private.h =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x.c,v retrieving revision 1.124 retrieving revision 1.125 diff -u -3 -r1.124 -r1.125 --- ecore_x.c 13 Feb 2007 16:24:37 -0000 1.124 +++ ecore_x.c 9 Mar 2007 01:11:09 -0000 1.125 @@ -444,6 +444,7 @@ _ecore_x_dnd_init(); _ecore_x_fixes_init(); _ecore_x_damage_init(); + _ecore_x_dpms_init(); _ecore_x_init_count++; @@ -802,74 +803,6 @@ /*****************************************************************************/ /** - * Retrieves the geometry of the given drawable. - * @param d The given drawable. - * @param x Pointer to an integer into which the X position is to be stored. - * @param y Pointer to an integer into which the Y position is to be stored. - * @param w Pointer to an integer into which the width is to be stored. - * @param h Pointer to an integer into which the height is to be stored. - */ -EAPI void -ecore_x_drawable_geometry_get(Ecore_X_Drawable d, int *x, int *y, int *w, int *h) -{ - Window dummy_win; - int ret_x, ret_y; - unsigned int ret_w, ret_h, dummy_border, dummy_depth; - - if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &ret_x, &ret_y, - &ret_w, &ret_h, &dummy_border, &dummy_depth)) - { - ret_x = 0; - ret_y = 0; - ret_w = 0; - ret_h = 0; - } - - if (x) *x = ret_x; - if (y) *y = ret_y; - if (w) *w = (int) ret_w; - if (h) *h = (int) ret_h; -} - -/** - * Retrieves the width of the border of the given drawable. - * @param d The given drawable. - * @return The border width of the given drawable. - */ -EAPI int -ecore_x_drawable_border_width_get(Ecore_X_Drawable d) -{ - Window dummy_win; - int dummy_x, dummy_y; - unsigned int dummy_w, dummy_h, border_ret, dummy_depth; - - if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y, - &dummy_w, &dummy_h, &border_ret, &dummy_depth)) - border_ret = 0; - - return (int) border_ret; -} - -/** - * Retrieves the depth of the given drawable. - * @param d The given drawable. - * @return The depth of the given drawable. - */ -EAPI int -ecore_x_drawable_depth_get(Ecore_X_Drawable d) -{ - Window dummy_win; - int dummy_x, dummy_y; - unsigned int dummy_w, dummy_h, dummy_border, depth_ret; - - if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y, - &dummy_w, &dummy_h, &dummy_border, &depth_ret)) - depth_ret = 0; - - return (int) depth_ret; -} - -/** * Get a list of all the root windows on the server. * * @note The returned array will need to be freed after use. @@ -1153,233 +1086,6 @@ XFree(children_ret); } return windows; -} - - - - - - -EAPI int -ecore_x_cursor_color_supported_get(void) -{ - return _ecore_x_xcursor; -} - -EAPI Ecore_X_Cursor -ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int hot_y) -{ -#ifdef ECORE_XCURSOR - if (_ecore_x_xcursor) - { - Cursor c; - XcursorImage *xci; - - xci = XcursorImageCreate(w, h); - if (xci) - { - int i; - - xci->xhot = hot_x; - xci->yhot = hot_y; - xci->delay = 0; - for (i = 0; i < (w * h); i++) - { -// int r, g, b, a; -// -// a = (pixels[i] >> 24) & 0xff; -// r = (((pixels[i] >> 16) & 0xff) * a) / 0xff; -// g = (((pixels[i] >> 8 ) & 0xff) * a) / 0xff; -// b = (((pixels[i] ) & 0xff) * a) / 0xff; - xci->pixels[i] = pixels[i]; -// (a << 24) | (r << 16) | (g << 8) | (b); - } - c = XcursorImageLoadCursor(_ecore_x_disp, xci); - XcursorImageDestroy(xci); - return c; - } - } - else -#endif - { - XColor c1, c2; - Cursor c; - Pixmap pmap, mask; - GC gc; - XGCValues gcv; - XImage *xim; - unsigned int *pix; - int fr, fg, fb, br, bg, bb; - int brightest = 0; - int darkest = 255 * 3; - int x, y; - const int dither[2][2] = - { - {0, 2}, - {3, 1} - }; - - - pmap = XCreatePixmap(_ecore_x_disp, win, w, h, 1); - mask = XCreatePixmap(_ecore_x_disp, win, w, h, 1); - xim = XCreateImage(_ecore_x_disp, - DefaultVisual(_ecore_x_disp, 0), - 1, ZPixmap, 0, NULL, w, h, 32, 0); - xim->data = malloc(xim->bytes_per_line * xim->height); - - fr = 0x00; fg = 0x00; fb = 0x00; - br = 0xff; bg = 0xff; bb = 0xff; - pix = (unsigned int*)pixels; - for (y = 0; y < h; y++) - { - for (x = 0; x < w; x++) - { - int 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 ((r + g + b) > brightest) - { - brightest = r + g + b; - br = r; - bg = g; - bb = b; - } - if ((r + g + b) < darkest) - { - darkest = r + g + b; - fr = r; - fg = g; - fb = b; - } - } - pix++; - } - } - - pix = (unsigned int*)pixels; - for (y = 0; y < h; y++) - { - for (x = 0; x < w; x++) - { - int v; - int r, g, b; - int 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; - } - XPutPixel(xim, x, y, v); - pix++; - } - } - gc = XCreateGC(_ecore_x_disp, pmap, 0, &gcv); - XPutImage(_ecore_x_disp, pmap, gc, xim, 0, 0, 0, 0, w, h); - XFreeGC(_ecore_x_disp, gc); - - pix = (unsigned int*)pixels; - for (y = 0; y < h; y++) - { - for (x = 0; x < w; x++) - { - int v; - - v = (((pix[0] >> 24) & 0xff) * 5) / 256; - if (v > dither[x & 0x1][y & 0x1]) v = 1; - else v = 0; - XPutPixel(xim, x, y, v); - pix++; - } - } - gc = XCreateGC(_ecore_x_disp, mask, 0, &gcv); - XPutImage(_ecore_x_disp, mask, gc, xim, 0, 0, 0, 0, w, h); - XFreeGC(_ecore_x_disp, gc); - - free(xim->data); - xim->data = NULL; - XDestroyImage(xim); - - c1.pixel = 0; - c1.red = fr << 8 | fr; - c1.green = fg << 8 | fg; - c1.blue = fb << 8 | fb; - c1.flags = DoRed | DoGreen | DoBlue; - - c2.pixel = 0; - c2.red = br << 8 | br; - c2.green = bg << 8 | bg; - c2.blue = bb << 8 | bb; - c2.flags = DoRed | DoGreen | DoBlue; - - c = XCreatePixmapCursor(_ecore_x_disp, - pmap, mask, - &c1, &c2, - hot_x, hot_y); - XFreePixmap(_ecore_x_disp, pmap); - XFreePixmap(_ecore_x_disp, mask); - return c; - } - return 0; -} - -EAPI void -ecore_x_cursor_free(Ecore_X_Cursor c) -{ - XFreeCursor(_ecore_x_disp, c); -} - -/* - * Returns the cursor for the given shape. - * Note that the return value must not be freed with - * ecore_x_cursor_free()! - */ -EAPI Ecore_X_Cursor -ecore_x_cursor_shape_get(int shape) -{ - /* Shapes are defined in Ecore_X_Cursor.h */ - return XCreateFontCursor(_ecore_x_disp, shape); -} - -EAPI void -ecore_x_cursor_size_set(int size) -{ -#ifdef ECORE_XCURSOR - XcursorSetDefaultSize(_ecore_x_disp, size); -#else - size = 0; -#endif -} - -EAPI int -ecore_x_cursor_size_get(void) -{ -#ifdef ECORE_XCURSOR - return XcursorGetDefaultSize(_ecore_x_disp); -#else - return 0; -#endif } EAPI int =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x_dpms.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ecore_x_dpms.c 13 Feb 2007 02:29:01 -0000 1.1 +++ ecore_x_dpms.c 9 Mar 2007 01:11:09 -0000 1.2 @@ -1,33 +1,85 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -/* - * DPMS code - */ -#include "Ecore.h" + #include "ecore_x_private.h" -#include "Ecore_X.h" -#include "Ecore_X_Atoms.h" -/* Are we capable */ -EAPI int -ecore_x_dpms_capable(void) + +static int _dpms_available; +#ifdef ECORE_XDPMS +static int _dpms_major, _dpms_minor; +#endif + + +void +_ecore_x_dpms_init(void) { - return DPMSCapable(_ecore_x_disp); +#ifdef ECORE_XDPMS + _dpms_major = 1; + _dpms_minor = 0; + + if (DpmsGetVersion(_ecore_x_disp, &_dpms_major, &_dpms_minor)) + _dpms_available = 1; + else + _dpms_available = 0; +#else + _dpms_available = 0; +#endif } -/* Are we enabled */ + +/** + * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions + * + * Functions related to the X DPMS extension. + */ + + + +/** + * Checks if the X DPMS extension is available on the server. + * @return @c 1 if the X DPMS extension is available, @c 0 otherwise. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI int +ecore_x_dpms_query(void) +{ + return _dpms_available; +} + +/** + * Checks if the X server is capable of DPMS. + * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI int +ecore_x_dpms_capable_get(void) +{ + return DPMSCapable(_ecore_x_disp); +} + + +/** + * Checks the DPMS state of the display. + * @return @c 1 if DPMS is enabled, @c 0 otherwise. + * @ingroup Ecore_X_DPMS_Group + */ EAPI int ecore_x_dpms_enabled_get(void) { unsigned char state; unsigned short power_lvl; - + DPMSInfo(_ecore_x_disp, &power_lvl, &state); return state; } -/* Enable/Disable DPMS */ + +/** + * Sets the DPMS state of the display. + * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise. + * @ingroup Ecore_X_DPMS_Group + */ EAPI void ecore_x_dpms_enabled_set(int enabled) { @@ -37,36 +89,76 @@ DPMSDisable(_ecore_x_disp); } -/* Set all timeouts to known values */ + +/** + * Gets the timeouts. The values are in unit of seconds. + * @param standby Amount of time of inactivity before standby mode will be invoked. + * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. + * @param off Amount of time of inactivity before the monitor is shut off. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI void +ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off) +{ + DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby, (unsigned short *)suspend, (unsigned short *)off); +} + + +/** + * Sets the timeouts. The values are in unit of seconds. + * @param standby Amount of time of inactivity before standby mode will be invoked. + * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. + * @param off Amount of time of inactivity before the monitor is shut off. + * @ingroup Ecore_X_DPMS_Group + */ EAPI int -ecore_x_dpms_timeouts_set(int standby, int suspend, int off) +ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off) { - return DPMSSetTimeouts(_ecore_x_disp, - standby, - suspend, - off); + return DPMSSetTimeouts(_ecore_x_disp, + standby, + suspend, + off); } -/* Get/Set Timeouts */ -EAPI int + +/** + * Returns the amount of time of inactivity before standby mode is invoked. + * @return The standby timeout value. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI unsigned int ecore_x_dpms_timeout_standby_get() { unsigned short standby, suspend, off; - + DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); return standby; } -EAPI int + +/** + * Returns the amount of time of inactivity before the second level of + * power saving is invoked. + * @return The suspend timeout value. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI unsigned int ecore_x_dpms_timeout_suspend_get() { unsigned short standby, suspend, off; - + DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); return suspend; } -EAPI int + +/** + * Returns the amount of time of inactivity before the third and final + * level of power saving is invoked. + * @return The off timeout value. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI unsigned int ecore_x_dpms_timeout_off_get() { unsigned short standby, suspend, off; @@ -75,37 +167,55 @@ return off; } -EAPI void -ecore_x_dpms_timeout_standby_set(int new_timeout) + +/** + * Sets the standby timeout (in unit of seconds). + * @param new_standby Amount of time of inactivity before standby mode will be invoked. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI void +ecore_x_dpms_timeout_standby_set(unsigned int new_timeout) { unsigned short standby, suspend, off; DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); - DPMSSetTimeouts(_ecore_x_disp, - new_timeout, + DPMSSetTimeouts(_ecore_x_disp, + new_timeout, suspend, off); } -EAPI void -ecore_x_dpms_timeout_suspend_set(int new_timeout) + +/** + * Sets the suspend timeout (in unit of seconds). + * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI void +ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout) { unsigned short standby, suspend, off; - + DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); - DPMSSetTimeouts(_ecore_x_disp, + DPMSSetTimeouts(_ecore_x_disp, standby, - new_timeout, + new_timeout, off); } -EAPI void -ecore_x_dpms_timeout_off_set(int new_timeout) + +/** + * Sets the off timeout (in unit of seconds). + * @param off Amount of time of inactivity before the monitor is shut off. + * @ingroup Ecore_X_DPMS_Group + */ +EAPI void +ecore_x_dpms_timeout_off_set(unsigned int new_timeout) { unsigned short standby, suspend, off; DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); - DPMSSetTimeouts(_ecore_x_disp, + DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout); =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_x/ecore_x_private.h,v retrieving revision 1.58 retrieving revision 1.59 diff -u -3 -r1.58 -r1.59 --- ecore_x_private.h 13 Feb 2007 16:24:37 -0000 1.58 +++ ecore_x_private.h 9 Mar 2007 01:11:09 -0000 1.59 @@ -43,6 +43,9 @@ #ifdef ECORE_XDAMAGE #include <X11/extensions/Xdamage.h> #endif +#ifdef ECORE_XDPMS +#include <X11/extensions/dpms.h> +#endif #include "ecore_private.h" #include "Ecore_X.h" @@ -235,9 +238,10 @@ int _ecore_x_netwm_startup_info_begin(Ecore_X_Window win, char *data); int _ecore_x_netwm_startup_info(Ecore_X_Window win, char *data); -/* Fixes * Damage */ +/* Fixes * Damage * DPMS */ void _ecore_x_fixes_init(void); void _ecore_x_damage_init(void); +void _ecore_x_dpms_init(void); /* from sync */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs