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