Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h buttons.c desktops.c lists.c pager.c settings.c 


Log Message:
Create/destroy desktops as needed.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.341
retrieving revision 1.342
diff -u -3 -r1.341 -r1.342
--- E.h 8 Jan 2005 08:31:55 -0000       1.341
+++ E.h 9 Jan 2005 10:06:05 -0000       1.342
@@ -1354,7 +1354,7 @@
 void                ButtonSetSwallowed(Button * b);
 const char         *ButtonGetName(const Button * b);
 int                 ButtonGetRefcount(const Button * b);
-int                 ButtonGetDesktop(const Button * b);
+int                 ButtonGetDesk(const Button * b);
 void                ButtonGetGeometry(const Button * b, int *x, int *y,
                                      unsigned int *w, unsigned int *h);
 int                 ButtonGetInfo(const Button * b, RectBox * r, int desk);
@@ -1441,12 +1441,9 @@
 Window              DeskGetCurrentRoot(void);
 void                DeskSetCurrentArea(int ax, int ay);
 int                 DesksGetNumber(void);
-int                 DesksGetTotal(void);
 int                 DesksGetCurrent(void);
 void                DesksSetCurrent(int desk);
 
-void                InitDesktopControls(void);
-void                ShowDesktopControls(void);
 void                SlideWindowTo(Window win, int fx, int fy, int tx, int ty,
                                  int speed);
 void                RefreshDesktop(int num);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/buttons.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- buttons.c   8 Jan 2005 08:46:39 -0000       1.41
+++ buttons.c   9 Jan 2005 10:06:06 -0000       1.42
@@ -176,6 +176,7 @@
      }
 
    while (RemoveItemByPtr(b, LIST_TYPE_BUTTON));
+
    EobjListStackDel(&b->o);
 
    if (b->name)
@@ -307,6 +308,9 @@
 
    EDBUG(3, "ButtonMoveToDesktop");
 
+   if (desk < 0 || desk >= DesksGetNumber())
+      EDBUG_RETURN_;
+
    if (EoIsSticky(b) && EoGetLayer(b) == 1)
       desk = 0;
    pdesk = EoGetDesk(b);
@@ -471,7 +475,7 @@
 }
 
 int
-ButtonGetDesktop(const Button * b)
+ButtonGetDesk(const Button * b)
 {
    return EoGetDesk(b);
 }
@@ -617,7 +621,7 @@
      {
        d = DesktopAt(Mode.x, Mode.y);
        ButtonMoveToDesktop(b, d);
-       d = ButtonGetDesktop(b);
+       d = EoGetDesk(b);
        ButtonMoveRelative(b, -DeskGetX(d), -DeskGetY(d));
      }
    else
@@ -1006,7 +1010,6 @@
             break;
          case BUTTON_DESK:
             desk = atoi(s2);
-            desk = ((unsigned int)desk) % DesksGetTotal();
             if (pbt)
                ButtonMoveToDesktop(pbt, desk);
             break;
