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