Configuration of dwm for Mac Computers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
5.1 KiB

17 years ago
17 years ago
17 years ago
  1. /* See LICENSE file for copyright and license details. */
  2. /* enums */
  3. enum { BarTop, BarBot, BarOff }; /* bar position */
  4. enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
  5. enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
  6. enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
  7. enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
  8. /* typedefs */
  9. typedef struct Client Client;
  10. struct Client {
  11. char name[256];
  12. int x, y, w, h;
  13. int rx, ry, rw, rh; /* revert geometry */
  14. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  15. int minax, maxax, minay, maxay;
  16. long flags;
  17. unsigned int border, oldborder;
  18. Bool isbanned, isfixed, ismax, isfloating, wasfloating;
  19. Bool *tags;
  20. Client *next;
  21. Client *prev;
  22. Client *snext;
  23. Window win;
  24. };
  25. typedef struct {
  26. int x, y, w, h;
  27. unsigned long norm[ColLast];
  28. unsigned long sel[ColLast];
  29. Drawable drawable;
  30. GC gc;
  31. struct {
  32. int ascent;
  33. int descent;
  34. int height;
  35. XFontSet set;
  36. XFontStruct *xfont;
  37. } font;
  38. } DC; /* draw context */
  39. typedef struct {
  40. unsigned long mod;
  41. KeySym keysym;
  42. void (*func)(const char *arg);
  43. const char *arg;
  44. } Key;
  45. typedef struct {
  46. const char *symbol;
  47. void (*arrange)(void);
  48. } Layout;
  49. typedef struct {
  50. const char *prop;
  51. const char *tags;
  52. Bool isfloating;
  53. } Rule;
  54. typedef struct {
  55. regex_t *propregex;
  56. regex_t *tagregex;
  57. } Regs;
  58. /* functions */
  59. void applyrules(Client *c);
  60. void arrange(void);
  61. void attach(Client *c);
  62. void attachstack(Client *c);
  63. void ban(Client *c);
  64. void buttonpress(XEvent *e);
  65. void checkotherwm(void);
  66. void cleanup(void);
  67. void compileregs(void);
  68. void configure(Client *c);
  69. void configurenotify(XEvent *e);
  70. void configurerequest(XEvent *e);
  71. void destroynotify(XEvent *e);
  72. void detach(Client *c);
  73. void detachstack(Client *c);
  74. void drawbar(void);
  75. void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
  76. void drawtext(const char *text, unsigned long col[ColLast]);
  77. void *emallocz(unsigned int size);
  78. void enternotify(XEvent *e);
  79. void eprint(const char *errstr, ...);
  80. void expose(XEvent *e);
  81. void floating(void); /* default floating layout */
  82. void focus(Client *c);
  83. void focusnext(const char *arg);
  84. void focusprev(const char *arg);
  85. Client *getclient(Window w);
  86. unsigned long getcolor(const char *colstr);
  87. long getstate(Window w);
  88. Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
  89. void grabbuttons(Client *c, Bool focused);
  90. unsigned int idxoftag(const char *tag);
  91. void initfont(const char *fontstr);
  92. Bool isarrange(void (*func)());
  93. Bool isoccupied(unsigned int t);
  94. Bool isprotodel(Client *c);
  95. Bool isvisible(Client *c);
  96. void keypress(XEvent *e);
  97. void killclient(const char *arg);
  98. void leavenotify(XEvent *e);
  99. void manage(Window w, XWindowAttributes *wa);
  100. void mappingnotify(XEvent *e);
  101. void maprequest(XEvent *e);
  102. void movemouse(Client *c);
  103. Client *nexttiled(Client *c);
  104. void propertynotify(XEvent *e);
  105. void quit(const char *arg);
  106. void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
  107. void resizemouse(Client *c);
  108. void restack(void);
  109. void run(void);
  110. void scan(void);
  111. void setclientstate(Client *c, long state);
  112. void setlayout(const char *arg);
  113. void setmwfact(const char *arg);
  114. void setup(void);
  115. void spawn(const char *arg);
  116. void tag(const char *arg);
  117. unsigned int textnw(const char *text, unsigned int len);
  118. unsigned int textw(const char *text);
  119. void tile(void);
  120. void togglebar(const char *arg);
  121. void togglefloating(const char *arg);
  122. void togglemax(const char *arg);
  123. void toggletag(const char *arg);
  124. void toggleview(const char *arg);
  125. void unban(Client *c);
  126. void unmanage(Client *c);
  127. void unmapnotify(XEvent *e);
  128. void updatebarpos(void);
  129. void updatesizehints(Client *c);
  130. void updatetitle(Client *c);
  131. void view(const char *arg);
  132. void viewprevtag(const char *arg); /* views previous selected tags */
  133. int xerror(Display *dpy, XErrorEvent *ee);
  134. int xerrordummy(Display *dsply, XErrorEvent *ee);
  135. int xerrorstart(Display *dsply, XErrorEvent *ee);
  136. void zoom(const char *arg);
  137. /* variables */
  138. char stext[256];
  139. double mwfact;
  140. int screen, sx, sy, sw, sh, wax, way, waw, wah;
  141. int (*xerrorxlib)(Display *, XErrorEvent *);
  142. unsigned int bh, bpos;
  143. unsigned int blw = 0;
  144. unsigned int ltidx = 0; /* default */
  145. unsigned int nlayouts = 0;
  146. unsigned int nrules = 0;
  147. unsigned int numlockmask = 0;
  148. void (*handler[LASTEvent]) (XEvent *) = {
  149. [ButtonPress] = buttonpress,
  150. [ConfigureRequest] = configurerequest,
  151. [ConfigureNotify] = configurenotify,
  152. [DestroyNotify] = destroynotify,
  153. [EnterNotify] = enternotify,
  154. [LeaveNotify] = leavenotify,
  155. [Expose] = expose,
  156. [KeyPress] = keypress,
  157. [MappingNotify] = mappingnotify,
  158. [MapRequest] = maprequest,
  159. [PropertyNotify] = propertynotify,
  160. [UnmapNotify] = unmapnotify
  161. };
  162. Atom wmatom[WMLast], netatom[NetLast];
  163. Bool otherwm, readin;
  164. Bool running = True;
  165. Bool selscreen = True;
  166. Client *clients = NULL;
  167. Client *sel = NULL;
  168. Client *stack = NULL;
  169. Cursor cursor[CurLast];
  170. Display *dpy;
  171. DC dc = {0};
  172. Window barwin, root;
  173. Regs *regs = NULL;
  174. /* configuration, allows nested code to access above variables */
  175. #include "config.h"
  176. /* statically define the number of tags. */
  177. unsigned int ntags = sizeof tags / sizeof tags[0];
  178. Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
  179. Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};