swm.h (5206B)
1 /* 2 * Copyright (C) Raymond Cole <rc@wolog.xyz> 3 * License: GPL-3.0-or-later 4 * 5 * Portions of the code are derived from suckless dwm. See file 6 * LICENSE-dwm for copyright and license details of those portions. 7 */ 8 9 #include "config.h" 10 #include "util.h" 11 12 #define ISVISIBLE(C) ((C)->tags & (C)->mon->tagset) 13 14 #define WIDTH(C) ((C)->isfullscreen ? (C)->mon->w : (C)->w + 2 * borderw) 15 #define HEIGHT(C) ((C)->isfullscreen ? (C)->mon->h : (C)->h + 2 * borderw) 16 17 #define BY(M) ((M)->showbar ? TOPBAR ? (M)->y : (M)->y + (M)->h - barh : -barh) 18 #define WY(M) ((M)->showbar && TOPBAR ? (M)->y + barh : (M)->y) 19 #define WH(M) ((M)->showbar ? (M)->h - barh : (M)->h) 20 21 #define parrange(M) (pending = 1, (M)->pending |= PArrange) 22 #define pdrawbar(M) (pending = 1, (M)->pending |= PDrawbar) 23 24 #define TAGMASK ((1 << LENGTH(tags)) - 1) 25 26 enum { WMProtocols, WMDeleteWindow, WMTakeFocus, WMState, WMLast }; 27 28 enum { NetSupported, NetActiveWindow, NetWMName, NetWMWindowType, 29 NetWMState, NetWMWindowTypeDialog, NetWMStateFullscreen, NetLast }; 30 31 enum { BarTags, BarLytDesc, BarWinTitle, BarStatus }; 32 33 enum { PArrange = 1, PDrawbar = 2 }; 34 35 typedef struct Client Client; 36 typedef struct LytNode LytNode; 37 typedef struct Workspace Workspace; 38 typedef struct Monitor Monitor; 39 40 struct Client { 41 char hintsvalid, isfixed, isfloating, isfullscreen; 42 char ishidden, isscratch, isurgent, neverfocus; 43 int x, y, w, h; 44 int maxw, maxh, minw, minh; 45 int basew, baseh, incw, inch; 46 float mina, maxa; 47 unsigned tags; 48 Window win; 49 char *appclass, *appname, *title; 50 Monitor *mon; 51 Client *next, *snext; 52 char bytes[256]; 53 }; 54 55 struct LytNode { 56 char type, ending, loaded, trailing; 57 float fact; 58 int plan[2]; 59 LytNode *next; 60 union { 61 LytNode *chain; 62 Client *client; 63 } p; 64 }; 65 66 struct Workspace { 67 unsigned tagset; 68 LytNode *lyt; 69 }; 70 71 struct Monitor { 72 char nogaps, showbar; 73 int pending; 74 int num; 75 int selws, altws; 76 int x, y, w, h; 77 int gapih, gapiv, gapoh, gapov; 78 int tagsw, statusw; 79 Window barwin; 80 unsigned tagset; 81 Client *clients, *sel, *stack; 82 LytNode *lyt; 83 Monitor *next; 84 char lytdesc[256]; 85 Workspace workspaces[LENGTH((char *[])TAGS)]; 86 }; 87 88 /* bar.c */ 89 void barsetup(void); 90 void barcleanup(void); 91 void initbar(Monitor *m); 92 void runsprog(void); 93 void endsprog(void); 94 void updatedrawable(void); 95 void updatestatus(void); 96 void drawbar(Monitor *m); 97 int posinbar(Monitor *m, int x, int *n); 98 99 /* client.c */ 100 void attach(Client *c); 101 void detach(Client *c); 102 void attachstack(Client *c); 103 void detachstack(Client *c); 104 Client *wintoclient(Window w); 105 Client *nextclient(Client *c); 106 Client *prevclient(Client *c); 107 void notifyconfigure(Client *c); 108 void configure(Client *c, int resize); 109 void updatetitle(Client *c); 110 void updatewindowtype(Client *c); 111 void updatewmhints(Client *c); 112 void updatesizehints(Client *c); 113 void applysizehints(Client *c, int *w, int *h); 114 void elevate(Client *c); 115 int sendevent(Client *c, Atom proto); 116 void setclientstate(Client *c, long state); 117 void setfloating(Client *c, int val); 118 void setfullscreen(Client *c, int val); 119 void setscratch(Client *c, int val); 120 void seturgent(Client *c, int val); 121 void focus(Client *c); 122 void sendtomon(Client *c, Monitor *m); 123 Client *manage(Window w, XWindowAttributes *wa); 124 void unmanage(Client *c, int destroyed); 125 126 /* config.c */ 127 void applyrules(Client *c); 128 void execmenu(void); 129 void keypress(XEvent *e); 130 void buttonpress(XEvent *e); 131 132 /* lyt.c */ 133 LytNode *lytparse(const char *desc); 134 void lytfree(LytNode *lyt); 135 void lyttile(Monitor *m); 136 void updatelytdesc(Monitor *m); 137 138 /* misc.c */ 139 int depart(int *pipe); 140 void spawn(char **argv); 141 int getrootptr(int *x, int *y); 142 long getstate(Window w); 143 void grabbuttons(Client *c, int focused); 144 void grabkeys(void); 145 void swap(Client *c, Client *d); 146 void tag(unsigned ts); 147 void view(unsigned ts); 148 void setworkspace(unsigned ws); 149 void setlayout(const char *desc); 150 void incnmaster(int i); 151 void incmfact(float f); 152 void movebymouse(void); 153 void resizebymouse(void); 154 void togglescratch(char **cmd); 155 void cyclescratch(void); 156 void newmenu(void); 157 void menuput(const char *fmt, ...); 158 char *menuget(void); 159 160 /* monitor.c */ 161 void wsload(Monitor *m); 162 void wssync(Monitor *m); 163 int updategeom(void); 164 void cleanupgeom(void); 165 Monitor *nextmon(Monitor *m); 166 Monitor *prevmon(Monitor *m); 167 Monitor *pttomon(int x, int y); 168 void focusmon(Monitor *m); 169 void arrange(Monitor *m); 170 171 /* bar.c */ 172 extern int barh; 173 extern int sfdw, sfdr; 174 175 /* config.c */ 176 extern const unsigned borderw, snap; 177 extern const int gapih, gapiv, gapoh, gapov; 178 extern const char **fonts; 179 extern const size_t nfonts; 180 extern const char *colnf, *colnb, *colsf, *colsb; 181 extern const char *colfocus, *colunfocus, *colurgent; 182 extern const char *defaultlayout; 183 extern char **statusprog; 184 185 /* evt.c */ 186 extern void (*handler[LASTEvent])(XEvent *); 187 188 /* main.c */ 189 extern int running; 190 extern int restart; 191 extern int pending; 192 extern Display *dpy; 193 extern Window root; 194 extern int screen; 195 extern int sw, sh; /* X display screen geometry width, height */ 196 extern Monitor *mons, *selmon; 197 extern Atom wmatom[WMLast], netatom[NetLast]; 198 extern const char *tags[LENGTH((char *[])TAGS)]; 199 extern unsigned long pixelfocus, pixelunfocus, pixelurgent; 200 extern Cursor curnormal, curresize, curmove; 201 extern unsigned lockmasks[4];