swm

sigma window manager
git clone git://wolog.xyz/swm
Log | Files | Refs | README | LICENSE

swm.h (5406B)


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