A mirror of phillbush's xmenu.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

102 lines
2.8 KiB

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