Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        areas.c pager.c 


Log Message:
Various pager fixes, eliminate recursive resizing.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/areas.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -3 -r1.85 -r1.86
--- areas.c     7 May 2005 11:19:55 -0000       1.85
+++ areas.c     26 May 2005 21:31:27 -0000      1.86
@@ -265,7 +265,7 @@
    /* re-focus on a new ewin on that new desktop area */
    FocusNewDesk();
 
-   ModulesSignal(ESIGNAL_AREA_SWITCH_DONE, NULL);
+   ModulesSignal(ESIGNAL_AREA_SWITCH_DONE, (void *)DesksGetCurrent());
 
    /* update which "edge flip resistance" detector windows are visible */
    EdgeWindowsShow();
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/pager.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -3 -r1.143 -r1.144
--- pager.c     22 May 2005 15:02:20 -0000      1.143
+++ pager.c     26 May 2005 21:31:27 -0000      1.144
@@ -34,15 +34,18 @@
    char               *name;
    Window              win;
    Pixmap              pmap;
-   PmapMask            bgpmap;
+   Pixmap              bgpmap;
    int                 desktop;
    int                 w, h;
    int                 dw, dh;
    int                 update_phase;
    EWin               *ewin;
    Window              sel_win;
-   char                update;
-   char                redraw;
+
+   /* State flags */
+   char                do_newbg;
+   char                do_update;
+   char                do_redraw;
 };
 
 typedef struct
@@ -56,51 +59,33 @@
 #define PAGER_EVENT_MOTION     0
 #define PAGER_EVENT_MOUSE_IN   1
 
+static void         PagerCheckUpdate(Pager * p);
 static void         PagerEwinUpdateFromPager(Pager * p, EWin * ewin);
 static void         PagerHiwinHide(Pager * p);
 static void         PagerEventMainWin(XEvent * ev, void *prm);
 static void         PagerHiwinEvent(XEvent * ev, void *prm);
 
+static char         pager_update_pending = 0;
+
 static PagerHiwin  *hiwin = NULL;
 
 static Pager       *
 PagerCreate(void)
 {
    Pager              *p;
-   int                 ax, ay;
-   ImageClass         *ic;
-   XSetWindowAttributes attr;
-   static char         did_dialog = 0;
 
    if (!Conf.pagers.enable)
       return NULL;
 
-   if ((!did_dialog) && (Conf.pagers.snap))
-      did_dialog = 1;
-
-   GetAreaSize(&ax, &ay);
    p = Ecalloc(1, sizeof(Pager));
    p->name = NULL;
-   attr.colormap = VRoot.cmap;
-   attr.border_pixel = 0;
-   attr.background_pixel = 0;
-   attr.save_under = False;
-   p->w = ((48 * VRoot.w) / VRoot.h) * ax;
-   p->h = 48 * ay;
-   p->dw = ((48 * VRoot.w) / VRoot.h);
-   p->dh = 48;
-   p->win = ECreateWindow(VRoot.win, 0, 0, p->w, p->h, 0);
+   p->win = ECreateWindow(VRoot.win, 0, 0, 1, 1, 0);
    EventCallbackRegister(p->win, 0, PagerEventMainWin, p);
-   p->pmap = ECreatePixmap(p->win, p->w, p->h, VRoot.depth);
-   ESetWindowBackgroundPixmap(p->win, p->pmap);
    p->desktop = 0;
    p->update_phase = 0;
    p->ewin = NULL;
-   p->sel_win = ECreateWindow(p->win, 0, 0, p->w / ax, p->h / ay, 0);
-   ic = ImageclassFind("PAGER_SEL", 0);
-   if (ic)
-      ImageclassApply(ic, p->sel_win, p->w / ax, p->h / ay, 0, 0, STATE_NORMAL,
-                     0, ST_PAGER);
+   p->sel_win = ECreateWindow(p->win, 0, 0, 1, 1, 0);
+
    return p;
 }
 
@@ -116,9 +101,11 @@
       Efree(p->name);
    EDestroyWindow(p->win);
    PagerHiwinHide(p);
-   if (p->pmap)
+   if (p->pmap != None)
       EFreePixmap(p->pmap);
-   FreePmapMask(&p->bgpmap);
+   if (p->bgpmap != None)
+      EFreePixmap(p->bgpmap);
+
    Efree(p);
 }
 
