wmfs.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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_HEAD(, mousebind) statusmousebinds;
  81. SLIST_ENTRY(barwin) next; /* global barwin */
  82. SLIST_ENTRY(barwin) enext; /* element barwin */
  83. };
  84. struct status_seq
  85. {
  86. struct geo geo;
  87. enum position align;
  88. char type;
  89. char *str;
  90. Color color;
  91. SLIST_HEAD(, mousebind) mousebinds;
  92. SLIST_ENTRY(status_seq) next;
  93. };
  94. struct status_ctx
  95. {
  96. struct barwin *barwin;
  97. struct theme *theme;
  98. char *status;
  99. bool update;
  100. SLIST_HEAD(, status_seq) statushead;
  101. };
  102. struct element
  103. {
  104. struct geo geo;
  105. struct infobar *infobar;
  106. struct status_ctx *statusctx;
  107. int type;
  108. char *data;
  109. enum position align;
  110. void (*func_init)(struct element *e);
  111. void (*func_update)(struct element *e);
  112. SLIST_HEAD(, barwin) bars;
  113. TAILQ_ENTRY(element) next;
  114. };
  115. struct infobar
  116. {
  117. struct barwin *bar;
  118. struct geo geo;
  119. struct screen *screen;
  120. struct theme *theme;
  121. struct status_ctx statusctx;
  122. enum barpos pos;
  123. char *elemorder;
  124. char *name;
  125. TAILQ_HEAD(esub, element) elements;
  126. SLIST_ENTRY(infobar) next;
  127. };
  128. struct screen
  129. {
  130. struct geo geo, ugeo;
  131. struct tag *seltag;
  132. int id;
  133. TAILQ_HEAD(tsub, tag) tags;
  134. SLIST_HEAD(, infobar) infobars;
  135. SLIST_ENTRY(screen) next;
  136. };
  137. SLIST_HEAD(chead, client);
  138. struct tag
  139. {
  140. struct screen *screen;
  141. struct client *sel;
  142. struct client *prevsel;
  143. struct tag *prev;
  144. char *name;
  145. int id;
  146. #define TAG_URGENT 0x01
  147. Flags flags;
  148. SLIST_HEAD(, client) clients;
  149. TAILQ_HEAD(ssub, layout_set) sets;
  150. TAILQ_ENTRY(tag) next;
  151. };
  152. struct client
  153. {
  154. struct tag *tag, *prevtag;
  155. struct screen *screen;
  156. struct barwin *titlebar;
  157. struct geo geo, wgeo, tgeo, ttgeo, rgeo, *tbgeo;
  158. struct colpair ncol, scol;
  159. struct theme *theme;
  160. struct client *tabmaster;
  161. int sizeh[SHLAST];
  162. char *title;
  163. int border, tbarw;
  164. #define CLIENT_HINT_FLAG 0x01
  165. #define CLIENT_IGNORE_ENTER 0x02
  166. #define CLIENT_DID_WINSIZE 0x04
  167. #define CLIENT_FAC_APPLIED 0x08
  168. #define CLIENT_IGNORE_LAYOUT 0x10
  169. #define CLIENT_RULED 0x20
  170. #define CLIENT_TABBED 0x40
  171. #define CLIENT_TABMASTER 0x80
  172. #define CLIENT_DYING 0x100 /* Saddest flag ever */
  173. #define CLIENT_REMOVEALL 0x200
  174. #define CLIENT_MAPPED 0x400
  175. #define CLIENT_FULLSCREEN 0x800
  176. #define CLIENT_FREE 0x1000
  177. #define CLIENT_TILED 0x2000
  178. Flags flags;
  179. Window win, frame, tmp;
  180. SLIST_ENTRY(client) next; /* Global list */
  181. SLIST_ENTRY(client) tnext; /* struct tag list */
  182. };
  183. struct layout_set
  184. {
  185. int n;
  186. SLIST_HEAD(, geo_list) geos;
  187. TAILQ_ENTRY(layout_set) next;
  188. };
  189. struct keybind
  190. {
  191. unsigned int mod;
  192. void (*func)(Uicb);
  193. Uicb cmd;
  194. KeySym keysym;
  195. SLIST_ENTRY(keybind) next;
  196. };
  197. struct mousebind
  198. {
  199. struct geo area;
  200. unsigned int button;
  201. bool use_area;
  202. void (*func)(Uicb);
  203. Uicb cmd;
  204. SLIST_ENTRY(mousebind) next;
  205. SLIST_ENTRY(mousebind) snext;
  206. SLIST_ENTRY(mousebind) globnext;
  207. };
  208. struct theme
  209. {
  210. char *name;
  211. /* Font */
  212. struct
  213. {
  214. int as, de, width, height;
  215. XFontSet fontset;
  216. } font;
  217. /* Bars */
  218. struct colpair bars;
  219. int bars_width;
  220. /* struct elements */
  221. struct colpair tags_n, tags_s, tags_o, tags_u; /* normal / selected / occupied */
  222. struct status_ctx tags_n_sl, tags_s_sl, tags_o_sl, tags_u_sl; /* status line */
  223. int tags_border_width;
  224. Color tags_border_col;
  225. /* client / frame */
  226. struct colpair client_n, client_s;
  227. struct status_ctx client_n_sl, client_s_sl;
  228. Color frame_bg;
  229. int client_titlebar_width;
  230. int client_border_width;
  231. SLIST_ENTRY(theme) next;
  232. };
  233. struct rule
  234. {
  235. struct theme *theme;
  236. char *class;
  237. char *instance;
  238. char *role;
  239. char *name;
  240. int tag, screen;
  241. #define RULE_FREE 0x01
  242. #define RULE_MAX 0x02
  243. #define RULE_IGNORE_TAG 0x04
  244. Flags flags;
  245. SLIST_ENTRY(rule) next;
  246. };
  247. struct launcher
  248. {
  249. char *name;
  250. char *prompt;
  251. char *command;
  252. #define HISTOLEN 64
  253. char histo[HISTOLEN][256];
  254. int nhisto;
  255. int width;
  256. SLIST_ENTRY(launcher) next;
  257. };
  258. struct _systray
  259. {
  260. struct geo geo;
  261. Window win;
  262. SLIST_ENTRY(_systray) next;
  263. };
  264. #define MAX_PATH_LEN 8192
  265. struct wmfs
  266. {
  267. /* X11 stuffs */
  268. Display *dpy;
  269. Window root;
  270. int xscreen, xdepth;
  271. int xmaxw, xmaxh;
  272. int nscreen;
  273. unsigned int client_mod;
  274. Flags numlockmask;
  275. #define WMFS_SCAN 0x01
  276. #define WMFS_RUNNING 0x02
  277. #define WMFS_RELOAD 0x04
  278. #define WMFS_SYSTRAY 0x08
  279. #define WMFS_LOG 0x10
  280. #define WMFS_LAUNCHER 0x20
  281. Flags flags;
  282. GC gc, rgc;
  283. Atom *net_atom;
  284. char **argv;
  285. char confpath[MAX_PATH_LEN];
  286. struct barwin *last_clicked_barwin;
  287. /* FIFO stuffs */
  288. struct
  289. {
  290. char *path;
  291. int fd;
  292. } fifo;
  293. /* Log file */
  294. FILE *log;
  295. /* Lists heads */
  296. struct
  297. {
  298. SLIST_HEAD(, screen) screen;
  299. SLIST_HEAD(, client) client;
  300. SLIST_HEAD(, keybind) keybind;
  301. SLIST_HEAD(, barwin) barwin;
  302. SLIST_HEAD(, theme) theme;
  303. SLIST_HEAD(, rule) rule;
  304. SLIST_HEAD(, mousebind) mousebind;
  305. SLIST_HEAD(, launcher) launcher;
  306. } h;
  307. /*
  308. * Temporary head of mousebind list from config
  309. * Will be copied in barwin of clickable drawable
  310. * later in code
  311. */
  312. struct
  313. {
  314. struct mbhead tag;
  315. struct mbhead client;
  316. struct mbhead root;
  317. } tmp_head;
  318. /*
  319. * Because there is only one systray per display,
  320. * set struct there
  321. */
  322. struct
  323. {
  324. struct barwin *barwin;
  325. struct infobar *infobar;
  326. bool redim;
  327. Window win;
  328. SLIST_HEAD(, _systray) head;
  329. } systray;
  330. /*
  331. * Selected screen, client
  332. */
  333. struct screen *screen;
  334. struct client *client;
  335. };
  336. int wmfs_error_handler(Display *d, XErrorEvent *event);
  337. int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
  338. void wmfs_grab_keys(void);
  339. void wmfs_numlockmask(void);
  340. void wmfs_init_font(char *font, struct theme *t);
  341. void wmfs_quit(void);
  342. void uicb_reload(Uicb cmd);
  343. void uicb_quit(Uicb cmd);
  344. /* Single global variable */
  345. struct wmfs *W;
  346. #endif /* WMFS_H */