structs.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. /* For resizehint usage */
  165. int basew, baseh, incw, inch;
  166. int maxw, maxh, minw, minh;
  167. int minax, maxax, minay, maxay;
  168. /* Client composant {{{ */
  169. Window win;
  170. Window *button;
  171. int button_last_x;
  172. BarWindow *titlebar;
  173. Window frame, resize[2];
  174. /* Border */
  175. Window right, left, top, bottom;
  176. /* }}} */
  177. struct
  178. {
  179. uint frame;
  180. char *fg;
  181. uint resizecorner;
  182. } colors;
  183. /* Client Information by flags */
  184. uint flags;
  185. /* Struct in chains */
  186. Client *next;
  187. Client *prev;
  188. };
  189. /* Keybind Structure */
  190. typedef struct
  191. {
  192. uint mod;
  193. KeySym keysym;
  194. void (*func)(uicb_t);
  195. uicb_t cmd;
  196. } Key;
  197. /* Mouse Binding Struct */
  198. typedef struct
  199. {
  200. int tag;
  201. int screen;
  202. uint button;
  203. void (*func)(uicb_t);
  204. uicb_t cmd;
  205. } MouseBinding;
  206. /* InfoBar Struct */
  207. typedef struct
  208. {
  209. BarWindow *bar;
  210. BarWindow *layout_button;
  211. BarWindow *tags[MAXTAG];
  212. XRectangle geo;
  213. int position;
  214. char *statustext;
  215. } InfoBar;
  216. /* Layout Structure */
  217. typedef struct
  218. {
  219. char *symbol;
  220. void (*func)(int screen);
  221. } Layout;
  222. /* Tag Structure */
  223. typedef struct
  224. {
  225. char *name;
  226. char **clients;
  227. int nclients;
  228. int layers;
  229. float mwfact;
  230. int nmaster;
  231. Bool resizehint;
  232. Bool request_update;
  233. Bool abovefc;
  234. int barpos;
  235. Layout layout;
  236. } Tag;
  237. /* Menu Item Struct */
  238. typedef struct
  239. {
  240. char *name;
  241. void (*func)(uicb_t);
  242. uicb_t cmd;
  243. } MenuItem;
  244. /* Menu Struct */
  245. typedef struct
  246. {
  247. /* Name of the menu for call
  248. * it in the conf (function = "menu"
  249. * menu = "<name>").
  250. */
  251. char *name;
  252. /* Placement */
  253. Bool place_at_mouse;
  254. int x, y;
  255. /* Color */
  256. struct
  257. {
  258. struct { uint bg; char *fg; } focus;
  259. struct { uint bg; char *fg; } normal;
  260. } colors;
  261. /* Number of item */
  262. int nitem, focus_item;
  263. /* Item */
  264. MenuItem *item;
  265. } Menu;
  266. /* Launcher struct */
  267. typedef struct
  268. {
  269. char *name;
  270. char *prompt;
  271. char *command;
  272. } Launcher;
  273. /* Button struct */
  274. typedef struct
  275. {
  276. MouseBinding *mouse;
  277. XSegment *linecoord;
  278. int nlines;
  279. int nmouse;
  280. } Button;
  281. /* Alias struct */
  282. typedef struct
  283. {
  284. char *name;
  285. char *content;
  286. } Alias;
  287. /* Configuration structure */
  288. typedef struct
  289. {
  290. /* Configuration file path */
  291. char confpath[512];
  292. /* Misc option */
  293. char *font;
  294. Bool raisefocus;
  295. Bool raiseswitch;
  296. Bool focus_fmouse;
  297. uint pad;
  298. int status_timing;
  299. struct
  300. {
  301. /*
  302. * Only the colors will be use for text
  303. * are 'char*' (for xprint -> XftColorAllocName)
  304. */
  305. uint bar;
  306. char *text;
  307. char *tagselfg;
  308. uint tagselbg;
  309. uint tag_occupied_bg;
  310. uint tagbord;
  311. char *layout_fg;
  312. uint layout_bg;
  313. } colors;
  314. struct
  315. {
  316. int height;
  317. MouseBinding *mouse;
  318. int nmouse;
  319. } bars;
  320. struct
  321. {
  322. char *background_command;
  323. MouseBinding *mouse;
  324. int nmouse;
  325. } root;
  326. struct
  327. {
  328. Bool set_new_win_master;
  329. Bool place_at_mouse;
  330. Bool border_shadow;
  331. int borderheight;
  332. uint bordernormal;
  333. uint borderfocus;
  334. uint resizecorner_normal;
  335. uint resizecorner_focus;
  336. uint mod;
  337. MouseBinding *mouse;
  338. int nmouse;
  339. } client;
  340. struct
  341. {
  342. int height;
  343. char *fg_normal;
  344. char *fg_focus;
  345. struct
  346. {
  347. Bool active;
  348. struct { uint normal, focus; } colors;
  349. } stipple;
  350. MouseBinding *mouse;
  351. int nmouse;
  352. Button *button;
  353. int nbutton;
  354. } titlebar;
  355. struct
  356. {
  357. Bool bar;
  358. Bool tag;
  359. Bool layout;
  360. } border;
  361. Alias alias[256];
  362. Layout layout[NUM_OF_LAYOUT];
  363. Menu *menu;
  364. Launcher *launcher;
  365. int *ntag;
  366. Bool tag_round;
  367. Bool layout_system; /* Switch: False, Menu: True. */
  368. /* Number of... */
  369. int nkeybind;
  370. int nlayout;
  371. int nmenu;
  372. int nlauncher;
  373. } Conf;
  374. /* Config.c struct */
  375. typedef struct
  376. {
  377. char *name;
  378. void *func;
  379. } func_name_list_t;
  380. typedef struct
  381. {
  382. char *name;
  383. KeySym keysym;
  384. } key_name_list_t;
  385. typedef struct
  386. {
  387. char *name;
  388. uint button;
  389. } name_to_uint_t;
  390. typedef struct
  391. {
  392. char *cmd;
  393. char *uicb;
  394. } vicmd_to_uicb;
  395. #endif /* STRUCTS_H */