[prev in list] [next in list] [prev in thread] [next in thread] 

List:       enlightenment-svn
Subject:    E CVS: epplets kwo
From:       Enlightenment CVS <noreply () fitx-00 ! ewr ! caosity ! org>
Date:       2006-03-31 22:56:47
Message-ID: 20060331225647.783FDA30A6 () cvs ! caosity ! org
[Download RAW message or body]

Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : epplets

Dir     : e16/epplets/api


Modified Files:
	Makefile.am epplet.c epplet.h.in 


Log Message:
Move to Imlib2. Build for e16.8.
- This is a quick and dirty port to imlib2. It's posible to clean/speed up
  things considerably here and there.
- It's not unlikely that I missed some spots that require fixups.

===================================================================
RCS file: /cvs/e/e16/epplets/api/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- Makefile.am	30 Jul 2003 02:21:17 -0000	1.9
+++ Makefile.am	31 Mar 2006 22:56:17 -0000	1.10
@@ -1,11 +1,11 @@
-# $Id: Makefile.am,v 1.9 2003/07/30 02:21:17 mej Exp $
+# $Id: Makefile.am,v 1.10 2006/03/31 22:56:17 kwo Exp $
 
 lib_LTLIBRARIES = libepplet.la
 
 include_HEADERS = epplet.h
 libepplet_la_SOURCES = epplet.c snprintf.c
 libepplet_la_DEPENDENCIES = $(top_builddir)/config.h epplet.h
-libepplet_la_LDFLAGS = -version-info 1:0:1
+libepplet_la_LDFLAGS = -version-info 1:0:0
 
 INCLUDES = -I$(top_srcdir) $(X_CFLAGS)
 
===================================================================
RCS file: /cvs/e/e16/epplets/api/epplet.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -3 -r1.132 -r1.133
--- epplet.c	5 Feb 2006 09:27:03 -0000	1.132
+++ epplet.c	31 Mar 2006 22:56:17 -0000	1.133
@@ -5,7 +5,11 @@
 #include <sys/utsname.h>
 #include <signal.h>
 #include <sys/wait.h>
+#include <X11/Xatom.h>
 #include <X11/keysym.h>
+#include <X11/extensions/shape.h>
+
+#define DEPTH() DefaultDepth(disp, DefaultScreen(disp))
 
 #define SET_HINTS_OLD  1
 #define SET_HINTS_EWM  1
@@ -37,7 +41,6 @@
 
 static Atom         wmDeleteWindow;
 
-static ImlibData   *id = NULL;
 static Display     *dd = NULL;
 static Window       comms_win = 0;
 static Window       my_win = 0;
@@ -182,12 +185,6 @@
 int                 Epplet_textbox_spacesize(Epplet_gadget gadget);
 static void         Epplet_find_instance(char *name);
 
-ImlibData          *
-Epplet_get_imlib_data(void)
-{
-   return (id);
-}
-
 typedef struct gad_general
   {
      GadType             type;
@@ -430,21 +427,23 @@
    Atom                atom_list[8];
    int                 atom_count;
 #endif
-   ImlibInitParams     iip;
 
    mainwin = malloc(sizeof(EppWindow));
    mainwin->win_vert = vertical;
    w *= 16;
    h *= 16;
    disp = XOpenDisplay(NULL);
-   iip.flags = PARAMS_VISUALID;
-   iip.visualid = XVisualIDFromVisual(DefaultVisual(disp, DefaultScreen(disp)));
-   id = Imlib_init_with_params(disp, &iip);
    if (!disp)
      {
 	fprintf(stderr, "Epplet Error: Cannot open display\n");
 	exit(1);
      }
+   XSynchronize(disp, True);
+
+   imlib_context_set_display(disp);
+   imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
+   imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp)));
+
    ECommsSetup(disp);
    XSelectInput(disp, DefaultRootWindow(disp), PropertyChangeMask);
 
