Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
      Tag: branch-exp
        E.h ewins.c iconify.c 


Log Message:
Simplify iconboxes, implement systray in iconbox.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.314.2.44
retrieving revision 1.314.2.45
diff -u -3 -r1.314.2.44 -r1.314.2.45
--- E.h 19 Sep 2004 08:02:13 -0000      1.314.2.44
+++ E.h 21 Sep 2004 19:45:13 -0000      1.314.2.45
@@ -844,8 +844,7 @@
    PmapMask            mini_pmm;
    int                 mini_w, mini_h;
    Snapshot           *snap;
-   PmapMask            icon_pmm;
-   int                 icon_w, icon_h;
+   Imlib_Image        *icon_image;
    int                 head;
    struct
    {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/Attic/ewins.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -3 -r1.1.2.15 -r1.1.2.16
--- ewins.c     19 Sep 2004 08:02:15 -0000      1.1.2.15
+++ ewins.c     21 Sep 2004 19:45:13 -0000      1.1.2.16
@@ -206,7 +206,11 @@
    if (ewin->session_id)
       Efree(ewin->session_id);
    FreePmapMask(&ewin->mini_pmm);
-   FreePmapMask(&ewin->icon_pmm);
+   if (ewin->icon_image)
+     {
+       imlib_context_set_image(ewin->icon_image);
+       imlib_free_image_and_decache();
+     }
    GroupsEwinRemove(ewin);
    Efree(ewin);
 
@@ -1736,6 +1740,7 @@
      case MapRequest:
        EwinDeIconify(ewin);
        break;
+#if 0
      case ConfigureRequest:
        EwinEventConfigureRequest(ewin, ev);
        break;
@@ -1745,6 +1750,7 @@
      case CirculateRequest:
        EwinEventCirculateRequest(ewin, ev);
        break;
+#endif
      default:
        Eprintf("EwinHandleEventsContainer: type=%2d win=%#lx: %s\n",
                ev->type, ewin->client.win, EwinGetTitle(ewin));
@@ -1770,19 +1776,24 @@
      case GravityNotify:
        break;
      case DestroyNotify:
-       EwinEventDestroy(ewin);
+       if (ev->xdestroywindow.window == ewin->client.win)
+          EwinEventDestroy(ewin);
        break;
      case UnmapNotify:
-       EwinEventUnmap(ewin);
+       if (ev->xunmap.window == ewin->client.win)
+          EwinEventUnmap(ewin);
        break;
      case MapNotify:
-       EwinEventMap(ewin);
+       if (ev->xmap.window == ewin->client.win)
+          EwinEventMap(ewin);
        break;
      case ConfigureRequest:
-       EwinEventConfigureRequest(ewin, ev);
+       if (ev->xconfigurerequest.window == ewin->client.win)
+          EwinEventConfigureRequest(ewin, ev);
        break;
      case ResizeRequest:
-       EwinEventResizeRequest(ewin, ev);
+       if (ev->xresizerequest.window == ewin->client.win)
+          EwinEventResizeRequest(ewin, ev);
        break;
      case CirculateRequest:
        EwinEventCirculateRequest(ewin, ev);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/iconify.c,v
retrieving revision 1.116.2.19
retrieving revision 1.116.2.20
diff -u -3 -r1.116.2.19 -r1.116.2.20
--- iconify.c   18 Sep 2004 13:32:27 -0000      1.116.2.19
+++ iconify.c   21 Sep 2004 19:45:13 -0000      1.116.2.20
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000-2004 Carsten Haitzler, Geoff Harrison and various contributors
+ * Copyright (C) 2004 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -25,13 +26,24 @@
 
 typedef struct _iconbox Iconbox;
 
-void                UpdateAppIcon(EWin * ewin, int imode);
-Iconbox            *SelectIconboxForEwin(EWin * ewin);
+static void         UpdateAppIcon(EWin * ewin, int imode);
+static Iconbox     *SelectIconboxForEwin(EWin * ewin);
+
+/* Systray stuff */
+static void         SystrayInit(Iconbox * obj, Window win, int screen);
+
+typedef union
+{
+   void               *obj;
+   EWin               *ewin;
+   Window              win;
+} IboxOject;
 
 struct _iconbox
 {
    /* user settings */
    char               *name;
+   char                type;
    char                orientation;
    char                animate;
    char                scrollbar_side;
@@ -73,8 +85,8 @@
    Window              scrollbarknob_win;
    EWin               *ewin;
 
-   int                 num_icons;
-   EWin              **icons;
+   int                 num_objs;
+   IboxOject          *objs;
 
    /* these are theme-settable parameters */
    int                 scroll_thickness;
@@ -273,18 +285,6 @@
    ecore_x_ungrab();
 }
 
-#if 0                          /* Unused */
-void
-MakeIcon(EWin * ewin)
-{
-   Iconbox            *ib;
-
-   ib = SelectIconboxForEwin(ewin);
-   if (ib)
-      IconboxAddEwin(ib, ewin);
-}
-#endif
-
 static Iconbox     *
 IconboxCreate(const char *name)
 {
@@ -292,12 +292,13 @@
 
    ib = Emalloc(sizeof(Iconbox));
    ib->name = Estrdup(name);
+   ib->type = (!strncmp(name, "_ST_", 4)) ? 1 : 0;     /* Type 1 is systray */
    ib->orientation = 0;
    ib->scrollbar_side = 1;
    ib->arrow_side = 1;
    ib->nobg = 0;
    ib->shownames = 1;
-   ib->iconsize = 48;
+   ib->iconsize = (ib->type == 0) ? 48 : 24;
    ib->icon_mode = 2;
    ib->auto_resize = 0;
    ib->draw_icon_base = 0;
@@ -367,11 +368,14 @@
    EMapWindow(disp, ib->scrollbarknob_win);
 
    ib->ewin = NULL;
-   ib->num_icons = 0;
-   ib->icons = NULL;
+   ib->num_objs = 0;
+   ib->objs = NULL;
 
    AddItem(ib, ib->name, 0, LIST_TYPE_ICONBOX);
 
+   if (ib->type == 1)
+      SystrayInit(ib, ib->icon_win, 0);
+
    return ib;
 }
 
@@ -385,11 +389,12 @@
    if (ib->name)
       Efree(ib->name);
 
-   for (i = 0; i < ib->num_icons; i++)
-      EwinDeIconify(ib->icons[i]);
+   if (ib->type == 0)
+      for (i = 0; i < ib->num_objs; i++)
+        EwinDeIconify(ib->objs[i].ewin);
 
-   if (ib->icons)
-      Efree(ib->icons);
+   if (ib->objs)
+      Efree(ib->objs);
 
    if (ib->pmap)
       ecore_x_pixmap_del(ib->pmap);
@@ -559,46 +564,103 @@
 }
 #endif
 
