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