@@ -200,6 +187,9 @@
    xx = cx * ww;
    yy = cy * hh;
    phase = p->update_phase;
+   if (ww <= 0 || hh <= 0)
+      return;
+
 #if 0
    /* Due to a bug in imlib2 <= 1.2.0 we have to scan left->right in stead
     * of top->bottom, at least for now. */
@@ -283,7 +273,9 @@
             ic = ImageclassFind("PAGER_WIN", 0);
             if (ic)
                ImageclassApplyCopy(ic, EoGetWin(ewin), w, h, 0, 0,
-                                   STATE_NORMAL, &ewin->mini_pmm, 1, ST_PAGER);
+                                   STATE_NORMAL, &ewin->mini_pmm, 1,
+                                   ST_UNKNWN);
+
          }
        else
          {
@@ -299,40 +291,27 @@
 }
 
 static void
-PagerRedraw(Pager * p, char newbg)
+PagerRedraw(Pager * p)
 {
-   static const char   pager_mode_map[5][4] = {
-      {0, 1, 2, 3},
-      {0, 1, 1, 0},
-      {1, 1, 1, 1},
-      {1, 1, 2, 2},
-      {0, 1, 2, 3},
-   };
-
-   p->redraw = pager_mode_map[(int)p->redraw][(int)newbg] + 1;
+   p->do_redraw = 1;
+   pager_update_pending = 1;
 }
 
 static void
-PagerForceUpdate(Pager * p)
+PagerUpdate(Pager * p)
 {
-   p->update = 1;
+   p->do_update = 1;
+   pager_update_pending = 1;
 }
 
 static void
-doPagerRedraw(Pager * p, char newbg)
+doPagerRedraw(Pager * p)
 {
    int                 x, y, ax, ay, cx, cy;
    GC                  gc;
    EWin               *const *lst;
    int                 i, num;
 
-   if (!Conf.pagers.enable)
-      return;
-
-   /* Desk may be gone */
-   if (p->desktop >= DesksGetNumber())
-      return;
-
    p->update_phase = 0;
    GetAreaSize(&ax, &ay);
    DeskGetArea(p->desktop, &cx, &cy);
@@ -341,92 +320,11 @@
    if (gc == None)
       return;
 
-   if ((newbg > 0) && (newbg < 3))
-     {
-       FreePmapMask(&p->bgpmap);
-
-       if (!Conf.pagers.snap)
-         {
-            ImageClass         *ic = NULL;
-
-            ic = ImageclassFind("PAGER_BACKGROUND", 0);
-            if (ic)
-               ImageclassApplyCopy(ic, p->win, p->w / ax, p->h / ay, 0, 0,
-                                   STATE_NORMAL, &p->bgpmap, 0, ST_PAGER);
-         }
-       else
-         {
-            Background         *bg;
-
-            bg = DeskGetBackground(p->desktop);
-            if (bg)
-              {
-                 char                s[4096];
-                 char               *uniq;
-                 Imlib_Image        *im;
-
-                 uniq = BackgroundGetUniqueString(bg);
-                 Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s",
-                           EDirUserCache(), BackgroundGetName(bg),
-                           (p->w / ax), (p->h / ay), uniq);
-                 Efree(uniq);
-
-                 im = imlib_load_image(s);
-                 if (im)
-                   {
-                      imlib_context_set_image(im);
-                      p->bgpmap.type = 1;
-                      imlib_render_pixmaps_for_whole_image_at_size(&p->
-                                                                   bgpmap.
-                                                                   pmap,
-                                                                   &p->
-                                                                   bgpmap.
-                                                                   mask,
-                                                                   (p->w /
-                                                                    ax),
-                                                                   (p->h /
-                                                                    ay));
-                      imlib_free_image_and_decache();
-                   }
-                 else
-                   {
-                      p->bgpmap.type = 0;
-                      p->bgpmap.pmap =
-                         ECreatePixmap(p->win, p->w / ax, p->h / ay,
-                                       VRoot.depth);
-                      p->bgpmap.mask = None;
-                      BackgroundApply(bg, p->bgpmap.pmap, 0);
-                      imlib_context_set_drawable(p->bgpmap.pmap);
-                      im =
-                         imlib_create_image_from_drawable(0, 0, 0,
-                                                          (p->w / ax),
-                                                          (p->h / ay), 0);
-                      imlib_context_set_image(im);
-                      imlib_image_set_format("png");
-                      imlib_save_image(s);
-                      imlib_free_image_and_decache();
-                   }
-              }
-            else
-              {
-                 p->bgpmap.type = 0;
-                 p->bgpmap.pmap =
-                    ECreatePixmap(p->win, p->w / ax, p->h / ay, VRoot.depth);
-                 p->bgpmap.mask = None;
-                 XSetForeground(disp, gc, BlackPixel(disp, VRoot.scr));
-                 XDrawRectangle(disp, p->bgpmap.pmap, gc, 0, 0, p->dw, p->dh);
-                 XSetForeground(disp, gc, WhitePixel(disp, VRoot.scr));
-                 XFillRectangle(disp, p->bgpmap.pmap, gc, 1, 1, p->dw - 2,
-                                p->dh - 2);
-              }
-         }
-     }
-
    for (y = 0; y < ay; y++)
      {
        for (x = 0; x < ax; x++)
-          XCopyArea(disp, p->bgpmap.pmap, p->pmap, gc, 0, 0, p->w / ax,
-                    p->h / ay, x * (p->w / ax), y * (p->h / ay));
+          XCopyArea(disp, p->bgpmap, p->pmap, gc, 0, 0, p->dw, p->dh,
+                    x * p->dw, y * p->dh);
      }
 
    lst = EwinListGetForDesk(&num, p->desktop);
