Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h actions.c buttons.c buttons.h desktops.c slideout.c 


Log Message:
Introduce button callbacks.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.486
retrieving revision 1.487
diff -u -3 -r1.486 -r1.487
--- E.h 21 Aug 2005 13:21:47 -0000      1.486
+++ E.h 27 Aug 2005 14:12:50 -0000      1.487
@@ -850,7 +850,6 @@
    EWin               *focuswin;
    EWin               *mouse_over_ewin;
    EWin               *context_ewin;
-   int                 deskdrag;
    Colormap            current_cmap;
    Window              context_win;
    char                constrained;
@@ -1118,8 +1117,6 @@
 void                DeskShow(int num);
 void                StackDesktop(int num);
 void                DeskGotoByEwin(EWin * ewin);
-void                DeskDragStart(int desk);
-void                DeskDragMotion(void);
 
 int                 DesksGetNumber(void);
 int                 DesksGetCurrent(void);
@@ -1722,7 +1719,6 @@
 
 /* slideouts.c */
 int                 SlideoutsConfigLoad(FILE * fs);
-void                SlideoutDoAction(EObj * seo, ActionClass * ac, XEvent * 
ev);
 
 /* snaps.c */
 void                Real_SaveSnapInfo(int dumval, void *dumdat);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/actions.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -3 -r1.191 -r1.192
--- actions.c   15 Aug 2005 16:57:13 -0000      1.191
+++ actions.c   27 Aug 2005 14:12:50 -0000      1.192
@@ -204,10 +204,6 @@
        ActionResizeHandleMotion();
        break;
 
-     case MODE_DESKDRAG:
-       DeskDragMotion();
-       break;
-
      default:
        break;
      }
@@ -266,10 +262,6 @@
        Mode.action_inhibit = 1;
        break;
 
-     case MODE_DESKDRAG:
-       Mode.mode = MODE_NONE;
-       break;
-
      default:
        did_end = 0;
        break;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/buttons.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -3 -r1.74 -r1.75
--- buttons.c   21 Aug 2005 13:21:47 -0000      1.74
+++ buttons.c   27 Aug 2005 14:12:50 -0000      1.75
@@ -55,7 +55,8 @@
    int                 flags;
    char                internal;
    char                default_show;
-   EObj               *container;
+   EObj               *owner;
+   ButtonCbFunc       *func;
 
    int                 state;
    Window              inside_win;
@@ -284,7 +285,7 @@
    b->internal = 1;
    b->default_show = 0;
    b->flags |= FLAG_FIXED;
-   b->container = eo;
+   b->owner = eo;
    b->ref_count++;
    EobjReparent(EoObj(b), eo, 0, 0);
    ButtonCalc(b);
@@ -292,6 +293,13 @@
    EMapWindow(EoGetWin(b));
 }
 
+void
+ButtonSetCallback(Button * b, ButtonCbFunc * func, EObj * eo)
+{
+   b->owner = eo;
+   b->func = func;
+}
+
 static void
 ButtonMoveToDesktop(Button * b, int desk)
 {
@@ -480,8 +488,8 @@
 static void
 ButtonDoAction(Button * b, XEvent * ev)
 {
-   if (b->container)
-      SlideoutDoAction(b->container, b->aclass, ev);
+   if (b->owner && b->func)
+      b->func(b->owner, ev, b->aclass);
    else
       ActionclassEvent(b->aclass, ev, NULL);
 }
@@ -578,19 +586,7 @@
        Mode_buttons.action_inhibit = 1;
      }
    if (!Mode_buttons.move_pending)
-     {
-       if (b)
-         {
-            ButtonMoveRelative(b, dx, dy);
-#if 0                          /* FIXME - Not active */
-            if (Conf.deskmode == MODE_DESKRAY)
-              {
-                 DeskMove(Mode.deskdrag, DeskGetX(Mode.deskdrag),
-                          DeskGetY(Mode.deskdrag) + dy);
-              }
-#endif
-         }
-     }
+      ButtonMoveRelative(b, dx, dy);
 }
 
 static void
@@ -676,6 +672,9 @@
 
    if (b->aclass)
       ButtonHandleTooltip(b, ev->type);
