Enlightenment CVS committal Author : raster Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_x Modified Files: Makefile.am ecore_x.c ecore_x_private.h Log Message: xcursor support... note the comment in the Makefile.am. i dont have enough expletives to describe what i think of libtool.... =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- Makefile.am 4 Dec 2004 10:10:20 -0000 1.16 +++ Makefile.am 4 Jan 2005 10:26:17 -0000 1.17 @@ -1,19 +1,22 @@ ## Process this file with automake to produce Makefile.in INCLUDES = \ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ \ -I$(top_srcdir)/src/lib/ecore \ -I$(top_srcdir)/src/lib/ecore_txt \ -I$(top_srcdir)/src/lib/ecore_job \ -I$(top_builddir)/src/lib/ecore \ -I$(top_builddir)/src/lib/ecore_txt \ --I$(top_builddir)/src/lib/ecore_job \ [EMAIL PROTECTED]@ +-I$(top_builddir)/src/lib/ecore_job libecore_x_la_LDFLAGS = -version-info 1:0:0 \ -L$(top_builddir)/src/lib/ecore/.libs \ -L$(top_builddir)/src/lib/ecore_txt/.libs \ -L$(top_builddir)/src/lib/ecore_job/.libs [EMAIL PROTECTED]@ + if BUILD_ECORE_X lib_LTLIBRARIES = libecore_x.la @@ -38,12 +41,32 @@ ecore_x_gc.c \ ecore_x_private.h +### FUCK FUCK FIXME: +# This line: [EMAIL PROTECTED]@ \ +# has been replaced by +###-lXcursor +# because -f or some unknonw reason libtool REFUSES to put -lXcursor into the +# .la file for libecore_x in the dependency libs UNLESS this is explicitly +# states and not used as a replace term. if someone knows why... let me know +# and send patches... but i'm fresh out of ideas. +# +# After trying to get this working for the last 2+ hours... i only have one +# thing to say... FUCK YOU LIBSPLEEN! FUCK YOU! +# +# GRRRR... (this is just an example of what shits developers off about auto +# foo - somehting that should obviously "just work" and if i make my own +# Makefiles it works. its happy. but once you go through the 368 layers of +# autofuck things mysteriously stop working and if you're lucky you may just +# run across a workaround as I have here... ARGH!) + libecore_x_la_LIBADD = \ +-lXcursor \ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ \ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_txt/libecore_txt.la \ -$(top_builddir)/src/lib/ecore_job/libecore_job.la \ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ +$(top_builddir)/src/lib/ecore_job/libecore_job.la libecore_x_la_DEPENDENCIES = \ $(top_builddir)/src/lib/ecore/libecore.la \ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x.c,v retrieving revision 1.60 retrieving revision 1.61 diff -u -3 -r1.60 -r1.61 --- ecore_x.c 30 Dec 2004 05:35:59 -0000 1.60 +++ ecore_x.c 4 Jan 2005 10:26:17 -0000 1.61 @@ -25,6 +25,7 @@ Window _ecore_x_event_last_win = 0; int _ecore_x_event_last_root_x = 0; int _ecore_x_event_last_root_y = 0; +int _ecore_x_xcursor = 0; /* FIXME - These are duplicates after making ecore atoms public */ Ecore_X_Atom ECORE_X_ATOM_FILE_NAME = 0; @@ -178,6 +179,9 @@ _ecore_x_disp = NULL; return 0; } +#ifdef ECORE_XCURSOR + _ecore_x_xcursor = XcursorSupportsARGB(_ecore_x_disp); +#endif _ecore_x_event_handlers[KeyPress] = _ecore_x_event_handle_key_press; _ecore_x_event_handlers[KeyRelease] = _ecore_x_event_handle_key_release; _ecore_x_event_handlers[ButtonPress] = _ecore_x_event_handle_button_press; @@ -985,137 +989,171 @@ Ecore_X_Cursor ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int hot_y) { - 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 = pixels; - for (y = 0; y < h; y++) +#ifdef ECORE_XCURSOR + if (_ecore_x_xcursor) { - for (x = 0; x < w; x++) + Cursor c; + XcursorImage *xci; + + xci = XcursorImageCreate(w, h); + if (xci) { - int r, g, b, a; + int i; - a = (pix[0] >> 24) & 0xff; - r = (pix[0] >> 16) & 0xff; - g = (pix[0] >> 8 ) & 0xff; - b = (pix[0] ) & 0xff; - if (a > 0) + xci->xhot = hot_x; + xci->yhot = hot_y; + xci->delay = 0; + for (i = 0; i < (w * h); i++) { - 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; - } + 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] = (a << 24) | (r << 16) | (g << 8) | (b); } - pix++; + c = XcursorImageLoadCursor(_ecore_x_disp, xci); + XcursorImageDestroy(xci); + return c; } } - - pix = pixels; - for (y = 0; y < h; y++) + else +#endif { - for (x = 0; x < w; x++) + 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 = pixels; + for (y = 0; y < h; y++) { - 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)); - v = (((d2 * 255) / (d1 + d2)) * 5) / 256; - if (v > dither[x & 0x1][y & 0x1]) v = 1; - else v = 0; - XPutPixel(xim, x, y, v); - pix++; + 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++; + } } - } - 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 = pixels; - for (y = 0; y < h; y++) - { - for (x = 0; x < w; x++) + + pix = pixels; + for (y = 0; y < h; y++) { - 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++; + 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)); + v = (((d2 * 255) / (d1 + d2)) * 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, pmap, 0, &gcv); + XPutImage(_ecore_x_disp, pmap, gc, xim, 0, 0, 0, 0, w, h); + XFreeGC(_ecore_x_disp, gc); + + pix = 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; } - 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; } void =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_private.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- ecore_x_private.h 27 Dec 2004 18:28:14 -0000 1.34 +++ ecore_x_private.h 4 Jan 2005 10:26:17 -0000 1.35 @@ -1,6 +1,8 @@ #ifndef _ECORE_X_PRIVATE_H #define _ECORE_X_PRIVATE_H +#include "config.h" + #include <sys/param.h> #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 @@ -15,6 +17,9 @@ #include <X11/keysymdef.h> #include <X11/extensions/XShm.h> #include <X11/extensions/shape.h> +#ifdef ECORE_XCURSOR +#include <X11/Xcursor/Xcursor.h> +#endif #include "Ecore_X.h" @@ -106,6 +111,7 @@ extern Window _ecore_x_event_last_win; extern int _ecore_x_event_last_root_x; extern int _ecore_x_event_last_root_y; +extern int _ecore_x_xcursor; extern Ecore_X_Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM]; ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs