8902c43b |
1 | #define PROGNAME "xmenu" |
2 | |
6bbc0e45 |
3 | /* Actions for the main loop */ |
4 | #define ACTION_NOP 0 |
5 | #define ACTION_MAP 1<<0 |
6 | #define ACTION_DRAW 1<<1 |
7 | |
006c94ce |
8 | /* enum for keyboard menu navigation */ |
9 | enum { ITEMPREV, ITEMNEXT, ITEMFIRST, ITEMLAST }; |
8902c43b |
10 | |
27c03246 |
11 | /* enum for text alignment */ |
12 | enum {LeftAlignment, CenterAlignment, RightAlignment}; |
13 | |
8902c43b |
14 | /* macros */ |
cdeaefaa |
15 | #define LEN(x) (sizeof (x) / sizeof (x[0])) |
16 | #define MAX(x,y) ((x)>(y)?(x):(y)) |
17 | #define MIN(x,y) ((x)<(y)?(x):(y)) |
18 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) |
6abae763 |
19 | #define GETNUM(n, s) { \ |
20 | unsigned long __TMP__; \ |
21 | if ((__TMP__ = strtoul((s), NULL, 10)) < INT_MAX) \ |
22 | (n) = __TMP__; \ |
23 | } |
8902c43b |
24 | |
25 | /* color enum */ |
26 | enum {ColorFG, ColorBG, ColorLast}; |
27 | |
28 | /* EWMH atoms */ |
29 | enum {NetWMName, NetWMWindowType, NetWMWindowTypePopupMenu, NetLast}; |
30 | |
31 | /* configuration structure */ |
32 | struct Config { |
05cfe1a0 |
33 | /* the values below are set by config.h */ |
8902c43b |
34 | const char *font; |
8902c43b |
35 | const char *background_color; |
36 | const char *foreground_color; |
37 | const char *selbackground_color; |
38 | const char *selforeground_color; |
39 | const char *separator_color; |
40 | const char *border_color; |
8902c43b |
41 | int width_pixels; |
42 | int height_pixels; |
43 | int border_pixels; |
44 | int separator_pixels; |
45 | int gap_pixels; |
8902c43b |
46 | int triangle_width; |
47 | int triangle_height; |
8902c43b |
48 | int iconpadding; |
71b4db92 |
49 | int horzpadding; |
27c03246 |
50 | int alignment; |
71b4db92 |
51 | |
237da982 |
52 | /* the values below are set by options */ |
53 | int monitor; |
54 | int posx, posy; /* rootmenu position */ |
55 | |
56 | /* the value below is computed by xmenu */ |
71b4db92 |
57 | int iconsize; |
8902c43b |
58 | }; |
59 | |
60 | /* draw context structure */ |
61 | struct DC { |
62 | XftColor normal[ColorLast]; |
63 | XftColor selected[ColorLast]; |
64 | XftColor border; |
65 | XftColor separator; |
66 | |
67 | GC gc; |
cdeaefaa |
68 | |
0b0faa5f |
69 | FcPattern *pattern; |
cdeaefaa |
70 | XftFont **fonts; |
71 | size_t nfonts; |
8902c43b |
72 | }; |
73 | |
74 | /* menu item structure */ |
75 | struct Item { |
76 | char *label; /* string to be drawed on menu */ |
77 | char *output; /* string to be outputed when item is clicked */ |
78 | char *file; /* filename of the icon */ |
79 | int y; /* item y position relative to menu */ |
80 | int h; /* item height */ |
27c03246 |
81 | int textw; /* text width */ |
8902c43b |
82 | struct Item *prev; /* previous item */ |
83 | struct Item *next; /* next item */ |
84 | struct Menu *submenu; /* submenu spawned by clicking on item */ |
cdeaefaa |
85 | Drawable sel, unsel; /* pixmap for selected and unselected item */ |
8902c43b |
86 | Imlib_Image icon; |
87 | }; |
88 | |
b1cf3ebd |
89 | /* monitor geometry structure */ |
237da982 |
90 | struct Monitor { |
91 | int x, y, w, h; /* monitor geometry */ |
92 | }; |
93 | |
8902c43b |
94 | /* menu structure */ |
95 | struct Menu { |
96 | struct Menu *parent; /* parent menu */ |
97 | struct Item *caller; /* item that spawned the menu */ |
98 | struct Item *list; /* list of items contained by the menu */ |
99 | struct Item *selected; /* item currently selected in the menu */ |
100 | int x, y, w, h; /* menu geometry */ |
a2ff706d |
101 | int hasicon; /* whether the menu has item with icons */ |
3d853664 |
102 | int drawn; /* whether the menu was already drawn */ |
27c03246 |
103 | int maxtextw; /* maximum text width */ |
8902c43b |
104 | unsigned level; /* menu level relative to root */ |
8902c43b |
105 | Window win; /* menu window to map on the screen */ |
f472bfac |
106 | XIC xic; /* input context */ |
8902c43b |
107 | }; |