diff options
Diffstat (limited to 'src/core/dwm.h')
| -rw-r--r-- | src/core/dwm.h | 268 |
1 files changed, 268 insertions, 0 deletions
diff --git a/src/core/dwm.h b/src/core/dwm.h new file mode 100644 index 0000000..68eaf93 --- /dev/null +++ b/src/core/dwm.h | |||
| @@ -0,0 +1,268 @@ | |||
| 1 | /* enums */ | ||
| 2 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | ||
| 3 | enum { SchemeNorm, SchemeSel }; /* color schemes */ | ||
| 4 | enum { | ||
| 5 | NetSupported, | ||
| 6 | NetWMName, | ||
| 7 | NetWMState, | ||
| 8 | NetWMCheck, | ||
| 9 | NetSystemTray, | ||
| 10 | NetSystemTrayOP, | ||
| 11 | NetSystemTrayOrientation, | ||
| 12 | NetSystemTrayOrientationHorz, | ||
| 13 | NetWMFullscreen, | ||
| 14 | NetActiveWindow, | ||
| 15 | NetWMWindowType, | ||
| 16 | NetWMWindowTypeDialog, | ||
| 17 | NetClientList, | ||
| 18 | NetLast | ||
| 19 | }; /* EWMH atoms */ | ||
| 20 | enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */ | ||
| 21 | enum { | ||
| 22 | WMProtocols, | ||
| 23 | WMDelete, | ||
| 24 | WMState, | ||
| 25 | WMTakeFocus, | ||
| 26 | WMLast | ||
| 27 | }; /* default atoms */ | ||
| 28 | enum { | ||
| 29 | ClkTagBar, | ||
| 30 | ClkLtSymbol, | ||
| 31 | ClkStatusText, | ||
| 32 | ClkWinTitle, | ||
| 33 | ClkClientWin, | ||
| 34 | ClkRootWin, | ||
| 35 | ClkLast | ||
| 36 | }; /* clicks */ | ||
| 37 | |||
| 38 | typedef union { | ||
| 39 | int i; | ||
| 40 | unsigned int ui; | ||
| 41 | float f; | ||
| 42 | const void *v; | ||
| 43 | } Arg; | ||
| 44 | |||
| 45 | typedef struct { | ||
| 46 | unsigned int click; | ||
| 47 | unsigned int mask; | ||
| 48 | unsigned int button; | ||
| 49 | void (*func)(const Arg *arg); | ||
| 50 | const Arg arg; | ||
| 51 | } Button; | ||
| 52 | |||
| 53 | typedef struct Monitor Monitor; | ||
| 54 | typedef struct Client Client; | ||
| 55 | struct Client { | ||
| 56 | char name[256]; | ||
| 57 | float mina, maxa; | ||
| 58 | int x, y, w, h; | ||
| 59 | int oldx, oldy, oldw, oldh; | ||
| 60 | int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; | ||
| 61 | int bw, oldbw; | ||
| 62 | unsigned int tags; | ||
| 63 | int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, | ||
| 64 | isterminal, noswallow; | ||
| 65 | pid_t pid; | ||
| 66 | Client *next; | ||
| 67 | Client *snext; | ||
| 68 | Client *swallowing; | ||
| 69 | Monitor *mon; | ||
| 70 | Window win; | ||
| 71 | }; | ||
| 72 | |||
| 73 | typedef struct { | ||
| 74 | unsigned int mod; | ||
| 75 | KeySym keysym; | ||
| 76 | void (*func)(const Arg *); | ||
| 77 | const Arg arg; | ||
| 78 | } Key; | ||
| 79 | |||
| 80 | typedef struct { | ||
| 81 | const char *symbol; | ||
| 82 | void (*arrange)(Monitor *); | ||
| 83 | } Layout; | ||
| 84 | |||
| 85 | struct Monitor { | ||
| 86 | char ltsymbol[16]; | ||
| 87 | float mfact; | ||
| 88 | int nmaster; | ||
| 89 | int num; | ||
| 90 | int by; /* bar geometry */ | ||
| 91 | int mx, my, mw, mh; /* screen size */ | ||
| 92 | int wx, wy, ww, wh; /* window area */ | ||
| 93 | int gappih; /* horizontal gap between windows */ | ||
| 94 | int gappiv; /* vertical gap between windows */ | ||
| 95 | int gappoh; /* horizontal outer gaps */ | ||
| 96 | int gappov; /* vertical outer gaps */ | ||
| 97 | unsigned int seltags; | ||
| 98 | unsigned int sellt; | ||
| 99 | unsigned int tagset[2]; | ||
| 100 | int showbar; | ||
| 101 | int topbar; | ||
| 102 | Client *clients; | ||
| 103 | Client *sel; | ||
| 104 | Client *stack; | ||
| 105 | Monitor *next; | ||
| 106 | Window barwin; | ||
| 107 | const Layout *lt[2]; | ||
| 108 | }; | ||
| 109 | |||
| 110 | typedef struct { | ||
| 111 | const char *class; | ||
| 112 | const char *instance; | ||
| 113 | const char *title; | ||
| 114 | unsigned int tags; | ||
| 115 | int isfloating; | ||
| 116 | int isterminal; | ||
| 117 | int noswallow; | ||
| 118 | int monitor; | ||
| 119 | } Rule; | ||
| 120 | |||
| 121 | typedef struct Systray Systray; | ||
| 122 | struct Systray { | ||
| 123 | Window win; | ||
| 124 | Client *icons; | ||
| 125 | }; | ||
| 126 | |||
| 127 | /* function declarations */ | ||
| 128 | static void applyrules(Client *c); | ||
| 129 | static int applysizehints(Client *c, int *x, int *y, int *w, int *h, | ||
| 130 | int interact); | ||
| 131 | static void arrange(Monitor *m); | ||
| 132 | static void arrangemon(Monitor *m); | ||
| 133 | static void attach(Client *c); | ||
| 134 | static void attachstack(Client *c); | ||
| 135 | static void buttonpress(XEvent *e); | ||
| 136 | static void checkotherwm(void); | ||
| 137 | static void cleanup(void); | ||
| 138 | static void cleanupmon(Monitor *mon); | ||
| 139 | static void clientmessage(XEvent *e); | ||
| 140 | static void configure(Client *c); | ||
| 141 | static void configurenotify(XEvent *e); | ||
| 142 | static void configurerequest(XEvent *e); | ||
| 143 | static Monitor *createmon(void); | ||
| 144 | static void destroynotify(XEvent *e); | ||
| 145 | static void detach(Client *c); | ||
| 146 | static void detachstack(Client *c); | ||
| 147 | static void drawbar(Monitor *m); | ||
| 148 | static void drawbars(void); | ||
| 149 | static void enternotify(XEvent *e); | ||
| 150 | static void expose(XEvent *e); | ||
| 151 | static void focus(Client *c); | ||
| 152 | static void focusin(XEvent *e); | ||
| 153 | static Atom getatomprop(Client *c, Atom prop); | ||
| 154 | static int getrootptr(int *x, int *y); | ||
| 155 | static long getstate(Window w); | ||
| 156 | static unsigned int getsystraywidth(); | ||
| 157 | static int gettextprop(Window w, Atom atom, char *text, unsigned int size); | ||
| 158 | static void grabbuttons(Client *c, int focused); | ||
| 159 | static void grabkeys(void); | ||
| 160 | static void keypress(XEvent *e); | ||
| 161 | static void killclient(const Arg *arg); | ||
| 162 | static void manage(Window w, XWindowAttributes *wa); | ||
| 163 | static void mappingnotify(XEvent *e); | ||
| 164 | static void maprequest(XEvent *e); | ||
| 165 | static void motionnotify(XEvent *e); | ||
| 166 | static void movemouse(const Arg *arg); | ||
| 167 | static Client *nexttiled(Client *c); | ||
| 168 | static void pop(Client *c); | ||
| 169 | static void propertynotify(XEvent *e); | ||
| 170 | static void quit(const Arg *arg); | ||
| 171 | static Monitor *recttomon(int x, int y, int w, int h); | ||
| 172 | static void removesystrayicon(Client *i); | ||
| 173 | static void resize(Client *c, int x, int y, int w, int h, int interact); | ||
| 174 | static void resizebarwin(Monitor *m); | ||
| 175 | static void resizeclient(Client *c, int x, int y, int w, int h); | ||
| 176 | static void resizemouse(const Arg *arg); | ||
| 177 | static void resizerequest(XEvent *e); | ||
| 178 | static void restack(Monitor *m); | ||
| 179 | static void run(void); | ||
| 180 | static void scan(void); | ||
| 181 | static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, | ||
| 182 | long d3, long d4); | ||
| 183 | static void sendmon(Client *c, Monitor *m); | ||
| 184 | static void setclientstate(Client *c, long state); | ||
| 185 | static void setfocus(Client *c); | ||
| 186 | static void setfullscreen(Client *c, int fullscreen); | ||
| 187 | static void setlayout(const Arg *arg); | ||
| 188 | static void setup(void); | ||
| 189 | static void seturgent(Client *c, int urg); | ||
| 190 | static void showhide(Client *c); | ||
| 191 | static void spawn(const Arg *arg); | ||
| 192 | static Monitor *systraytomon(Monitor *m); | ||
| 193 | static void tag(const Arg *arg); | ||
| 194 | static void tile(Monitor *m); | ||
| 195 | static void togglebar(const Arg *arg); | ||
| 196 | static void togglefloating(const Arg *arg); | ||
| 197 | static void togglefullscr(const Arg *arg); | ||
| 198 | static void toggletag(const Arg *arg); | ||
| 199 | static void toggleview(const Arg *arg); | ||
| 200 | static void unfocus(Client *c, int setfocus); | ||
| 201 | static void unmanage(Client *c, int destroyed); | ||
| 202 | static void unmapnotify(XEvent *e); | ||
| 203 | static void updatebarpos(Monitor *m); | ||
| 204 | static void updatebars(void); | ||
| 205 | static void updateclientlist(void); | ||
| 206 | static int updategeom(void); | ||
| 207 | static void updatenumlockmask(void); | ||
| 208 | static void updatesystray(void); | ||
| 209 | static void updatesystrayicongeom(Client *i, int w, int h); | ||
| 210 | static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); | ||
| 211 | static void updatesizehints(Client *c); | ||
| 212 | static void updatestatus(void); | ||
| 213 | static void updatetitle(Client *c); | ||
| 214 | static void updatewindowtype(Client *c); | ||
| 215 | static void updatewmhints(Client *c); | ||
| 216 | static void view(const Arg *arg); | ||
| 217 | static Client *wintoclient(Window w); | ||
| 218 | static Monitor *wintomon(Window w); | ||
| 219 | static Client *wintosystrayicon(Window w); | ||
| 220 | static int xerror(Display *dpy, XErrorEvent *ee); | ||
| 221 | static int xerrordummy(Display *dpy, XErrorEvent *ee); | ||
| 222 | static int xerrorstart(Display *dpy, XErrorEvent *ee); | ||
| 223 | static void zoom(const Arg *arg); | ||
| 224 | |||
| 225 | static pid_t getparentprocess(pid_t p); | ||
| 226 | static int isdescprocess(pid_t p, pid_t c); | ||
| 227 | static Client *swallowingclient(Window w); | ||
| 228 | static Client *termforwin(const Client *c); | ||
| 229 | static pid_t winpid(Window w); | ||
| 230 | |||
| 231 | /* variables */ | ||
| 232 | static Systray *systray = NULL; | ||
| 233 | static const char broken[] = "broken"; | ||
| 234 | static char stext[256]; | ||
| 235 | static int screen; | ||
| 236 | static int sw, sh; /* X display screen geometry width, height */ | ||
| 237 | static int bh; /* bar height */ | ||
| 238 | static int enablegaps = 1; /* enables gaps, used by togglegaps */ | ||
| 239 | static int lrpad; /* sum of left and right padding for text */ | ||
| 240 | static int (*xerrorxlib)(Display *, XErrorEvent *); | ||
| 241 | static unsigned int numlockmask = 0; | ||
| 242 | static void (*handler[LASTEvent])(XEvent *) = { | ||
| 243 | [ButtonPress] = buttonpress, | ||
| 244 | [ClientMessage] = clientmessage, | ||
| 245 | [ConfigureRequest] = configurerequest, | ||
| 246 | [ConfigureNotify] = configurenotify, | ||
| 247 | [DestroyNotify] = destroynotify, | ||
| 248 | [EnterNotify] = enternotify, | ||
| 249 | [Expose] = expose, | ||
| 250 | [FocusIn] = focusin, | ||
| 251 | [KeyPress] = keypress, | ||
| 252 | [MappingNotify] = mappingnotify, | ||
| 253 | [MapRequest] = maprequest, | ||
| 254 | [MotionNotify] = motionnotify, | ||
| 255 | [PropertyNotify] = propertynotify, | ||
| 256 | [ResizeRequest] = resizerequest, | ||
| 257 | [UnmapNotify] = unmapnotify}; | ||
| 258 | |||
| 259 | static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast]; | ||
| 260 | static int running = 1; | ||
| 261 | static Cur *cursor[CurLast]; | ||
| 262 | static Clr **scheme; | ||
| 263 | static Display *dpy; | ||
| 264 | static Drw *drw; | ||
| 265 | static Monitor *mons, *selmon; | ||
| 266 | static Window root, wmcheckwin; | ||
| 267 | |||
| 268 | static xcb_connection_t *xcon; | ||