@@ -1234,6 +1237,7 @@
      {
        Button            **lst, *b;
 
+       IpcPrintf("Win       d  s  l     x     y     w     h name\n");
        lst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
        for (i = 0; i < num; i++)
          {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -3 -r1.109 -r1.110
--- desktops.c  8 Jan 2005 08:31:55 -0000       1.109
+++ desktops.c  9 Jan 2005 10:06:07 -0000       1.110
@@ -32,6 +32,7 @@
 typedef struct
 {
    EObj                o;
+   int                 num;
    char                viewable;
    Background         *bg;
    Button             *tag;
@@ -45,7 +46,7 @@
 typedef struct _desktops
 {
    int                 current;
-   Desk                desk[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
+   Desk               *desk[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
    int                 order[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
 }
 Desktops;
@@ -55,7 +56,403 @@
 /* The desktops */
 static Desktops     desks;
 
-#define _DeskGet(d) (&desks.desk[d])
+#define _DeskGet(d) (desks.desk[d])
+
+static void
+DeskControlsCreate(Desk * d)
+{
+   char                s[512];
+   ActionClass        *ac, *ac2, *ac3;
+   ImageClass         *ic, *ic2, *ic3, *ic4;
+   Button             *b;
+   Action             *a;
+   int                 x[3], y[3], w[3], h[3], m, n, o;
+   const char         *t;
+
+   Esnprintf(s, sizeof(s), "DRAGBAR_DESKTOP_%i", d->num);
+
+   ac = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
+   if (!ac)
+     {
+       ac = ActionclassCreate(s, 0);
+       a = ActionCreate(EVENT_MOUSE_DOWN, 0, 0, 0, 1, 0, NULL, NULL);
+       ActionclassAddAction(ac, a);
+
+       Esnprintf(s, sizeof(s), "desk drag %i", d->num);
+       ActionAddTo(a, s);
+
+       a = ActionCreate(EVENT_MOUSE_DOWN, 0, 0, 0, 3, 0, NULL, NULL);
+       ActionclassAddAction(ac, a);
+       ActionAddTo(a, "menus show deskmenu");
+
+       a = ActionCreate(EVENT_MOUSE_DOWN, 0, 0, 0, 2, 0, NULL, NULL);
+       ActionclassAddAction(ac, a);
+       ActionAddTo(a, "menus show taskmenu");
+
+       if (d->num > 0)
+         {
+            t = _("Hold down the mouse button and drag\n"
+                  "the mouse to be able to drag the desktop\n"
+                  "back and forth.\n"
+                  "Click right mouse button for a list of all\n"
+                  "Desktops and their applications.\n"
+                  "Click middle mouse button for a list of all\n"
+                  "applications currently running.\n");
+            ActionclassSetTooltipString(ac, t);
+         }
+       else
+         {
+            t = _("This is the Root desktop.\n"
+                  "You cannot drag the root desktop around.\n"
+                  "Click right mouse button for a list of all\n"
+                  "Desktops and their applications.\n"
+                  "Click middle mouse button for a list of all\n"
+                  "applications currently running.\n");
+            ActionclassSetTooltipString(ac, t);
+         }
+     }
+
+   Esnprintf(s, sizeof(s), "RAISEBUTTON_DESKTOP_%i", d->num);
+   ac2 = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
+   if (!ac2)
+     {
+       ac2 = ActionclassCreate(s, 0);
+       a = ActionCreate(EVENT_MOUSE_UP, 1, 0, 1, 0, 0, NULL, NULL);
+       ActionclassAddAction(ac2, a);
+
+       Esnprintf(s, sizeof(s), "desk raise %i", d->num);
+       ActionAddTo(a, s);
+       t = _("Click here to raise this desktop\nto the top.\n");
+       ActionclassSetTooltipString(ac, t);
+     }
+
+   Esnprintf(s, sizeof(s), "LOWERBUTTON_DESKTOP_%i", d->num);
+   ac3 = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
+   if (!ac3)
+     {
+       ac3 = ActionclassCreate(s, 0);
+       a = ActionCreate(EVENT_MOUSE_UP, 1, 0, 1, 0, 0, NULL, NULL);
+       ActionclassAddAction(ac3, a);
+
+       Esnprintf(s, sizeof(s), "desk lower %i", d->num);
+       ActionAddTo(a, s);
+       t = _("Click here to lower this desktop\nto the bottom.\n");
+       ActionclassSetTooltipString(ac, t);
+     }
+
+   if (Conf.desks.dragdir < 2)
+     {
+       ic = ImageclassFind("DESKTOP_DRAGBUTTON_VERT", 0);
+       ic2 = ImageclassFind("DESKTOP_RAISEBUTTON_VERT", 0);
+       ic3 = ImageclassFind("DESKTOP_LOWERBUTTON_VERT", 0);
+       ic4 = ImageclassFind("DESKTOP_DESKRAY_VERT", 0);
+     }
+   else
+     {
+       ic = ImageclassFind("DESKTOP_DRAGBUTTON_HORIZ", 0);
+       ic2 = ImageclassFind("DESKTOP_RAISEBUTTON_HORIZ", 0);
+       ic3 = ImageclassFind("DESKTOP_LOWERBUTTON_HORIZ", 0);
+       ic4 = ImageclassFind("DESKTOP_DESKRAY_HORIZ", 0);
+     }
+
+   switch (Conf.desks.dragbar_ordering)
+     {
+     case 0:
+       m = 0;
+       n = 1;
+       o = 2;
+       break;
+     case 1:
+       m = 0;
+       n = 2;
+       o = 1;
+       break;
+     case 2:
+       m = 2;
+       n = 0;
+       o = 1;
+       break;
+     case 3:
+       m = 1;
+       n = 0;
+       o = 2;
+       break;
+     case 4:
+       m = 1;
+       n = 2;
+       o = 0;
+       break;
+     case 5:
+       m = 2;
+       n = 1;
+       o = 0;
+       break;
+     default:
+       m = 0;
+       n = 1;
+       o = 2;
+       break;
+     }
+
+   switch (Conf.desks.dragdir)
+     {
+     case 0:
+       w[0] = w[1] = w[2] = h[0] = h[1] = Conf.desks.dragbar_width;
+       if (Conf.desks.dragbar_length == 0)
+          h[2] = VRoot.h - (Conf.desks.dragbar_width * 2);
+       else
+          h[2] = Conf.desks.dragbar_length;
+       x[0] = x[1] = x[2] = 0;
+       y[m] = 0;
+       y[n] = y[m] + h[m];
+       y[o] = y[n] + h[n];
+       break;
+     case 1:
+       w[0] = w[1] = w[2] = h[0] = h[1] = Conf.desks.dragbar_width;
+       if (Conf.desks.dragbar_length == 0)
+          h[2] = VRoot.h - (Conf.desks.dragbar_width * 2);
+       else
+          h[2] = Conf.desks.dragbar_length;
+       x[0] = x[1] = x[2] = VRoot.w - Conf.desks.dragbar_width;
+       y[m] = 0;
+       y[n] = y[m] + h[m];
+       y[o] = y[n] + h[n];
+       break;
+     case 2:
+       h[0] = h[1] = h[2] = w[0] = w[1] = Conf.desks.dragbar_width;
+       if (Conf.desks.dragbar_length == 0)
+          w[2] = VRoot.w - (Conf.desks.dragbar_width * 2);
+       else
+          w[2] = Conf.desks.dragbar_length;
+       y[0] = y[1] = y[2] = 0;
+       x[m] = 0;
+       x[n] = x[m] + w[m];
+       x[o] = x[n] + w[n];
+       break;
+     case 3:
+       h[0] = h[1] = h[2] = w[0] = w[1] = Conf.desks.dragbar_width;
+       if (Conf.desks.dragbar_length == 0)
+          w[2] = VRoot.w - (Conf.desks.dragbar_width * 2);
+       else
+          w[2] = Conf.desks.dragbar_length;
+       y[0] = y[1] = y[2] = VRoot.h - Conf.desks.dragbar_width;
+       x[m] = 0;
+       x[n] = x[m] + w[m];
+       x[o] = x[n] + w[n];
+       break;
+     default:
+       break;
+     }
+
+   b = NULL;
+
+   if (Conf.desks.dragbar_width > 0)
+     {
+       b = ButtonCreate("_DESKTOP_DRAG_CONTROL", 1, ic2, ac2, NULL, NULL,
+                        -1, FLAG_FIXED, 1, 99999, 1, 99999, 0, 0, x[0], 0,
+                        y[0], 0, 0, w[0], 0, h[0], 0, d->num, 0);
+       b = ButtonCreate("_DESKTOP_DRAG_CONTROL", 1, ic3, ac3, NULL, NULL,
+                        -1, FLAG_FIXED, 1, 99999, 1, 99999, 0, 0, x[1], 0,
+                        y[1], 0, 0, w[1], 0, h[1], 0, d->num, 0);
+       b = ButtonCreate("_DESKTOP_DRAG_CONTROL", 1, ic, ac, NULL, NULL,
+                        -1, FLAG_FIXED, 1, 99999, 1, 99999, 0, 0, x[2], 0,
+                        y[2], 0, 0, w[2], 0, h[2], 0, d->num, 0);
+     }
+
+#if 0                          /* What is this anyway? */
+   if (d->num > 0)
+     {
+       if (Conf.desks.dragdir == 0)
+         {
+            b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
+                             NULL, NULL, 1, FLAG_FIXED_VERT, 1, 99999, 1,
+                             99999, 0, 0, EoGetX(d), 0, EoGetY(d),
+                             0, 0, 0, 0, 0, 1, 0, 1);
+         }
+       else if (Conf.desks.dragdir == 1)
+         {
+            b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
+                             NULL, NULL, 1, FLAG_FIXED_VERT, 1, 99999, 1,
+                             99999, 0, 0,
+                             EoGetX(d) + VRoot.w -
+                             Conf.desks.dragbar_width, 0, EoGetY(d),
+                             0, 0, 0, 0, 0, 1, 0, 1);
+         }
+       else if (Conf.desks.dragdir == 2)
+         {
+            b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
+                             NULL, NULL, 1, FLAG_FIXED_HORIZ, 1, 99999, 1,
+                             99999, 0, 0, EoGetX(d), 0, EoGetY(d),
+                             0, 0, 0, 0, 0, 1, 0, 1);
+         }
+       else
+         {
+            b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
+                             NULL, NULL, 1, FLAG_FIXED_HORIZ, 1, 99999, 1,
+                             99999, 0, 0, EoGetX(d), 0,
+                             EoGetY(d) + VRoot.h - Conf.desks.dragbar_width,
+                             0, 0, 0, 0, 0, 1, 0, 1);
+         }
+     }
+#endif
+
+   d->tag = b;
+}
+
+static void
+DeskControlsDestroy(Desk * d)
+{
+   Button            **blst;
+   int                 num, i;
+
+   blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1);
+   if (blst)
+     {
+       for (i = 0; i < num; i++)
+          if (ButtonGetDesk(blst[i]) == d->num)
+             ButtonDestroy(blst[i]);
+       Efree(blst);
+     }
+}
+
+static void
+DeskControlsShow(Desk * d)
+{
+   Button            **blst;
+   int                 num, i;
+
+   blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1);
+   if (blst)
+     {
+       for (i = 0; i < num; i++)
+          if (ButtonGetDesk(blst[i]) == d->num)
+             ButtonShow(blst[i]);
+       Efree(blst);
+     }
+}
+
+static void
+DeskEventsConfigure(Desk * d, int mode)
+{
+   long                event_mask;
+   XWindowAttributes   xwa;
+
+   if (mode)
+     {
+       event_mask = d->event_mask;
+     }
+   else
+     {
+       XGetWindowAttributes(disp, EoGetWin(d), &xwa);
+       d->event_mask = xwa.your_event_mask | EDESK_EVENT_MASK;
+       event_mask =
+          PropertyChangeMask | SubstructureRedirectMask |
+          ButtonPressMask | ButtonReleaseMask;
+#if USE_COMPOSITE
+       /* Handle ConfigureNotify's while sliding */
+       event_mask |= SubstructureNotifyMask;
+#endif
+     }
+   XSelectInput(disp, EoGetWin(d), event_mask);
+}
+
+static Desk        *
+DeskCreate(int desk, int add_controls)
+{
+   Desk               *d;
+   Window              win;
+
+   if (desk < 0 || desk >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
+      return NULL;
+
+   d = Ecalloc(1, sizeof(Desk));
+
+   desks.desk[desk] = d;
+   d->num = desk;
+   desks.order[desk] = desk;
+
+   if (desk == 0)
+      win = VRoot.win;
+   else
+      win = ECreateWindow(VRoot.win, -VRoot.w, -VRoot.h, VRoot.w, VRoot.h, 0);
+
+   EobjInit(&d->o, EOBJ_TYPE_DESK, 0, 0, VRoot.w, VRoot.h);
+   EoSetWin(d, win);
+   EoSetLayer(d, 0);
+   EoDisableShadows(d);
+   if (desk > 0)
+     {
+       EoSetFloating(d, 1);
+       EobjListStackAdd(&d->o, 0);
+     }
+   EventCallbackRegister(win, 0, DesktopHandleEvents, d);
+
+   if (add_controls)
+     {
+       DeskControlsCreate(d);
+       DeskControlsShow(d);
+     }
+
+   DeskEventsConfigure(d, 1);
+
+   {
+      Background        **lst;
+      int                 num;
+      unsigned int        rnd;
+
+      lst = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND);
+      if (lst)
+       {
+          rnd = rand();
+          rnd %= num;
+          DesktopSetBg(desk, lst[rnd], 0);
+          Efree(lst);
+       }
+   }
+
+   return d;
+}
+
+static void
+DeskDestroy(int desk)
+{
+   Desk               *d;
+   Button            **blst;
+   int                 num, i;
+
+   d = _DeskGet(desk);
+
+   EventCallbackUnregister(EoGetWin(d), 0, DesktopHandleEvents, d);
+
+   blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1);
+   for (i = 0; i < num; i++)
+     {
+       if (ButtonGetDesk(blst[i]) == desk)
+          ButtonDestroy(blst[i]);
+     }
+   if (blst)
+      Efree(blst);
+
+   blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 2);
+   for (i = 0; i < num; i++)
+     {
+       if (ButtonGetDesk(blst[i]) == desk)
+          ButtonDestroy(blst[i]);
+     }
+   if (blst)
+      Efree(blst);
+
+   if (d->bg)
+      BackgroundDecRefcount(d->bg);
+
+   if (desk > 0)
+      EobjListStackDel(&d->o);
+
+   EDestroyWindow(disp, EoGetWin(d));
+
+   Efree(d);
+   desks.desk[desk] = NULL;
+}
 
 Window
 DeskGetWin(int desk)