+
+   if (b->func)
+      b->func(b->owner, ev, NULL);
 }
 
 /*
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/buttons.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- buttons.h   21 Aug 2005 13:21:47 -0000      1.1
+++ buttons.h   27 Aug 2005 14:12:50 -0000      1.2
@@ -27,9 +27,11 @@
 
 typedef struct _button Button;
 
+typedef void        (ButtonCbFunc) (EObj * eo, XEvent * ev, ActionClass * ac);
+
 /* buttons.c */
 Button             *ButtonCreate(const char *name, int id, ImageClass * ic,
-                                ActionClass * aclass, TextClass * tclass,
+                                ActionClass * ac, TextClass * tc,
                                 const char *label, char ontop, int flags,
                                 int minw, int maxw, int minh, int maxh, int xo,
                                 int yo, int xa, int xr, int ya, int yr,
@@ -42,7 +44,9 @@
 void                ButtonMoveRelative(Button * b, int dx, int dy);
 void                ButtonIncRefcount(Button * b);
 void                ButtonDecRefcount(Button * b);
-void                ButtonSwallowInto(Button * bi, EObj * eo);
+void                ButtonSwallowInto(Button * b, EObj * eo);
+void                ButtonSetCallback(Button * b, ButtonCbFunc * func,
+                                     EObj * eo);
 int                 ButtonGetInfo(const Button * b, RectBox * r, int desk);
 int                 ButtonDoShowDefault(const Button * b);
 int                 ButtonEmbedWindow(Button * ButtonToUse,
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -3 -r1.173 -r1.174
--- desktops.c  22 Aug 2005 21:08:58 -0000      1.173
+++ desktops.c  27 Aug 2005 14:12:50 -0000      1.174
@@ -43,12 +43,15 @@
    Desk               *desk[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
    int                 order[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
    Background         *bg[ENLIGHTENMENT_CONF_NUM_DESKTOPS];
+   int                 drag_x0, drag_y0;
 }
 Desktops;
 
 static void         DeskRaise(int num);
 static void         DeskLower(int num);
 static void         DesktopHandleEvents(XEvent * ev, void *prm);
+static void         DeskButtonCallback(EObj * eo, XEvent * ev,
+                                      ActionClass * ac);
 
 /* The desktops */
 static Desktops     desks;
@@ -266,6 +269,7 @@
        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);
+       ButtonSetCallback(b, DeskButtonCallback, EoObj(d));
      }
 
 #if 0                          /* What is this anyway? */
@@ -1275,56 +1279,83 @@
                 ev);
 }
 
-void
+static void
 DeskDragStart(int desk)
 {
    Desk               *d;
 
    d = _DeskGet(desk);
 
-   Mode.deskdrag = desk;
+   desks.drag_x0 = Mode.events.x - EoGetX(d);
+   desks.drag_y0 = Mode.events.y - EoGetY(d);
+
    Mode.mode = MODE_DESKDRAG;
 }
 
-void
-DeskDragMotion(void)
+static void
+DeskDragEnd(Desk * d __UNUSED__)
 {
-   Desk               *d;
-   int                 desk, dx, dy;
+   Mode.mode = MODE_NONE;
+}
 
