add support for mouse scrolling (#26)
[xmenu] / xmenu.h
CommitLineData
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 */
60ddf397 9#define ACTION_WARP 1<<4 /* warp the pointer */
6bbc0e45 10
006c94ce 11/* enum for keyboard menu navigation */
12enum { ITEMPREV, ITEMNEXT, ITEMFIRST, ITEMLAST };
8902c43b 13
27c03246 14/* enum for text alignment */
15enum {LeftAlignment, CenterAlignment, RightAlignment};
16
8902c43b 17/* macros */
cdeaefaa 18#define LEN(x) (sizeof (x) / sizeof (x[0]))
19#define MAX(x,y) ((x)>(y)?(x):(y))
20#define MIN(x,y) ((x)<(y)?(x):(y))
21#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
6abae763 22#define GETNUM(n, s) { \
23 unsigned long __TMP__; \
24 if ((__TMP__ = strtoul((s), NULL, 10)) < INT_MAX) \
25 (n) = __TMP__; \
26 }
8902c43b 27
28/* color enum */
29enum {ColorFG, ColorBG, ColorLast};
30
31/* EWMH atoms */
32enum {NetWMName, NetWMWindowType, NetWMWindowTypePopupMenu, NetLast};
33
34/* configuration structure */
35struct Config {
05cfe1a0 36 /* the values below are set by config.h */
8902c43b 37 const char *font;
8902c43b 38 const char *background_color;
39 const char *foreground_color;
40 const char *selbackground_color;
41 const char *selforeground_color;
42 const char *separator_color;
43 const char *border_color;
8902c43b 44 int width_pixels;
45 int height_pixels;
46 int border_pixels;
47 int separator_pixels;
48 int gap_pixels;
8902c43b 49 int triangle_width;
50 int triangle_height;
8902c43b 51 int iconpadding;
71b4db92 52 int horzpadding;
27c03246 53 int alignment;
71b4db92 54
237da982 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 */
71b4db92 60 int iconsize;
8902c43b 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;
cdeaefaa 71
0b0faa5f 72 FcPattern *pattern;
cdeaefaa 73 XftFont **fonts;
74 size_t nfonts;
8902c43b 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 */
27c03246 84 int textw; /* text width */
8902c43b 85 struct Item *prev; /* previous item */
86 struct Item *next; /* next item */
87 struct Menu *submenu; /* submenu spawned by clicking on item */
cdeaefaa 88 Drawable sel, unsel; /* pixmap for selected and unselected item */
8902c43b 89 Imlib_Image icon;
90};
91
b1cf3ebd 92/* monitor geometry structure */
237da982 93struct Monitor {
94 int x, y, w, h; /* monitor geometry */
95};
96
8902c43b 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 */
a2ff706d 104 int hasicon; /* whether the menu has item with icons */
3d853664 105 int drawn; /* whether the menu was already drawn */
27c03246 106 int maxtextw; /* maximum text width */
8902c43b 107 unsigned level; /* menu level relative to root */
8902c43b 108 Window win; /* menu window to map on the screen */
f472bfac 109 XIC xic; /* input context */
8902c43b 110};