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.
 
 
 
 
 

84 lines
2.4 KiB

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