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.

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