dwm.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef __DWM__
  2. #define __DWM__
  3. #include <errno.h>
  4. #include <locale.h>
  5. #include <stdarg.h>
  6. #include <signal.h>
  7. #include <stdbool.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <unistd.h>
  12. #include <sys/types.h>
  13. #include <sys/wait.h>
  14. #include <X11/cursorfont.h>
  15. #include <X11/keysym.h>
  16. #include <X11/Xatom.h>
  17. #include <X11/Xlib.h>
  18. #include <X11/Xproto.h>
  19. #include <X11/Xutil.h>
  20. #ifdef XINERAMA
  21. #include <X11/extensions/Xinerama.h>
  22. #endif /* XINERAMA */
  23. #include <X11/Xft/Xft.h>
  24. #include "drw.h"
  25. #include "util.h"
  26. /* macros */
  27. #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
  28. #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
  29. #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
  30. * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
  31. #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
  32. #define LENGTH(X) (sizeof X / sizeof X[0])
  33. #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
  34. #define WIDTH(X) ((X)->w + 2 * (X)->bw)
  35. #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
  36. #define TAGMASK ((1 << LENGTH(tags)) - 1)
  37. #define TEXTW(X) (drw_text(drw, 0, 0, 0, 0, (X), 0) + drw->fonts[0]->h)
  38. /* enums */
  39. enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
  40. enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */
  41. enum { NetSupported, NetWMName, NetWMState,
  42. NetWMFullscreen, NetActiveWindow, NetWMWindowType,
  43. NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
  44. enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
  45. enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
  46. ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
  47. typedef union {
  48. int i;
  49. unsigned int ui;
  50. float f;
  51. const void *v;
  52. } Arg;
  53. typedef struct {
  54. unsigned int click;
  55. unsigned int mask;
  56. unsigned int button;
  57. void (*func)(const Arg *arg);
  58. const Arg arg;
  59. } Button;
  60. typedef struct Monitor Monitor;
  61. typedef struct Client Client;
  62. struct Client {
  63. char name[256];
  64. float mina, maxa;
  65. int x, y, w, h;
  66. int oldx, oldy, oldw, oldh;
  67. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  68. int bw, oldbw;
  69. unsigned int tags;
  70. bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
  71. Client *next;
  72. Client *snext;
  73. Monitor *mon;
  74. Window win;
  75. };
  76. typedef struct {
  77. unsigned int mod;
  78. KeySym keysym;
  79. void (*func)(const Arg *);
  80. const Arg arg;
  81. } Key;
  82. typedef struct {
  83. const char *symbol;
  84. void (*arrange)(Monitor *);
  85. } Layout;
  86. typedef struct Pertag Pertag;
  87. struct Monitor {
  88. char ltsymbol[16];
  89. float mfact;
  90. int nmaster;
  91. int num;
  92. int by; /* bar geometry */
  93. int mx, my, mw, mh; /* screen size */
  94. int wx, wy, ww, wh; /* window area */
  95. unsigned int seltags;
  96. unsigned int sellt;
  97. unsigned int tagset[2];
  98. bool showbar;
  99. bool topbar;
  100. Client *clients;
  101. Client *sel;
  102. Client *stack;
  103. Monitor *next;
  104. Window barwin;
  105. const Layout *lt[2];
  106. Pertag *pertag;
  107. };
  108. typedef struct {
  109. const char *class;
  110. const char *instance;
  111. const char *title;
  112. unsigned int tags;
  113. bool isfloating;
  114. int monitor;
  115. } Rule;
  116. Monitor *selmon;
  117. void focus(Client *c);
  118. void arrange(Monitor* m);
  119. #endif