@@ -436,93 +334,167 @@
        int                 wx, wy, ww, wh;
 
        ewin = lst[i];
-       if (EoIsShown(ewin))
+       if (!EoIsShown(ewin))
+          continue;
+
+       wx = ((EoGetX(ewin) + (cx * VRoot.w)) * (p->w / ax)) / VRoot.w;
+       wy = ((EoGetY(ewin) + (cy * VRoot.h)) * (p->h / ay)) / VRoot.h;
+       ww = ((EoGetW(ewin)) * (p->w / ax)) / VRoot.w;
+       wh = ((EoGetH(ewin)) * (p->h / ay)) / VRoot.h;
+       PagerEwinUpdateMini(p, ewin);
+       if (ewin->mini_pmm.pmap)
          {
-            wx = ((EoGetX(ewin) + (cx * VRoot.w)) * (p->w / ax)) / VRoot.w;
-            wy = ((EoGetY(ewin) + (cy * VRoot.h)) * (p->h / ay)) / VRoot.h;
-            ww = ((EoGetW(ewin)) * (p->w / ax)) / VRoot.w;
-            wh = ((EoGetH(ewin)) * (p->h / ay)) / VRoot.h;
-            PagerEwinUpdateMini(p, ewin);
-            if (ewin->mini_pmm.pmap)
+            if (ewin->mini_pmm.mask)
               {
-                 if (ewin->mini_pmm.mask)
-                   {
-                      XSetClipMask(disp, gc, ewin->mini_pmm.mask);
-                      XSetClipOrigin(disp, gc, wx, wy);
-                   }
-                 XCopyArea(disp, ewin->mini_pmm.pmap, p->pmap, gc, 0, 0,
-                           ww, wh, wx, wy);
-                 if (ewin->mini_pmm.mask)
-                    XSetClipMask(disp, gc, None);
-              }
-            else
-              {
-                 XSetForeground(disp, gc, BlackPixel(disp, VRoot.scr));
-                 XDrawRectangle(disp, p->pmap, gc, wx - 1, wy - 1, ww + 1,
-                                wh + 1);
-                 XSetForeground(disp, gc, WhitePixel(disp, VRoot.scr));
-                 XFillRectangle(disp, p->pmap, gc, wx, wy, ww, wh);
+                 XSetClipMask(disp, gc, ewin->mini_pmm.mask);
+                 XSetClipOrigin(disp, gc, wx, wy);
               }
+            XCopyArea(disp, ewin->mini_pmm.pmap, p->pmap, gc, 0, 0,
+                      ww, wh, wx, wy);
+            if (ewin->mini_pmm.mask)
+               XSetClipMask(disp, gc, None);
+         }
+       else
+         {
+            XSetForeground(disp, gc, BlackPixel(disp, VRoot.scr));
+            XDrawRectangle(disp, p->pmap, gc, wx - 1, wy - 1, ww + 1, wh + 1);
+            XSetForeground(disp, gc, WhitePixel(disp, VRoot.scr));
+            XFillRectangle(disp, p->pmap, gc, wx, wy, ww, wh);
          }
      }
 