-   dx = Mode.events.x - Mode.events.px;
-   dy = Mode.events.y - Mode.events.py;
+static void
+DeskDragMotion(Desk * d)
+{
+   int                 x, y;
 
-   desk = Mode.deskdrag;
-   d = _DeskGet(desk);
+   x = Mode.events.x - desks.drag_x0;
+   y = Mode.events.y - desks.drag_y0;
 
    switch (Conf.desks.dragdir)
      {
      case 0:
-       if ((EoGetX(d) + dx) < 0)
-          dx = -EoGetX(d);
-       DeskMove(d, EoGetX(d) + dx, EoGetY(d));
+       if (x < 0)
+          x = 0;
+       y = 0;
        break;
      case 1:
-       if ((EoGetX(d) + dx) > 0)
-          DeskMove(d, 0, EoGetY(d));
-       else
-          DeskMove(d, EoGetX(d) + dx, EoGetY(d));
+       if (x > 0)
+          x = 0;
+       y = 0;
        break;
      case 2:
-       if ((EoGetY(d) + dy) < 0)
-          dy = -EoGetY(d);
-       DeskMove(d, EoGetX(d), EoGetY(d) + dy);
+       x = 0;
+       if (y < 0)
+          y = 0;
        break;
      case 3:
-       if ((EoGetY(d) + dy) > 0)
-          DeskMove(d, EoGetX(d), 0);
-       else
-          DeskMove(d, EoGetX(d), EoGetY(d) + dy);
+       x = 0;
+       if (y > 0)
+          y = 0;
        break;
      default:
        break;
      }
+   DeskMove(d, x, y);
+}
+
+static void
+DeskButtonCallback(EObj * eo, XEvent * ev, ActionClass * ac)
+{
+   Desk               *d;
+
+   if (Mode.mode != MODE_DESKDRAG)
+     {
+       if (ac)
+          ActionclassEvent(ac, ev, NULL);
+       return;
+     }
+
+   d = (Desk *) eo;
+   switch (ev->type)
+     {
+     case ButtonRelease:
+       DeskDragEnd(d);
+       break;
+     case MotionNotify:
+       DeskDragMotion(d);
+       break;
+     }
 }
 
 static int
@@ -1434,7 +1465,8 @@
 static void
 DeskDragdirSet(const char *params)
 {
-   int                 pd;
+   Desk               *d;
+   int                 i, pd;
 
    pd = Conf.desks.dragdir;
 
@@ -1447,18 +1479,15 @@
           Conf.desks.dragdir = 0;
      }
 
-   if (pd != Conf.desks.dragdir)
-     {
-       int                 i;
-       Desk               *d;
+   if (pd == Conf.desks.dragdir)
+      return;
 
-       for (i = 0; i < Conf.desks.num; i++)
-         {
-            d = _DeskGet(i);
-            EoMove(d, (d->viewable) ? 0 : VRoot.w, 0);
-         }
-       DesksControlsRefresh();
+   for (i = 1; i < Conf.desks.num; i++)
+     {
+       d = _DeskGet(i);
+       EoMove(d, (d->viewable) ? 0 : VRoot.w, 0);
      }
+   DesksControlsRefresh();
 }
 
 static void
@@ -1477,10 +1506,10 @@
           Conf.desks.dragbar_ordering = 0;
      }
 
-   if (pd != Conf.desks.dragbar_ordering)
-     {
-       DesksControlsRefresh();
-     }
+   if (pd == Conf.desks.dragbar_ordering)
+      return;
+
+   DesksControlsRefresh();
 }
 
 #if 0                          /* FIXME */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/slideout.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- slideout.c  21 Aug 2005 13:21:48 -0000      1.40
+++ slideout.c  27 Aug 2005 14:12:50 -0000      1.41
@@ -308,6 +308,19 @@
 }
 
 static void
+SlideoutButtonCallback(EObj * seo, XEvent * ev, ActionClass * ac)
+{
+   Slideout           *s = (Slideout *) seo;
+   EWin               *ewin = s->context_ewin;
+
+   if (ev->type == ButtonRelease)
+      SlideoutHide(s);
+
+   if (ac)
+      ActionclassEvent(ac, ev, ewin);
+}
+
+static void
 SlideoutAddButton(Slideout * s, Button * b)
 {
    EObj               *eob = (EObj *) b;
@@ -321,6 +334,7 @@
    s->objs = Erealloc(s->objs, sizeof(EObj *) * s->num_objs);
    s->objs[s->num_objs - 1] = eob;
    ButtonSwallowInto(b, EoObj(s));
+   ButtonSetCallback(b, SlideoutButtonCallback, EoObj(s));
    SlideoutCalcSize(s);
 }
 
@@ -333,18 +347,6 @@
 }
 #endif
 
-void
-SlideoutDoAction(EObj * seo, ActionClass * ac, XEvent * ev)
-{
-   Slideout           *s = (Slideout *) seo;
-   EWin               *ewin = s->context_ewin;
-
-   if (ev->type == ButtonRelease)
-      SlideoutHide(s);
-
-   ActionclassEvent(ac, ev, ewin);
-}
-
 static void
 SlideoutHandleEvent(XEvent * ev, void *prm)
 {




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to