diff --git a/README.md b/README.md index 2bff4ce..e98bf26 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2020-03-31 - Added the rounded corners patch + 2020-03-27 - Revamped the dragmfact patch to support both horizontal and vertical layout splits as well as centered master variants 2020-03-25 - Added dragcfact patch @@ -281,6 +283,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [rotatestack](https://dwm.suckless.org/patches/rotatestack/) - let's you rotate through the stack using keyboard shortcuts + - [roundedcorners](https://github.com/mitchweaver/suckless/blob/master/dwm/patches_mitch/mitch-06-rounded_corners-db6093f6ec1bb884f7540f2512935b5254750b30.patch) + - adds rounded corners to client windows + - [savefloats](https://dwm.suckless.org/patches/save_floats/) - saves size and position of every floating window before it is forced into tiled mode - if the window is made floating again then the old dimensions will be restored diff --git a/config.def.h b/config.def.h index 88aa852..7d74da5 100644 --- a/config.def.h +++ b/config.def.h @@ -36,6 +36,9 @@ static const int showsystray = 1; /* 0 means no systray */ #if ONLYQUITONEMPTY_PATCH static const int quit_empty_window_count = 2; /* only allow dwm to quit if no windows are open, value here represents number of deamons */ #endif // ONLYQUITONEMPTY_PATCH +#if ROUNDED_CORNERS_PATCH +static const int corner_radius = 10; +#endif // ROUNDED_CORNERS_PATCH #if EXTRABAR_PATCH static const char statussep = ';'; /* separator between status bars */ #endif // EXTRABAR_PATCH diff --git a/config.mk b/config.mk index c1308d6..6dbf624 100644 --- a/config.mk +++ b/config.mk @@ -23,12 +23,15 @@ FREETYPEINC = /usr/include/freetype2 # Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH #LMPDCLIENT = -lmpdclient +# Uncomment this for the rounded corners patch / ROUNDED_CORNERS_PATCH +#XEXTLIB = -lXext + # Uncomment this for the swallow patch / SWALLOW_PATCH #LXCBLIBS = -lX11-xcb -lxcb -lxcb-res # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender ${LMPDCLIENT} ${LXCBLIBS} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender ${LMPDCLIENT} ${LXCBLIBS} ${XEXTLIB} # flags diff --git a/dwm.c b/dwm.c index 5ad3bec..6cd331d 100644 --- a/dwm.c +++ b/dwm.c @@ -652,6 +652,11 @@ arrangemon(Monitor *m) strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol); if (m->lt[m->sellt]->arrange) m->lt[m->sellt]->arrange(m); + #if ROUNDED_CORNERS_PATCH + Client *c; + for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) + drawroundedcorners(c); + #endif // ROUNDED_CORNERS_PATCH } void @@ -2261,6 +2266,9 @@ movemouse(const Arg *arg) resize(c, nx, ny, c->w, c->h, 1); #endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH } + #if ROUNDED_CORNERS_PATCH + drawroundedcorners(c); + #endif // ROUNDED_CORNERS_PATCH break; } } while (ev.type != ButtonRelease); @@ -2270,6 +2278,9 @@ movemouse(const Arg *arg) selmon = m; focus(NULL); } + #if ROUNDED_CORNERS_PATCH + drawroundedcorners(c); + #endif // ROUNDED_CORNERS_PATCH } Client * @@ -2526,6 +2537,9 @@ resizemouse(const Arg *arg) c->sfh = nh; #endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH #endif // RESIZECORNERS_PATCH + #if ROUNDED_CORNERS_PATCH + drawroundedcorners(c); + #endif // ROUNDED_CORNERS_PATCH } break; } diff --git a/patch/include.c b/patch/include.c index 5cbb942..c30b794 100644 --- a/patch/include.c +++ b/patch/include.c @@ -84,6 +84,9 @@ #if ROTATESTACK_PATCH #include "rotatestack.c" #endif +#if ROUNDED_CORNERS_PATCH +#include "roundedcorners.c" +#endif #if SCRATCHPAD_PATCH #include "scratchpad.c" #endif diff --git a/patch/include.h b/patch/include.h index 5d6ee6c..e683a5b 100644 --- a/patch/include.h +++ b/patch/include.h @@ -87,6 +87,9 @@ #if ROTATESTACK_PATCH #include "rotatestack.h" #endif +#if ROUNDED_CORNERS_PATCH +#include "roundedcorners.h" +#endif #if SCRATCHPAD_PATCH #include "scratchpad.h" #endif diff --git a/patch/roundedcorners.c b/patch/roundedcorners.c new file mode 100644 index 0000000..56c54c8 --- /dev/null +++ b/patch/roundedcorners.c @@ -0,0 +1,50 @@ +#include + +void drawroundedcorners(Client *c) +{ + if (corner_radius <= 0 || !c || c->isfullscreen) + return; + + Window win; + win = c->win; + if (!win) + return; + + XWindowAttributes win_attr; + if (!XGetWindowAttributes(dpy, win, &win_attr)) + return; + + int dia = 2 * corner_radius; + int w = c->w; + int h = c->h; + if (w < dia || h < dia) + return; + + Pixmap mask; + mask = XCreatePixmap(dpy, win, w, h, 1); + if (!mask) + return; + + XGCValues xgcv; + GC shape_gc; + shape_gc = XCreateGC(dpy, mask, 0, &xgcv); + + if (!shape_gc) { + XFreePixmap(dpy, mask); + free(shape_gc); + return; + } + + XSetForeground(dpy, shape_gc, 0); + XFillRectangle(dpy, mask, shape_gc, 0, 0, w, h); + XSetForeground(dpy, shape_gc, 1); + XFillArc(dpy, mask, shape_gc, 0, 0, dia, dia, 0, 23040); + XFillArc(dpy, mask, shape_gc, w-dia-1, 0, dia, dia, 0, 23040); + XFillArc(dpy, mask, shape_gc, 0, h-dia-1, dia, dia, 0, 23040); + XFillArc(dpy, mask, shape_gc, w-dia-1, h-dia-1, dia, dia, 0, 23040); + XFillRectangle(dpy, mask, shape_gc, corner_radius, 0, w-dia, h); + XFillRectangle(dpy, mask, shape_gc, 0, corner_radius, w, h-dia); + XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, mask, ShapeSet); + XFreePixmap(dpy, mask); + XFreeGC(dpy, shape_gc); +} \ No newline at end of file diff --git a/patch/roundedcorners.h b/patch/roundedcorners.h new file mode 100644 index 0000000..40f7549 --- /dev/null +++ b/patch/roundedcorners.h @@ -0,0 +1 @@ +static void drawroundedcorners(Client *c); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index 4758ce2..f1d4c24 100644 --- a/patches.def.h +++ b/patches.def.h @@ -382,6 +382,13 @@ */ #define ROTATESTACK_PATCH 0 +/* This patch adds rounded corners to client windows in dwm. + * You need to uncomment the corresponding line in config.mk to include the -lXext library + * when including this patch. You will also want to set "borderpx = 0;" in your config.h. + * https://github.com/mitchweaver/suckless/blob/master/dwm/patches_mitch/mitch-06-rounded_corners-db6093f6ec1bb884f7540f2512935b5254750b30.patch + */ +#define ROUNDED_CORNERS_PATCH 0 + /* This patch saves size and position of every floating window before it is forced * into tiled mode. If the window is made floating again then the old dimensions * will be restored.