wmfs.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. #include "log.h"
  22. #define CONFIG_DEFAULT_PATH ".config/wmfs/wmfsrc"
  23. #define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
  24. #define MouseMask (ButtonMask | PointerMotionMask)
  25. #define KeyMask (KeyPressMask | KeyReleaseMask)
  26. typedef unsigned long Flags;
  27. typedef unsigned int Color;
  28. typedef const char* Uicb;
  29. enum barpos
  30. {
  31. BarTop = 0,
  32. BarBottom,
  33. BarHide,
  34. BarLast
  35. };
  36. enum position
  37. {
  38. Right = 0,
  39. Left,
  40. Top,
  41. Bottom,
  42. Center,
  43. NoAlign,
  44. PositionLast
  45. };
  46. enum size_hints
  47. {
  48. BASEW, BASEH,
  49. INCW, INCH,
  50. MAXW, MAXH,
  51. MINW, MINH,
  52. MINAX, MINAY,
  53. MAXAX, MAXAY,
  54. SHLAST
  55. };
  56. /*
  57. * Structures
  58. */
  59. struct geo
  60. {
  61. int x, y, w, h;
  62. };
  63. struct geo_list
  64. {
  65. struct geo geo;
  66. SLIST_ENTRY(geo_list) next;
  67. };
  68. struct colpair
  69. {
  70. Color fg, bg;
  71. };
  72. struct barwin
  73. {
  74. struct geo geo;
  75. Window win;
  76. Drawable dr;
  77. Color fg, bg;
  78. void *ptr; /* Special cases */
  79. SLIST_HEAD(mbhead, mousebind) mousebinds;
  80. SLIST_ENTRY(barwin) next; /* global barwin */
  81. SLIST_ENTRY(barwin) enext; /* element barwin */
  82. };
  83. struct status_seq
  84. {
  85. struct geo geo;
  86. enum position align;
  87. char type;
  88. char *str;
  89. Color color;
  90. SLIST_HEAD(, mousebind) mousebinds;
  91. SLIST_ENTRY(status_seq) next;
  92. };
  93. struct element
  94. {
  95. struct geo geo;
  96. struct infobar *infobar;
  97. int type;
  98. enum position align;
  99. void (*func_init)(struct element *e);
  100. void (*func_update)(struct element *e);
  101. SLIST_HEAD(, barwin) bars;
  102. TAILQ_ENTRY(element) next;
  103. };
  104. struct infobar
  105. {
  106. struct barwin *bar;
  107. struct geo geo;
  108. struct screen *screen;
  109. struct theme *theme;
  110. enum barpos pos;
  111. char *elemorder;
  112. char *name;
  113. char *status;
  114. TAILQ_HEAD(esub, element) elements;
  115. SLIST_HEAD(, status_seq) statushead;
  116. SLIST_ENTRY(infobar) next;
  117. };
  118. struct screen
  119. {
  120. struct geo geo, ugeo;
  121. struct tag *seltag;
  122. int id;
  123. Flags elemupdate;
  124. TAILQ_HEAD(tsub, tag) tags;
  125. SLIST_HEAD(, infobar) infobars;
  126. SLIST_ENTRY(screen) next;
  127. };
  128. SLIST_HEAD(chead, client);
  129. struct tag
  130. {
  131. struct screen *screen;
  132. struct client *sel;
  133. struct client *prevsel;
  134. struct tag *prev;
  135. char *name;
  136. int id;
  137. Flags flags;
  138. SLIST_HEAD(, client) clients;
  139. TAILQ_HEAD(ssub, layout_set) sets;
  140. TAILQ_ENTRY(tag) next;
  141. };
  142. struct client
  143. {
  144. struct tag *tag, *prevtag;
  145. struct screen *screen;
  146. struct barwin *titlebar;
  147. struct geo geo, wgeo, tgeo, ttgeo, rgeo, *tbgeo;
  148. struct colpair ncol, scol;
  149. struct theme *theme;
  150. struct client *tabmaster;
  151. int sizeh[SHLAST];
  152. char *title;
  153. int border, tbarw;
  154. #define CLIENT_HINT_FLAG 0x01
  155. #define CLIENT_IGNORE_ENTER 0x02
  156. #define CLIENT_DID_WINSIZE 0x04
  157. #define CLIENT_FAC_APPLIED 0x08
  158. #define CLIENT_IGNORE_LAYOUT 0x10
  159. #define CLIENT_RULED 0x20
  160. #define CLIENT_TABBED 0x40
  161. #define CLIENT_TABMASTER 0x80
  162. #define CLIENT_DYING 0x100 /* Saddest flag ever */
  163. #define CLIENT_REMOVEALL 0x200
  164. #define CLIENT_MAPPED 0x400
  165. #define CLIENT_FULLSCREEN 0x800
  166. Flags flags;
  167. Window win, frame, tmp;
  168. SLIST_ENTRY(client) next; /* Global list */
  169. SLIST_ENTRY(client) tnext; /* struct tag list */
  170. };
  171. struct layout_set
  172. {
  173. int n;
  174. SLIST_HEAD(, geo_list) geos;
  175. TAILQ_ENTRY(layout_set) next;
  176. };
  177. struct keybind
  178. {
  179. unsigned int mod;
  180. void (*func)(Uicb);
  181. Uicb cmd;
  182. KeySym keysym;
  183. SLIST_ENTRY(keybind) next;
  184. };
  185. struct mousebind
  186. {
  187. struct geo area;
  188. unsigned int button;
  189. bool use_area;
  190. void (*func)(Uicb);
  191. Uicb cmd;
  192. SLIST_ENTRY(mousebind) next;
  193. SLIST_ENTRY(mousebind) snext;
  194. SLIST_ENTRY(mousebind) globnext;
  195. };
  196. struct theme
  197. {
  198. char *name;
  199. /* Font */
  200. struct
  201. {
  202. int as, de, width, height;
  203. XFontSet fontset;
  204. } font;
  205. /* Bars */
  206. struct colpair bars;
  207. int bars_width;
  208. /* struct elements */
  209. struct colpair tags_n, tags_s; /* normal / selected */
  210. int tags_border_width;
  211. Color tags_border_col;
  212. /* client / frame */
  213. struct colpair client_n, client_s;
  214. Color frame_bg;
  215. int client_titlebar_width;
  216. int client_border_width;
  217. SLIST_ENTRY(theme) next;
  218. };
  219. struct rule
  220. {
  221. struct theme *theme;
  222. char *class;
  223. char *instance;
  224. char *role;
  225. char *name;
  226. int tag, screen;
  227. #define RULE_FREE 0x01
  228. #define RULE_MAX 0x02
  229. #define RULE_IGNORE_TAG 0x04
  230. Flags flags;
  231. SLIST_ENTRY(rule) next;
  232. };
  233. #define MAX_PATH_LEN 8192
  234. struct wmfs
  235. {
  236. /* X11 stuffs */
  237. Display *dpy;
  238. Window root;
  239. int xscreen, xdepth;
  240. int xmaxw, xmaxh;
  241. int nscreen;
  242. Flags numlockmask;
  243. #define WMFS_SCAN 0x01
  244. #define WMFS_RUNNING 0x02
  245. #define WMFS_RELOAD 0x04
  246. Flags flags;
  247. GC gc, rgc;
  248. Atom *net_atom;
  249. char **argv;
  250. char confpath[MAX_PATH_LEN];
  251. struct barwin *last_clicked_barwin;
  252. /* FIFO stuffs */
  253. struct
  254. {
  255. char *path;
  256. int fd;
  257. } fifo;
  258. /* Log file */
  259. FILE *log;
  260. /* Lists heads */
  261. struct
  262. {
  263. SLIST_HEAD(, screen) screen;
  264. SLIST_HEAD(, client) client;
  265. SLIST_HEAD(, keybind) keybind;
  266. SLIST_HEAD(, barwin) barwin;
  267. SLIST_HEAD(, theme) theme;
  268. SLIST_HEAD(, rule) rule;
  269. SLIST_HEAD(, mousebind) mousebind;
  270. } h;
  271. /*
  272. * Temporary head of mousebind list from config
  273. * Will be copied in barwin of clickable drawable
  274. * later in code
  275. */
  276. struct
  277. {
  278. struct mbhead tag;
  279. struct mbhead client;
  280. struct mbhead root;
  281. } tmp_head;
  282. /*
  283. * Selected screen, client
  284. */
  285. struct screen *screen;
  286. struct client *client;
  287. };
  288. int wmfs_error_handler(Display *d, XErrorEvent *event);
  289. int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
  290. void wmfs_grab_keys(void);
  291. void wmfs_numlockmask(void);
  292. void wmfs_init_font(char *font, struct theme *t);
  293. void wmfs_quit(void);
  294. void uicb_reload(Uicb cmd);
  295. void uicb_quit(Uicb cmd);
  296. /* Single global variable */
  297. struct wmfs *W;
  298. #endif /* WMFS_H */