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.

141 lines
3.4 KiB

19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
19 years ago
  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include "config.h"
  6. #include <X11/Xlib.h>
  7. /* mask shorthands, used in event.c and client.c */
  8. #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
  9. #define MOUSEMASK (BUTTONMASK | PointerMotionMask)
  10. #define PROTODELWIN 1
  11. typedef union {
  12. const char *cmd;
  13. int i;
  14. } Arg;
  15. /* atoms */
  16. enum { NetSupported, NetWMName, NetLast };
  17. enum { WMProtocols, WMDelete, WMLast };
  18. /* cursor */
  19. enum { CurNormal, CurResize, CurMove, CurLast };
  20. /* color */
  21. enum { ColFG, ColBG, ColLast };
  22. /* window corners */
  23. typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
  24. typedef struct {
  25. int ascent;
  26. int descent;
  27. int height;
  28. XFontSet set;
  29. XFontStruct *xfont;
  30. } Fnt;
  31. typedef struct { /* draw context */
  32. int x, y, w, h;
  33. unsigned long norm[ColLast];
  34. unsigned long sel[ColLast];
  35. unsigned long status[ColLast];
  36. Drawable drawable;
  37. Fnt font;
  38. GC gc;
  39. } DC;
  40. typedef struct Client Client;
  41. struct Client {
  42. char name[256];
  43. int proto;
  44. int x, y, w, h;
  45. int tx, ty, tw, th; /* title */
  46. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  47. int grav;
  48. long flags;
  49. unsigned int border, weight;
  50. Bool isfloat;
  51. Bool *tags;
  52. Client *next;
  53. Client *prev;
  54. Window win;
  55. Window twin;
  56. };
  57. extern const char *tags[];
  58. extern char stext[1024];
  59. extern int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
  60. extern unsigned int ntags, numlockmask;
  61. extern void (*handler[LASTEvent])(XEvent *);
  62. extern void (*arrange)(Arg *);
  63. extern Atom wmatom[WMLast], netatom[NetLast];
  64. extern Bool running, issel, maximized, *seltag;
  65. extern Client *clients, *sel;
  66. extern Cursor cursor[CurLast];
  67. extern DC dc;
  68. extern Display *dpy;
  69. extern Window root, barwin;
  70. /* client.c */
  71. extern void ban(Client *c);
  72. extern void focus(Client *c);
  73. extern Client *getclient(Window w);
  74. extern Client *getctitle(Window w);
  75. extern void gravitate(Client *c, Bool invert);
  76. extern void killclient(Arg *arg);
  77. extern void manage(Window w, XWindowAttributes *wa);
  78. extern void resize(Client *c, Bool sizehints, Corner sticky);
  79. extern void setsize(Client *c);
  80. extern void settitle(Client *c);
  81. extern void togglemax(Arg *arg);
  82. extern void unmanage(Client *c);
  83. /* draw.c */
  84. extern void drawall();
  85. extern void drawstatus();
  86. extern void drawtitle(Client *c);
  87. extern unsigned long getcolor(const char *colstr);
  88. extern void setfont(const char *fontstr);
  89. extern unsigned int textw(const char *text);
  90. /* event.c */
  91. extern void grabkeys();
  92. extern void procevent();
  93. /* main.c */
  94. extern int getproto(Window w);
  95. extern void quit(Arg *arg);
  96. extern void sendevent(Window w, Atom a, long value);
  97. extern int xerror(Display *dsply, XErrorEvent *ee);
  98. /* tag.c */
  99. extern void initrregs();
  100. extern Client *getnext(Client *c);
  101. extern Client *getprev(Client *c);
  102. extern void settags(Client *c);
  103. extern void tag(Arg *arg);
  104. extern void toggletag(Arg *arg);
  105. /* util.c */
  106. extern void *emallocz(unsigned int size);
  107. extern void eprint(const char *errstr, ...);
  108. extern void *erealloc(void *ptr, unsigned int size);
  109. extern void spawn(Arg *arg);
  110. /* view.c */
  111. extern void detach(Client *c);
  112. extern void dofloat(Arg *arg);
  113. extern void dotile(Arg *arg);
  114. extern void focusnext(Arg *arg);
  115. extern void focusprev(Arg *arg);
  116. extern void growcol(Arg *arg);
  117. extern Bool isvisible(Client *c);
  118. extern void restack();
  119. extern void togglemode(Arg *arg);
  120. extern void toggleview(Arg *arg);
  121. extern void view(Arg *arg);
  122. extern void viewall(Arg *arg);
  123. extern void zoom(Arg *arg);