-   if (newbg < 2)
-     {
-       ESetWindowBackgroundPixmap(p->win, p->pmap);
-       EClearWindow(p->win);
-     }
+   EClearWindow(p->win);
 
    EFreeGC(gc);
 }
 
 static void
-doPagerForceUpdate(Pager * p)
+doPagerUpdate(Pager * p)
 {
-   int                 ww, hh, xx, yy, ax, ay, cx, cy;
+   int                 cx, cy;
    EWin               *const *lst;
    int                 i, num;
 
-   if (!Conf.pagers.enable)
-      return;
-
-   /* Desk may be gone */
-   if (p->desktop >= DesksGetNumber())
-      return;
-
-   if ((p->desktop != DesksGetCurrent()) || (!Conf.pagers.snap))
-     {
-       PagerRedraw(p, 0);
-       return;
-     }
-
    p->update_phase = 0;
-   GetAreaSize(&ax, &ay);
    DeskGetArea(p->desktop, &cx, &cy);
-   ww = p->w / ax;
-   hh = p->h / ay;
-   xx = cx * ww;
-   yy = cy * hh;
 
-   ScaleRect(VRoot.win, p->pmap, NULL, 0, 0, VRoot.w, VRoot.h, xx, yy, ww, hh,
-            Conf.pagers.hiq);
+   /* Update pager area by snapshotting entire screen */
+   ScaleRect(VRoot.win, p->pmap, NULL, 0, 0, VRoot.w, VRoot.h, cx * p->dw,
+            cy * p->dh, p->dw, p->dh, Conf.pagers.hiq);
    EClearWindow(p->win);
 
+   /* Update ewin snapshots */
    lst = EwinListGetForDesk(&num, p->desktop);
    for (i = 0; i < num; i++)
       PagerEwinUpdateFromPager(p, lst[i]);
 }
 
 static void
