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