Better organize DWM included files

This commit is contained in:
Alex Kotov 2021-11-16 20:03:26 +05:00
parent f90668bbd1
commit 4b424b1dfd
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
10 changed files with 79 additions and 32 deletions

View File

@ -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}

35
dwm.c
View File

@ -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;

View File

@ -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

18
dwm/handlers.h Normal file
View File

@ -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

View File

@ -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

9
dwm/layouts.h Normal file
View File

@ -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

View File

@ -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

12
dwm/swallow.h Normal file
View File

@ -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

View File

@ -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

12
dwm/systray.h Normal file
View File

@ -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