diff --git a/Makefile b/Makefile index 6123311..9b9b0d0 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ include config.mk SRC = atoms.c drw.c dwm.c helpers.c layouts.c settings.c spawn.c tags.c util.c OBJ = ${SRC:.c=.o} +DWM_SRC = dwm/handlers.c dwm/layouts.c dwm/swallow.c dwm/systray.c +DWM_HDR = ${DWM_SRC:.c=.h} + all: options polytreewm options: @@ -17,7 +20,7 @@ options: %.o: %.c ${CC} -c $< -o $@ ${CFLAGS} -dwm.o: dwm/handlers.c dwm/layouts.c dwm/swallow.c dwm/systray.c +dwm.o: ${DWM_SRC} ${DWM_HDR} ${OBJ}: atoms.h drw.h config.def.h config.mk helpers.h layouts.h settings.h spawn.h tags.h util.h polytreewm: ${OBJ} diff --git a/dwm.c b/dwm.c index 4c9b56f..b205838 100644 --- a/dwm.c +++ b/dwm.c @@ -184,7 +184,6 @@ static void attach(Client *c); static void attachstack(Client *c); static void configborder(const Arg *arg); static void configgap(const Arg *arg); -static void centeredmaster(Monitor *m); static void checkotherwm(void); static void cleanup(void); static void cleanupmon(Monitor *mon); @@ -201,15 +200,12 @@ static void focusstack(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); static int getrootptr(int *x, int *y); static long getstate(Window w); -static unsigned int getsystraywidth(); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void grabkeys(void); -static void horizontile(Monitor *); static void incnmaster(const Arg *arg); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); -static void monocle(Monitor *m); static void movemouse(const Arg *arg); static void movestack(const Arg *arg); static void nametag(const Arg *arg); @@ -217,7 +213,6 @@ static Client *nexttiled(Client *c); static void pop(Client *); static void quit(const Arg *arg); static Monitor *recttomon(int x, int y, int w, int h); -static void removesystrayicon(Client *i); static void resetnmaster(const Arg *arg); static void resize(Client *c, int x, int y, int w, int h, int bw, int interact); static void resizebarwin(Monitor *m); @@ -239,10 +234,8 @@ static void showhide(Client *c); static void sigchld(int unused); static void spawn(const Arg *arg); static void spawn_callback(); -static Monitor *systraytomon(Monitor *m); static void tag(const Arg *arg); static void tagmon(const Arg *arg); -static void tile(Monitor *); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); @@ -256,9 +249,6 @@ static int updategeom(void); static void updatenumlockmask(void); static void updatesizehints(Client *c); static void updatestatus(void); -static void updatesystray(void); -static void updatesystrayicongeom(Client *i, int w, int h); -static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); @@ -266,32 +256,15 @@ static void view(const Arg *arg); static void viewrel(const Arg *arg); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); -static Client *wintosystrayicon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); -static pid_t getparentprocess(pid_t p); -static int isdescprocess(pid_t p, pid_t c); -static Client *swallowingclient(Window w); -static Client *termforwin(const Client *c); -static pid_t winpid(Window w); - -/* handlers */ -static void on_button_press(XEvent *e); -static void on_client_message(XEvent *e); -static void on_configure_notify(XEvent *e); -static void on_configure_request(XEvent *e); -static void on_destroy_notify(XEvent *e); -static void on_expose(XEvent *e); -static void on_focus_in(XEvent *e); -static void on_key_press(XEvent *e); -static void on_mapping_notify(XEvent *e); -static void on_map_request(XEvent *e); -static void on_property_notify(XEvent *e); -static void on_resize_request(XEvent *e); -static void on_unmap_notify(XEvent *e); +#include "dwm/handlers.h" +#include "dwm/layouts.h" +#include "dwm/swallow.h" +#include "dwm/systray.h" /* variables */ static Systray *systray = NULL; diff --git a/dwm/handlers.c b/dwm/handlers.c index 2160880..f11a055 100644 --- a/dwm/handlers.c +++ b/dwm/handlers.c @@ -1,3 +1,6 @@ +#ifndef _DWM_HANDLERS_C +#define _DWM_HANDLERS_C + void on_button_press(XEvent *e) { @@ -367,3 +370,5 @@ on_unmap_notify(XEvent *e) updatesystray(); } } + +#endif // _DWM_HANDLERS_C diff --git a/dwm/handlers.h b/dwm/handlers.h new file mode 100644 index 0000000..d42138f --- /dev/null +++ b/dwm/handlers.h @@ -0,0 +1,18 @@ +#ifndef _DWM_HANDLERS_H +#define _DWM_HANDLERS_H + +static void on_button_press(XEvent *e); +static void on_client_message(XEvent *e); +static void on_configure_notify(XEvent *e); +static void on_configure_request(XEvent *e); +static void on_destroy_notify(XEvent *e); +static void on_expose(XEvent *e); +static void on_focus_in(XEvent *e); +static void on_key_press(XEvent *e); +static void on_mapping_notify(XEvent *e); +static void on_map_request(XEvent *e); +static void on_property_notify(XEvent *e); +static void on_resize_request(XEvent *e); +static void on_unmap_notify(XEvent *e); + +#endif // _DWM_HANDLERS_H diff --git a/dwm/layouts.c b/dwm/layouts.c index 6847925..73c5797 100644 --- a/dwm/layouts.c +++ b/dwm/layouts.c @@ -1,3 +1,6 @@ +#ifndef _DWM_LAYOUTS_C +#define _DWM_LAYOUTS_C + void centeredmaster(Monitor *m) { @@ -259,3 +262,5 @@ tile(Monitor *m) } } } + +#endif // _DWM_LAYOUTS_C diff --git a/dwm/layouts.h b/dwm/layouts.h new file mode 100644 index 0000000..e57a34e --- /dev/null +++ b/dwm/layouts.h @@ -0,0 +1,9 @@ +#ifndef _DWM_LAYOUTS_H +#define _DWM_LAYOUTS_H + +static void centeredmaster(Monitor *m); +static void horizontile(Monitor *); +static void monocle(Monitor *m); +static void tile(Monitor *); + +#endif // _DWM_LAYOUTS_H diff --git a/dwm/swallow.c b/dwm/swallow.c index 7380f8a..70aae6c 100644 --- a/dwm/swallow.c +++ b/dwm/swallow.c @@ -1,3 +1,6 @@ +#ifndef _DWM_SWALLOW_C +#define _DWM_SWALLOW_C + pid_t getparentprocess(pid_t p) { @@ -172,3 +175,5 @@ winpid(Window w) #endif /* __OpenBSD__ */ return result; } + +#endif // _DWM_SWALLOW_C diff --git a/dwm/swallow.h b/dwm/swallow.h new file mode 100644 index 0000000..ddd9ca8 --- /dev/null +++ b/dwm/swallow.h @@ -0,0 +1,12 @@ +#ifndef _DWM_SWALLOW_H +#define _DWM_SWALLOW_H + +static pid_t getparentprocess(pid_t p); +static int isdescprocess(pid_t p, pid_t c); +static void swallow(Client *p, Client *c); +static Client *swallowingclient(Window w); +static Client *termforwin(const Client *c); +static void unswallow(Client *c); +static pid_t winpid(Window w); + +#endif // _DWM_SWALLOW_H diff --git a/dwm/systray.c b/dwm/systray.c index 90acc4c..5677749 100644 --- a/dwm/systray.c +++ b/dwm/systray.c @@ -1,3 +1,6 @@ +#ifndef _DWM_SYSTRAY_C +#define _DWM_SYSTRAY_C + unsigned int getsystraywidth() { @@ -163,3 +166,5 @@ wintosystrayicon(Window w) { for (i = systray->icons; i && i->win != w; i = i->next) ; return i; } + +#endif // _DWM_SYSTRAY_C diff --git a/dwm/systray.h b/dwm/systray.h new file mode 100644 index 0000000..20a9926 --- /dev/null +++ b/dwm/systray.h @@ -0,0 +1,12 @@ +#ifndef _DWM_SYSTRAY_H +#define _DWM_SYSTRAY_H + +static unsigned int getsystraywidth(); +static void removesystrayicon(Client *i); +static Monitor *systraytomon(Monitor *m); +static void updatesystray(void); +static void updatesystrayicongeom(Client *i, int w, int h); +static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); +static Client *wintosystrayicon(Window w); + +#endif // _DWM_SYSTRAY_H