-#define PROGNAME "xmenu"
-#define ITEMPREV 0
-#define ITEMNEXT 1
-#define IMGPADDING 8
-
-/* macros */
-#define LEN(x) (sizeof (x) / sizeof (x[0]))
-#define MAX(x,y) ((x)>(y)?(x):(y))
-#define MIN(x,y) ((x)<(y)?(x):(y))
-
-/* color enum */
-enum {ColorFG, ColorBG, ColorLast};
-
-/* draw context structure */
-struct DC {
- XftColor normal[ColorLast];
- XftColor selected[ColorLast];
- XftColor border;
- XftColor separator;
-
- GC gc;
- XftFont *font;
-};
-
-/* menu geometry structure */
-struct Geometry {
- int border; /* window border width */
- int separator; /* menu separator width */
- int itemw, itemh; /* item width and height */
- int cursx, cursy; /* cursor position */
- int screenw, screenh; /* screen width and height */
-};
-
-/* menu item structure */
-struct Item {
- char *label; /* string to be drawed on menu */
- char *output; /* string to be outputed when item is clicked */
- char *file; /* filename of the icon */
- int y; /* item y position relative to menu */
- int h; /* item height */
- size_t labellen; /* strlen(label) */
- struct Item *prev; /* previous item */
- struct Item *next; /* next item */
- struct Menu *submenu; /* submenu spawned by clicking on item */
- Imlib_Image icon;
-};
-
-/* menu structure */
-struct Menu {
- struct Menu *parent; /* parent menu */
- struct Item *caller; /* item that spawned the menu */
- struct Item *list; /* list of items contained by the menu */
- struct Item *selected; /* item currently selected in the menu */
- int x, y, w, h; /* menu geometry */
- unsigned level; /* menu level relative to root */
- Drawable pixmap; /* pixmap to draw the menu on */
- XftDraw *draw;
- Window win; /* menu window to map on the screen */
-};
-
-/* functions declarations */
-static void getresources(void);
-static void getcolor(const char *s, XftColor *color);
-static void setupdc(void);
-static void calcgeom(struct Geometry *geom);
+/*
+ * Function declarations
+ */
+
+/* initializers, and their helper routines */
+static void ealloccolor(const char *s, XftColor *color);
+static void initresources(void);
+static void initdc(void);
+static void initscreengeom(void);
+static void initatoms(void);
+
+/* structure builders, and their helper routines */