| 1 | #define PROGNAME "xmenu" |
| 2 | |
| 3 | /* macros for keyboard menu navigation */ |
| 4 | #define ITEMPREV 0 |
| 5 | #define ITEMNEXT 1 |
| 6 | |
| 7 | /* macros */ |
| 8 | #define LEN(x) (sizeof (x) / sizeof (x[0])) |
| 9 | #define MAX(x,y) ((x)>(y)?(x):(y)) |
| 10 | #define MIN(x,y) ((x)<(y)?(x):(y)) |
| 11 | |
| 12 | /* color enum */ |
| 13 | enum {ColorFG, ColorBG, ColorLast}; |
| 14 | |
| 15 | /* EWMH atoms */ |
| 16 | enum {NetWMName, NetWMWindowType, NetWMWindowTypePopupMenu, NetLast}; |
| 17 | |
| 18 | /* configuration structure */ |
| 19 | struct Config { |
| 20 | const char *font; |
| 21 | |
| 22 | const char *background_color; |
| 23 | const char *foreground_color; |
| 24 | const char *selbackground_color; |
| 25 | const char *selforeground_color; |
| 26 | const char *separator_color; |
| 27 | const char *border_color; |
| 28 | |
| 29 | int width_pixels; |
| 30 | int height_pixels; |
| 31 | int border_pixels; |
| 32 | int separator_pixels; |
| 33 | int gap_pixels; |
| 34 | |
| 35 | int triangle_width; |
| 36 | int triangle_height; |
| 37 | |
| 38 | int iconpadding; |
| 39 | |
| 40 | int cursx, cursy; /* cursor position */ |
| 41 | int screenw, screenh; /* screen width and height */ |
| 42 | }; |
| 43 | |
| 44 | /* draw context structure */ |
| 45 | struct DC { |
| 46 | XftColor normal[ColorLast]; |
| 47 | XftColor selected[ColorLast]; |
| 48 | XftColor border; |
| 49 | XftColor separator; |
| 50 | |
| 51 | GC gc; |
| 52 | XftFont *font; |
| 53 | }; |
| 54 | |
| 55 | /* menu item structure */ |
| 56 | struct Item { |
| 57 | char *label; /* string to be drawed on menu */ |
| 58 | char *output; /* string to be outputed when item is clicked */ |
| 59 | char *file; /* filename of the icon */ |
| 60 | int y; /* item y position relative to menu */ |
| 61 | int h; /* item height */ |
| 62 | size_t labellen; /* strlen(label) */ |
| 63 | struct Item *prev; /* previous item */ |
| 64 | struct Item *next; /* next item */ |
| 65 | struct Menu *submenu; /* submenu spawned by clicking on item */ |
| 66 | Imlib_Image icon; |
| 67 | }; |
| 68 | |
| 69 | /* menu structure */ |
| 70 | struct Menu { |
| 71 | struct Menu *parent; /* parent menu */ |
| 72 | struct Item *caller; /* item that spawned the menu */ |
| 73 | struct Item *list; /* list of items contained by the menu */ |
| 74 | struct Item *selected; /* item currently selected in the menu */ |
| 75 | int x, y, w, h; /* menu geometry */ |
| 76 | unsigned level; /* menu level relative to root */ |
| 77 | Drawable pixmap; /* pixmap to draw the menu on */ |
| 78 | XftDraw *draw; |
| 79 | Window win; /* menu window to map on the screen */ |
| 80 | }; |