wmfs.h 8.6 KB

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