wmfs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
  3. * For license, see COPYING.
  4. */
  5. #ifndef WMFS_H
  6. #define WMFS_H
  7. /* Standard */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <stdbool.h>
  11. #include <stdarg.h>
  12. #include <signal.h>
  13. #include <unistd.h>
  14. #include <locale.h>
  15. #include <err.h>
  16. #include <sys/queue.h>
  17. /* Xlib */
  18. #include <X11/Xlib.h>
  19. #include <X11/Xatom.h>
  20. /* Local */
  21. #define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
  22. #define MouseMask (ButtonMask | PointerMotionMask)
  23. #define KeyMask (KeyPressMask | KeyReleaseMask)
  24. typedef unsigned int Flags;
  25. typedef unsigned int Color;
  26. typedef const char* Uicb;
  27. typedef enum { BarTop = 0, BarBottom, BarHide, BarLast } Barpos;
  28. typedef enum { Right = 0, Left, Top, Bottom, Center, PositionLast } Position;
  29. /*
  30. * Structures
  31. */
  32. struct geo
  33. {
  34. int x, y, w, h;
  35. };
  36. struct barwin
  37. {
  38. struct geo geo;
  39. Window win;
  40. Drawable dr;
  41. Color fg, bg;
  42. void *ptr; /* Special cases */
  43. SLIST_HEAD(, mousebind) mousebinds;
  44. SLIST_ENTRY(barwin) next; /* global barwin */
  45. SLIST_ENTRY(barwin) enext; /* element barwin */
  46. };
  47. struct element
  48. {
  49. struct geo geo;
  50. struct infobar *infobar;
  51. int type;
  52. void (*func_init)(struct element *e);
  53. void (*func_update)(struct element *e);
  54. SLIST_HEAD(, barwin) bars;
  55. TAILQ_ENTRY(element) next;
  56. };
  57. struct infobar
  58. {
  59. struct barwin *bar;
  60. struct geo geo;
  61. struct screen *screen;
  62. struct theme *theme;
  63. char *elemorder;
  64. Barpos pos;
  65. TAILQ_HEAD(esub, element) elements;
  66. SLIST_ENTRY(infobar) next;
  67. };
  68. struct screen
  69. {
  70. struct geo geo, ugeo;
  71. struct tag *seltag;
  72. int id;
  73. Flags elemupdate;
  74. TAILQ_HEAD(tsub, tag) tags;
  75. SLIST_HEAD(, infobar) infobars;
  76. SLIST_ENTRY(screen) next;
  77. };
  78. struct tag
  79. {
  80. struct screen *screen;
  81. struct client *sel;
  82. char *name;
  83. Flags flags;
  84. Window frame;
  85. SLIST_HEAD(, client) clients;
  86. TAILQ_ENTRY(tag) next;
  87. };
  88. struct client
  89. {
  90. struct tag *tag;
  91. struct screen *screen;
  92. struct barwin *titlebar;
  93. struct geo geo, tgeo, wgeo;
  94. char *title;
  95. Flags flags;
  96. Window win;
  97. SLIST_ENTRY(client) next; /* Global list */
  98. SLIST_ENTRY(client) tnext; /* struct tag list */
  99. };
  100. struct keybind
  101. {
  102. unsigned int mod;
  103. void (*func)(Uicb);
  104. Uicb cmd;
  105. KeySym keysym;
  106. SLIST_ENTRY(keybind) next;
  107. };
  108. struct mousebind
  109. {
  110. struct geo area;
  111. int button;
  112. bool use_area;
  113. void (*func)(Uicb);
  114. Uicb cmd;
  115. SLIST_ENTRY(mousebind) next;
  116. };
  117. struct colpair
  118. {
  119. Color fg, bg;
  120. };
  121. struct theme
  122. {
  123. char *name;
  124. /* Font */
  125. struct
  126. {
  127. int as, de, width, height;
  128. XFontSet fontset;
  129. } font;
  130. /* Bars */
  131. struct colpair bars;
  132. int bars_width;
  133. /* struct elements */
  134. struct colpair tags_n, tags_s; /* normal / selected */
  135. int tags_border_width;
  136. Color tags_border_col;
  137. /* client / frame */
  138. struct colpair client_n, client_s;
  139. Color frame_bg;
  140. int client_titlebar_width;
  141. int client_border_width;
  142. SLIST_ENTRY(theme) next;
  143. };
  144. struct wmfs
  145. {
  146. /* X11 stuffs */
  147. Display *dpy;
  148. Window root;
  149. int xscreen, xdepth;
  150. Flags numlockmask;
  151. GC gc;
  152. Atom *net_atom;
  153. bool running;
  154. /* Lists heads */
  155. struct
  156. {
  157. SLIST_HEAD(, screen) screen;
  158. SLIST_HEAD(, client) client;
  159. SLIST_HEAD(, keybind) keybind;
  160. SLIST_HEAD(, barwin) barwin;
  161. SLIST_HEAD(, theme) theme;
  162. } h;
  163. /*
  164. * Selected screen, client
  165. */
  166. struct screen *screen;
  167. struct client *client;
  168. };
  169. int wmfs_error_handler(Display *d, XErrorEvent *event);
  170. int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
  171. void wmfs_grab_keys(void);
  172. void wmfs_numlockmask(void);
  173. void wmfs_init_font(char *font, struct theme *t);
  174. void wmfs_quit(void);
  175. void uicb_reload(Uicb cmd);
  176. void uicb_quit(Uicb cmd);
  177. /* Single global variable */
  178. struct wmfs *W;
  179. #endif /* WMFS_H */