diff --git a/legacy/ecore/configure.in b/legacy/ecore/configure.in index 488c205be7..83601580ae 100644 --- a/legacy/ecore/configure.in +++ b/legacy/ecore/configure.in @@ -242,9 +242,9 @@ if test "x$have_ecore_x" = "xyes"; then BUILD_ECORE_X=1 x_dir="/usr/X11R6"; x_includes=""; - x_cflags="-I"$x_dir"/include" - x_libs="-L"$x_dir"/lib -lX11 -lXext" - x_ldflags=""; + x_cflags="-I"$x_dir"/include"; + x_libs="-L"$x_dir"/lib -lX11 -lXext"; + x_ldflags=" "$ecore_x_libs; ecore_x_libs="-lecore_x"; else AM_CONDITIONAL(BUILD_ECORE_X, false) @@ -258,6 +258,33 @@ AC_SUBST(x_includes) AC_SUBST(x_ldflags) AC_SUBST(x_libs) +Xcursor_libs="" +Xcursor_cflags="" +use_Xcursor="no" +AC_CHECK_HEADER(X11/Xcursor/Xcursor.h, [ + AC_CHECK_LIB(Xcursor, XcursorImageLoadCursor, [ + AC_DEFINE(ECORE_XCURSOR, 1, [Build support for Xcursor]) + Xcursor_cflags="" + Xcursor_libs="-IXcursor" + use_Xcursor="yes" + ], [ + Xcursor_cflags="" + Xcursor_libs="" + use_Xcursor="no" + ] + ) + ], [ + Xcursor_cflags="" + Xcursor_libs="" + use_Xcursor="no" + ], [ + #include + ] +) + +AC_SUBST(Xcursor_cflags) +AC_SUBST(Xcursor_libs) + AC_SUBST(ecore_x_cflags) AC_SUBST(ecore_x_libs) @@ -684,7 +711,7 @@ echo echo " Ecore_Job...............: $have_ecore_job" echo " Ecore_Con...............: $have_ecore_con (OpenSSL: $use_openssl)" echo " Ecore_Txt...............: $have_ecore_txt" -echo " Ecore_X.................: $have_ecore_x" +echo " Ecore_X.................: $have_ecore_x (Xcursor: $use_Xcursor)" echo " Ecore_FB................: $have_ecore_fb" echo " Ecore_Evas..............: $have_ecore_evas" echo " Ecore_Evas GL Support...: $have_ecore_evas_gl" diff --git a/legacy/ecore/src/bin/Makefile.am b/legacy/ecore/src/bin/Makefile.am index 71640577f8..1ff91021d4 100644 --- a/legacy/ecore/src/bin/Makefile.am +++ b/legacy/ecore/src/bin/Makefile.am @@ -80,13 +80,13 @@ ecore_test.c ecore_test_LDADD = \ $(top_builddir)/src/lib/ecore/libecore.la \ +$(ECORE_X_LIB) \ +$(ECORE_TXT_LIB) \ $(ECORE_JOB_LIB) \ $(ECORE_FB_LIB) \ -$(ECORE_X_LIB) \ $(ECORE_EVAS_LIB) \ $(ECORE_CON_LIB) \ $(ECORE_IPC_LIB) \ -$(ECORE_TXT_LIB) \ -lm @iconv_libs@ ecore_test_CFLAGS = \ @@ -95,13 +95,13 @@ $(INCLUDES) ecore_test_DEPENDENCIES = \ $(top_builddir)/src/lib/ecore/libecore.la \ +$(ECORE_X_LIB) \ +$(ECORE_TXT_LIB) \ $(ECORE_JOB_LIB) \ $(ECORE_FB_LIB) \ -$(ECORE_X_LIB) \ $(ECORE_EVAS_LIB) \ $(ECORE_CON_LIB) \ -$(ECORE_IPC_LIB) \ -$(ECORE_TXT_LIB) +$(ECORE_IPC_LIB) ecore_evas_test_SOURCES = \ ecore_evas_test.c \ @@ -112,13 +112,13 @@ ecore_evas_test.h ecore_evas_test_LDADD = \ $(top_builddir)/src/lib/ecore/libecore.la \ +$(ECORE_X_LIB) \ +$(ECORE_TXT_LIB) \ $(ECORE_JOB_LIB) \ $(ECORE_FB_LIB) \ -$(ECORE_X_LIB) \ $(ECORE_EVAS_LIB) \ $(ECORE_CON_LIB) \ $(ECORE_IPC_LIB) \ -$(ECORE_TXT_LIB) \ -lm @iconv_libs@ ecore_evas_test_CFLAGS = \ diff --git a/legacy/ecore/src/lib/ecore_x/Makefile.am b/legacy/ecore/src/lib/ecore_x/Makefile.am index c0763525b7..dfcc4ac411 100644 --- a/legacy/ecore/src/lib/ecore_x/Makefile.am +++ b/legacy/ecore/src/lib/ecore_x/Makefile.am @@ -1,19 +1,22 @@ ## Process this file with automake to produce Makefile.in INCLUDES = \ +@Xcursor_cflags@ \ +@x_cflags@ \ -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 \ -@x_cflags@ +-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 +XCURSOR_LIBS=@Xcursor_libs@ + if BUILD_ECORE_X lib_LTLIBRARIES = libecore_x.la @@ -38,12 +41,32 @@ ecore_x_pixmap.c \ ecore_x_gc.c \ ecore_x_private.h +### FUCK FUCK FIXME: +# This line: +###@Xcursor_libs@ \ +# 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 \ +@x_ldflags@ \ +@x_libs@ \ $(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 \ -@x_ldflags@ \ -@x_libs@ +$(top_builddir)/src/lib/ecore_job/libecore_job.la libecore_x_la_DEPENDENCIES = \ $(top_builddir)/src/lib/ecore/libecore.la \ diff --git a/legacy/ecore/src/lib/ecore_x/ecore_x.c b/legacy/ecore/src/lib/ecore_x/ecore_x.c index fe9134a8a4..395dad8c07 100644 --- a/legacy/ecore/src/lib/ecore_x/ecore_x.c +++ b/legacy/ecore/src/lib/ecore_x/ecore_x.c @@ -25,6 +25,7 @@ Time _ecore_x_event_last_time = 0; 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_init(const char *name) _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_window_children_get(Ecore_X_Window win, int *num) 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 diff --git a/legacy/ecore/src/lib/ecore_x/ecore_x_private.h b/legacy/ecore/src/lib/ecore_x/ecore_x_private.h index 59131b266a..d74a9f7368 100644 --- a/legacy/ecore/src/lib/ecore_x/ecore_x_private.h +++ b/legacy/ecore/src/lib/ecore_x/ecore_x_private.h @@ -1,6 +1,8 @@ #ifndef _ECORE_X_PRIVATE_H #define _ECORE_X_PRIVATE_H +#include "config.h" + #include #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 @@ -15,6 +17,9 @@ #include #include #include +#ifdef ECORE_XCURSOR +#include +#endif #include "Ecore_X.h" @@ -106,6 +111,7 @@ extern Time _ecore_x_event_last_time; 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];