dwm

my dwm build
Log | Files | Refs | LICENSE

commit c572ac2dc8b5f54b7bf0c135e3cd4313ecd592b1
parent f75b1715f8b64d5740da62c23e2c54fecf81945a
Author: ssnf <ssnf@ssnf.xyz>
Date:   Tue,  5 Mar 2024 19:07:32 +0000

merge upstream changes

Diffstat:
MMakefile | 10++--------
Mconfig.mk | 2+-
Mdwm.c | 235+++++++++++++++++++++++++++++++++++++++++++------------------------------------
3 files changed, 132 insertions(+), 115 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,13 +6,7 @@ include config.mk SRC = drw.c dwm.c util.c OBJ = ${SRC:.c=.o} -all: options dwm - -options: - @echo dwm build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" +all: dwm .c.o: ${CC} -c ${CFLAGS} $< @@ -41,4 +35,4 @@ install: all uninstall: rm -f ${DESTDIR}${PREFIX}/bin/dwm -.PHONY: all options clean dist install uninstall +.PHONY: all clean dist install uninstall diff --git a/config.mk b/config.mk @@ -27,7 +27,7 @@ INCS = -I${X11INC} -I${FREETYPEINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lXrender # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} diff --git a/dwm.c b/dwm.c @@ -168,102 +168,102 @@ typedef struct { } Rule; /* function declarations */ -static void applyrules(Client* c); -static int applysizehints(Client* c, int* x, int* y, int* w, int* h, int interact); -static void arrange(Monitor* m); -static void arrangemon(Monitor* m); -static void attach(Client* c); -static void attachstack(Client* c); -static void buttonpress(XEvent* e); -static void checkotherwm(void); -static void cleanup(void); -static void cleanupmon(Monitor* mon); -static void clientmessage(XEvent* e); -static void configure(Client* c); -static void configurenotify(XEvent* e); -static void configurerequest(XEvent* e); -static Monitor* createmon(void); -static void destroynotify(XEvent* e); -static void detach(Client* c); -static void detachstack(Client* c); -static Monitor* dirtomon(int dir); -static void drawbar(Monitor* m); -static void drawbars(void); -static void enternotify(XEvent* e); -static void expose(XEvent* e); -static void focus(Client* c); -static void focusin(XEvent* e); -static void focusmon(const Arg* arg); -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 int gettextprop(Window w, Atom atom, char* text, uint size); -static void grabbuttons(Client* c, int focused); -static void grabkeys(void); -static void keypress(XEvent* e); -static void killclient(const Arg* arg); -static void manage(Window w, XWindowAttributes* wa); -static void mappingnotify(XEvent* e); -static void maprequest(XEvent* e); -static void monocle(Monitor* m); -static void motionnotify(XEvent* e); -static void movemouse(const Arg* arg); -static Client* nexttiled(Client* c); -static void pop(Client*); -static void propertynotify(XEvent* e); -static void quit(const Arg* arg); -static Monitor* recttomon(int x, int y, int w, int h); -static void resize(Client* c, int x, int y, int w, int h, int interact); -static void resizeclient(Client* c, int x, int y, int w, int h); -static void resizemouse(const Arg* arg); -static void restack(Monitor* m); -static void run(void); -static void scan(void); -static int sendevent(Client* c, Atom proto); -static void sendmon(Client* c, Monitor* m); -static void setclientstate(Client* c, long state); -static void setfocus(Client* c); -static void setfullscreen(Client* c, int fullscreen); -static void setlayout(const Arg* arg); -static void setmfact(const Arg* arg); -static void setup(void); -static void seturgent(Client* c, int urg); -static void showhide(Client* c); -static void sigchld(int unused); -static void spawn(const Arg* arg); -static void tag(const Arg* arg); -static void tagmon(const Arg* arg); -static void tile(Monitor* m); -static void togglebar(const Arg* arg); -static void togglefloating(const Arg* arg); -static void toggletag(const Arg* arg); -static void toggleview(const Arg* arg); -static void unfocus(Client* c, int setfocus); -static void unmanage(Client* c, int destroyed); -static void unmapnotify(XEvent* e); -static void updatebarpos(Monitor* m); -static void updatebars(void); -static void updateclientlist(void); -static int updategeom(void); -static void updatenumlockmask(void); -static void updatesizehints(Client* c); -static void updatestatus(void); -static void updatetitle(Client* c); -static void updatewindowtype(Client* c); -static void updatewmhints(Client* c); -static void view(const Arg* arg); -static Client* wintoclient(Window w); -static Monitor* wintomon(Window w); -static int xerror(Display* dpy, XErrorEvent* error_event); -static int xerrordummy(Display* dpy, XErrorEvent* error_event); -static int xerrorstart(Display* dpy, XErrorEvent* error_event); -static void zoom(const Arg* arg); +static void applyrules(Client *c); +static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); +static void arrange(Monitor *m); +static void arrangemon(Monitor *m); +static void attach(Client *c); +static void attachstack(Client *c); +static void buttonpress(XEvent *e); +static void checkotherwm(void); +static void cleanup(void); +static void cleanupmon(Monitor *mon); +static void clientmessage(XEvent *e); +static void configure(Client *c); +static void configurenotify(XEvent *e); +static void configurerequest(XEvent *e); +static Monitor *createmon(void); +static void destroynotify(XEvent *e); +static void detach(Client *c); +static void detachstack(Client *c); +static Monitor *dirtomon(int dir); +static void drawbar(Monitor *m); +static void drawbars(void); +static void enternotify(XEvent *e); +static void expose(XEvent *e); +static void focus(Client *c); +static void focusin(XEvent *e); +static void focusmon(const Arg *arg); +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 int gettextprop(Window w, Atom atom, char *text, unsigned int size); +static void grabbuttons(Client *c, int focused); +static void grabkeys(void); +static void keypress(XEvent *e); +static void killclient(const Arg *arg); +static void manage(Window w, XWindowAttributes *wa); +static void mappingnotify(XEvent *e); +static void maprequest(XEvent *e); +static void monocle(Monitor *m); +static void motionnotify(XEvent *e); +static void movemouse(const Arg *arg); +static Client *nexttiled(Client *c); +static void pop(Client *c); +static void propertynotify(XEvent *e); +static void quit(const Arg *arg); +static Monitor *recttomon(int x, int y, int w, int h); +static void resize(Client *c, int x, int y, int w, int h, int interact); +static void resizeclient(Client *c, int x, int y, int w, int h); +static void resizemouse(const Arg *arg); +static void restack(Monitor *m); +static void run(void); +static void scan(void); +static int sendevent(Client *c, Atom proto); +static void sendmon(Client *c, Monitor *m); +static void setclientstate(Client *c, long state); +static void setfocus(Client *c); +static void setfullscreen(Client *c, int fullscreen); +static void setlayout(const Arg *arg); +static void setmfact(const Arg *arg); +static void setup(void); +static void seturgent(Client *c, int urg); +static void showhide(Client *c); +static void spawn(const Arg *arg); +static void tag(const Arg *arg); +static void tagmon(const Arg *arg); +static void tile(Monitor *m); +static void togglebar(const Arg *arg); +static void togglefloating(const Arg *arg); +static void toggletag(const Arg *arg); +static void toggleview(const Arg *arg); +static void unfocus(Client *c, int setfocus); +static void unmanage(Client *c, int destroyed); +static void unmapnotify(XEvent *e); +static void updatebarpos(Monitor *m); +static void updatebars(void); +static void updateclientlist(void); +static int updategeom(void); +static void updatenumlockmask(void); +static void updatesizehints(Client *c); +static void updatestatus(void); +static void updatetitle(Client *c); +static void updatewindowtype(Client *c); +static void updatewmhints(Client *c); +static void view(const Arg *arg); +static Client *wintoclient(Window w); +static Monitor *wintomon(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 void fibonacci(Monitor *m); static pid_t getparentprocess(pid_t p); static int isdescprocess(pid_t p, pid_t c); static void keyrelease(XEvent *e); +static void sigchld(int unused); static Client* swallowingclient(Window w); static Client* termforwin(const Client* c); static void togglefullscr(const Arg* arg); @@ -1205,18 +1205,26 @@ grabkeys(void) { updatenumlockmask(); { - uint i, j; - uint modifiers[] = { 0, LockMask, numlockmask, numlockmask | LockMask }; - KeyCode code; + unsigned int i, j, k; + unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; + int start, end, skip; + KeySym *syms; XUngrabKey(dpy, AnyKey, AnyModifier, root); - for (i = 0; i < LENGTH(keys); ++i) - if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); ++j) - XGrabKey( - dpy, code, keys[i].mod | modifiers[j], - root, True, GrabModeAsync, GrabModeAsync - ); + XDisplayKeycodes(dpy, &start, &end); + syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip); + if (!syms) + return; + for (k = start; k <= end; k++) + for (i = 0; i < LENGTH(keys); i++) + /* skip modifier codes, we do that ourselves */ + if (keys[i].keysym == syms[(k - start) * skip]) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabKey(dpy, k, + keys[i].mod | modifiers[j], + root, True, + GrabModeAsync, GrabModeAsync); + XFree(syms); } } @@ -1826,11 +1834,18 @@ void setup() { XSetWindowAttributes wa; - int i; - Atom utf8string; + int i; + Atom utf8string; + struct sigaction sa; + + /* do not transform children into zombies when they terminate */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART; + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); - /* clean up any zombies immediately */ - sigchld(0); + /* clean up any zombies (inherited from .xinitrc etc) immediately */ + while (waitpid(-1, NULL, WNOHANG) > 0); /* init screen */ screen = DefaultScreen(dpy); @@ -1956,14 +1971,22 @@ sigchld(int unused) } void -spawn(const Arg* arg) +spawn(const Arg *arg) { + struct sigaction sa; + if (arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); setsid(); + + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &sa, NULL); + execvp(((char **)arg->v)[0], (char **)arg->v); die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]); }