@@ -78,33 +475,36 @@
 Background         *
 DeskGetBackground(int desk)
 {
-   return desks.desk[desk].bg;
+   if (desk < 0 || desk >= Conf.desks.num)
+      return NULL;
+
+   return _DeskGet(desk)->bg;
 }
 
 void
 DeskGetArea(int desk, int *ax, int *ay)
 {
-   *ax = desks.desk[desk].current_area_x;
-   *ay = desks.desk[desk].current_area_y;
+   *ax = _DeskGet(desk)->current_area_x;
+   *ay = _DeskGet(desk)->current_area_y;
 }
 
 void
 DeskSetArea(int desk, int ax, int ay)
 {
-   desks.desk[desk].current_area_x = ax;
-   desks.desk[desk].current_area_y = ay;
+   _DeskGet(desk)->current_area_x = ax;
+   _DeskGet(desk)->current_area_y = ay;
 }
 
 int
 DeskIsViewable(int desk)
 {
-   return desks.desk[desk].viewable;
+   return _DeskGet(desk)->viewable;
 }
 
 void
 DeskSetViewable(int desk, int on)
 {
-   desks.desk[desk].viewable = on;
+   _DeskGet(desk)->viewable = on;
 }
 
 Window
@@ -132,12 +532,6 @@
 }
 
 int
-DesksGetTotal(void)
-{
-   return ENLIGHTENMENT_CONF_NUM_DESKTOPS;
-}
-
-int
 DesksGetCurrent(void)
 {
    return desks.current;
@@ -150,42 +544,21 @@
 }
 
 static void
