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.

137 lines
3.2 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 <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. /* atoms */
  20. enum { WMProtocols, WMDelete, WMLast };
  21. enum { NetSupported, NetWMName, NetLast };
  22. /* cursor */
  23. enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
  24. struct Fnt {
  25. XFontStruct *xfont;
  26. XFontSet set;
  27. int ascent;
  28. int descent;
  29. int height;
  30. };
  31. struct DC { /* draw context */
  32. GC gc;
  33. Drawable drawable;
  34. int x, y, w, h;
  35. Fnt font;
  36. unsigned long bg;
  37. unsigned long fg;
  38. unsigned long border;
  39. };
  40. struct Client {
  41. char name[256];
  42. char *tags[TLast];
  43. int proto;
  44. int x, y, w, h;
  45. int tx, ty, tw, th;
  46. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  47. int grav;
  48. unsigned int border;
  49. long flags;
  50. Window win;
  51. Window trans;
  52. Window title;
  53. Client *next;
  54. Client *snext;
  55. };
  56. struct Key {
  57. unsigned long mod;
  58. KeySym keysym;
  59. void (*func)(void *aux);
  60. void *aux;
  61. };
  62. extern Display *dpy;
  63. extern Window root;
  64. extern Atom wm_atom[WMLast], net_atom[NetLast];
  65. extern Cursor cursor[CurLast];
  66. extern Bool running, issel;
  67. extern void (*handler[LASTEvent]) (XEvent *);
  68. extern int tsel, screen, sx, sy, sw, sh, th;
  69. extern char stext[1024], *tags[TLast];
  70. extern DC dc;
  71. extern Client *clients, *stack;
  72. /* client.c */
  73. extern void manage(Window w, XWindowAttributes *wa);
  74. extern void unmanage(Client *c);
  75. extern Client *getclient(Window w);
  76. extern void focus(Client *c);
  77. extern void update_name(Client *c);
  78. extern void draw_client(Client *c);
  79. extern void resize(Client *c);
  80. extern void update_size(Client *c);
  81. extern Client *gettitle(Window w);
  82. extern void craise(Client *c);
  83. extern void lower(Client *c);
  84. extern void ckill(void *aux);
  85. extern void sel(void *aux);
  86. extern void max(void *aux);
  87. extern void floating(void *aux);
  88. extern void tiling(void *aux);
  89. extern void gravitate(Client *c, Bool invert);
  90. /* draw.c */
  91. extern void draw(Bool border, const char *text);
  92. extern unsigned long initcolor(const char *colstr);
  93. extern void initfont(const char *fontstr);
  94. extern unsigned int textnw(char *text, unsigned int len);
  95. extern unsigned int textw(char *text);
  96. extern unsigned int texth(void);
  97. /* event.c */
  98. extern void discard_events(long even_mask);
  99. /* dev.c */
  100. extern void update_keys(void);
  101. extern void keypress(XEvent *e);
  102. extern void mresize(Client *c);
  103. extern void mmove(Client *c);
  104. /* main.c */
  105. extern int error_handler(Display *dsply, XErrorEvent *e);
  106. extern void send_message(Window w, Atom a, long value);
  107. extern int win_proto(Window w);
  108. extern void quit(void *aux);
  109. /* util.c */
  110. extern void error(const char *errstr, ...);
  111. extern void *emallocz(unsigned int size);
  112. extern void *emalloc(unsigned int size);
  113. extern void *erealloc(void *ptr, unsigned int size);
  114. extern char *estrdup(const char *str);
  115. extern void spawn(char *argv[]);
  116. extern void swap(void **p1, void **p2);