-static void
-IconboxAddEwin(Iconbox * ib, EWin * ewin)
+/*
+ * Return index, -1 if not found.
+ */
+static int
+IconboxObjectFind(Iconbox * ib, void *obj)
 {
    int                 i;
 
-   /* check if its already there - then dont add */
-   for (i = 0; i < ib->num_icons; i++)
+   for (i = 0; i < ib->num_objs; i++)
+      if (ib->objs[i].obj == obj)
+        return i;
+
+   return -1;
+}
+
+static int
+IconboxObjectAdd(Iconbox * ib, void *obj)
+{
+   /* Not if already there */
+   if (IconboxObjectFind(ib, obj) >= 0)
+      return -1;
+
+   ib->num_objs++;
+   ib->objs = Erealloc(ib->objs, sizeof(EWin *) * ib->num_objs);
+   ib->objs[ib->num_objs - 1].obj = obj;
+
+   return 0;                   /* Success */
+}
+
+static int
+IconboxObjectDel(Iconbox * ib, void *obj)
+{
+   int                 i, j;
+
+   /* Quit if not there */
+   i = IconboxObjectFind(ib, obj);
+   if (i < 0)
+      return -1;
+
+   for (j = i; j < ib->num_objs - 1; j++)
+      ib->objs[j] = ib->objs[j + 1];
+   ib->num_objs--;
+   if (ib->num_objs > 0)
+      ib->objs = Erealloc(ib->objs, sizeof(EWin *) * ib->num_objs);
+   else
      {
-       if (ib->icons[i] == ewin)
-          return;
+       Efree(ib->objs);
+       ib->objs = NULL;
      }
-   ib->num_icons++;
-   ib->icons = Erealloc(ib->icons, sizeof(EWin *) * ib->num_icons);
-   ib->icons[ib->num_icons - 1] = ewin;
-   IconboxRedraw(ib);
+
+   return 0;                   /* Success */
+}
+
+static int
+IconboxFindEwin(Iconbox * ib, EWin * ewin)
+{
+   return IconboxObjectFind(ib, ewin);
+}
+
+static void
+IconboxAddEwin(Iconbox * ib, EWin * ewin)
+{
+   if (IconboxObjectAdd(ib, ewin) == 0)
+      IconboxRedraw(ib);
 }
 
 static void
 IconboxDelEwin(Iconbox * ib, EWin * ewin)
 {
-   int                 i, j;
+   if (IconboxObjectDel(ib, ewin) == 0)
+      IconboxRedraw(ib);
+}
 
