structs.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. /*
  2. * structs.h
  3. * Copyright © 2008, 2009 Martin Duquesnoy <xorg62@gmail.com>
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are
  8. * met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above
  13. * copyright notice, this list of conditions and the following disclaimer
  14. * in the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of the nor the names of its
  17. * contributors may be used to endorse or promote products derived from
  18. * this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef STRUCTS_H
  33. #define STRUCTS_H
  34. #include "wmfs.h"
  35. #define NBUTTON 8
  36. #define MAXTAG 36
  37. #define NUM_OF_LAYOUT 10
  38. /* Clients flags definition */
  39. #define FreeFlag (1 << 1)
  40. #define MaxFlag (1 << 2)
  41. #define TileFlag (1 << 3)
  42. #define HideFlag (1 << 4)
  43. #define LMaxFlag (1 << 5)
  44. #define UnmapFlag (1 << 6)
  45. #define HintFlag (1 << 7)
  46. #define FSSFlag (1 << 8)
  47. #define AboveFlag (1 << 9)
  48. /* XEMBED messages */
  49. #define XEMBED_MAPPED (1 << 0)
  50. #define XEMBED_EMBEDDED_NOTIFY 0
  51. #define XEMBED_WINDOW_ACTIVATE 1
  52. #define XEMBED_WINDOW_DEACTIVATE 2
  53. #define XEMBED_REQUEST_FOCUS 3
  54. #define XEMBED_FOCUS_IN 4
  55. #define XEMBED_FOCUS_OUT 5
  56. #define XEMBED_FOCUS_NEXT 6
  57. #define XEMBED_FOCUS_PREV 7
  58. /* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
  59. #define XEMBED_MODALITY_ON 10
  60. #define XEMBED_MODALITY_OFF 11
  61. #define XEMBED_REGISTER_ACCELERATOR 12
  62. #define XEMBED_UNREGISTER_ACCELERATOR 13
  63. #define XEMBED_ACTIVATE_ACCELERATOR 14
  64. /* Details for XEMBED_FOCUS_IN: */
  65. #define XEMBED_FOCUS_CURRENT 0
  66. #define XEMBED_FOCUS_FIRST 1
  67. #define XEMBED_FOCUS_LAST 2
  68. /* Typedef */
  69. typedef const char* uicb_t;
  70. typedef unsigned int uint;
  71. typedef unsigned long ulong;
  72. typedef unsigned short ushort;
  73. typedef unsigned char uchar;
  74. /* Enum */
  75. enum { CurNormal, CurResize, CurRightResize, CurLeftResize, CurMove, CurLast };
  76. /* Infobar position */
  77. enum { IB_Hide = 0, IB_Bottom = 1, IB_Top = 2 };
  78. typedef enum { Right, Left, Top, Bottom, Center, PositionLast } Position;
  79. /* Ewmh hints list */
  80. enum
  81. {
  82. net_supported,
  83. net_wm_name,
  84. net_client_list,
  85. net_frame_extents,
  86. net_number_of_desktops,
  87. net_current_desktop,
  88. net_desktop_names,
  89. net_desktop_geometry,
  90. net_workarea,
  91. net_active_window,
  92. net_close_window,
  93. net_wm_icon_name,
  94. net_wm_window_type,
  95. net_wm_pid,
  96. net_showing_desktop,
  97. net_supporting_wm_check,
  98. net_wm_window_type_normal,
  99. net_wm_window_type_dock,
  100. net_wm_window_type_splash,
  101. net_wm_window_type_dialog,
  102. net_wm_desktop,
  103. net_wm_icon,
  104. net_wm_state,
  105. net_wm_state_fullscreen,
  106. net_wm_state_demands_attention,
  107. utf8_string,
  108. /* WMFS HINTS */
  109. wmfs_running,
  110. wmfs_update_hints,
  111. wmfs_update_status,
  112. wmfs_current_tag,
  113. wmfs_current_screen,
  114. wmfs_current_layout,
  115. wmfs_tag_list,
  116. wmfs_mwfact,
  117. wmfs_nmaster,
  118. wmfs_set_screen,
  119. wmfs_screen_count,
  120. wmfs_function,
  121. wmfs_cmd,
  122. wmfs_statustext,
  123. net_last
  124. };
  125. /*
  126. * BarWindow Structure
  127. * (titlebar, infobar..)
  128. */
  129. typedef struct
  130. {
  131. Window win;
  132. Drawable dr;
  133. struct
  134. {
  135. /* Border Window */
  136. Window left, right, top, bottom;
  137. /* Border color */
  138. uint dark, light;
  139. } border;
  140. uint bg;
  141. char *fg;
  142. uint stipple_color;
  143. XRectangle geo;
  144. Bool mapped, stipple, bord;
  145. } BarWindow;
  146. /* Client Structure. */
  147. typedef struct Client Client;
  148. struct Client
  149. {
  150. /* Client title */
  151. char *title;
  152. /* Tag num */
  153. uint tag;
  154. /* Screen */
  155. int screen;
  156. /* Layer */
  157. int layer;
  158. /* Window attribute */
  159. XRectangle geo;
  160. XRectangle tmp_geo;
  161. XRectangle frame_geo;
  162. /* Old window attribute */
  163. XRectangle ogeo;
  164. /* Free window attribute */
  165. XRectangle free_geo;
  166. /* For resizehint usage */
  167. int basew, baseh, incw, inch;
  168. int maxw, maxh, minw, minh;
  169. int minax, maxax, minay, maxay;
  170. /* Client composant {{{ */
  171. Window win;
  172. Window *button;
  173. int button_last_x;
  174. BarWindow *titlebar;
  175. Window frame, resize[2];
  176. /* Border */
  177. Window right, left, top, bottom;
  178. /* }}} */
  179. struct
  180. {
  181. uint frame;
  182. char *fg;
  183. uint resizecorner;
  184. } colors;
  185. /* Client Information by flags */
  186. uint flags;
  187. /* Struct in chains */
  188. Client *next;
  189. Client *prev;
  190. };
  191. /* Keybind Structure */
  192. typedef struct
  193. {
  194. uint mod;
  195. KeySym keysym;
  196. void (*func)(uicb_t);
  197. uicb_t cmd;
  198. } Key;
  199. /* Mouse Binding Struct */
  200. typedef struct
  201. {
  202. int tag;
  203. int screen;
  204. uint button;
  205. void (*func)(uicb_t);
  206. uicb_t cmd;
  207. } MouseBinding;
  208. /* InfoBar Struct */
  209. typedef struct
  210. {
  211. BarWindow *bar, *selbar;
  212. BarWindow *layout_button;
  213. BarWindow *tags_board, *tags[MAXTAG];
  214. XRectangle geo;
  215. int position;
  216. char *statustext;
  217. } InfoBar;
  218. /* Layout Structure */
  219. typedef struct
  220. {
  221. char *symbol;
  222. void (*func)(int screen);
  223. } Layout;
  224. /* Tag Structure */
  225. typedef struct
  226. {
  227. char *name;
  228. char **clients;
  229. int nclients;
  230. int layers;
  231. float mwfact;
  232. int nmaster;
  233. Bool resizehint;
  234. Bool request_update;
  235. Bool abovefc;
  236. int barpos;
  237. Layout layout;
  238. } Tag;
  239. /* Menu Item Struct */
  240. typedef struct
  241. {
  242. char *name;
  243. void (*func)(uicb_t);
  244. uicb_t cmd;
  245. } MenuItem;
  246. /* Menu Struct */
  247. typedef struct
  248. {
  249. /* Name of the menu for call
  250. * it in the conf (function = "menu"
  251. * menu = "<name>").
  252. */
  253. char *name;
  254. /* Placement */
  255. Bool place_at_mouse;
  256. int x, y;
  257. /* Color */
  258. struct
  259. {
  260. struct { uint bg; char *fg; } focus;
  261. struct { uint bg; char *fg; } normal;
  262. } colors;
  263. /* Number of item */
  264. int nitem, focus_item;
  265. /* Item */
  266. MenuItem *item;
  267. } Menu;
  268. /* Launcher struct */
  269. typedef struct
  270. {
  271. char *name;
  272. char *prompt;
  273. char *command;
  274. } Launcher;
  275. /* Button struct */
  276. typedef struct
  277. {
  278. MouseBinding *mouse;
  279. XSegment *linecoord;
  280. int nlines;
  281. int nmouse;
  282. uint flags;
  283. } Button;
  284. /* Alias struct */
  285. typedef struct
  286. {
  287. char *name;
  288. char *content;
  289. } Alias;
  290. /* Configuration structure */
  291. typedef struct
  292. {
  293. /* Configuration file path */
  294. char confpath[512];
  295. /* Misc option */
  296. char *font;
  297. Bool raisefocus;
  298. Bool raiseswitch;
  299. Bool focus_fmouse;
  300. Bool ignore_next_client_rules;
  301. uint pad;
  302. int status_timing;
  303. char *status_path;
  304. struct
  305. {
  306. /*
  307. * Only the colors will be use for text
  308. * are 'char*' (for xprint -> XftColorAllocName)
  309. */
  310. uint bar;
  311. char *text;
  312. char *tagselfg;
  313. uint tagselbg;
  314. uint tag_occupied_bg;
  315. uint tagbord;
  316. char *layout_fg;
  317. uint layout_bg;
  318. } colors;
  319. struct
  320. {
  321. int height;
  322. MouseBinding *mouse;
  323. int nmouse;
  324. Bool selbar;
  325. } bars;
  326. struct
  327. {
  328. char *background_command;
  329. MouseBinding *mouse;
  330. int nmouse;
  331. } root;
  332. struct
  333. {
  334. Bool set_new_win_master;
  335. Bool place_at_mouse;
  336. Bool border_shadow;
  337. int borderheight;
  338. uint bordernormal;
  339. uint borderfocus;
  340. uint resizecorner_normal;
  341. uint resizecorner_focus;
  342. uint mod;
  343. MouseBinding *mouse;
  344. int nmouse;
  345. } client;
  346. struct
  347. {
  348. int height;
  349. char *fg_normal;
  350. char *fg_focus;
  351. struct
  352. {
  353. Bool active;
  354. struct { uint normal, focus; } colors;
  355. } stipple;
  356. MouseBinding *mouse;
  357. int nmouse;
  358. Button *button;
  359. int nbutton;
  360. } titlebar;
  361. struct
  362. {
  363. Bool bar;
  364. Bool tag;
  365. Bool layout;
  366. } border;
  367. Alias alias[256];
  368. Layout layout[NUM_OF_LAYOUT];
  369. Menu *menu;
  370. Launcher *launcher;
  371. int *ntag;
  372. Bool tag_round;
  373. Bool layout_system; /* Switch: False, Menu: True. */
  374. Bool layout_placement; /* Right (normal): False, Left: True. */
  375. /* Number of... */
  376. int nkeybind;
  377. int nlayout;
  378. int nmenu;
  379. int nlauncher;
  380. } Conf;
  381. typedef struct
  382. {
  383. uint x, y, w, h;
  384. uint color;
  385. } StatusRec;
  386. typedef struct
  387. {
  388. uint x, y;
  389. char color[8];
  390. char text[512];
  391. } StatusText;
  392. typedef struct
  393. {
  394. uint x, y, w, h;
  395. char name[512];
  396. } ImageAttr;
  397. /* Config.c struct */
  398. typedef struct
  399. {
  400. char *name;
  401. void *func;
  402. } func_name_list_t;
  403. typedef struct
  404. {
  405. char *name;
  406. KeySym keysym;
  407. } key_name_list_t;
  408. typedef struct
  409. {
  410. char *name;
  411. uint button;
  412. } name_to_uint_t;
  413. typedef struct
  414. {
  415. char *cmd;
  416. char *uicb;
  417. } vicmd_to_uicb;
  418. #endif /* STRUCTS_H */