diff options
Diffstat (limited to 'pkgs/dwm')
-rw-r--r-- | pkgs/dwm/default.nix | 4 | ||||
-rw-r--r-- | pkgs/dwm/dwm-rounded.diff | 102 | ||||
-rw-r--r-- | pkgs/dwm/pndwm.nix | 1 |
3 files changed, 105 insertions, 2 deletions
diff --git a/pkgs/dwm/default.nix b/pkgs/dwm/default.nix index 421455e..0f8eed4 100644 --- a/pkgs/dwm/default.nix +++ b/pkgs/dwm/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchgit, libX11, libXinerama, libXft, patches ? [] }: +{ stdenv, fetchgit, libX11, libXinerama, libXft, libXext, patches ? [] }: with stdenv.lib; @@ -11,7 +11,7 @@ stdenv.mkDerivation rec { sha256 = "1fi0q68zqcmnx4spvjaqlv0k43ij96bz3545qdlc077qhzw2lxxh"; }; - buildInputs = [ libX11 libXinerama libXft ]; + buildInputs = [ libX11 libXinerama libXft libXext ]; prePatch = ''sed -i "s@/usr/local@$out@" config.mk''; diff --git a/pkgs/dwm/dwm-rounded.diff b/pkgs/dwm/dwm-rounded.diff new file mode 100644 index 0000000..320846c --- /dev/null +++ b/pkgs/dwm/dwm-rounded.diff @@ -0,0 +1,102 @@ +diff --git a/dwm.c b/dwm.c +index 290dc2d..f3e70c9 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -40,6 +40,7 @@ + #ifdef XINERAMA + #include <X11/extensions/Xinerama.h> + #endif /* XINERAMA */ ++#include <X11/extensions/shape.h> + #include <X11/Xft/Xft.h> + #include <X11/Xlib-xcb.h> + #include <xcb/res.h> +@@ -315,6 +316,7 @@ 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 drawroundedcorners(Client *c); + static void xrdb(const Arg *arg); + static void zoom(const Arg *arg); + +@@ -1391,6 +1393,9 @@ manage(Window w, XWindowAttributes *wa) + unfocus(selmon->sel, 0); + c->mon->sel = c; + arrange(c->mon); ++ ++ drawroundedcorners(c); ++ + XMapWindow(dpy, c->win); + if (term) + swallow(term, c); +@@ -1508,6 +1513,7 @@ movemouse(const Arg *arg) + togglefloating(NULL); + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) + resize(c, nx, ny, c->w, c->h, 1); ++ drawroundedcorners(c); + break; + } + } while (ev.type != ButtonRelease); +@@ -1671,6 +1677,55 @@ resizeclient(Client *c, int x, int y, int w, int h) + XSync(dpy, False); + } + ++void drawroundedcorners(Client *c) { ++ // if set to zero in config.h, do not attempt to round ++ if(CORNER_RADIUS < 0) return; ++ ++ // NOTE: this is extremely hacky and surely could be optimized. ++ // Any X wizards out there reading this, please pull request. ++ if (CORNER_RADIUS > 0 && c && !c->isfullscreen) { ++ Window win; ++ win = c->win; ++ if(!win) return; ++ ++ XWindowAttributes win_attr; ++ if(!XGetWindowAttributes(dpy, win, &win_attr)) return; ++ ++ // set in config.h: ++ 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); ++ } ++} ++ + void + resizemouse(const Arg *arg) + { +@@ -1726,6 +1781,7 @@ resizemouse(const Arg *arg) + selmon = m; + focus(NULL); + } ++ drawroundedcorners(c); + } + + void diff --git a/pkgs/dwm/pndwm.nix b/pkgs/dwm/pndwm.nix index 95d0f1a..a4aa6f2 100644 --- a/pkgs/dwm/pndwm.nix +++ b/pkgs/dwm/pndwm.nix @@ -6,6 +6,7 @@ let ./dwm-center.diff ./dwm-apps.diff ./dwm-autostart.diff + # ./dwm-rounded.diff ]; }; in |