-   for (i = 0; i < ib->num_icons; i++)
-     {
-       if (ib->icons[i] == ewin)
-         {
-            for (j = i; j < ib->num_icons - 1; j++)
-               ib->icons[j] = ib->icons[j + 1];
-            ib->num_icons--;
-            if (ib->num_icons > 0)
-               ib->icons = Erealloc(ib->icons, sizeof(EWin *) * ib->num_icons);
-            else
-              {
-                 Efree(ib->icons);
-                 ib->icons = NULL;
-              }
-            IconboxRedraw(ib);
-            return;
-         }
-     }
+#if 0
+static int
+IconboxFindWindow(Iconbox * ib, Window win)
+{
+   return IconboxObjectFind(ib, (void *)win);
+}
+#endif
+
+static void
+IconboxAddWindow(Iconbox * ib, Window win)
+{
+   if (IconboxObjectAdd(ib, (void *)win))
+      return;
+
+   XReparentWindow(disp, win, ib->icon_win, 0, 0);
+   IconboxRedraw(ib);
+   EMapWindow(disp, win);
+}
+
+static void
+IconboxDelWindow(Iconbox * ib, Window win)
+{
+   if (IconboxObjectDel(ib, (void *)win) == 0)
+      IconboxRedraw(ib);
 }
 
 static void
@@ -643,11 +705,12 @@
 static void
 IB_SnapEWin(EWin * ewin)
 {
-   int                 w, h, ord, rn, i;
-   GC                  gc;
-   XRectangle         *r = NULL;
+   /* Make snapshot of window */
+   /* TODO - HiQ feature? */
+   int                 w, h;
    Iconbox            *ib;
    ImageClass         *ic;
+   Imlib_Image        *im;
 
    w = 40;
    h = 40;
@@ -657,6 +720,7 @@
        w = ib->iconsize;
        h = ib->iconsize;
      }
+
    if (ib->draw_icon_base)
      {
        ic = ImageclassFind("DEFAULT_ICON_BUTTON", 0);
@@ -675,63 +739,22 @@
    if (h < 4)
       h = 4;
 
-   ewin->icon_pmm.type = 0;
-   ewin->icon_w = w;
-   ewin->icon_h = h;
-
-   ewin->icon_pmm.pmap = ecore_x_pixmap_new(ewin->win, w, h, VRoot.depth);
-   if (EwinIsMapped(ewin))
-     {
-       ScaleRect(ewin->icon_pmm.pmap, ewin->win, 0, 0, 0, 0, ewin->w, ewin->h,
-                 w, h);
-     }
-   else
-     {
-       gc = ecore_x_gc_new(ewin->icon_pmm.pmap);
-       XSetForeground(disp, gc, BlackPixel(disp, VRoot.scr));
-       XFillRectangle(disp, ewin->icon_pmm.pmap, gc, 0, 0, w, h);
-       ecore_x_gc_del(gc);
-     }
-
-   ewin->icon_pmm.mask = ecore_x_pixmap_new(ewin->win, w, h, 1);
-   gc = ecore_x_gc_new(ewin->icon_pmm.mask);
-   r = EShapeGetRectangles(disp, ewin->win, ShapeBounding, &rn, &ord);
-   if (r)
-     {
-       XSetForeground(disp, gc, 0);
-       XFillRectangle(disp, ewin->icon_pmm.mask, gc, 0, 0, w, h);
-       XSetForeground(disp, gc, 1);
-       for (i = 0; i < rn; i++)
-         {
-            int                 x, y, ww, hh;
-
-            x = (r[i].x * w) / ewin->w;
-            y = (r[i].y * h) / ewin->h;
-            ww = (r[i].width * w) / ewin->w;
-            hh = (r[i].height * h) / ewin->h;
-            if (ww < 4)
-               ww = 4;
-            if (hh < 4)
-               hh = 4;
-            XFillRectangle(disp, ewin->icon_pmm.mask, gc, x, y, ww, hh);
-         }
-       XFree(r);
-     }
-   else
-     {
-       XSetForeground(disp, gc, 1);
-       XFillRectangle(disp, ewin->icon_pmm.mask, gc, 0, 0, w, h);
-     }
-   ecore_x_gc_del(gc);
+   if (!EwinIsMapped(ewin))
+      return;
 
-   if ((ewin->icon_w < 1) || (ewin->icon_h < 1))
-      FreePmapMask(&ewin->icon_pmm);
+   imlib_context_set_drawable(ewin->win);
+   im =
+      imlib_create_scaled_image_from_drawable(None, 0, 0, ewin->w, ewin->h, w,
+                                             h, 1, 1);
+   imlib_context_set_image(im);
+   imlib_image_set_has_alpha(1);       /* Should be set by imlib? */
+   ewin->icon_image = im;
 }
 
 static void
 IB_GetAppIcon(EWin * ewin)
 {
-   /* get the applications icon pixmap and make a copy... */
+   /* Get the applications icon pixmap/mask */
    int                 x, y;
    unsigned int        w, h, depth, bw;
    Window              rt;
@@ -744,52 +767,17 @@
    h = 0;
    EGetGeometry(disp, ewin->client.icon_pmap, &rt, &x, &y, &w, &h, &bw, &depth);
 
-   ewin->icon_w = (int)w;
-   ewin->icon_h = (int)h;
    if (w < 1 || h < 1)
       return;
 
    imlib_context_set_colormap(None);
    imlib_context_set_drawable(ewin->client.icon_pmap);
-   im = imlib_create_image_from_drawable(ewin->client.icon_mask, 0, 0, w, h, 0);
+   im = imlib_create_image_from_drawable(ewin->client.icon_mask, 0, 0, w, h, 1);
    imlib_context_set_image(im);
-   imlib_image_set_has_alpha(1);
+   imlib_image_set_has_alpha(1);       /* Should be set by imlib? */
    imlib_context_set_colormap(VRoot.cmap);
    imlib_context_set_drawable(VRoot.win);
-   ewin->icon_pmm.type = 1;
-   imlib_render_pixmaps_for_whole_image(&ewin->icon_pmm.pmap,
-                                       &ewin->icon_pmm.mask);
-}
-
-static void
-IB_PasteDefaultBase(Drawable d, int x, int y, int w, int h)
-{
-   ImageClass         *ic;
-   PmapMask            pmm;
-
-   /* get the base pixmap */
-   ic = ImageclassFind("DEFAULT_ICON_BUTTON", 0);
-   if (!ic)
-      return;
-
-   ImageclassApplyCopy(ic, d, w, h, 0, 0, STATE_NORMAL, &pmm, 1, ST_ICONBOX);
-   PastePixmap(disp, d, pmm.pmap, pmm.mask, x, y);
-   FreePmapMask(&pmm);
-}
-
-static void
-IB_PasteDefaultBaseMask(Drawable d, int x, int y, int w, int h)
-{
-   ImageClass         *ic;
-   PmapMask            pmm;
-
-   /* get the base pixmap */
-   ic = ImageclassFind("DEFAULT_ICON_BUTTON", 0);
-   if (!ic)
-      return;
-   ImageclassApplyCopy(ic, d, w, h, 0, 0, STATE_NORMAL, &pmm, 1, ST_ICONBOX);
-   PasteMask(disp, d, pmm.mask, x, y, w, h);
-   FreePmapMask(&pmm);
+   ewin->icon_image = im;
 }
 
 static Icondef    **
