aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dwm/dwm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/dwm/dwm.h')
-rw-r--r--src/cmd/dwm/dwm.h384
1 files changed, 384 insertions, 0 deletions
diff --git a/src/cmd/dwm/dwm.h b/src/cmd/dwm/dwm.h
new file mode 100644
index 0000000..afec1f2
--- /dev/null
+++ b/src/cmd/dwm/dwm.h
@@ -0,0 +1,384 @@
+/* See LICENSE file for copyright and license details. */
+#pragma once
+#include <u.h>
+#include <base.h>
+#include <libutf.h>
+
+#include <errno.h>
+#include <locale.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <X11/cursorfont.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/Xproto.h>
+#include <X11/Xutil.h>
+#include <X11/Xlib-xcb.h>
+#include <xcb/res.h>
+#include <X11/extensions/Xinerama.h>
+#include <X11/Xft/Xft.h>
+#include <X11/XF86keysym.h>
+
+/* macros */
+#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
+#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
+#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
+ * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
+#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+#define WIDTH(X) ((X)->w + 2 * (X)->bw)
+#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+#define TAGMASK ((1 << arrlen(tags)) - 1)
+#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
+
+
+/* enums */
+enum
+{
+ MouseNormal,
+ MouseResize,
+ MouseMove,
+ MouseLast,
+}; /* mouse states */
+
+enum
+{
+ SchemeNorm,
+ SchemeSel
+}; /* color schemes */
+
+enum
+{
+ NetSupported,
+ NetWMName,
+ NetWMState,
+ NetWMCheck,
+ NetWMFullscreen,
+ NetActiveWindow,
+ NetWMWindowType,
+ NetWMWindowTypeDialog,
+ NetWMWindowOpacity,
+ NetClientList,
+ NetLast
+}; /* EWMH atoms */
+
+enum
+{
+ WMProtocols,
+ WMDelete,
+ WMState,
+ WMTakeFocus,
+ WMLast
+}; /* default atoms */
+
+enum
+{
+ ClkTagBar,
+ ClkLtSymbol,
+ ClkStatusText,
+ ClkWinTitle,
+ ClkClientWin,
+ ClkRootWin,
+ ClkLast
+}; /* clicks */
+
+enum
+{
+ ColFg,
+ ColBg,
+ ColBorder
+}; /* color scheme index */
+
+typedef struct Monitor Monitor;
+typedef struct Layout Layout;
+typedef struct Client Client;
+typedef struct Keyboard Keyboard;
+typedef struct Button Button;
+typedef struct Key Key;
+typedef struct Rule Rule;
+typedef union Arg Arg;
+
+union Arg {
+ int i;
+ uint ui;
+ float f;
+ void *v;
+};
+
+struct Button {
+ uint click;
+ uint mask;
+ uint button;
+ void (*func)(Arg *arg);
+ Arg arg;
+};
+
+struct Client {
+ char name[256];
+ float mina, maxa;
+ int x, y, w, h;
+ int oldx, oldy, oldw, oldh;
+ int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+ int bw, oldbw;
+ uint tags;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterm, noswallow;
+ pid_t pid;
+ Client *next;
+ Client *snext;
+ Client *swallowing;
+ Monitor *mon;
+ Window win;
+};
+
+struct Key {
+ uint mod;
+ KeySym keysym;
+ void (*func)(Arg *);
+ Arg arg;
+};
+
+struct Layout {
+ char *symbol;
+ void (*arrange)(Monitor *);
+};
+
+struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+ int nmaster;
+ int num;
+ int by; /* bar geometry */
+ int mx, my, mw, mh; /* screen size */
+ int wx, wy, ww, wh; /* window area */
+ uint seltags;
+ uint sellt;
+ uint tagset[2];
+ int showbar;
+ int topbar;
+ Client *clients;
+ Client *sel;
+ Client *stack;
+ Monitor *next;
+ Window barwin;
+ Layout *lt[2];
+};
+
+struct Rule {
+ char *class;
+ char *instance;
+ char *title;
+ uint tags;
+ int isfloating;
+ int isterm;
+ int noswallow;
+ int monitor;
+};
+
+/* draw.c */
+typedef struct {
+ Cursor cursor;
+} Cur;
+
+typedef struct Fnt {
+ Display *dpy;
+ uint h;
+ XftFont *xfont;
+ FcPattern *pattern;
+ struct Fnt *next;
+} Fnt;
+
+typedef XftColor Clr;
+
+typedef struct {
+ uint w, h;
+ Display *dpy;
+ int screen;
+ Window root;
+ Drawable drawable;
+ GC gc;
+ Clr *scheme;
+ Fnt *fonts;
+} Drw;
+
+/* global state */
+
+extern char broken[];
+extern char stext[256];
+extern int scanner;
+extern int screen;
+extern int sw, sh;
+extern int bh, blw;
+extern int lrpad;
+extern int (*xerrorxlib)(Display *, XErrorEvent *);
+extern uint numlockmask;
+extern void (*handler[LASTEvent]) (XEvent *);
+extern int scratchtag;
+
+extern xcb_connection_t *xcon;
+
+extern Atom wmatom[WMLast], netatom[NetLast];
+extern int running;
+extern Cur *cursor[MouseLast];
+extern Clr **scheme;
+extern Display *dpy;
+extern Drw *drw;
+extern Monitor *mons, *selmon;
+extern Window root, wmcheckwin;
+
+// -----------------------------------------------------------------------
+// function declarations
+
+// TODO: remove declarations that don't require global existence...
+void applyrules(Client *c);
+int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
+void arrange(Monitor *m);
+void arrangemon(Monitor *m);
+void attach(Client *c);
+void enqueue(Client *c);
+void attachbottom(Client *c);
+void attachstack(Client *c);
+void enqueuestack(Client *c);
+void buttonpress(XEvent *e);
+void checkotherwm(void);
+void cleanup(void);
+void cleanupmon(Monitor *mon);
+void clientmessage(XEvent *e);
+void configure(Client *c);
+void configurenotify(XEvent *e);
+void configurerequest(XEvent *e);
+Monitor *createmon(void);
+void destroynotify(XEvent *e);
+void detach(Client *c);
+void detachstack(Client *c);
+Monitor *dirtomon(int dir);
+void drawbar(Monitor *m);
+void drawbars(void);
+void enternotify(XEvent *e);
+void expose(XEvent *e);
+void focus(Client *c);
+void focusin(XEvent *e);
+void focusmon(Arg *arg);
+void focusstack(Arg *arg);
+void focusdirection(Arg *arg);
+void rotatestack(Arg *arg);
+Atom getatomprop(Client *c, Atom prop);
+int getrootptr(int *x, int *y);
+long getstate(Window w);
+int gettextprop(Window w, Atom atom, char *text, uint size);
+void grabbuttons(Client *c, int focused);
+void grabkeys(void);
+void incnmaster(Arg *arg);
+void keypress(XEvent *e);
+void killclient(Arg *arg);
+void manage(Window w, XWindowAttributes *wa);
+void mappingnotify(XEvent *e);
+void maprequest(XEvent *e);
+void monocle(Monitor *m);
+void motionnotify(XEvent *e);
+void movemouse(Arg *arg);
+Client *nexttiled(Client *c);
+void pop(Client *);
+void propertynotify(XEvent *e);
+void quit(Arg *arg);
+Monitor *recttomon(int x, int y, int w, int h);
+void resize(Client *c, int x, int y, int w, int h, int interact);
+void resizeclient(Client *c, int x, int y, int w, int h);
+void resizemouse(Arg *arg);
+void restack(Monitor *m);
+void run(void);
+void scan(void);
+int sendevent(Client *c, Atom proto);
+void sendtomon(Client *c, Monitor *m);
+void setclientstate(Client *c, long state);
+void setfocus(Client *c);
+void setfullscreen(Client *c, int fullscreen);
+void setlayout(Arg *arg);
+void setmfact(Arg *arg);
+void setup(void);
+void seturgent(Client *c, int urg);
+void showhide(Client *c);
+void sigchld(int unused);
+void swallow(Client *p, Client *c);
+Client *swallowing(Window w);
+void spawn(Arg *arg);
+void tag(Arg *arg);
+void tagmon(Arg *arg);
+Client *termof(Client *c);
+void tile(Monitor *);
+void togglebar(Arg *arg);
+void togglefocus(Arg *arg);
+void togglefloating(Arg *arg);
+void togglescratch(Arg *arg);
+void toggletag(Arg *arg);
+void toggleview(Arg *arg);
+void unfocus(Client *c, int setfocus);
+void unmanage(Client *c, int destroyed);
+void unmapnotify(XEvent *e);
+void unswallow(Client *c);
+void updatebarpos(Monitor *m);
+void updatebars(void);
+void updateclientlist(void);
+int updategeom(void);
+void updatenumlockmask(void);
+void updatesizehints(Client *c);
+void updatestatus(void);
+void updatetitle(Client *c);
+void updatewindowtype(Client *c);
+void updatewmhints(Client *c);
+void view(Arg *arg);
+pid_t winpid(Window w);
+Client *wintoclient(Window w);
+Monitor *wintomon(Window w);
+int xerror(Display *dpy, XErrorEvent *ee);
+int xerrordummy(Display *dpy, XErrorEvent *ee);
+int xerrorstart(Display *dpy, XErrorEvent *ee);
+void zoom(Arg *arg);
+
+#include "config.h"
+
+/* draw.c */
+
+/* Drawable abstraction */
+Drw *drw_create(Display *dpy, int screen, Window win, uint w, uint h);
+void drw_resize(Drw *drw, uint w, uint h);
+void drw_free(Drw *drw);
+
+/* Fnt abstraction */
+Fnt *drw_fontset_create(Drw* drw, char *fonts[], size_t fontcount);
+void drw_fontset_free(Fnt* set);
+uint drw_fontset_getwidth(Drw *drw, char *text);
+void drw_font_getexts(Fnt *font, char *text, uint len, uint *w, uint *h);
+
+/* Colorscheme abstraction */
+void drw_clr_create(Drw *drw, Clr *dest, char *clrname);
+Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
+
+/* Cursor abstraction */
+Cur *drw_cur_create(Drw *drw, int shape);
+void drw_cur_free(Drw *drw, Cur *cursor);
+
+/* Drawing context manipulation */
+void drw_setfontset(Drw *drw, Fnt *set);
+void drw_setscheme(Drw *drw, Clr *scm);
+
+/* Drawing functions */
+void drw_rect(Drw *drw, int x, int y, uint w, uint h, int filled, int invert);
+int drw_text(Drw *drw, int x, int y, uint w, uint h, uint lpad, char *text, int invert);
+
+/* Map functions */
+void drw_map(Drw *drw, Window win, int x, int y, uint w, uint h);
+
+/* util.c */
+void fatal(char *fmt, ...);
+void *ecalloc(size_t nmemb, size_t size);
+pid_t getparentproc(pid_t p);
+pid_t isdescendent(pid_t p, pid_t c);