Configuration file for DWM on MacBook Air
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.

152 lines
6.6 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
  2. * See LICENSE file for license details.
  3. *
  4. * dynamic window manager is designed like any other X client as well. It is
  5. * driven through handling X events. In contrast to other X clients, a window
  6. * manager selects for SubstructureRedirectMask on the root window, to receive
  7. * events about window (dis-)appearance. Only one X connection at a time is
  8. * allowed to select for this event mask.
  9. *
  10. * Calls to fetch an X event from the event queue are blocking. Due reading
  11. * status text from standard input, a select()-driven main loop has been
  12. * implemented which selects for reads on the X connection and STDIN_FILENO to
  13. * handle all data smoothly. The event handlers of dwm are organized in an
  14. * array which is accessed whenever a new event has been fetched. This allows
  15. * event dispatching in O(1) time.
  16. *
  17. * Each child of the root window is called a client, except windows which have
  18. * set the override_redirect flag. Clients are organized in a global
  19. * doubly-linked client list, the focus history is remembered through a global
  20. * stack list. Each client contains an array of Bools of the same size as the
  21. * global tags array to indicate the tags of a client. For each client dwm
  22. * creates a small title window, which is resized whenever the (_NET_)WM_NAME
  23. * properties are updated or the client is moved/resized.
  24. *
  25. * Keys and tagging rules are organized as arrays and defined in the config.h
  26. * file. These arrays are kept static in event.o and tag.o respectively,
  27. * because no other part of dwm needs access to them. The current layout is
  28. * represented by the lt pointer.
  29. *
  30. * To understand everything else, start reading main.c:main().
  31. */
  32. #include "config.h"
  33. #include <X11/Xlib.h>
  34. /* mask shorthands, used in event.c and client.c */
  35. #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
  36. enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
  37. enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
  38. enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
  39. enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
  40. typedef struct {
  41. int ascent;
  42. int descent;
  43. int height;
  44. XFontSet set;
  45. XFontStruct *xfont;
  46. } Fnt;
  47. typedef struct {
  48. int x, y, w, h;
  49. unsigned long norm[ColLast];
  50. unsigned long sel[ColLast];
  51. Drawable drawable;
  52. Fnt font;
  53. GC gc;
  54. } DC; /* draw context */
  55. typedef struct Client Client;
  56. struct Client {
  57. char name[256];
  58. int x, y, w, h;
  59. int rx, ry, rw, rh; /* revert geometry */
  60. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  61. int minax, minay, maxax, maxay;
  62. long flags;
  63. unsigned int border;
  64. Bool isbanned, isfixed, ismax, isversatile;
  65. Bool *tags;
  66. Client *next;
  67. Client *prev;
  68. Client *snext;
  69. Window win;
  70. };
  71. typedef struct {
  72. const char *symbol;
  73. void (*arrange)(void);
  74. } Layout;
  75. extern const char *tags[]; /* all tags */
  76. extern char stext[256]; /* status text */
  77. extern int screen, sx, sy, sw, sh; /* screen geometry */
  78. extern int wax, way, wah, waw; /* windowarea geometry */
  79. extern unsigned int bh, blw; /* bar height, bar layout label width */
  80. extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
  81. extern void (*handler[LASTEvent])(XEvent *); /* event handler */
  82. extern Atom wmatom[WMLast], netatom[NetLast];
  83. extern Bool selscreen, *seltag; /* seltag is array of Bool */
  84. extern Client *clients, *sel, *stack; /* global client list and stack */
  85. extern Cursor cursor[CurLast];
  86. extern DC dc; /* global draw context */
  87. extern Display *dpy;
  88. extern Layout *lt;
  89. extern Window root, barwin;
  90. /* client.c */
  91. extern void attach(Client *c); /* attaches c to global client list */
  92. extern void configure(Client *c); /* send synthetic configure event */
  93. extern void detach(Client *c); /* detaches c from global client list */
  94. extern void focus(Client *c); /* focus c, c may be NULL */
  95. extern void killclient(const char *arg); /* kill c nicely */
  96. extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
  97. extern void resize(Client *c, int x, int y,
  98. int w, int h, Bool sizehints); /* resize with given coordinates c*/
  99. extern void toggleversatile(const char *arg); /* toggles focused client between versatile/and non-versatile state */
  100. extern void updatesizehints(Client *c); /* update the size hint variables of c */
  101. extern void updatetitle(Client *c); /* update the name of c */
  102. extern void unmanage(Client *c); /* destroy c */
  103. /* draw.c */
  104. extern void drawstatus(void); /* draw the bar */
  105. extern void drawtext(const char *text, unsigned long col[ColLast]); /* draw text */
  106. extern unsigned int textw(const char *text); /* return the width of text in px*/
  107. /* event.c */
  108. extern void grabkeys(void); /* grab all keys defined in config.h */
  109. /* layout.c */
  110. extern void focusnext(const char *arg); /* focuses next visible client, arg is ignored */
  111. extern void focusprev(const char *arg); /* focuses previous visible client, arg is ignored */
  112. extern void incmasterw(const char *arg); /* increments the master width with arg's index value */
  113. extern void incnmaster(const char *arg); /* increments nmaster with arg's index value */
  114. extern void initlayouts(void); /* initialize layout array */
  115. extern Client *nexttiled(Client *c); /* returns tiled successor of c */
  116. extern void restack(void); /* restores z layers of all clients */
  117. extern void setlayout(const char *arg); /* sets layout, -1 toggles */
  118. extern void togglemax(const char *arg); /* toggles maximization of versatile client */
  119. extern void versatile(void); /* arranges all windows versatile */
  120. extern void zoom(const char *arg); /* zooms the focused client to master area, arg is ignored */
  121. /* main.c */
  122. extern void quit(const char *arg); /* quit dwm nicely */
  123. extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
  124. extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
  125. /* tag.c */
  126. extern void compileregs(void); /* initialize regexps of rules defined in config.h */
  127. extern Bool isvisible(Client *c); /* returns True if client is visible */
  128. extern void settags(Client *c, Client *trans); /* sets tags of c */
  129. extern void tag(const char *arg); /* tags c with arg's index */
  130. extern void toggletag(const char *arg); /* toggles c tags with arg's index */
  131. extern void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */
  132. extern void view(const char *arg); /* views the tag with arg's index */
  133. /* util.c */
  134. extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
  135. extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
  136. extern void spawn(const char *arg); /* forks a new subprocess with arg's cmd */