+PagerReconfigure(Pager * p)
+{
+   EWin               *ewin;
+   int                 ax, ay;
+   double              aspect;
+
+   ewin = p->ewin;
+
+   GetAreaSize(&ax, &ay);
+
+   ewin->client.w_inc = ax * 4;
+   ewin->client.h_inc = ay * 8;
+   ewin->client.width.min = 10 * ax;
+   ewin->client.height.min = 8 * ay;
+   ewin->client.width.max = 320 * ax;
+   ewin->client.height.max = 240 * ay;
+   aspect = ((double)VRoot.w) / ((double)VRoot.h);
+   ewin->client.aspect_min = aspect * ((double)ax / (double)ay);
+   ewin->client.aspect_max = aspect * ((double)ax / (double)ay);
+}
+
+static void
+PagerUpdateBg(Pager * p)
+{
+   Pixmap              pmap;
+   GC                  gc;
+   Background         *bg;
+
+   pmap = p->bgpmap;
+   if (pmap != None)
+      EFreePixmap(pmap);
+   pmap = p->bgpmap = ECreatePixmap(p->win, p->dw, p->dh, VRoot.depth);
+
+   if (!Conf.pagers.snap)
+     {
+       ImageClass         *ic;
+       PmapMask            pmm;
+
+       ic = ImageclassFind("PAGER_BACKGROUND", 0);
+       if (ic)
+          ImageclassApplyCopy(ic, pmap, p->dw, p->dh, 0, 0,
+                              STATE_NORMAL, &pmm, 0, ST_UNKNWN);
+       gc = ECreateGC(pmap, 0, NULL);
+       if (gc == None)
+          return;
+       XCopyArea(disp, pmm.pmap, pmap, gc, 0, 0, p->dw, p->dh, 0, 0);
+       EFreeGC(gc);
+       FreePmapMask(&pmm);
+       return;
+     }
+
+   bg = DeskGetBackground(p->desktop);
+   if (bg)
+     {
+       char                s[4096];
+       char               *uniq;
+       Imlib_Image        *im;
+
+       uniq = BackgroundGetUniqueString(bg);
+       Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s",
+                 EDirUserCache(), BackgroundGetName(bg), p->dw, p->dh, uniq);
+       Efree(uniq);
+
+       im = imlib_load_image(s);
+       if (im)
+         {
+            imlib_context_set_image(im);
+            imlib_context_set_drawable(pmap);
+            imlib_render_image_on_drawable_at_size(0, 0, p->dw, p->dh);
+            imlib_free_image_and_decache();
+         }
+       else
+         {
+            BackgroundApply(bg, pmap, 0);
+            imlib_context_set_drawable(pmap);
+            im = imlib_create_image_from_drawable(0, 0, 0, p->dw, p->dh, 1);
+            imlib_context_set_image(im);
+            imlib_image_set_format("png");
+            imlib_save_image(s);
+            imlib_free_image_and_decache();
+         }
+       return;
+     }
+
+   gc = ECreateGC(pmap, 0, NULL);
+   if (gc == None)
+      return;
+
+   XSetForeground(disp, gc, BlackPixel(disp, VRoot.scr));
+   XDrawRectangle(disp, pmap, gc, 0, 0, p->dw, p->dh);
+   XSetForeground(disp, gc, WhitePixel(disp, VRoot.scr));
+   XFillRectangle(disp, pmap, gc, 1, 1, p->dw - 2, p->dh - 2);
+
+   EFreeGC(gc);
+}
+
+static void
 PagerEwinMoveResize(EWin * ewin, int resize __UNUSED__)
 {
    Pager              *p = ewin->data;
    int                 w, h;
    int                 ax, ay, cx, cy;
    ImageClass         *ic;
-   EWin               *const *lst;
-   int                 i, num;
 
-   if (!Conf.pagers.enable || !p)
+   if (!Conf.pagers.enable || !p || Mode.mode != MODE_NONE)
       return;
 
    w = ewin->client.w;
@@ -531,28 +503,19 @@
       return;
 
    GetAreaSize(&ax, &ay);
-   EFreePixmap(p->pmap);
-   FreePmapMask(&p->bgpmap);
-   EResizeWindow(p->win, w, h);
+
+   if (p->pmap != None)
+      EFreePixmap(p->pmap);
+
    p->w = w;
    p->h = h;
    p->dw = w / ax;
    p->dh = h / ay;
+
    p->pmap = ECreatePixmap(p->win, p->w, p->h, VRoot.depth);
-   if (EoIsShown(ewin))
-      PagerRedraw(p, 1);
    ESetWindowBackgroundPixmap(p->win, p->pmap);
-   EClearWindow(p->win);
-   if (p->ewin)
-     {
-       double              aspect;
-
-       aspect = ((double)VRoot.w) / ((double)VRoot.h);
-       p->ewin->client.w_inc = ax * 4;
-       p->ewin->client.h_inc = ay * 8;
-       p->ewin->client.aspect_min = aspect * ((double)ax / (double)ay);
-       p->ewin->client.aspect_max = aspect * ((double)ax / (double)ay);
-     }
+   p->do_newbg = 1;
+   PagerCheckUpdate(p);
 
    ic = ImageclassFind("PAGER_SEL", 0);
    if (ic)
@@ -562,10 +525,6 @@
        ImageclassApply(ic, p->sel_win, p->dw, p->dh, 0, 0, STATE_NORMAL, 0,
                        ST_PAGER);
      }
-
-   lst = EwinListGetForDesk(&num, p->desktop);
-   for (i = 0; i < num; i++)
-      PagerEwinUpdateMini(p, lst[i]);
 }
 
 static void
