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