-DesktopInit(unsigned int desk)
+DesktopsInit(void)
 {
-   Desk               *d;
-   Window              win;
-
-   if (desk >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
-      return;
-
-   d = &desks.desk[desk];
-   memset(d, 0, sizeof(Desk));
-   desks.order[desk] = desk;
-
-   if (desk == 0)
-      win = VRoot.win;
-   else
-      win = ECreateWindow(VRoot.win, -VRoot.w, -VRoot.h, VRoot.w, VRoot.h, 0);
+   int                 i;
 
-   EobjInit(&d->o, EOBJ_TYPE_DESK, 0, 0, VRoot.w, VRoot.h);
-   EoSetWin(d, win);
-   EoSetLayer(d, 0);
-   EoDisableShadows(d);
-   if (desk > 0)
-     {
-       EoSetFloating(d, 1);
-       EobjListStackAdd(&d->o, 0);
-     }
-   EventCallbackRegister(win, 0, DesktopHandleEvents, d);
+   for (i = 0; i < Conf.desks.num; i++)
+      DeskCreate(i, 0);
 }
 
-static void
-DesktopsInit(void)
+void
+DesktopsEventsConfigure(int mode)
 {
    int                 i;
 
-   for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
-      DesktopInit(i);
+   for (i = 0; i < Conf.desks.num; i++)
+      DeskEventsConfigure(_DeskGet(i), mode);
 }
 
 static void
@@ -194,32 +567,39 @@
    int                 pnum, i, num;
    EWin               *const *lst;
 
+   if (quantity >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
+      quantity = ENLIGHTENMENT_CONF_NUM_DESKTOPS;
+
+   if (quantity <= 0 || quantity == Conf.desks.num)
+      return;
+
    pnum = Conf.desks.num;
-   for (i = quantity; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+   for (i = quantity; i < Conf.desks.num; i++)
       LowerDesktop(i);
    Conf.desks.num = quantity;
 
-   if (Conf.desks.num <= 0)
-      Conf.desks.num = 1;
-   else if (Conf.desks.num > ENLIGHTENMENT_CONF_NUM_DESKTOPS)
-      Conf.desks.num = ENLIGHTENMENT_CONF_NUM_DESKTOPS;
-
-   lst = EwinListGetAll(&num);
-   for (i = 0; i < num; i++)
-     {
-       if (EoGetDesk(lst[i]) >= Conf.desks.num)
-          MoveEwinToDesktop(lst[i], Conf.desks.num - 1);
-     }
-
    if (Conf.desks.num > pnum)
      {
        for (i = pnum; i < Conf.desks.num; i++)
-          ModulesSignal(ESIGNAL_DESK_ADDED, (void *)i);
+         {
+            DeskCreate(i, 1);
+            ModulesSignal(ESIGNAL_DESK_ADDED, (void *)i);
+         }
      }
    else if (Conf.desks.num < pnum)
      {
+       lst = EwinListGetAll(&num);
+       for (i = 0; i < num; i++)
+         {
+            if (EoGetDesk(lst[i]) >= Conf.desks.num)
+               MoveEwinToDesktop(lst[i], Conf.desks.num - 1);
+         }
+
        for (i = Conf.desks.num; i < pnum; i++)
-          ModulesSignal(ESIGNAL_DESK_REMOVED, (void *)i);
+         {
+            DeskDestroy(i);
+            ModulesSignal(ESIGNAL_DESK_REMOVED, (void *)i);
+         }
      }
    if (DesksGetCurrent() >= Conf.desks.num)
       GotoDesktop(Conf.desks.num - 1);
@@ -227,20 +607,50 @@
    HintsSetDesktopConfig();
 }
 
-void
-ShowDesktopControls(void)
+static void
+DesksControlsCreate(void)
 {
-   Button            **blst;
-   int                 num, i;
+   int                 i;
 
-   blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 1);
-   if (blst)
-     {
-       for (i = 0; i < num; i++)
-          ButtonShow(blst[i]);
-       Efree(blst);
-       StackDesktops();
-     }
+   for (i = 0; i < Conf.desks.num; i++)
+      DeskControlsCreate(_DeskGet(i));
+}
+
+static void
+DesksControlsDestroy(void)
+{
+   int                 i;
+
+   for (i = 0; i < Conf.desks.num; i++)
+      DeskControlsDestroy(_DeskGet(i));
+#if 0
+   while ((b = RemoveItem("_DESKTOP_DRAG_CONTROL", 0,
+                         LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
+      ButtonDestroy(b);
+   while ((b = RemoveItem("_DESKTOP_DESKRAY_DRAG_CONTROL", 0,
+                         LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
+      ButtonDestroy(b);
+#endif
+}
+
+static void
+DesksControlsShow(void)
+{
+   int                 i;
+
+   for (i = 0; i < Conf.desks.num; i++)
+      DeskControlsShow(_DeskGet(i));
+}
+
+static void
+DesksControlsRefresh(void)
+{
+   DesksControlsDestroy();
+   DesksControlsCreate();
+   DesksControlsShow();
+
+   /* Restack buttons - Hmmm. */
+   StackDesktops();
 }
 
 #if 0                          /* Unused */
@@ -300,11 +710,11 @@
 {
    int                 i, j;
 
-   EobjListStackRaise(&desks.desk[num].o);
+   EobjListStackRaise(&desks.desk[num]->o);
 
    j = -1;
    i = 0;
-   while ((j < 0) && (i < ENLIGHTENMENT_CONF_NUM_DESKTOPS))
+   while (j < 0 && i < Conf.desks.num)
      {
        if (desks.order[i] == num)
           j = i;
@@ -325,11 +735,11 @@
 {
    int                 i, j;
 
-   EobjListStackLower(&desks.desk[num].o);
+   EobjListStackLower(&desks.desk[num]->o);
 
    j = -1;
    i = 0;
-   while ((j < 0) && (i < ENLIGHTENMENT_CONF_NUM_DESKTOPS))
+   while (j < 0 && i < Conf.desks.num)
      {
        if (desks.order[i] == num)
           j = i;
@@ -337,11 +747,11 @@
      }
    if (j < 0)
       return;
-   if (j < ENLIGHTENMENT_CONF_NUM_DESKTOPS - 1)
+   if (j < Conf.desks.num - 1)
      {
-       for (i = j; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS - 1; i++)
+       for (i = j; i < Conf.desks.num - 1; i++)
           desks.order[i] = desks.order[i + 1];
-       desks.order[ENLIGHTENMENT_CONF_NUM_DESKTOPS - 1] = num;
+       desks.order[Conf.desks.num - 1] = num;
      }
 }
 
@@ -373,8 +783,10 @@
    Desk               *d;
    Background         *bg;
 
-   desk = desk % ENLIGHTENMENT_CONF_NUM_DESKTOPS;
-   if (!desks.desk[desk].viewable)
+   if (desk < 0 || desk >= Conf.desks.num)
+      return;
+
+   if (!_DeskGet(desk)->viewable)
       return;
 
    if (EventDebug(EDBUG_TYPE_DESKS))
@@ -394,280 +806,44 @@
 void
 DesktopsRefresh(void)
 {
-   int                 i;
-
-   for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
-     {
-       if (desks.desk[i].bg)
-          DesktopSetBg(i, desks.desk[i].bg, 1);
-     }
-}
-
-void
-InitDesktopControls(void)
-{
    Desk               *d;
    int                 i;
-   ActionClass        *ac, *ac2, *ac3;
-   ImageClass         *ic, *ic2, *ic3, *ic4;
-   Button             *b;
-   Action             *a;
-   int                 x[3], y[3], w[3], h[3], m, n, o;
-   char                s[512];
-   const char         *t;
 
-   for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+   for (i = 0; i < Conf.desks.num; i++)
      {
        d = _DeskGet(i);
-
-       Esnprintf(s, sizeof(s), "DRAGBAR_DESKTOP_%i", i);
-
-       ac = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
-       if (!ac)
-         {
-            ac = ActionclassCreate(s, 0);
-            a = ActionCreate(EVENT_MOUSE_DOWN, 0, 0, 0, 1, 0, NULL, NULL);
-            ActionclassAddAction(ac, a);
-
-            Esnprintf(s, sizeof(s), "desk drag %i", i);
-            ActionAddTo(a, s);
-
-            a = ActionCreate(EVENT_MOUSE_DOWN, 0, 0, 0, 3, 0, NULL, NULL);
-            ActionclassAddAction(ac, a);
-            ActionAddTo(a, "menus show deskmenu");
-
-            a = ActionCreate(EVENT_MOUSE_DOWN, 0, 0, 0, 2, 0, NULL, NULL);
-            ActionclassAddAction(ac, a);
-            ActionAddTo(a, "menus show taskmenu");
-
-            if (i > 0)
-              {
-                 t = _("Hold down the mouse button and drag\n"
-                       "the mouse to be able to drag the desktop\n"
-                       "back and forth.\n"
-                       "Click right mouse button for a list of all\n"
-                       "Desktops and their applications.\n"
-                       "Click middle mouse button for a list of all\n"
-                       "applications currently running.\n");
-                 ActionclassSetTooltipString(ac, t);
-              }
-            else
-              {
-                 t = _("This is the Root desktop.\n"
-                       "You cannot drag the root desktop around.\n"
-                       "Click right mouse button for a list of all\n"
-                       "Desktops and their applications.\n"
-                       "Click middle mouse button for a list of all\n"
-                       "applications currently running.\n");
-                 ActionclassSetTooltipString(ac, t);
-              }
-         }
-       Esnprintf(s, sizeof(s), "RAISEBUTTON_DESKTOP_%i", i);
-       ac2 = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
-       if (!ac2)
-         {
-            ac2 = ActionclassCreate(s, 0);
-            a = ActionCreate(EVENT_MOUSE_UP, 1, 0, 1, 0, 0, NULL, NULL);
-            ActionclassAddAction(ac2, a);
-
-            Esnprintf(s, sizeof(s), "desk raise %i", i);
-            ActionAddTo(a, s);
-            t = _("Click here to raise this desktop\nto the top.\n");
-            ActionclassSetTooltipString(ac, t);
-         }
-       Esnprintf(s, sizeof(s), "LOWERBUTTON_DESKTOP_%i", i);
-       ac3 = FindItem(s, 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
-       if (!ac3)
-         {
-            ac3 = ActionclassCreate(s, 0);
-            a = ActionCreate(EVENT_MOUSE_UP, 1, 0, 1, 0, 0, NULL, NULL);
-            ActionclassAddAction(ac3, a);
-
-            Esnprintf(s, sizeof(s), "desk lower %i", i);
-            ActionAddTo(a, s);
-            t = _("Click here to lower this desktop\nto the bottom.\n");
-            ActionclassSetTooltipString(ac, t);
-         }
-       b = NULL;
-
-       if (Conf.desks.dragdir < 2)
-         {
-            ic = ImageclassFind("DESKTOP_DRAGBUTTON_VERT", 0);
-            ic2 = ImageclassFind("DESKTOP_RAISEBUTTON_VERT", 0);
-            ic3 = ImageclassFind("DESKTOP_LOWERBUTTON_VERT", 0);
-            ic4 = ImageclassFind("DESKTOP_DESKRAY_VERT", 0);
-         }
-       else
-         {
-            ic = ImageclassFind("DESKTOP_DRAGBUTTON_HORIZ", 0);
-            ic2 = ImageclassFind("DESKTOP_RAISEBUTTON_HORIZ", 0);
-            ic3 = ImageclassFind("DESKTOP_LOWERBUTTON_HORIZ", 0);
-            ic4 = ImageclassFind("DESKTOP_DESKRAY_HORIZ", 0);
-         }
-
-       switch (Conf.desks.dragbar_ordering)
-         {
-         case 0:
-            m = 0;
-            n = 1;
-            o = 2;
-            break;
-         case 1:
-            m = 0;
-            n = 2;
-            o = 1;
-            break;
-         case 2:
-            m = 2;
-            n = 0;
-            o = 1;
-            break;
-         case 3:
-            m = 1;
-            n = 0;
-            o = 2;
-            break;
-         case 4:
-            m = 1;
-            n = 2;
-            o = 0;
-            break;
-         case 5:
-            m = 2;
-            n = 1;
-            o = 0;
-            break;
-         default:
-            m = 0;
-            n = 1;
-            o = 2;
-            break;
-         }
-
-       switch (Conf.desks.dragdir)
-         {
-         case 0:
-            w[0] = w[1] = w[2] = h[0] = h[1] = Conf.desks.dragbar_width;
-            if (Conf.desks.dragbar_length == 0)
-               h[2] = VRoot.h - (Conf.desks.dragbar_width * 2);
-            else
-               h[2] = Conf.desks.dragbar_length;
-            x[0] = x[1] = x[2] = 0;
-            y[m] = 0;
-            y[n] = y[m] + h[m];
-            y[o] = y[n] + h[n];
-            break;
-         case 1:
-            w[0] = w[1] = w[2] = h[0] = h[1] = Conf.desks.dragbar_width;
-            if (Conf.desks.dragbar_length == 0)
-               h[2] = VRoot.h - (Conf.desks.dragbar_width * 2);
-            else
-               h[2] = Conf.desks.dragbar_length;
-            x[0] = x[1] = x[2] = VRoot.w - Conf.desks.dragbar_width;
-            y[m] = 0;
-            y[n] = y[m] + h[m];
-            y[o] = y[n] + h[n];
-            break;
-         case 2:
-            h[0] = h[1] = h[2] = w[0] = w[1] = Conf.desks.dragbar_width;
-            if (Conf.desks.dragbar_length == 0)
-               w[2] = VRoot.w - (Conf.desks.dragbar_width * 2);
-            else
-               w[2] = Conf.desks.dragbar_length;
-            y[0] = y[1] = y[2] = 0;
-            x[m] = 0;
-            x[n] = x[m] + w[m];
-            x[o] = x[n] + w[n];
-            break;
-         case 3:
-            h[0] = h[1] = h[2] = w[0] = w[1] = Conf.desks.dragbar_width;
-            if (Conf.desks.dragbar_length == 0)
-               w[2] = VRoot.w - (Conf.desks.dragbar_width * 2);
-            else
-               w[2] = Conf.desks.dragbar_length;
-            y[0] = y[1] = y[2] = VRoot.h - Conf.desks.dragbar_width;
-            x[m] = 0;
-            x[n] = x[m] + w[m];
-            x[o] = x[n] + w[n];
-            break;
-         default:
-            break;
-         }
-
-       if (Conf.desks.dragbar_width > 0)
-         {
-            b = ButtonCreate("_DESKTOP_DRAG_CONTROL", 1, ic2, ac2, NULL, NULL,
-                             -1, FLAG_FIXED, 1, 99999, 1, 99999, 0, 0, x[0], 0,
-                             y[0], 0, 0, w[0], 0, h[0], 0, i, 0);
-            b = ButtonCreate("_DESKTOP_DRAG_CONTROL", 1, ic3, ac3, NULL, NULL,
-                             -1, FLAG_FIXED, 1, 99999, 1, 99999, 0, 0, x[1], 0,
-                             y[1], 0, 0, w[1], 0, h[1], 0, i, 0);
-            b = ButtonCreate("_DESKTOP_DRAG_CONTROL", 1, ic, ac, NULL, NULL,
-                             -1, FLAG_FIXED, 1, 99999, 1, 99999, 0, 0, x[2], 0,
-                             y[2], 0, 0, w[2], 0, h[2], 0, i, 0);
-         }
-       if (i > 0)
-         {
-            if (Conf.desks.dragdir == 0)
-              {
-                 b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
-                                  NULL, NULL, 1, FLAG_FIXED_VERT, 1, 99999, 1,
-                                  99999, 0, 0, EoGetX(d), 0,
-                                  EoGetY(d), 0, 0, 0, 0, 0, 1, 0, 1);
-              }
-            else if (Conf.desks.dragdir == 1)
-              {
-                 b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
-                                  NULL, NULL, 1, FLAG_FIXED_VERT, 1, 99999, 1,
-                                  99999, 0, 0,
-                                  EoGetX(d) + VRoot.w -
-                                  Conf.desks.dragbar_width, 0, EoGetY(d),
-                                  0, 0, 0, 0, 0, 1, 0, 1);
-              }
-            else if (Conf.desks.dragdir == 2)
-              {
-                 b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
-                                  NULL, NULL, 1, FLAG_FIXED_HORIZ, 1, 99999, 1,
-                                  99999, 0, 0, EoGetX(d), 0,
-                                  EoGetY(d), 0, 0, 0, 0, 0, 1, 0, 1);
-              }
-            else
-              {
-                 b = ButtonCreate("_DESKTOP_DESKRAY_DRAG_CONTROL", 2, ic4, ac,
-                                  NULL, NULL, 1, FLAG_FIXED_HORIZ, 1, 99999, 1,
-                                  99999, 0, 0, EoGetX(d), 0,
-                                  EoGetY(d) + VRoot.h -
-                                  Conf.desks.dragbar_width, 0, 0, 0, 0, 0, 1,
-                                  0, 1);
-              }
-         }
-       d->tag = b;
+       if (d->bg)
+          DesktopSetBg(i, d->bg, 1);
      }
 }
 
 void
 DesktopSetBg(int desk, Background * bg, int refresh)
 {
-   if (desk < 0 || desk >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
+   Desk               *d;
+
+   if (desk < 0 || desk >= Conf.desks.num)
       return;
 
+   d = _DeskGet(desk);
+
    if (refresh)
-      BackgroundPixmapFree(desks.desk[desk].bg);
+      BackgroundPixmapFree(d->bg);
 
    if (bg && !strcmp(BackgroundGetName(bg), "NONE"))
       bg = NULL;
 
-   if (desks.desk[desk].bg != bg)
+   if (d->bg != bg)
      {
-       if (desks.desk[desk].bg)
-          BackgroundDecRefcount(desks.desk[desk].bg);
+       if (d->bg)
+          BackgroundDecRefcount(d->bg);
        if (bg)
           BackgroundIncRefcount(bg);
      }
 
-   desks.desk[desk].bg = bg;
+   d->bg = bg;
 
-   if (desks.desk[desk].viewable)
+   if (d->viewable)
       RefreshDesktop(desk);
 
    ModulesSignal(ESIGNAL_BACKGROUND_CHANGE, (void *)desk);
@@ -679,7 +855,7 @@
    Desk               *d;
    int                 i;
 
-   for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+   for (i = 0; i < Conf.desks.num; i++)
      {
        d = _DeskGet(desks.order[i]);
        if (x >= EoGetX(d) && x < (EoGetX(d) + VRoot.w) &&
@@ -851,7 +1027,7 @@
      {
        n = -1;
        i = 0;
-       while ((n < 0) && (i < ENLIGHTENMENT_CONF_NUM_DESKTOPS))
+       while (n < 0 && i < Conf.desks.num)
          {
             if (desks.order[i] == desk)
                n = i;
@@ -859,7 +1035,7 @@
          }
        if (n >= 0)
          {
-            for (i = n + 1; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+            for (i = n + 1; i < Conf.desks.num; i++)
               {
                  dd = _DeskGet(desks.order[i]);
                  if (dd->viewable)
@@ -873,7 +1049,7 @@
        n = -1;
        i = 0;
 
-       while ((n < 0) && (i < ENLIGHTENMENT_CONF_NUM_DESKTOPS))
+       while (n < 0 && i < Conf.desks.num)
          {
             if (desks.order[i] == desk)
                n = i;
@@ -892,7 +1068,7 @@
                  v = 0;
               }
 
-            for (i = n + 1; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+            for (i = n + 1; i < Conf.desks.num; i++)
               {
                  dd = _DeskGet(desks.order[i]);
                  if ((!d->viewable) && (v))
@@ -966,7 +1142,7 @@
 
    if (desk == 0)
      {
-       for (i = ENLIGHTENMENT_CONF_NUM_DESKTOPS - 1; i > 0; i--)
+       for (i = Conf.desks.num - 1; i > 0; i--)
          {
             HideDesktop(desks.order[i]);
          }
@@ -1043,7 +1219,7 @@
 
    if (desk == 0)
      {
-       for (i = ENLIGHTENMENT_CONF_NUM_DESKTOPS - 1; i > 0; i--)
+       for (i = Conf.desks.num - 1; i > 0; i--)
           HideDesktop(desks.order[i]);
      }
    else
@@ -1160,38 +1336,6 @@
      }
 }
 
-void
-DesktopsEventsConfigure(int mode)
-{
-   Desk               *d;
-   int                 i;
-   long                event_mask;
-   XWindowAttributes   xwa;
-
-   for (i = 0; i < Conf.desks.num; i++)
-     {
-       d = _DeskGet(i);
-
-       if (mode)
-         {
-            event_mask = d->event_mask;
-         }
-       else
-         {
-            XGetWindowAttributes(disp, EoGetWin(d), &xwa);
-            d->event_mask = xwa.your_event_mask | EDESK_EVENT_MASK;
-            event_mask =
-               PropertyChangeMask | SubstructureRedirectMask |
-               ButtonPressMask | ButtonReleaseMask;
-#if USE_COMPOSITE
-            /* Handle ConfigureNotify's while sliding */
-            event_mask |= SubstructureNotifyMask;
-#endif
-         }
-       XSelectInput(disp, EoGetWin(d), event_mask);
-     }
-}
-
 static char         sentpress = 0;
 
 static void
@@ -1205,12 +1349,16 @@
 void
 DeskDragStart(int desk)
 {
+   Desk               *d;
+
+   d = _DeskGet(desk);
+
    Mode.deskdrag = desk;
    Mode.mode = MODE_DESKDRAG;
    Mode.start_x = Mode.x;
    Mode.start_y = Mode.y;
-   Mode.win_x = DeskGetX(desk);
-   Mode.win_y = DeskGetY(desk);
+   Mode.win_x = EoGetX(d);
+   Mode.win_y = EoGetY(d);
 }
 
 void
@@ -1320,19 +1468,13 @@
        if (Conf.desks.dragdir > 3)
           Conf.desks.dragdir = 0;
      }
+
    if (pd != Conf.desks.dragdir)
      {
        GotoDesktop(DesksGetCurrent());
-       for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+       for (i = 0; i < Conf.desks.num; i++)
           MoveDesktop(i, 0, 0);
-       while ((b = RemoveItem("_DESKTOP_DRAG_CONTROL", 0,
-                              LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
-          ButtonDestroy(b);
-       while ((b = RemoveItem("_DESKTOP_DESKRAY_DRAG_CONTROL", 0,
-                              LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
-          ButtonDestroy(b);
-       InitDesktopControls();
-       ShowDesktopControls();
+       DesksControlsRefresh();
      }
    autosave();
    return 0;
@@ -1353,13 +1495,10 @@
        if (Conf.desks.dragbar_ordering > 5)
           Conf.desks.dragbar_ordering = 0;
      }
+
    if (pd != Conf.desks.dragbar_ordering)
      {
-       while ((b = RemoveItem("_DESKTOP_DRAG_CONTROL", 0,
-                              LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
-          ButtonDestroy(b);
-       InitDesktopControls();
-       ShowDesktopControls();
+       DesksControlsRefresh();
      }
    autosave();
    return 0;
@@ -1374,13 +1513,10 @@
    pd = Conf.desks.dragbar_width;
    if (params)
       Conf.desks.dragbar_width = atoi(params);
+
    if (pd != Conf.desks.dragbar_width)
      {
-       while ((b = RemoveItem("_DESKTOP_DRAG_CONTROL", 0,
-                              LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
-          ButtonDestroy(b);
-       InitDesktopControls();
-       ShowDesktopControls();
+       DesksControlsRefresh();
      }
    autosave();
    return 0;
@@ -1395,13 +1531,10 @@
    pd = Conf.desks.dragbar_length;
    if (params)
       Conf.desks.dragbar_length = atoi(params);
+
    if (pd != Conf.desks.dragbar_length)
      {
-       while ((b = RemoveItem("_DESKTOP_DRAG_CONTROL", 0,
-                              LIST_FINDBY_NAME, LIST_TYPE_BUTTON)))
-          ButtonDestroy(b);
-       InitDesktopControls();
-       ShowDesktopControls();
+       DesksControlsRefresh();
      }
    autosave();
    return 0;
@@ -1460,12 +1593,11 @@
        RefreshDesktop(0);
 
        /* toss down the dragbar and related */
-       InitDesktopControls();
+       DesksControlsCreate();
+       DesksControlsShow();
 
        /* then draw all the buttons that belong on the desktop */
        ShowDesktopButtons();
-
-       ShowDesktopControls();
        break;
      }
 }
@@ -1477,6 +1609,8 @@
 static DItem       *tmp_desk_text;
 static Dialog      *tmp_desk_dialog;
 static char         tmp_desktop_wraparound;
+static char         tmp_dragbar;
+static int          tmp_dragdir;
 
 static void
 CB_ConfigureDesktops(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
@@ -1485,6 +1619,18 @@
      {
        ChangeNumberOfDesktops(tmp_desktops);
        Conf.desks.desks_wraparound = tmp_desktop_wraparound;
+
+       if ((Conf.desks.dragdir != tmp_dragdir) ||
+           ((tmp_dragbar) && (Conf.desks.dragbar_width < 1)) ||
+           ((!tmp_dragbar) && (Conf.desks.dragbar_width > 0)))
+         {
+            if (tmp_dragbar)
+               Conf.desks.dragbar_width = 16;
+            else
+               Conf.desks.dragbar_width = 0;
+            Conf.desks.dragdir = tmp_dragdir;
+            DesksControlsRefresh();
+         }
      }
    autosave();
 }
@@ -1499,45 +1645,57 @@
    int                 w, h;
    static int          prev_desktops = -1;
    char                s[64];
+   ImageClass         *ic;
 
    if (val == 1)
       called = 0;
 
    if ((val != 1) && (prev_desktops == tmp_desktops))
       return;
+
    prev_desktops = tmp_desktops;
    di = (DItem *) data;
    win = DialogItemAreaGetWindow(di);
    DialogItemAreaGetSize(di, &w, &h);
+
    if (!called)
      {
-       ImageClass         *ic;
-
        ic = ImageclassFind("SETTINGS_DESKTOP_AREA", 0);
        if (ic)
           ImageclassApply(ic, win, w, h, 0, 0, STATE_NORMAL, 0, ST_UNKNWN);
-       for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
+       for (i = 0; i < Conf.desks.num; i++)
           wins[i] = 0;
        called = 1;
      }
+
    for (i = 0; i < tmp_desktops; i++)
      {
        if (!wins[i])
          {
+            Background         *bg;
+            Pixmap              pmap;
+
             wins[i] = ECreateWindow(win, 0, 0, 64, 48, 0);
             XSetWindowBorderWidth(disp, wins[i], 1);
-            if (DeskGetBackground(i))
-              {
-                 Pixmap              pmap;
+            pmap = ecore_x_pixmap_new(wins[i], 64, 48, VRoot.depth);
+            ESetWindowBackgroundPixmap(disp, wins[i], pmap);
 
-                 pmap = ecore_x_pixmap_new(wins[i], 64, 48, VRoot.depth);
-                 ESetWindowBackgroundPixmap(disp, wins[i], pmap);
-                 BackgroundApply(DeskGetBackground(i), pmap, 0);
-                 ecore_x_pixmap_del(pmap);
+            bg = DeskGetBackground(i);
+            if (bg)
+               BackgroundApply(DeskGetBackground(i), pmap, 0);
+            else
+              {
+                 ic = ImageclassFind("SETTINGS_DESKTOP_AREA", 0);
+                 if (ic)
+                    ImageclassApply(ic, wins[i], 64, 48, 0, 0, STATE_NORMAL, 0,
+                                    ST_UNKNWN);
               }
+
+            ecore_x_pixmap_del(pmap);
          }
      }
-   for (i = (tmp_desktops - 1); i >= 0; i--)
+
+   for (i = tmp_desktops - 1; i >= 0; i--)
      {
        int                 num;
 
@@ -1549,8 +1707,14 @@
                    (i * (h - 48 - 2)) / num);
        EMapWindow(disp, wins[i]);
      }
-   for (i = tmp_desktops; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
-      EUnmapWindow(disp, wins[i]);
+
+   for (i = tmp_desktops; i < Conf.desks.num; i++)
+     {
+       EUnmapWindow(disp, wins[i]);
+       EDestroyWindow(disp, wins[i]);
+       wins[i] = None;
+     }
+
    if (tmp_desktops > 1)
       Esnprintf(s, sizeof(s), _("%i Desktops"), tmp_desktops);
    else
@@ -1563,7 +1727,7 @@
 SettingsDesktops(void)
 {
    Dialog             *d;
-   DItem              *table, *di, *area, *slider;
+   DItem              *table, *di, *area, *slider, *radio;
    char                s[64];
 
    if ((d =
@@ -1577,6 +1741,11 @@
 
    tmp_desktops = Conf.desks.num;
    tmp_desktop_wraparound = Conf.desks.desks_wraparound;
+   if (Conf.desks.dragbar_width < 1)
+      tmp_dragbar = 0;
+   else
+      tmp_dragbar = 1;
+   tmp_dragdir = Conf.desks.dragdir;
 
    d = tmp_desk_dialog = DialogCreate("CONFIGURE_DESKTOPS");
    DialogSetTitle(d, _("Multiple Desktop Settings"));
@@ -1657,6 +1826,60 @@
    DialogItemSetFill(di, 1, 0);
    DialogItemSeparatorSetOrientation(di, 0);
 
+   di = DialogAddItem(table, DITEM_CHECKBUTTON);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSetColSpan(di, 2);
+   DialogItemCheckButtonSetText(di, _("Display desktop dragbar"));
+   DialogItemCheckButtonSetState(di, tmp_dragbar);
+   DialogItemCheckButtonSetPtr(di, &tmp_dragbar);
+
+   di = DialogAddItem(table, DITEM_TEXT);
+   DialogItemSetColSpan(di, 2);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSetAlign(di, 0, 512);
+   DialogItemTextSetText(di, _("Drag bar position:"));
+
+   radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
+   DialogItemSetColSpan(di, 2);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemRadioButtonSetText(di, _("Top"));
+   DialogItemRadioButtonSetFirst(di, radio);
+   DialogItemRadioButtonGroupSetVal(di, 2);
+
+   di = DialogAddItem(table, DITEM_RADIOBUTTON);
+   DialogItemSetColSpan(di, 2);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemRadioButtonSetText(di, _("Bottom"));
+   DialogItemRadioButtonSetFirst(di, radio);
+   DialogItemRadioButtonGroupSetVal(di, 3);
+
+   di = DialogAddItem(table, DITEM_RADIOBUTTON);
+   DialogItemSetColSpan(di, 2);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemRadioButtonSetText(di, _("Left"));
+   DialogItemRadioButtonSetFirst(di, radio);
+   DialogItemRadioButtonGroupSetVal(di, 0);
+
+   di = DialogAddItem(table, DITEM_RADIOBUTTON);
+   DialogItemSetColSpan(di, 2);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemRadioButtonSetText(di, _("Right"));
+   DialogItemRadioButtonSetFirst(di, radio);
+   DialogItemRadioButtonGroupSetVal(di, 1);
+   DialogItemRadioButtonGroupSetValPtr(radio, &tmp_dragdir);
+
+   di = DialogAddItem(table, DITEM_SEPARATOR);
+   DialogItemSetColSpan(di, 2);
+   DialogItemSetPadding(di, 2, 2, 2, 2);
+   DialogItemSetFill(di, 1, 0);
+   DialogItemSeparatorSetOrientation(di, 0);
+
    DialogAddButton(d, _("OK"), CB_ConfigureDesktops, 1);
    DialogAddButton(d, _("Apply"), CB_ConfigureDesktops, 0);
    DialogAddButton(d, _("Close"), CB_ConfigureDesktops, 1);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/lists.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- lists.c     21 Mar 2004 01:39:40 -0000      1.13
+++ lists.c     9 Jan 2005 10:06:07 -0000       1.14
@@ -319,7 +319,8 @@
 
    while (ptr)
      {
-       if (ptr == ptritem)
+       p = ptr->item;
+       if (p == ptritem)
          {
             if (pptr)
               {
@@ -329,7 +330,6 @@
               {
                  lists[type].next = ptr->next;
               }
-            p = ptr->item;
             if (ptr->name)
                Efree(ptr->name);
             Efree(ptr);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/pager.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -3 -r1.108 -r1.109
--- pager.c     28 Dec 2004 23:46:46 -0000      1.108
+++ pager.c     9 Jan 2005 10:06:07 -0000       1.109
@@ -286,6 +286,10 @@
        return;
      }
 
+   /* Desk may be gone */
+   if (p->desktop >= DesksGetNumber())
+      return;
+
    p->update_phase = 0;
    GetAreaSize(&ax, &ay);
    DeskGetArea(p->desktop, &cx, &cy);
@@ -454,6 +458,10 @@
        return;
      }
 
+   /* Desk may be gone */
+   if (p->desktop >= DesksGetNumber())
+      return;
+
    if ((p->desktop != DesksGetCurrent()) || (!Conf.pagers.snap))
      {
        PagerRedraw(p, 0);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/settings.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -3 -r1.127 -r1.128
--- settings.c  31 Dec 2004 11:53:44 -0000      1.127
+++ settings.c  9 Jan 2005 10:06:29 -0000       1.128
@@ -1039,8 +1039,6 @@
 static char         tmp_cleanup_slide;
 static char         tmp_desktop_slide;
 static char         tmp_animate_shading;
-static char         tmp_dragbar;
-static int          tmp_dragdir;
 static int          tmp_slide_mode;
 static int          tmp_map_slide_speed;
 static int          tmp_cleanup_slide_speed;
@@ -1065,25 +1063,6 @@
        Conf.slidespeedmap = tmp_map_slide_speed;
        Conf.slidespeedcleanup = tmp_cleanup_slide_speed;
        Conf.desks.slidespeed = tmp_desktop_slide_speed;
-
-       if ((Conf.desks.dragdir != tmp_dragdir) ||
-           ((tmp_dragbar) && (Conf.desks.dragbar_width < 1)) ||
-           ((!tmp_dragbar) && (Conf.desks.dragbar_width > 0)))
-         {
-            Button             *b;
-
-            if (tmp_dragbar)
-               Conf.desks.dragbar_width = 16;
-            else
-               Conf.desks.dragbar_width = 0;
-            Conf.desks.dragdir = tmp_dragdir;
-            while ((b =
-                    RemoveItem("_DESKTOP_DRAG_CONTROL", 0, LIST_FINDBY_NAME,
-                               LIST_TYPE_BUTTON)))
-               ButtonDestroy(b);
-            InitDesktopControls();
-            ShowDesktopControls();
-         }
      }
    autosave();
 }
@@ -1110,11 +1089,6 @@
    tmp_cleanup_slide = Conf.cleanupslide;
    tmp_desktop_slide = Conf.desks.slidein;
    tmp_animate_shading = Conf.animate_shading;
-   if (Conf.desks.dragbar_width < 1)
-      tmp_dragbar = 0;
-   else
-      tmp_dragbar = 1;
-   tmp_dragdir = Conf.desks.dragdir;
    tmp_slide_mode = Conf.slidemode;
    tmp_map_slide_speed = Conf.slidespeedmap;
    tmp_shade_speed = Conf.shadespeed;
@@ -1270,70 +1244,6 @@
    DialogItemSetFill(di, 1, 0);
    DialogItemSeparatorSetOrientation(di, 0);
 
-   di = DialogAddItem(table, DITEM_CHECKBUTTON);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 1, 0);
-   DialogItemSetColSpan(di, 4);
-   DialogItemCheckButtonSetText(di, _("Display desktop dragbar"));
-   DialogItemCheckButtonSetState(di, tmp_dragbar);
-   DialogItemCheckButtonSetPtr(di, &tmp_dragbar);
-
-   di = DialogAddItem(table, DITEM_TEXT);
-   DialogItemSetColSpan(di, 1);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 0, 0);
-   DialogItemSetAlign(di, 0, 512);
-   DialogItemTextSetText(di, _("Drag bar position:"));
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   radio = di = DialogAddItem(table, DITEM_RADIOBUTTON);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 1, 0);
-   DialogItemRadioButtonSetText(di, _("Top"));
-   DialogItemRadioButtonSetFirst(di, radio);
-   DialogItemRadioButtonGroupSetVal(di, 2);
-
-   di = DialogAddItem(table, DITEM_RADIOBUTTON);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 1, 0);
-   DialogItemRadioButtonSetText(di, _("Bottom"));
-   DialogItemRadioButtonSetFirst(di, radio);
-   DialogItemRadioButtonGroupSetVal(di, 3);
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   di = DialogAddItem(table, DITEM_RADIOBUTTON);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 1, 0);
-   DialogItemRadioButtonSetText(di, _("Left"));
-   DialogItemRadioButtonSetFirst(di, radio);
-   DialogItemRadioButtonGroupSetVal(di, 0);
-
-   di = DialogAddItem(table, DITEM_RADIOBUTTON);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 1, 0);
-   DialogItemRadioButtonSetText(di, _("Right"));
-   DialogItemRadioButtonSetFirst(di, radio);
-   DialogItemRadioButtonGroupSetVal(di, 1);
-   DialogItemRadioButtonGroupSetValPtr(radio, &tmp_dragdir);
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   di = DialogAddItem(table, DITEM_NONE);
-
-   di = DialogAddItem(table, DITEM_SEPARATOR);
-   DialogItemSetColSpan(di, 4);
-   DialogItemSetPadding(di, 2, 2, 2, 2);
-   DialogItemSetFill(di, 1, 0);
-   DialogItemSeparatorSetOrientation(di, 0);
-
    di = DialogAddItem(table, DITEM_TEXT);
    DialogItemSetPadding(di, 2, 2, 2, 2);
    DialogItemSetFill(di, 0, 0);




-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to