diff options
| author | bakkeby <[email protected]> | 2020-03-31 08:21:00 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-03-31 10:21:45 +0200 |
| commit | a560b9cb53f3efc031e8d944231f53f4a9720203 (patch) | |
| tree | eb0d0e3a7a5d96cd93beaffdead935011cc1acd6 /patch/roundedcorners.c | |
| parent | f2673fec53bbba86cc5ba2c1ea8ff5f67346f908 (diff) | |
| download | dwm-flexipatch-a560b9cb53f3efc031e8d944231f53f4a9720203.tar.gz dwm-flexipatch-a560b9cb53f3efc031e8d944231f53f4a9720203.zip | |
Adding rounded corners patch
Diffstat (limited to 'patch/roundedcorners.c')
| -rw-r--r-- | patch/roundedcorners.c | 50 |
1 files changed, 50 insertions, 0 deletions
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 <X11/extensions/shape.h> + +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 |
