Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h borders.c config.c cursors.c ipc.c main.c 


Log Message:
Cursor code namespace cleanup.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.305
retrieving revision 1.306
diff -u -3 -r1.305 -r1.306
--- E.h 13 Jul 2004 19:58:57 -0000      1.305
+++ E.h 15 Jul 2004 16:46:04 -0000      1.306
@@ -589,6 +589,7 @@
 typedef struct _slideout Slideout;
 typedef struct _soundclass SoundClass;
 typedef struct _background Background;
+typedef struct _ecursor ECursor;
 
 typedef struct _efont Efont;
 
@@ -818,19 +819,6 @@
 }
 Geometry;
 
-typedef struct _ecursor
-{
-   char               *name;
-#if 0                          /* Not used */
-   Imlib_Color         fg, bg;
-#endif
-   char               *file;
-   Cursor              cursor;
-   unsigned int        ref_count;
-   char                inroot;
-}
-ECursor;
-
 typedef struct _winpart
 {
    Geometry            geom;
@@ -1922,10 +1910,22 @@
 void                CoordsHide(void);
 
 /* cursors.c */
-ECursor            *CreateECursor(char *name, char *image, int native_id,
-                                 XColor * fg, XColor * bg);
-void                ApplyECursor(Window win, ECursor * ec);
-void                FreeECursor(ECursor * ec);
+#define ECSR_ROOT           0
+#define ECSR_GRAB           1
+#define ECSR_ACT_MOVE       2
+#define ECSR_ACT_RESIZE     3
+#define ECSR_COUNT          4
+void                ECursorsInit(void);
+ECursor            *ECursorCreate(const char *name, const char *image,
+                                 int native_id, XColor * fg, XColor * bg);
+void                ECursorApply(ECursor * ec, Window win);
+void                ECursorDestroy(ECursor * ec);
+void                ECursorIncRefcount(ECursor * ec);
+void                ECursorDecRefcount(ECursor * ec);
+int                 ECursorGetRefcount(ECursor * ec);
+const char         *ECursorGetName(ECursor * ec);
+Cursor              ECsrGet(int which);
+void                ECsrApply(int which, Window win);
 
 /* desktops.c */
 void                ChangeNumberOfDesktops(int quantity);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/borders.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -3 -r1.215 -r1.216
--- borders.c   14 Jul 2004 19:05:30 -0000      1.215
+++ borders.c   15 Jul 2004 16:46:04 -0000      1.216
@@ -1692,7 +1692,7 @@
        else
          {
             ewin->bits[i].win = ECreateWindow(ewin->win, -10, -10, 1, 1, 0);
-            ApplyECursor(ewin->bits[i].win, b->part[i].ec);
+            ECursorApply(b->part[i].ec, ewin->bits[i].win);
             EMapWindow(disp, ewin->bits[i].win);
             /*
              * KeyPressMask KeyReleaseMask ButtonPressMask 
@@ -2272,7 +2272,7 @@
        if (b->part[i].aclass)
           b->part[i].aclass->ref_count--;
        if (b->part[i].ec)
-          b->part[i].ec->ref_count--;
+          ECursorDecRefcount(b->part[i].ec);
      }
 
    if (b->num_winparts > 0)
@@ -2354,7 +2354,7 @@
 
    b->part[n - 1].ec = ec;
    if (ec)
-      ec->ref_count++;
+      ECursorIncRefcount(ec);
 
    b->part[n - 1].ontop = ontop;
    b->part[n - 1].flags = flags;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -3 -r1.107 -r1.108
--- config.c    3 Jul 2004 00:58:19 -0000       1.107
+++ config.c    15 Jul 2004 16:46:05 -0000      1.108
@@ -2074,9 +2074,7 @@
        switch (ii1)
          {
          case CONFIG_CLOSE:
-            ec = CreateECursor(name, file, native_id, &xclr, &xclr2);
-            if (ec)
-               AddItem(ec, ec->name, 0, LIST_TYPE_ECURSOR);
+            ec = ECursorCreate(name, file, native_id, &xclr, &xclr2);
             if (name)
                Efree(name);
             if (file)
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/cursors.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- cursors.c   4 May 2004 19:04:26 -0000       1.17
+++ cursors.c   15 Jul 2004 16:46:05 -0000      1.18
@@ -21,9 +21,25 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "E.h"
+#include "X11/cursorfont.h"
+
+struct _ecursor
+{
+   char               *name;
+#if 0                          /* Not used */
+   Imlib_Color         fg, bg;
+#endif
+   char               *file;
+   Cursor              cursor;
+   unsigned int        ref_count;
+#if 0                          /* Not used */
+   char                inroot;
+#endif
+};
 
 ECursor            *
-CreateECursor(char *name, char *image, int native_id, XColor * fg, XColor * bg)
+ECursorCreate(const char *name, const char *image, int native_id, XColor * fg,
+             XColor * bg)
 {
    Cursor              curs;
    Pixmap              pmap, mask;
@@ -80,21 +96,43 @@
 #endif
    ec->cursor = curs;
    ec->ref_count = 0;
+#if 0                          /* Not used */
    ec->inroot = 0;
+#endif
+
+   AddItem(ec, ec->name, 0, LIST_TYPE_ECURSOR);
 
    return ec;
 }
 
 void
-ApplyECursor(Window win, ECursor * ec)
+ECursorApply(ECursor * ec, Window win)
 {
    if (!ec)
       return;
    XDefineCursor(disp, win, ec->cursor);
+#if 0                          /* Not used */
+   if (win == VRoot.win)
+      ec->inroot = 1;
+#endif
+}
+
+static              Cursor
+ECursorGetByName(const char *name, unsigned int fallback)
+{
+   ECursor            *ec;
+
+   ec = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR);
+   if (!ec)
+      return fallback;
+
+   ECursorIncRefcount(ec);
+
+   return ec->cursor;
 }
 
 void