@@ -454,7 +453,7 @@
    /* create a window with everythign set */
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
@@ -464,8 +463,7 @@
       ExposureMask | FocusChangeMask | PropertyChangeMask |
       VisibilityChangeMask;
    mainwin->win = XCreateWindow(disp, DefaultRootWindow(disp), 0, 0, w, h, 0,
-				id->x.depth, InputOutput,
-				Imlib_get_visual(id),
+				CopyFromParent, InputOutput, CopyFromParent,
 				CWOverrideRedirect | CWSaveUnder |
 				CWBackingStore | CWColormap | CWBackPixel |
 				CWBorderPixel | CWEventMask, &attr);
@@ -611,7 +609,7 @@
    ret->win_vert = vertical;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
@@ -622,7 +620,7 @@
       VisibilityChangeMask;
 
    ret->win = XCreateWindow(disp, DefaultRootWindow(disp), 0, 0, w, h, 0,
-			    id->x.depth, InputOutput, Imlib_get_visual(id),
+			    CopyFromParent, InputOutput, CopyFromParent,
 			    CWOverrideRedirect | CWSaveUnder | CWBackingStore
 			    | CWColormap | CWBackPixel | CWBorderPixel |
 			    CWEventMask, &attr);
@@ -774,11 +772,23 @@
 void
 Epplet_window_destroy_children(Epplet_window win)
 {
-   int                 i;
+   int                 i, num;
+   Epplet_gadget      *lst;
 
-   for (i = 0; i < gad_num; i++)
-      if (((GadGeneral *) gads[i])->parent == win)
-	 Epplet_gadget_destroy(gads[i]);
+   if (!gads || gad_num <= 0)
+      return;
+
+   /* Create work copy of gadget list
+    * (gads is modified by Epplet_gadget_destroy) */
+   num = gad_num;
+   lst = malloc(num * sizeof(Epplet_gadget));
+   memcpy(lst, gads, num * sizeof(Epplet_gadget));
+
+   for (i = 0; i < num; i++)
+      if (((GadGeneral *) lst[i])->parent == win)
+	 Epplet_gadget_destroy(lst[i]);
+
+   free(lst);
 }
 
 void
@@ -791,9 +801,6 @@
    if (win == NULL)
       return;
 
-   XDestroyWindow(disp, win->win);
-   /* wait for the window to be destroyed */
-   XMaskEvent(disp, StructureNotifyMask, &ev);
    Epplet_unregister_window(win);
    Epplet_window_destroy_children(win);
    if (win->bg_pmap)
@@ -802,6 +809,11 @@
       XFreePixmap(disp, win->bg_bg);
    if (win->bg_mask)
       XFreePixmap(disp, win->bg_mask);
+
+   XDestroyWindow(disp, win->win);
+   /* wait for the window to be destroyed */
+   XMaskEvent(disp, StructureNotifyMask, &ev);
+
    free(win);
    win = NULL;
 }