@@ -598,8 +557,7 @@
 {
    EWin               *ewin = NULL;
    char                s[4096];
-   int                 ax, ay, w, h;
-   double              aspect;
+   int                 w, h;
 
    if (!Conf.pagers.enable)
       return;
@@ -618,28 +576,18 @@
    if (!ewin)
       return;
 
+   p->ewin = ewin;
+
+   PagerReconfigure(p);
+
    ewin->client.event_mask |=
       ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
    ESelectInput(p->win, ewin->client.event_mask);
 
-   aspect = ((double)VRoot.w) / ((double)VRoot.h);
-   GetAreaSize(&ax, &ay);
-   ewin->client.aspect_min = aspect * ((double)ax / (double)ay);
-   ewin->client.aspect_max = aspect * ((double)ax / (double)ay);
-   ewin->client.w_inc = ax * 4;
-   ewin->client.h_inc = ay * 8;
-   ewin->client.width.min = 10 * ax;
-   ewin->client.height.min = 8 * ay;
-   ewin->client.width.max = 320 * ax;
-   ewin->client.height.max = 240 * ay;
-
-   p->ewin = ewin;
-
-   /* get the size right damnit! */
    w = ewin->client.w;
    h = ewin->client.h;
-   ewin->client.w = 1;
-   ewin->client.h = 1;
+
+   MoveEwinToDesktop(ewin, EoGetDesk(ewin));
    if (ewin->client.already_placed)
      {
        MoveResizeEwin(ewin, EoGetX(ewin), EoGetY(ewin), w, h);
@@ -647,14 +595,16 @@
    else
      {
        /* no snapshots ? first time ? make a row on the bottom left up */
-       MoveResizeEwin(ewin, 0, VRoot.h - (Conf.desks.num -
-                                          p->desktop) * EoGetH(ewin), w, h);
-     }
-   MoveEwinToDesktop(ewin, EoGetDesk(ewin));
+       int                 ax, ay;
 
-   PagerRedraw(p, 1);
+       GetAreaSize(&ax, &ay);
+       w = ((48 * VRoot.w) / VRoot.h) * ax;
+       h = 48 * ay;
+       ResizeEwin(ewin, w, h); /* Does layout */
+       MoveEwin(ewin, 0,
+                VRoot.h - (Conf.desks.num - p->desktop) * EoGetH(ewin));
+     }
 
-   /* show the pager ewin */
    ShowEwin(ewin);
 
    if (Conf.pagers.snap)
@@ -680,6 +630,9 @@
 
    *num = 0;
    pl = (Pager **) ListItemType(&pnum, LIST_TYPE_PAGER);
+   if (!pl)
+      return NULL;
+
    for (i = 0; i < pnum; i++)
      {
        if (pl[i]->desktop == d)
@@ -689,14 +642,14 @@
             pp[(*num) - 1] = pl[i];
          }
      }
-   if (pl)
-      Efree(pl);
+
+   Efree(pl);
 
    return pp;
 }
 
 static void
-RedrawPagersForDesktop(int d, char newbg)
+RedrawPagersForDesktop(int d)
 {
    Pager             **pl;
    int                 i, num;
@@ -705,14 +658,17 @@
       return;
 
    pl = PagersForDesktop(d, &num);
+   if (!pl)
+      return;
+
    for (i = 0; i < num; i++)
-      PagerRedraw(pl[i], newbg);
-   if (pl)
-      Efree(pl);
+      PagerRedraw(pl[i]);
+
+   Efree(pl);
 }
 
 static void
-ForceUpdatePagersForDesktop(int d)
+UpdatePagersForDesktop(int d)
 {
    Pager             **pl;
    int                 i, num;
@@ -721,38 +677,57 @@
       return;
 
    pl = PagersForDesktop(d, &num);
+   if (!pl)
+      return;
+
    for (i = 0; i < num; i++)
-      PagerForceUpdate(pl[i]);
-   if (pl)
-      Efree(pl);
+      PagerUpdate(pl[i]);
+
+   Efree(pl);
+}
+
+static void
+PagerCheckUpdate(Pager * p)
+{
+   if (p->do_newbg)
+     {
+       PagerUpdateBg(p);
+       p->do_update = p->do_redraw = 1;
+     }
+
+   if (p->desktop == DesksGetCurrent() && Conf.pagers.snap)
+     {
+       if (p->do_redraw)
+          doPagerRedraw(p);
+       if (p->do_update)
+          doPagerUpdate(p);
+     }
+   else
+     {
+       if (p->do_redraw || p->do_update)
+          doPagerRedraw(p);
+     }
+
+   p->do_newbg = p->do_redraw = p->do_update = 0;
 }
 
 static void
 PagersCheckUpdate(void)
 {
-   Pager              *p, **pl;
+   Pager             **pl;
    int                 i, num;
 
-   if (!Conf.pagers.enable)
+   if (!pager_update_pending || !Conf.pagers.enable)
       return;
 
    pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
+   if (!pl)
+      return;
+
    for (i = 0; i < num; i++)
-     {
-       p = pl[i];
-       if (p->redraw)
-         {
-            doPagerRedraw(p, p->redraw - 1);
-            p->redraw = 0;
-         }
-       if (p->update)
-         {
-            doPagerForceUpdate(p);
-            p->update = 0;
-         }
-     }
-   if (pl)
-      Efree(pl);
+      PagerCheckUpdate(pl[i]);
+
+   Efree(pl);
 }
 
 static void