@@ -850,10 +838,7 @@
 {
    /* get the icon defined for this window in E's iconf match file */
    Icondef            *idef;
-   ImageClass         *ic;
    Imlib_Image        *im;
-   int                 w, h, mw, mh;
-   Iconbox            *ib;
 
    idef = IB_MatchIcondef(ewin->icccm.wm_name, ewin->icccm.wm_res_name,
                          ewin->icccm.wm_res_class);
@@ -865,42 +850,7 @@
    if (!im)
       return;
 
-   imlib_context_set_image(im);
-   w = imlib_image_get_width();
-   h = imlib_image_get_height();
-
-   ib = SelectIconboxForEwin(ewin);
-   if (ib)
-     {
-       mw = ib->iconsize;
-       mh = ib->iconsize;
-       if (ib->draw_icon_base)
-         {
-            ic = ImageclassFind("DEFAULT_ICON_BUTTON", 0);
-            if (ic)
-              {
-                 mw -= ic->padding.left + ic->padding.right;
-                 mh -= ic->padding.top + ic->padding.bottom;
-              }
-         }
-       if (mw < w)
-         {
-            h = (mw * h) / w;
-            w = mw;
-         }
-       if (mh < h)
-         {
-            w = (mh * w) / h;
-            h = mh;
-         }
-     }
-
-   imlib_render_pixmaps_for_whole_image_at_size(&ewin->icon_pmm.pmap,
-                                               &ewin->icon_pmm.mask, w, h);
-   ewin->icon_pmm.type = 1;
-   ewin->icon_w = w;
-   ewin->icon_h = h;
-   imlib_free_image();
+   ewin->icon_image = im;
 }
 
 static void
@@ -1081,83 +1031,64 @@
    return (Iconbox **) ListItemType(num, LIST_TYPE_ICONBOX);
 }
 