-FreeECursor(ECursor * ec)
+ECursorDestroy(ECursor * ec)
 {
    if (!ec)
       return;
@@ -114,3 +152,55 @@
       Efree(ec->file);
    Efree(ec);
 }
+
+void
+ECursorIncRefcount(ECursor * ec)
+{
+   if (ec)
+      ec->ref_count++;
+}
+
+void
+ECursorDecRefcount(ECursor * ec)
+{
+   if (ec)
+      ec->ref_count--;
+}
+
+const char         *
+ECursorGetName(ECursor * ec)
+{
+   return (ec) ? ec->name : 0;
+}
+
+int
+ECursorGetRefcount(ECursor * ec)
+{
+   return (ec) ? ec->ref_count : 0;
+}
+
+static Cursor       ECsrs[ECSR_COUNT];
+
+Cursor
+ECsrGet(int which)
+{
+   return (which >= 0 && which < ECSR_COUNT) ? ECsrs[which] : None;
+}
+
+void
+ECsrApply(int which, Window win)
+{
+   XDefineCursor(disp, win, ECsrGet(which));
+}
+
+/*
+ * Set up some basic cursors
+ */
+void
+ECursorsInit(void)
+{
+   ECsrs[ECSR_ROOT] = ECursorGetByName("DEFAULT", XC_arrow);
+   ECsrs[ECSR_GRAB] = ECursorGetByName("GRAB", XC_circle);
+   ECsrs[ECSR_ACT_MOVE] = ECursorGetByName("ACTION_MOVE", XC_X_cursor);
+   ECsrs[ECSR_ACT_RESIZE] = ECursorGetByName("ACTION_RESIZE", XC_sizing);
+}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -3 -r1.169 -r1.170
--- ipc.c       13 Jul 2004 19:58:58 -0000      1.169
+++ ipc.c       15 Jul 2004 16:46:05 -0000      1.170
@@ -853,7 +853,7 @@
                  ec = (ECursor *) FindItem(param1, 0, LIST_FINDBY_NAME,
                                            LIST_TYPE_ECURSOR);
                  if (ec)
-                    FreeECursor(ec);
+                    ECursorDestroy(ec);
               }
             else if (!strcmp(param2, "modify"))
               {
@@ -866,7 +866,7 @@
                                            LIST_TYPE_ECURSOR);
                  if (ec)
                     Esnprintf(buf, sizeof(buf), "%u references remain",
-                              ec->ref_count);
+                              ECursorGetRefcount(ec));
               }
             else
               {
@@ -1548,7 +1548,7 @@
             for (i = 0; i < num; i++)
               {
                  buf2[0] = 0;
-                 Esnprintf(buf2, sizeof(buf2), "%s\n", lst[i]->name);
+                 Esnprintf(buf2, sizeof(buf2), "%s\n", ECursorGetName(lst[i]));
                  if (buf)
                     buf = realloc(buf, strlen(buf) + strlen(buf2) + 1);
                  else
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -3 -r1.98 -r1.99
--- main.c      30 Jun 2004 13:04:18 -0000      1.98
+++ main.c      15 Jul 2004 16:46:06 -0000      1.99
@@ -53,7 +53,6 @@
 main(int argc, char **argv)
 {
    int                 i;
-   ECursor            *ec = NULL;
    struct utsname      ubuf;
    char               *str;
 
@@ -304,13 +303,8 @@
    Mode.queue_up = DRAW_QUEUE_ENABLE;
 
    /* of course, we have to set the cursors */
-   ec = FindItem("DEFAULT", 0, LIST_FINDBY_NAME, LIST_TYPE_ECURSOR);
-   if (ec)
-     {
-       ApplyECursor(VRoot.win, ec);
-       ec->ref_count++;
-       ec->inroot = 1;
-     }
+   ECursorsInit();
+   ECsrApply(ECSR_ROOT, VRoot.win);
 
    Mode.wm.startup = 0;
    Mode.wm.save_ok = Mode.wm.master;




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to