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.

147 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
  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include <X11/Xlib.h>
  6. /********** CUSTOMIZE **********/
  7. #define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
  8. #define BGCOLOR "DarkSlateGrey"
  9. #define FGCOLOR "LightSteelBlue"
  10. #define BORDERCOLOR "SlateGray"
  11. #define WM_PROTOCOL_DELWIN 1
  12. /* tags */
  13. enum { Tscratch, Tdev, Tirc, Twww, Twork, TLast };
  14. /********** CUSTOMIZE **********/
  15. typedef struct DC DC;
  16. typedef struct Client Client;
  17. typedef struct Fnt Fnt;
  18. typedef struct Key Key;
  19. typedef union Arg Arg;
  20. union Arg {
  21. const char **argv;
  22. int i;
  23. };
  24. /* atoms */
  25. enum { WMProtocols, WMDelete, WMLast };
  26. enum { NetSupported, NetWMName, NetLast };
  27. /* cursor */
  28. enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
  29. struct Fnt {
  30. XFontStruct *xfont;
  31. XFontSet set;
  32. int ascent;
  33. int descent;
  34. int height;
  35. };
  36. struct DC { /* draw context */
  37. GC gc;
  38. Drawable drawable;
  39. int x, y, w, h;
  40. Fnt font;
  41. unsigned long bg;
  42. unsigned long fg;
  43. unsigned long border;
  44. };
  45. struct Client {
  46. char name[256];
  47. char *tags[TLast];
  48. int proto;
  49. int x, y, w, h;
  50. int tx, ty, tw, th;
  51. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  52. int grav;
  53. unsigned int border;
  54. long flags;
  55. Window win;
  56. Window trans;
  57. Window title;
  58. Client *next;
  59. Client *revert;
  60. };
  61. struct Key {
  62. unsigned long mod;
  63. KeySym keysym;
  64. void (*func)(Arg *arg);
  65. Arg arg;
  66. };
  67. extern Display *dpy;
  68. extern Window root;
  69. extern Atom wm_atom[WMLast], net_atom[NetLast];
  70. extern Cursor cursor[CurLast];
  71. extern Bool running, issel;
  72. extern void (*handler[LASTEvent]) (XEvent *);
  73. extern int tsel, screen, sx, sy, sw, sh, th;
  74. extern char stext[1024], *tags[TLast];
  75. extern DC dc;
  76. extern Client *clients, *sel;
  77. /* client.c */
  78. extern void manage(Window w, XWindowAttributes *wa);
  79. extern void unmanage(Client *c);
  80. extern Client *getclient(Window w);
  81. extern void focus(Client *c);
  82. extern void update_name(Client *c);
  83. extern void draw_client(Client *c);
  84. extern void resize(Client *c);
  85. extern void update_size(Client *c);
  86. extern Client *gettitle(Window w);
  87. extern void craise(Client *c);
  88. extern void lower(Client *c);
  89. extern void ckill(Arg *arg);
  90. extern void nextc(Arg *arg);
  91. extern void prevc(Arg *arg);
  92. extern void max(Arg *arg);
  93. extern void floating(Arg *arg);
  94. extern void tiling(Arg *arg);
  95. extern void tag(Arg *arg);
  96. extern void view(Arg *arg);
  97. extern void zoom(Arg *arg);
  98. extern void gravitate(Client *c, Bool invert);
  99. /* draw.c */
  100. extern void draw(Bool border, const char *text);
  101. extern unsigned long initcolor(const char *colstr);
  102. extern void initfont(const char *fontstr);
  103. extern unsigned int textnw(char *text, unsigned int len);
  104. extern unsigned int textw(char *text);
  105. extern unsigned int texth(void);
  106. /* event.c */
  107. extern void discard_events(long even_mask);
  108. /* dev.c */
  109. extern void update_keys(void);
  110. extern void keypress(XEvent *e);
  111. extern void mresize(Client *c);
  112. extern void mmove(Client *c);
  113. /* main.c */
  114. extern int error_handler(Display *dsply, XErrorEvent *e);
  115. extern void send_message(Window w, Atom a, long value);
  116. extern int win_proto(Window w);
  117. extern void quit(Arg *arg);
  118. /* util.c */
  119. extern void error(const char *errstr, ...);
  120. extern void *emallocz(unsigned int size);
  121. extern void *emalloc(unsigned int size);
  122. extern void *erealloc(void *ptr, unsigned int size);
  123. extern char *estrdup(const char *str);
  124. extern void spawn(Arg *arg);
  125. extern void swap(void **p1, void **p2);