-Iconbox            *
+static Iconbox     *
 SelectIconboxForEwin(EWin * ewin)
 {
    /* find the appropriate iconbox from all available ones for this app */
    /* if it is to be iconified, or if it is alreayd return which iconbox */
    /* it's in */
-   Iconbox           **ib, *ib_sel = NULL;
-   int                 i, j, num = 0;
+   Iconbox           **lst, *ib, *ib_sel = NULL;
+   int                 i, num = 0;
 
    if (!ewin)
       return NULL;
-   ib = IconboxesList(&num);
-   if (ib)
+
+   lst = IconboxesList(&num);
+   if (!lst)
+      return NULL;
+
+   if (ewin->iconified)
      {
-       if (ewin->iconified)
+       /* find the iconbox this window got iconifed into */
+       for (i = 0; i < num; i++)
          {
-            /* find the iconbox this window got iconifed into */
-            for (i = 0; i < num; i++)
-              {
-                 for (j = 0; j < ib[i]->num_icons; j++)
-                   {
-                      if (ib[i]->icons[j] == ewin)
-                        {
-                           Iconbox            *ibr;
-
-                           ibr = ib[i];
-                           Efree(ib);
-                           return ibr;
-                        }
-                   }
-              }
+            ib = lst[i];
+            if (ib->type != 0)
+               continue;
+
+            if (IconboxFindEwin(ib, ewin) < 0)
+               continue;
+            ib_sel = ib;
+            break;
          }
-       else
+     }
+   else
+     {
+       /* pick the closest iconbox physically on screen to put it in */
+       int                 min_dist;
+       int                 dx, dy, dist;
+
+       min_dist = 0x7fffffff;
+       for (i = 0; i < num; i++)
          {
-            /* pick the closest iconbox physically on screen to put it in */
-            int                 min_dist;
+            ib = lst[i];
+            if (ib->ewin == NULL || ib->type != 0)
+               continue;
 
-            ib_sel = ib[0];
-            min_dist = 0x7fffffff;
-            for (i = 0; i < num; i++)
+            dx = (ib->ewin->x + (ib->ewin->w / 2)) - (ewin->x + (ewin->w / 2));
+            dy = (ib->ewin->y + (ib->ewin->h / 2)) - (ewin->y + (ewin->h / 2));
+            dist = (dx * dx) + (dy * dy);
+            if ((!ib->ewin->sticky) && (ib->ewin->desktop != ewin->desktop))
+               dist += (VRoot.w * VRoot.w) + (VRoot.h * VRoot.h);
+            if (dist < min_dist)
               {
-                 int                 dx, dy, dist;
-
-                 if (ib[i]->ewin == NULL)
-                    continue;
-                 dx = (ib[i]->ewin->x + (ib[i]->ewin->w / 2)) - (ewin->x +
-                                                                 (ewin->w /
-                                                                  2));
-                 dy = (ib[i]->ewin->y + (ib[i]->ewin->h / 2)) - (ewin->y +
-                                                                 (ewin->h /
-                                                                  2));
-                 dist = (dx * dx) + (dy * dy);
-                 if ((!ib[i]->ewin->sticky)
-                     && (ib[i]->ewin->desktop != ewin->desktop))
-                    dist += (VRoot.w * VRoot.w) + (VRoot.h * VRoot.h);
-                 if (dist < min_dist)
-                   {
-                      min_dist = dist;
-                      ib_sel = ib[i];
-                   }
+                 min_dist = dist;
+                 ib_sel = ib;
               }
          }
-       Efree(ib);
      }
-#if 0                          /* Do not autocreate iconboxes */
-   else
-     {
-       /* If there are no iconboxes, create one. */
-       doCreateIconbox(NULL);
-       ib = IconboxesList(&num);
-       if (ib)
-         {                     /* paranoia */
-            ib_sel = ib[0];
-            Efree(ib);
-         }
-     }
-#endif
+
+   Efree(lst);
 
    return ib_sel;
 }
@@ -1165,19 +1096,14 @@
 static void
 IconboxUpdateEwinIcon(Iconbox * ib, EWin * ewin, int icon_mode)
 {
-   int                 i;
-
    if (ib->icon_mode != icon_mode)
       return;
 
-   for (i = 0; i < ib->num_icons; i++)
-     {
-       if (ib->icons[i] != ewin)
-          continue;
-       UpdateAppIcon(ewin, icon_mode);
-       IconboxRedraw(ib);
-       break;
-     }
+   if (IconboxFindEwin(ib, ewin) < 0)
+      return;
+
+   UpdateAppIcon(ewin, icon_mode);
+   IconboxRedraw(ib);
 }
 
 static void
@@ -1187,43 +1113,48 @@
    int                 i, num = 0;
 
    ib = IconboxesList(&num);
-   if (ib)
-     {
-       for (i = 0; i < num; i++)
-          IconboxUpdateEwinIcon(ib[i], ewin, icon_mode);
-       Efree(ib);
-     }
+   if (!ib)
+      return;
+
+   for (i = 0; i < num; i++)
+      IconboxUpdateEwinIcon(ib[i], ewin, icon_mode);
+   Efree(ib);
 }
 
