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.

179 lines
7.9 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. *
  5. * dynamic window manager is designed like any other X client as well. It is
  6. * driven through handling X events. In contrast to other X clients, a window
  7. * manager like dwm selects for SubstructureRedirectMask on the root window, to
  8. * receive events about child window appearance and disappearance. Only one X
  9. * connection at a time is allowed to select for this event mask by any X
  10. * server, thus only one window manager instance can be executed at a time.
  11. * Any attempt to select for SubstructureRedirectMask by any connection after
  12. * another connection already selected for those events, will result in an
  13. * error generated by the server. Such errors are reported through calling the
  14. * current X error handler.
  15. *
  16. * Calls to pop an X event from the event queue of the X connection are
  17. * blocking. Due the fact, that dwm reads status text from standard input, a
  18. * select-driven main loop has been implemented which selects for reads on the
  19. * X connection and STDIN_FILENO to handle all data smoothly and without
  20. * busy-loop quirks.. The event handlers of dwm are organized in an array
  21. * which is accessed whenever a new event has been popped. This allows event
  22. * dispatching in O(1) time.
  23. *
  24. * Each child window of the root window is called a client in window manager
  25. * terminology, except windows which have set the override_redirect flag.
  26. * Clients are organized in a global doubly-linked client list, the focus
  27. * history is remembered through a global stack list. Each client contains an
  28. * array of Bools of the same size as the global tags array to indicate the
  29. * tags of a client. There are no other data structures to organize the clients
  30. * in tag lists, because a single global list is most simple. All clients which
  31. * have at least one tag enabled of the current tags viewed, will be visible on
  32. * the screen, all other clients are banned to the x-location 2 * screen width.
  33. * This avoids having additional layers of workspace handling.
  34. *
  35. * For each client dwm creates a small title window which is resized whenever
  36. * the WM_NAME or _NET_WM_NAME properties are updated.
  37. *
  38. * Keys and tagging rules are organized as arrays as well and defined in the
  39. * config.h file. These arrays are kept static in event.o and tag.o
  40. * respectively, because no other part of dwm needs access to them.
  41. *
  42. * The current mode is represented by the arrange function pointer which wether
  43. * points to dofloat or dotile.
  44. */
  45. #include "config.h"
  46. #include <X11/Xlib.h>
  47. /* mask shorthands, used in event.c and client.c */
  48. #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
  49. #define MOUSEMASK (BUTTONMASK | PointerMotionMask)
  50. #define PROTODELWIN 1
  51. enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
  52. enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
  53. enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
  54. enum { ColFG, ColBG, ColLast }; /* color */
  55. typedef enum {
  56. TopLeft, TopRight, BotLeft, BotRight
  57. } Corner; /* window corners */
  58. typedef union {
  59. const char *cmd;
  60. int i;
  61. } Arg; /* argument type */
  62. typedef struct {
  63. int ascent;
  64. int descent;
  65. int height;
  66. XFontSet set;
  67. XFontStruct *xfont;
  68. } Fnt;
  69. typedef struct {
  70. int x, y, w, h;
  71. unsigned long norm[ColLast];
  72. unsigned long sel[ColLast];
  73. unsigned long status[ColLast];
  74. Drawable drawable;
  75. Fnt font;
  76. GC gc;
  77. } DC; /* draw context */
  78. typedef struct Client Client;
  79. struct Client {
  80. char name[256];
  81. int proto;
  82. int x, y, w, h;
  83. int tx, ty, tw, th; /* title window geometry */
  84. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  85. int grav;
  86. long flags;
  87. unsigned int border, weight;
  88. Bool isfloat;
  89. Bool *tags;
  90. Client *next;
  91. Client *prev;
  92. Client *snext;
  93. Window win;
  94. Window twin;
  95. };
  96. extern const char *tags[]; /* all tags */
  97. extern char stext[1024]; /* status text */
  98. extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
  99. extern int mw, screen, sx, sy, sw, sh; /* screen geometry, master width */
  100. extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
  101. extern void (*handler[LASTEvent])(XEvent *); /* event handler */
  102. extern void (*arrange)(Arg *); /* arrange function, indicates mode */
  103. extern Atom wmatom[WMLast], netatom[NetLast];
  104. extern Bool running, issel, maximized, *seltag; /* seltag is array of Bool */
  105. extern Client *clients, *sel, *stack; /* global cleint list and stack */
  106. extern Cursor cursor[CurLast];
  107. extern DC dc; /* global draw context */
  108. extern Display *dpy;
  109. extern Window root, barwin;
  110. /* client.c */
  111. extern void ban(Client *c); /* ban c from screen */
  112. extern void focus(Client *c); /* focus c, c may be NULL */
  113. extern Client *getclient(Window w); /* return client of w */
  114. extern Client *getctitle(Window w); /* return client of title window */
  115. extern void gravitate(Client *c, Bool invert); /* gravitate c */
  116. extern void killclient(Arg *arg); /* kill c nicely */
  117. extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
  118. extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
  119. extern void updatesize(Client *c); /* update the size structs of c */
  120. extern void updatetitle(Client *c); /* update the name of c */
  121. extern void togglemax(Arg *arg); /* (un)maximize c */
  122. extern void unmanage(Client *c); /* destroy c */
  123. /* draw.c */
  124. extern void drawall(); /* draw all visible client titles and the bar */
  125. extern void drawstatus(); /* draw the bar */
  126. extern void drawtitle(Client *c); /* draw title of c */
  127. extern unsigned long getcolor(const char *colstr); /* return color of colstr */
  128. extern void setfont(const char *fontstr); /* set the font for DC */
  129. extern unsigned int textw(const char *text); /* return the width of text in px*/
  130. /* event.c */
  131. extern void grabkeys(); /* grab all keys defined in config.h */
  132. extern void procevent(); /* process pending X events */
  133. /* main.c */
  134. extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
  135. extern void quit(Arg *arg); /* quit dwm nicely */
  136. extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
  137. extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
  138. /* tag.c */
  139. extern void initrregs(); /* initialize regexps of rules defined in config.h */
  140. extern Client *getnext(Client *c); /* returns next visible client */
  141. extern Client *getprev(Client *c); /* returns previous visible client */
  142. extern void settags(Client *c, Client *trans); /* sets tags of c */
  143. extern void tag(Arg *arg); /* tags c with arg's index */
  144. extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
  145. /* util.c */
  146. extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
  147. extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
  148. extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */
  149. extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
  150. /* view.c */
  151. extern void detach(Client *c); /* detaches c from global client list */
  152. extern void dofloat(Arg *arg); /* arranges all windows floating, arg is ignored */
  153. extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */
  154. extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
  155. extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
  156. extern Bool isvisible(Client *c); /* returns True if client is visible */
  157. extern void resizecol(Arg *arg); /* resizes the master width with arg's index value */
  158. extern void restack(); /* restores z layers of all clients */
  159. extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
  160. extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
  161. extern void view(Arg *arg); /* views the tag with arg's index */
  162. extern void viewall(Arg *arg); /* views all tags, arg is ignored */
  163. extern void zoom(Arg *arg); /* zooms the focused client to master column, arg is ignored */