@@ -799,44 +774,26 @@
 }
 
 static void
-PagerReArea(Pager * p)
+PagersUpdateEwin(EWin * ewin, int gone)
 {
-   int                 w, h, ax, ay;
-   double              aspect;
-
-   GetAreaSize(&ax, &ay);
+   if (!Conf.pagers.enable)
+      return;
 
-   w = p->dw * ax;
-   h = p->dh * ay;
-   if (p->ewin)
+   if (gone)
      {
-
-       aspect = ((double)VRoot.w) / ((double)VRoot.h);
-       p->ewin->client.w_inc = ax * 4;
-       p->ewin->client.h_inc = ay * 8;
-       p->ewin->client.aspect_min = aspect * ((double)ax / (double)ay);
-       p->ewin->client.aspect_max = aspect * ((double)ax / (double)ay);
-       MoveResizeEwin(p->ewin, EoGetX(p->ewin), EoGetY(p->ewin), w, h);
+       RedrawPagersForDesktop(EoGetDesk(ewin));
+       return;
      }
-}
 
-static void
-PagerEwinOutsideAreaUpdate(EWin * ewin)
-{
-   if (!Conf.pagers.enable)
+   if (Mode.mode != MODE_NONE || !EoIsShown(ewin))
       return;
 
-#if 0
-   /* We could save a bit of time by checking if other areas are affected */
    if ((EoGetX(ewin) < 0) || (EoGetY(ewin) < 0)
        || ((EoGetX(ewin) + EoGetW(ewin)) > VRoot.w)
        || ((EoGetY(ewin) + EoGetH(ewin)) > VRoot.h))
-      RedrawPagersForDesktop(EoGetDesk(ewin), 3);
-#else
-   RedrawPagersForDesktop(EoGetDesk(ewin), 3);
-#endif
-
-   ForceUpdatePagersForDesktop(EoGetDesk(ewin));
+      RedrawPagersForDesktop(EoGetDesk(ewin));
+   else
+      UpdatePagersForDesktop(EoGetDesk(ewin));
 }
 
 static EWin        *
@@ -1443,9 +1400,32 @@
 }
 
 static void
-PagerSetHiQ(char onoff)
+PagersUpdateBackground(int desk)
 {
    Pager             **pl;
+   int                 i, num;
+
+   if (desk >= 0)
+      pl = PagersForDesktop(desk, &num);
+   else
+      pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
+   if (!pl)
+      return;
+
+   for (i = 0; i < num; i++)
+     {
+       PagerHiwinHide(pl[i]);
+       pl[i]->do_newbg = 1;
+     }
+
+   Efree(pl);
+
+   pager_update_pending = 1;
+}
+
+static void
+PagerSetHiQ(char onoff)
+{
    EWin               *const *lst;
    int                 i, num;
 
@@ -1458,15 +1438,7 @@
        lst[i]->mini_h = 0;
      }
 
-   pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
-   for (i = 0; i < num; i++)
-     {
-       PagerHiwinHide(pl[i]);
-       PagerRedraw(pl[i], 2);
-       PagerForceUpdate(pl[i]);
-     }
-   if (pl)
-      Efree(pl);
+   PagersUpdateBackground(-1);
 
    autosave();
 }
@@ -1488,22 +1460,24 @@
        lst[i]->mini_h = 0;
      }
 
-   pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
-   for (i = 0; i < num; i++)
+   PagersUpdateBackground(-1);
+
+   if (Conf.pagers.snap)
      {
-       PagerHiwinHide(pl[i]);
-       PagerRedraw(pl[i], 2);
-       PagerForceUpdate(pl[i]);
-       if (Conf.pagers.snap)
+       pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
+       if (!pl)
+          return;
+
+       for (i = 0; i < num; i++)
          {
             Esnprintf(s, sizeof(s), "__.%x", (unsigned)pl[i]->win);
             if (Conf.pagers.scanspeed > 0)
                DoIn(s, 1 / ((double)Conf.pagers.scanspeed),
                     PagerUpdateTimeout, 0, pl[i]);
          }
+
+       Efree(pl);
      }