-void
+static void
 UpdateAppIcon(EWin * ewin, int imode)
 {
    /* free whatever we had before */
-   FreePmapMask(&ewin->icon_pmm);
+   if (ewin->icon_image)
+     {
+       imlib_context_set_image(ewin->icon_image);
+       imlib_free_image();
+       ewin->icon_image = NULL;
+     }
 
    switch (imode)
      {
      case 0:
        /* snap first - if fails try app, then e */
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
          {
             if (ewin->shaded)
                EwinInstantUnShade(ewin);
             RaiseEwin(ewin);
             IB_SnapEWin(ewin);
          }
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
           IB_GetAppIcon(ewin);
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
           IB_GetEIcon(ewin);
        break;
      case 1:
        /* try app first, then e, then snap */
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
           IB_GetAppIcon(ewin);
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
           IB_GetEIcon(ewin);
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
          {
             if (ewin->shaded)
                EwinInstantUnShade(ewin);
@@ -1233,16 +1164,16 @@
        break;
      case 2:
        /* try E first, then snap, then app */
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
           IB_GetEIcon(ewin);
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
          {
             if (ewin->shaded)
                EwinInstantUnShade(ewin);
             RaiseEwin(ewin);
             IB_SnapEWin(ewin);
          }
-       if (!ewin->icon_pmm.pmap)
+       if (!ewin->icon_image)
           IB_GetAppIcon(ewin);
        break;
      default:
@@ -1253,25 +1184,33 @@
 static void
 IB_CalcMax(Iconbox * ib)
 {
-   int                 i, x, y;
+   int                 i, x, y, w, h;
 
    x = 0;
    y = 0;
-   for (i = 0; i < ib->num_icons; i++)
+   for (i = 0; i < ib->num_objs; i++)
      {
-       int                 w, h;
-       EWin               *ewin;
-
        w = 8;
        h = 8;
-       ewin = ib->icons[i];
-       if (!ewin->icon_pmm.pmap)
-          UpdateAppIcon(ewin, ib->icon_mode);
-       if (ewin->icon_pmm.pmap)
+       if (ib->type == 0)
          {
-            w = ewin->icon_w;
-            h = ewin->icon_h;
+            EWin               *ewin;
+
+            ewin = ib->objs[i].ewin;
+            if (!ewin->icon_image)
+               UpdateAppIcon(ewin, ib->icon_mode);
+            if (ewin->icon_image)
+              {
+                 imlib_context_set_image(ewin->icon_image);
+                 w = imlib_image_get_width();
+                 h = imlib_image_get_height();
+              }
          }
+       else
+         {
+            w = h = ib->iconsize;
+         }
+
        if (ib->draw_icon_base)
          {
             x += ib->iconsize;
@@ -1283,6 +1222,7 @@
             y += h + 2;
          }
      }
+
    if (ib->orientation)
       ib->max = y - 2;
    else
@@ -1321,38 +1261,48 @@
          }
      }
 
-   for (i = 0; i < ib->num_icons; i++)
+   for (i = 0; i < ib->num_objs; i++)
      {
        int                 w, h, xx, yy;
-       EWin               *ewin;
 
        w = 8;
        h = 8;
-       ewin = ib->icons[i];
-       if (!ewin->icon_pmm.pmap)
-          UpdateAppIcon(ewin, ib->icon_mode);
-       if (ewin->icon_pmm.pmap)
-         {
-            w = ewin->icon_w;
-            h = ewin->icon_h;
-            xx = x;
-            yy = y;
-            if (ib->orientation)
-              {
-                 if (ib->draw_icon_base)
-                    yy += (ib->iconsize - h) / 2;
-                 xx += (ib->iconsize - w) / 2;
-              }
-            else
-              {
-                 if (ib->draw_icon_base)
-                    xx += (ib->iconsize - w) / 2;
-                 yy += (ib->iconsize - h) / 2;
+       if (ib->type == 0)
+         {
+            EWin               *ewin;
+
+            ewin = ib->objs[i].ewin;
+            if (!ewin->icon_image)
+               UpdateAppIcon(ewin, ib->icon_mode);
+            if (ewin->icon_image)
+              {
+                 imlib_context_set_image(ewin->icon_image);
+                 w = imlib_image_get_width();
+                 h = imlib_image_get_height();
+                 xx = x;
+                 yy = y;
+                 if (ib->orientation)
+                   {
+                      if (ib->draw_icon_base)
+                         yy += (ib->iconsize - h) / 2;
+                      xx += (ib->iconsize - w) / 2;
+                   }
+                 else
+                   {
+                      if (ib->draw_icon_base)
+                         xx += (ib->iconsize - w) / 2;
+                      yy += (ib->iconsize - h) / 2;
+                   }
+                 if ((px >= (xx - 1)) && (py >= (yy - 1))
+                     && (px < (xx + w + 1)) && (py < (yy + h + 1)))
+                    return ewin;
               }
-            if ((px >= (xx - 1)) && (py >= (yy - 1)) && (px < (xx + w + 1))
-                && (py < (yy + h + 1)))
-               return ewin;
          }
+       else
+         {
+            w = h = ib->iconsize;
+         }
+
        if (ib->orientation)
          {
             if (ib->draw_icon_base)
@@ -1911,7 +1861,7 @@
 static void
 IconboxRedraw(Iconbox * ib)
 {
-   Pixmap              m = 0;
+   Pixmap              m = 0, pmap, mask;
    char                pq;
    char                was_shaded = 0;
    int                 i, x, y, w, h;
@@ -2090,54 +2040,82 @@
        y += ib_ic_box->padding.top;
      }
 
-   for (i = 0; i < ib->num_icons; i++)
+   for (i = 0; i < ib->num_objs; i++)
      {
        EWin               *ewin;
 
        w = 8;
        h = 8;
 
-       ewin = ib->icons[i];
-
-       if (!ewin->icon_pmm.pmap)
-          UpdateAppIcon(ewin, ib->icon_mode);
-       if (ewin->icon_pmm.pmap)
+       if (ib->type == 0)
          {
-            int                 xoff, yoff;
+            ewin = ib->objs[i].ewin;
 
-            w = ewin->icon_w;
-            h = ewin->icon_h;
-            if (ib->orientation)
+            if (!ewin->icon_image)
+               UpdateAppIcon(ewin, ib->icon_mode);
+            if (ewin->icon_image)
               {
-                 xoff = (ib->iconsize - w) / 2;
-                 yoff = 0;
-              }
-            else
-              {
-                 xoff = 0;
-                 yoff = (ib->iconsize - h) / 2;
-              }
-            if (ib->draw_icon_base)
-              {
-                 IB_PasteDefaultBase(ib->pmap, x, y, ib->iconsize,
-                                     ib->iconsize);
-                 if (ib->nobg)
-                    IB_PasteDefaultBaseMask(m, x, y, ib->iconsize,
-                                            ib->iconsize);
-              }
+                 int                 xoff, yoff;
 
-            if (ib->draw_icon_base)
-               PastePixmap(disp, ib->pmap, ewin->icon_pmm.pmap,
-                           ewin->icon_pmm.mask,
-                           x + ((ib->iconsize - w) / 2),
-                           y + ((ib->iconsize - h) / 2));
-            else
-               PastePixmap(disp, ib->pmap, ewin->icon_pmm.pmap,
-                           ewin->icon_pmm.mask, x + xoff, y + yoff);
+                 imlib_context_set_image(ewin->icon_image);
+                 w = imlib_image_get_width();
+                 h = imlib_image_get_height();
+
+                 if (ib->orientation)
+                   {
+                      xoff = (ib->iconsize - w) / 2;
+                      yoff = 0;
+                   }
+                 else
+                   {
+                      xoff = 0;
+                      yoff = (ib->iconsize - h) / 2;
+                   }
+
+                 if (ib->draw_icon_base)
+                   {
+                      ImageClass         *ic;
+                      PmapMask            pmm;
+
+                      /* get the base pixmap */
+                      ic = ImageclassFind("DEFAULT_ICON_BUTTON", 0);
+                      if (ic)
+                        {
+                           ImageclassApplyCopy(ic, ib->pmap,
+                                               ib->iconsize, ib->iconsize, 0,
+                                               0, STATE_NORMAL, &pmm, 1,
+                                               ST_ICONBOX);
+                           PastePixmap(disp, ib->pmap, pmm.pmap, pmm.mask, x,
+                                       y);
+                           if (ib->nobg)
+                              PasteMask(disp, ib->pmap, pmm.mask, x, y,
+                                        ib->iconsize, ib->iconsize);
+                           FreePmapMask(&pmm);
+                        }
+                   }
+
+                 imlib_context_set_drawable(ib->pmap);
+                 imlib_context_set_image(ewin->icon_image);
+                 imlib_render_pixmaps_for_whole_image(&pmap, &mask);
+
+                 if (ib->draw_icon_base)
+                    PastePixmap(disp, ib->pmap, pmap, mask,
+                                x + ((ib->iconsize - w) / 2),
+                                y + ((ib->iconsize - h) / 2));
+                 else
+                    PastePixmap(disp, ib->pmap, pmap, mask, x + xoff,
+                                y + yoff);
+
+                 if (ib->nobg)
+                    PasteMask(disp, m, mask, x + xoff, y + yoff, w, h);
 
-            if (ib->nobg)
-               PasteMask(disp, m, ewin->icon_pmm.mask,
-                         x + xoff, y + yoff, w, h);
+                 imlib_free_pixmap_and_mask(pmap);
+              }
+         }
+       else
+         {
+            w = h = ib->iconsize;
+            EMoveResizeWindow(disp, ib->objs[i].win, x, y, w, h);
          }
 
        if (ib->orientation)
@@ -2150,7 +2128,7 @@
      {
        EShapeCombineMask(disp, ib->icon_win, ShapeBounding, 0, 0, m, ShapeSet);
        ecore_x_pixmap_del(m);
-       if (ib->num_icons == 0)
+       if (ib->num_objs == 0)
           EMoveWindow(disp, ib->icon_win, -ib->w, -ib->h);
      }
    ESetWindowBackgroundPixmap(disp, ib->icon_win, ib->pmap);
@@ -3147,3 +3125,125 @@
    {N_IPC_FUNCS, IconboxesIpcArray},
    {0, NULL}
 };
+
+/*
+ * System tray functions
+ */
+
+/* Selection atoms */
+static Atom         E_XA_MANAGER = 0;
+
+/* XEmbed atoms */
+static Atom         E_XA__XEMBED = 0;
+
+/* Systray atoms */
+static Atom         _NET_SYSTEM_TRAY_Sx = 0;
+static Atom         _NET_SYSTEM_TRAY_OPCODE = 0;
+static Atom         _NET_SYSTEM_TRAY_MESSAGE_DATA = 0;
+
+#define SYSTEM_TRAY_REQUEST_DOCK    0
+#define SYSTEM_TRAY_BEGIN_MESSAGE   1
+#define SYSTEM_TRAY_CANCEL_MESSAGE  2
+
+#define XEMBED_EMBEDDED_NOTIFY      0
+
+#ifndef USE_ECORE_X
+extern Display     *_ecore_x_disp;
+int                 ecore_x_client_message32_send(Window win, Atom type,
+                                                 long d0, long d1, long d2,
+                                                 long d3, long d4);
+
+int
+ecore_x_client_message32_send(Window win, Atom type, long d0, long d1,
+                             long d2, long d3, long d4)
+{
+   XEvent              xev;
+
+   xev.xclient.window = win;
+   xev.xclient.type = ClientMessage;
+   xev.xclient.message_type = type;
+   xev.xclient.format = 32;
+   xev.xclient.data.l[0] = d0;
+   xev.xclient.data.l[1] = d1;
+   xev.xclient.data.l[2] = d2;
+   xev.xclient.data.l[3] = d3;
+   xev.xclient.data.l[4] = d4;
+
+   return !XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
+}
+#endif
+
+static void
+SystrayEventClientMessage(void *ib, XClientMessageEvent * ev)
+{
+   Window              win;
+
+   Eprintf("ev->data.l: %#lx %#lx %#lx %#lx\n",
+          ev->data.l[0], ev->data.l[1], ev->data.l[2], ev->data.l[3]);
+
+   if (ev->message_type == _NET_SYSTEM_TRAY_OPCODE)
+     {
+       win = ev->data.l[2];
+
+       IconboxAddWindow(ib, win);
+
+       /* Should proto be set according to clients _XEMBED_INFO? */
+       ecore_x_client_message32_send(win, E_XA__XEMBED,
+                                     CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0,
+                                     ev->window, /*proto */ 1);
+     }
+   else if (ev->message_type == _NET_SYSTEM_TRAY_MESSAGE_DATA)
+     {
+       Eprintf("got message\n");
+     }
+}
+
+static void
+SystrayEvent(XEvent * ev, void *prm)
+{
+   Eprintf("SystrayEvent %2d %#lx\n", ev->type, ev->xany.window);
+
+   switch (ev->type)
+     {
+     case DestroyNotify:
+       IconboxDelWindow(prm, ev->xdestroywindow.window);
+       break;
+     case ClientMessage:
+       SystrayEventClientMessage(prm, &(ev->xclient));
+       break;
+     }
+}
+
+static void
+SystrayInit(Iconbox * obj, Window win, int screen)
+{
+   char                buf[32];
+
+   Esnprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", screen);
+
+   E_XA_MANAGER = XInternAtom(disp, "MANAGER", False);
+   E_XA__XEMBED = XInternAtom(disp, "_XEMBED", False);
+   _NET_SYSTEM_TRAY_Sx = XInternAtom(disp, buf, False);
+   _NET_SYSTEM_TRAY_OPCODE =
+      XInternAtom(disp, "_NET_SYSTEM_TRAY_OPCODE", False);
+   _NET_SYSTEM_TRAY_MESSAGE_DATA =
+      XInternAtom(disp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
+
+   /* Acquire selection */
+   XSetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx, win, CurrentTime);
+
+   if (XGetSelectionOwner(disp, _NET_SYSTEM_TRAY_Sx) != win)
+     {
+       Eprintf("Failed to acquire selection %s\n", buf);
+       return;
+     }
+
+   Eprintf("Window %#lx is now system tray\n", win);
+
+   XSelectInput(disp, win, SubstructureRedirectMask | ResizeRedirectMask |
+               SubstructureNotifyMask);
+   EventCallbackRegister(win, 0, SystrayEvent, obj);
+
+   ecore_x_client_message32_send(VRoot.win, E_XA_MANAGER, CurrentTime,
+                                _NET_SYSTEM_TRAY_Sx, win, 0, 0);
+}




-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to