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