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.

138 lines
3.3 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 Arg Arg;
  12. typedef struct Client Client;
  13. typedef struct DC DC;
  14. typedef struct Fnt Fnt;
  15. union Arg {
  16. const char *cmd;
  17. int i;
  18. };
  19. /* atoms */
  20. enum { NetSupported, NetWMName, NetLast };
  21. enum { WMProtocols, WMDelete, WMLast };
  22. /* cursor */
  23. enum { CurNormal, CurResize, CurMove, CurLast };
  24. /* windowcorners */
  25. typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
  26. struct Fnt {
  27. int ascent;
  28. int descent;
  29. int height;
  30. XFontSet set;
  31. XFontStruct *xfont;
  32. };
  33. struct DC { /* draw context */
  34. int x, y, w, h;
  35. unsigned long bg;
  36. unsigned long fg;
  37. unsigned long border;
  38. Drawable drawable;
  39. Fnt font;
  40. GC gc;
  41. };
  42. struct Client {
  43. char name[256];
  44. int proto;
  45. int x, y, w, h;
  46. int tx, ty, tw, th; /* title */
  47. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  48. int grav;
  49. long flags;
  50. unsigned int border;
  51. Bool isfloat;
  52. Bool ismax;
  53. Bool *tags;
  54. Client *next;
  55. Client *prev;
  56. Window win;
  57. Window title;
  58. };
  59. extern const char *tags[];
  60. extern char stext[1024];
  61. extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
  62. extern unsigned int ntags;
  63. extern void (*handler[LASTEvent])(XEvent *);
  64. extern void (*arrange)(Arg *);
  65. extern Atom wmatom[WMLast], netatom[NetLast];
  66. extern Bool running, issel, *seltag;
  67. extern Client *clients, *sel;
  68. extern Cursor cursor[CurLast];
  69. extern DC dc;
  70. extern Display *dpy;
  71. extern Window root, barwin;
  72. /* client.c */
  73. extern void ban(Client *c);
  74. extern void focus(Client *c);
  75. extern void focusnext(Arg *arg);
  76. extern void focusprev(Arg *arg);
  77. extern Client *getclient(Window w);
  78. extern Client *getctitle(Window w);
  79. extern void gravitate(Client *c, Bool invert);
  80. extern void killclient(Arg *arg);
  81. extern void manage(Window w, XWindowAttributes *wa);
  82. extern void resize(Client *c, Bool sizehints, Corner sticky);
  83. extern void setsize(Client *c);
  84. extern void settitle(Client *c);
  85. extern void togglemax(Arg *arg);
  86. extern void unmanage(Client *c);
  87. extern void zoom(Arg *arg);
  88. /* draw.c */
  89. extern void drawall();
  90. extern void drawstatus();
  91. extern void drawtitle(Client *c);
  92. extern unsigned long getcolor(const char *colstr);
  93. extern void setfont(const char *fontstr);
  94. extern unsigned int textw(const char *text);
  95. /* event.c */
  96. extern void grabkeys();
  97. extern void ungrabkeys();
  98. /* main.c */
  99. extern int getproto(Window w);
  100. extern void quit(Arg *arg);
  101. extern void sendevent(Window w, Atom a, long value);
  102. extern int xerror(Display *dsply, XErrorEvent *ee);
  103. /* tag.c */
  104. extern void appendtag(Arg *arg);
  105. extern void dofloat(Arg *arg);
  106. extern void dotile(Arg *arg);
  107. extern void initrregs();
  108. extern Bool isvisible(Client *c);
  109. extern Client *getnext(Client *c);
  110. extern Client *getprev(Client *c);
  111. extern void replacetag(Arg *arg);
  112. extern void restack();
  113. extern void settags(Client *c);
  114. extern void togglemode(Arg *arg);
  115. extern void view(Arg *arg);
  116. extern void toggleview(Arg *arg);
  117. /* util.c */
  118. extern void *emallocz(unsigned int size);
  119. extern void eprint(const char *errstr, ...);
  120. extern void *erealloc(void *ptr, unsigned int size);
  121. extern void spawn(Arg *arg);