-   if (pl)
-      Efree(pl);
 
    autosave();
 }
@@ -1788,16 +1762,7 @@
          }
 
        if (ewin)
-         {
-            RedrawPagersForDesktop(EoGetDesk(ewin), 3);
-            ForceUpdatePagersForDesktop(EoGetDesk(ewin));
-            if (prev_desk >= 0 && prev_desk != EoGetDesk(ewin))
-              {
-                 RedrawPagersForDesktop(prev_desk, 3);
-                 ForceUpdatePagersForDesktop(prev_desk);
-              }
-            PagerHiwinHide(p);
-         }
+          PagerHiwinHide(p);
 
        GrabPointerRelease();
      }
@@ -1938,9 +1903,9 @@
 }
 
 static void
-PagersReArea(void)
+PagersReconfigure(void)
 {
-   Pager             **pl = NULL;
+   Pager             **pl, *p;
    int                 i, num;
 
    if (!Conf.pagers.enable)
@@ -1951,7 +1916,11 @@
       return;
 
    for (i = 0; i < num; i++)
-      PagerReArea(pl[i]);
+     {
+       p = pl[i];
+       PagerReconfigure(p);
+       ResizeEwin(p->ewin, p->ewin->client.w, p->ewin->client.h);
+     }
    Efree(pl);
 }
 
@@ -2262,10 +2231,6 @@
 static void
 PagersSighan(int sig, void *prm)
 {
-   static int          pdesk = -1;     /* Last desk */
-   int                 desk;
-   EWin               *ewin;
-
    switch (sig)
      {
      case ESIGNAL_INIT:
@@ -2287,12 +2252,11 @@
        break;
 
      case ESIGNAL_AREA_CONFIGURED:
-       PagersReArea();
+       PagersReconfigure();
        break;
      case ESIGNAL_AREA_SWITCH_DONE:
+       RedrawPagersForDesktop((int)prm);
        UpdatePagerSel();
-       RedrawPagersForDesktop(DesksGetCurrent(), 3);
-       ForceUpdatePagersForDesktop(DesksGetCurrent());
        break;
      case ESIGNAL_DESK_ADDED:
        NewPagerForDesktop((int)(prm));
@@ -2301,52 +2265,23 @@
        PagersDisableForDesktop((int)(prm));
        break;
      case ESIGNAL_DESK_SWITCH_DONE:
-#if 0
-       /* Raise */
-       RedrawPagersForDesktop(desk, 3);
-       ForceUpdatePagersForDesktop(desk);
-       UpdatePagerSel();
-       /* Lower */
-       RedrawPagersForDesktop(desks.order[0], 3);
-       ForceUpdatePagersForDesktop(desks.order[0]);
        UpdatePagerSel();
-#endif
-       /* DeskGoto */
-       desk = DesksGetCurrent();
-       if (pdesk >= 0)
-          RedrawPagersForDesktop(pdesk, 0);
-       RedrawPagersForDesktop(desk, 3);
-       ForceUpdatePagersForDesktop(desk);
-       UpdatePagerSel();
-       pdesk = desk;
        break;
      case ESIGNAL_BACKGROUND_CHANGE:
-       desk = (int)prm;
-       if (desk == DesksGetCurrent())
-         {
-            RedrawPagersForDesktop(desk, 2);
-            ForceUpdatePagersForDesktop(desk);
-         }
-       else
-          RedrawPagersForDesktop(desk, 1);
+       PagersUpdateBackground((int)prm);
        break;
      case ESIGNAL_DESK_CHANGE:
-       ForceUpdatePagersForDesktop((int)prm);
+       RedrawPagersForDesktop((int)prm);
+       UpdatePagerSel();
        break;
      case ESIGNAL_DESK_RESIZE:
-       PagersReArea();
+       PagersReconfigure();
        break;
      case ESIGNAL_EWIN_UNMAP:
-       ewin = prm;
-       PagerEwinOutsideAreaUpdate(ewin);
+       PagersUpdateEwin(prm, 1);
        break;
      case ESIGNAL_EWIN_CHANGE:
-       if (Mode.mode != MODE_NONE)
-          break;
-       ewin = prm;
-       if (!EoIsShown(ewin))
-          break;
-       PagerEwinOutsideAreaUpdate(ewin);
+       PagersUpdateEwin(prm, 0);
        break;
      }
 }




-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to