A mirror of phillbush's xmenu.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

92 lines
2.5 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 set by options */
  34. int monitor;
  35. int posx, posy; /* rootmenu position */
  36. /* the value below is computed by xmenu */
  37. int iconsize;
  38. int screenw, screenh; /* screen width and height */
  39. };
  40. /* draw context structure */
  41. struct DC {
  42. XftColor normal[ColorLast];
  43. XftColor selected[ColorLast];
  44. XftColor border;
  45. XftColor separator;
  46. GC gc;
  47. XftFont **fonts;
  48. size_t nfonts;
  49. };
  50. /* menu item structure */
  51. struct Item {
  52. char *label; /* string to be drawed on menu */
  53. char *output; /* string to be outputed when item is clicked */
  54. char *file; /* filename of the icon */
  55. int y; /* item y position relative to menu */
  56. int h; /* item height */
  57. size_t labellen; /* strlen(label) */
  58. struct Item *prev; /* previous item */
  59. struct Item *next; /* next item */
  60. struct Menu *submenu; /* submenu spawned by clicking on item */
  61. Drawable sel, unsel; /* pixmap for selected and unselected item */
  62. Imlib_Image icon;
  63. };
  64. /* monitor and cursor geometry structure */
  65. struct Monitor {
  66. int x, y, w, h; /* monitor geometry */
  67. };
  68. /* menu structure */
  69. struct Menu {
  70. struct Menu *parent; /* parent menu */
  71. struct Item *caller; /* item that spawned the menu */
  72. struct Item *list; /* list of items contained by the menu */
  73. struct Item *selected; /* item currently selected in the menu */
  74. int x, y, w, h; /* menu geometry */
  75. int drawn; /* whether the menu was already drawn */
  76. unsigned level; /* menu level relative to root */
  77. Window win; /* menu window to map on the screen */
  78. };