@@ -940,8 +952,11 @@
 {
    char                s[1024];
 
+#if 0 /* No, I think this causes unintended e16 snaps/respawning */
+   printf("Epplet_cleanup remember=%d\n", need_remember);
    if (need_remember)
       Epplet_remember();
+#endif
 
    /* remove lock file */
    Esnprintf(s, sizeof(s), "%s/.lock_%i", conf_dir, epplet_instance);
@@ -1117,7 +1132,7 @@
 	sscanf(msg, "%x %x", (unsigned int *)&pp, (unsigned int *)&mm);
 	free(msg);
 	if (pp)
-	   *p = XCreatePixmap(disp, context_win->win, w, h, id->x.depth);
+	   *p = XCreatePixmap(disp, context_win->win, w, h, DEPTH());
 	else
 	   *p = 0;
 	if (mm)
@@ -1949,12 +1964,13 @@
 int
 Epplet_get_color(int r, int g, int b)
 {
-   int                 rr, gg, bb;
+   XColor xc;
 
-   rr = r;
-   gg = g;
-   bb = b;
-   return Imlib_best_color_match(id, &rr, &gg, &bb);
+   xc.red = (r << 8) | r;            
+   xc.green = (g << 8) | g;
+   xc.blue = (b << 8) | b;
+   XAllocColor(disp, imlib_context_get_colormap(), &xc);
+   return xc.pixel;
 }
 
 static char        *
@@ -1974,26 +1990,30 @@
 void
 Epplet_paste_image(char *image, Window ww, int x, int y)
 {
-   ImlibImage         *im;
+   Imlib_Image        *im;
 
-   im = Imlib_load_image(id, image);
+   im = imlib_load_image(image);
    if (im)
      {
-	Imlib_paste_image(id, im, ww, x, y, im->rgb_width, im->rgb_height);
-	Imlib_destroy_image(id, im);
+	imlib_context_set_image(im);
+	imlib_context_set_drawable(ww);
+	imlib_render_image_on_drawable(x, y);
+	imlib_free_image();
      }
 }
 
 void
 Epplet_paste_image_size(char *image, Window ww, int x, int y, int w, int h)
 {
-   ImlibImage         *im;
+   Imlib_Image        *im;
 
-   im = Imlib_load_image(id, image);
+   im = imlib_load_image(image);
    if (im)
      {
-	Imlib_paste_image(id, im, ww, x, y, w, h);
-	Imlib_destroy_image(id, im);
+	imlib_context_set_image(im);
+	imlib_context_set_drawable(ww);
+	imlib_render_image_on_drawable_at_size(x, y, w, h);
+	imlib_free_image();
      }
 }
 
@@ -2112,7 +2132,7 @@
 
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
@@ -2121,7 +2141,7 @@
       KeyPressMask | KeyReleaseMask;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, g->w, g->h, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
@@ -2308,30 +2328,32 @@
 				 &(g->pmap), &(g->mask), g->w, g->h);
    if (g->image)
      {
-	ImlibImage         *im;
+	Imlib_Image        *im;
 
 	ESYNC;
-	im = Imlib_load_image(id, g->image);
+	im = imlib_load_image(g->image);
 	if (im)
 	  {
              int                 x, y, w, h;
-            
-             if (g->w > im->rgb_width) {
-               w = im->rgb_width;
-               x = (g->w - im->rgb_width) / 2;
+
+             imlib_context_set_image(im);
+             if (g->w > imlib_image_get_width()) {
+               w = imlib_image_get_width();
+               x = (g->w - imlib_image_get_width()) / 2;
              } else {
                w = g->w - 4;
                x = 2;
              }
-             if (g->h > im->rgb_height) {
-               h = im->rgb_height;
-               y = (g->h - im->rgb_height) / 2;
+             if (g->h > imlib_image_get_height()) {
+               h = imlib_image_get_height();
+               y = (g->h - imlib_image_get_height()) / 2;
              } else {
                h = g->h - 4;
                y = 2;
              }
-             Imlib_paste_image(id, im, g->pmap, x, y, w, h);
-	     Imlib_destroy_image(id, im);
+	     imlib_context_set_drawable(g->pmap);
+	     imlib_render_image_on_drawable_at_size(x, y, w, h);
+	     imlib_free_image();
 	  }
      }
 
@@ -2350,7 +2372,8 @@
 	g->contents[g->cursor_pos] = temp;
 
 	/* Get the position in pixels to the cursor */
-	Epplet_textbox_textsize(eg, &(g->to_cursor), &h, s);
+	Epplet_textbox_textsize(eg, &x, &h, s);
+	g->to_cursor = x;
 
 	if (h == 0)
 	   Epplet_textbox_textsize(eg, &x, &h, "X");
@@ -2684,7 +2707,7 @@
    g->pop_parent = pop_parent;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
@@ -2694,7 +2717,7 @@
    if (parent)
      {
 	g->win = XCreateWindow(disp, parent, x, y, g->w, g->h, 0,
-			       id->x.depth, InputOutput, Imlib_get_visual(id),
+			       CopyFromParent, InputOutput, CopyFromParent,
 			       CWOverrideRedirect | CWSaveUnder |
 			       CWBackingStore | CWColormap | CWBackPixel |
 			       CWBorderPixel | CWEventMask, &attr);
@@ -2702,7 +2725,7 @@
      }
    else
       g->win = XCreateWindow(disp, context_win->win, x, y, g->w, g->h, 0,
-			     id->x.depth, InputOutput, Imlib_get_visual(id),
+			     CopyFromParent, InputOutput, CopyFromParent,
 			     CWOverrideRedirect | CWSaveUnder | CWBackingStore
 			     | CWColormap | CWBackPixel | CWBorderPixel |
 			     CWEventMask, &attr);
@@ -2779,30 +2802,32 @@
 				      &(g->pmap), &(g->mask), g->w, g->h);
 	if (g->image)
 	  {
-	     ImlibImage         *im;
+	     Imlib_Image        *im;
 
 	     ESYNC;
-	     im = Imlib_load_image(id, g->image);
+	     im = imlib_load_image(g->image);
 	     if (im)
 	       {
 		  int                 x, y, w, h;
 
-                  if (g->w > im->rgb_width) {
-                    w = im->rgb_width;
-                    x = (g->w - im->rgb_width) / 2;
+                  imlib_context_set_image(im);
+                  if (g->w > imlib_image_get_width()) {
+                    w = imlib_image_get_width();
+                    x = (g->w - imlib_image_get_width()) / 2;
                   } else {
                     w = g->w - 4;
                     x = 2;
                   }
-                  if (g->h > im->rgb_height) {
-                    h = im->rgb_height;
-                    y = (g->h - im->rgb_height) / 2;
+                  if (g->h > imlib_image_get_height()) {
+                    h = imlib_image_get_height();
+                    y = (g->h - imlib_image_get_height()) / 2;
                   } else {
                     h = g->h - 4;
                     y = 2;
                   }
-		  Imlib_paste_image(id, im, g->pmap, x, y, w, h);
-		  Imlib_destroy_image(id, im);
+		  imlib_context_set_drawable(g->pmap);
+		  imlib_render_image_on_drawable_at_size(x, y, w, h);
+		  imlib_free_image();
 	       }
 	  }
 	if (g->label)
@@ -2822,30 +2847,32 @@
 				      &(g->pmap), &(g->mask), g->w, g->h);
 	if (g->image)
 	  {
-	     ImlibImage         *im;
+	     Imlib_Image        *im;
 
 	     ESYNC;
-	     im = Imlib_load_image(id, g->image);
+	     im = imlib_load_image(g->image);
 	     if (im)
 	       {
 		  int                 x, y, w, h;
 
-                  if (g->w > im->rgb_width) {
-                    w = im->rgb_width;
-                    x = (g->w - im->rgb_width) / 2;
+                  imlib_context_set_image(im);
+                  if (g->w > imlib_image_get_width()) {
+                    w = imlib_image_get_width();
+                    x = (g->w - imlib_image_get_width()) / 2;
                   } else {
                     w = g->w - 4;
                     x = 2;
                   }
-                  if (g->h > im->rgb_height) {
-                    h = im->rgb_height;
-                    y = (g->h - im->rgb_height) / 2;
+                  if (g->h > imlib_image_get_height()) {
+                    h = imlib_image_get_height();
+                    y = (g->h - imlib_image_get_height()) / 2;
                   } else {
                     h = g->h - 4;
                     y = 2;
                   }
-		  Imlib_paste_image(id, im, g->pmap, x, y, w, h);
-		  Imlib_destroy_image(id, im);
+		  imlib_context_set_drawable(g->pmap);
+		  imlib_render_image_on_drawable_at_size(x, y, w, h);
+		  imlib_free_image();
 	       }
 	  }
 	if (g->label)
@@ -2891,7 +2918,7 @@
    g->clicked = 0;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
@@ -2899,7 +2926,7 @@
       EnterWindowMask | LeaveWindowMask;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
@@ -2943,30 +2970,32 @@
 				    &(g->pmap), &(g->mask), g->w, g->h);
    if (g->image)
      {
-	ImlibImage         *im;
+	Imlib_Image        *im;
 
 	ESYNC;
-	im = Imlib_load_image(id, g->image);
+	im = imlib_load_image(g->image);
 	if (im)
 	  {
              int                 x, y, w, h;
-            
-             if (g->w > im->rgb_width) {
-               w = im->rgb_width;
-               x = (g->w - im->rgb_width) / 2;
+
+	     imlib_context_set_image(im);
+             if (g->w > imlib_image_get_width()) {
+               w = imlib_image_get_width();
+               x = (g->w - imlib_image_get_width()) / 2;
              } else {
                w = g->w - 4;
                x = 2;
              }
-             if (g->h > im->rgb_height) {
-               h = im->rgb_height;
-               y = (g->h - im->rgb_height) / 2;
+             if (g->h > imlib_image_get_height()) {
+               h = imlib_image_get_height();
+               y = (g->h - imlib_image_get_height()) / 2;
              } else {
                h = g->h - 4;
                y = 2;
              }
-             Imlib_paste_image(id, im, g->pmap, x, y, w, h);
-	     Imlib_destroy_image(id, im);
+	     imlib_context_set_drawable(g->pmap);
+	     imlib_render_image_on_drawable_at_size(x, y, w, h);
+	     imlib_free_image();
 	  }
      }
    if (g->label)
@@ -3013,14 +3042,14 @@
    g->h = h;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
    attr.event_mask = 0;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
@@ -3029,7 +3058,7 @@
       LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonMotionMask |
       ExposureMask;
    g->win_in = XCreateWindow(disp, g->win, 2, 2, w - 4, h - 4, 0,
-			     id->x.depth, InputOutput, Imlib_get_visual(id),
+			     CopyFromParent, InputOutput, CopyFromParent,
 			     CWOverrideRedirect | CWSaveUnder | CWBackingStore
 			     | CWColormap | CWBackPixel | CWBorderPixel |
 			     CWEventMask, &attr);
@@ -3076,22 +3105,21 @@
    g->clicked = 0;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
    attr.event_mask = ButtonPressMask | ButtonReleaseMask;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, len, 8, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
    attr.event_mask = ButtonPressMask | ButtonReleaseMask |
       PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask;
    g->win_knob = XCreateWindow(disp, context_win->win, x, y, 8, 8, 0,
-			       id->x.depth, InputOutput,
-			       Imlib_get_visual(id),
+			       CopyFromParent, InputOutput, CopyFromParent,
 			       CWOverrideRedirect | CWSaveUnder |
 			       CWBackingStore | CWColormap | CWBackPixel |
 			       CWBorderPixel | CWEventMask, &attr);
@@ -3156,22 +3184,21 @@
    g->clicked = 0;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
    attr.event_mask = ButtonPressMask | ButtonReleaseMask;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, 8, len, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
    attr.event_mask = ButtonPressMask | ButtonReleaseMask |
       PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask;
    g->win_knob = XCreateWindow(disp, context_win->win, x, y, 8, 8, 0,
-			       id->x.depth, InputOutput,
-			       Imlib_get_visual(id),
+			       CopyFromParent, InputOutput, CopyFromParent,
 			       CWOverrideRedirect | CWSaveUnder |
 			       CWBackingStore | CWColormap | CWBackPixel |
 			       CWBorderPixel | CWEventMask, &attr);
@@ -3225,19 +3252,19 @@
    g->val = val;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
    attr.event_mask = 0;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
    g->win_in = XCreateWindow(disp, g->win, 2, 2, w - 4, h - 4, 0,
-			     id->x.depth, InputOutput, Imlib_get_visual(id),
+			     CopyFromParent, InputOutput, CopyFromParent,
 			     CWOverrideRedirect | CWSaveUnder | CWBackingStore
 			     | CWColormap | CWBackPixel | CWBorderPixel |
 			     CWEventMask, &attr);
@@ -3284,19 +3311,19 @@
    g->val = val;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
    attr.event_mask = 0;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
    g->win_in = XCreateWindow(disp, g->win, 2, 2, w - 4, h - 4, 0,
-			     id->x.depth, InputOutput, Imlib_get_visual(id),
+			     CopyFromParent, InputOutput, CopyFromParent,
 			     CWOverrideRedirect | CWSaveUnder | CWBackingStore
 			     | CWColormap | CWBackPixel | CWBorderPixel |
 			     CWEventMask, &attr);
@@ -3353,33 +3380,33 @@
    GadImage           *g;
    GC                  gc = 0;
    XGCValues           gcv;
-   ImlibImage         *im;
+   Imlib_Image        *im;
 
    g = (GadImage *) eg;
    gc = XCreateGC(disp, g->general.parent->bg_pmap, 0, &gcv);
    if ((g->pw > 0) && (g->ph > 0))
       XCopyArea(disp, g->general.parent->bg_bg, g->general.parent->bg_pmap, gc,
 		g->x, g->y, g->pw, g->ph, g->x, g->y);
-   if (!un_only)
+   if (g->image && !un_only)
      {
-	im = Imlib_load_image(id, g->image);
+	im = imlib_load_image(g->image);
 	if (im)
 	  {
+	     imlib_context_set_image(im);
+	     imlib_context_set_drawable(g->general.parent->bg_pmap);
 	     if ((g->w > 0) && (g->h > 0))
 	       {
-		  Imlib_paste_image(id, im, g->general.parent->bg_pmap, g->x,
-				    g->y, g->w, g->h);
+		  imlib_render_image_on_drawable_at_size(g->x, g->y, g->w, g->h);
 		  g->pw = g->w;
 		  g->ph = g->h;
 	       }
 	     else
 	       {
-		  Imlib_paste_image(id, im, g->general.parent->bg_pmap, g->x,
-				    g->y, im->rgb_width, im->rgb_height);
-		  g->pw = im->rgb_width;
-		  g->ph = im->rgb_height;
+		  imlib_render_image_on_drawable(g->x, g->y);
+		  g->pw = imlib_image_get_width();
+		  g->ph = imlib_image_get_height();
 	       }
-	     Imlib_destroy_image(id, im);
+	     imlib_free_image();
 	  }
      }
    XSetWindowBackgroundPixmap(disp, g->general.parent->win,
@@ -3532,14 +3559,14 @@
    g->changed = 1;
    attr.backing_store = NotUseful;
    attr.override_redirect = True;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
    attr.event_mask = ButtonPressMask | ButtonReleaseMask |
       PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask;
    g->win = XCreateWindow(disp, root, 0, 0, 5, 5, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
@@ -3575,12 +3602,13 @@
    g->entry[g->entry_num - 1].gadget = NULL;
    if (g->entry[g->entry_num - 1].image)
      {
-	ImlibImage         *im;
+	Imlib_Image        *im;
 
-	im = Imlib_load_image(id, g->entry[g->entry_num - 1].image);
-	g->entry[g->entry_num - 1].w = ((w == -1) ? im->rgb_width : w);
-	g->entry[g->entry_num - 1].h = ((h == -1) ? im->rgb_height : h);
-	Imlib_destroy_image(id, im);
+	im = imlib_load_image(g->entry[g->entry_num - 1].image);
+	imlib_context_set_image(im);
+	g->entry[g->entry_num - 1].w = ((w == -1) ? imlib_image_get_width() : w);
+	g->entry[g->entry_num - 1].h = ((h == -1) ? imlib_image_get_height() : h);
+	imlib_free_image();
      }
    else if (g->entry[g->entry_num - 1].label)
      {
@@ -3803,7 +3831,7 @@
    g->popup = popup;
    attr.backing_store = NotUseful;
    attr.override_redirect = False;
-   attr.colormap = Imlib_get_colormap(id);
+   attr.colormap = imlib_context_get_colormap();
    attr.border_pixel = 0;
    attr.background_pixel = 0;
    attr.save_under = False;
@@ -3811,7 +3839,7 @@
       EnterWindowMask | LeaveWindowMask;
    g->general.visible = 0;
    g->win = XCreateWindow(disp, context_win->win, x, y, g->w, g->h, 0,
-			  id->x.depth, InputOutput, Imlib_get_visual(id),
+			  CopyFromParent, InputOutput, CopyFromParent,
 			  CWOverrideRedirect | CWSaveUnder | CWBackingStore |
 			  CWColormap | CWBackPixel | CWBorderPixel |
 			  CWEventMask, &attr);
@@ -3864,30 +3892,32 @@
 				      &(g->pmap), &(g->mask), g->w, g->h);
 	if (g->image)
 	  {
-	     ImlibImage         *im;
+	     Imlib_Image        *im;
 
 	     ESYNC;
-	     im = Imlib_load_image(id, g->image);
+	     im = imlib_load_image(g->image);
 	     if (im)
 	       {
 		  int                 x, y, w, h;
 
-                  if (g->w > im->rgb_width) {
-                    w = im->rgb_width;
-                    x = (g->w - im->rgb_width) / 2;
+		  imlib_context_set_image(im);
+                  if (g->w > imlib_image_get_width()) {
+                    w = imlib_image_get_width();
+                    x = (g->w - imlib_image_get_width()) / 2;
                   } else {
                     w = g->w - 4;
                     x = 2;
                   }
-                  if (g->h > im->rgb_height) {
-                    h = im->rgb_height;
-                    y = (g->h - im->rgb_height) / 2;
+                  if (g->h > imlib_image_get_height()) {
+                    h = imlib_image_get_height();
+                    y = (g->h - imlib_image_get_height()) / 2;
                   } else {
                     h = g->h - 4;
                     y = 2;
                   }
-		  Imlib_paste_image(id, im, g->pmap, x, y, w, h);
-		  Imlib_destroy_image(id, im);
+		  imlib_context_set_drawable(g->pmap);
+		  imlib_render_image_on_drawable_at_size(x, y, w, h);
+		  imlib_free_image();
 	       }
 	  }
 	if (g->label)
@@ -4592,7 +4622,7 @@
    else
       Epplet_imageclass_get_pixmaps("EPPLET_BACKGROUND_HORIZONTAL", "normal",
 				  &win->bg_bg, &win->bg_mask, win->w, win->h);
-   win->bg_pmap = XCreatePixmap(disp, win->win, win->w, win->h, id->x.depth);
+   win->bg_pmap = XCreatePixmap(disp, win->win, win->w, win->h, DEPTH());
 
    gc = XCreateGC(disp, win->bg_pmap, 0, &gcv);
    XCopyArea(disp, win->bg_bg, win->bg_pmap, gc, 0, 0, win->w, win->h, 0, 0);
@@ -5249,28 +5279,26 @@
 Epplet_make_rgb_buf(int w, int h)
 {
    RGB_buf             buf;
-   unsigned char      *data;
 
    buf = malloc(sizeof(RGB_buf));
-   data = malloc(w * h * 3 * sizeof(unsigned char));
 
-   buf->im = Imlib_create_image_from_data(id, data, NULL, w, h);
-   free(data);
+   buf->im = imlib_create_image(w, h);
    return buf;
 }
 
 unsigned char      *
 Epplet_get_rgb_pointer(RGB_buf buf)
 {
-   return buf->im->rgb_data;
+   imlib_context_set_image(buf->im);
+   return (unsigned char*)imlib_image_get_data();	/* Readonly? */
 }
 
 void
 Epplet_paste_buf(RGB_buf buf, Window win, int x, int y)
 {
-   Imlib_changed_image(id, buf->im);
-   Imlib_paste_image(id, buf->im, win, x, y,
-		     buf->im->rgb_width, buf->im->rgb_height);
+   imlib_context_set_image(buf->im);
+   imlib_context_set_drawable(win);
+   imlib_render_image_on_drawable(x, y);
 }
 
 void
@@ -5280,7 +5308,8 @@
      {
 	if (buf->im)
 	  {
-	     Imlib_destroy_image(id, buf->im);
+	     imlib_context_set_image(buf->im);
+	     imlib_free_image();
 	  }
 	free(buf);
      }
===================================================================
RCS file: /cvs/e/e16/epplets/api/epplet.h.in,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- epplet.h.in	29 Jun 2000 23:54:24 -0000	1.51
+++ epplet.h.in	31 Mar 2006 22:56:17 -0000	1.52
@@ -14,7 +14,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
-#include <Imlib.h>
+#include <Imlib2.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -59,7 +59,7 @@
 typedef void       *Epplet_gadget;
 typedef struct _rgb_buf
   {
-     ImlibImage         *im;
+     Imlib_Image        *im;
   }
                    *RGB_buf;
 
@@ -122,9 +122,6 @@
 
 /* return the X display connection used */
 Display            *Epplet_get_display(void);
-
-/* return the ImlibData pointer being used */
-ImlibData          *Epplet_get_imlib_data(void);
 
 /* Get locations and sizes of gadgets */
 int Epplet_gadget_get_x(Epplet_gadget gad);




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic