mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 12:05:45 +00:00
Adding rounded corners patch
This commit is contained in:
parent
f2673fec53
commit
a560b9cb53
@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
|||||||
|
|
||||||
### Changelog:
|
### 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-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
|
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/)
|
- [rotatestack](https://dwm.suckless.org/patches/rotatestack/)
|
||||||
- let's you rotate through the stack using keyboard shortcuts
|
- 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/)
|
- [savefloats](https://dwm.suckless.org/patches/save_floats/)
|
||||||
- saves size and position of every floating window before it is forced into tiled mode
|
- 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
|
- if the window is made floating again then the old dimensions will be restored
|
||||||
|
@ -36,6 +36,9 @@ static const int showsystray = 1; /* 0 means no systray */
|
|||||||
#if ONLYQUITONEMPTY_PATCH
|
#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 */
|
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
|
#endif // ONLYQUITONEMPTY_PATCH
|
||||||
|
#if ROUNDED_CORNERS_PATCH
|
||||||
|
static const int corner_radius = 10;
|
||||||
|
#endif // ROUNDED_CORNERS_PATCH
|
||||||
#if EXTRABAR_PATCH
|
#if EXTRABAR_PATCH
|
||||||
static const char statussep = ';'; /* separator between status bars */
|
static const char statussep = ';'; /* separator between status bars */
|
||||||
#endif // EXTRABAR_PATCH
|
#endif // EXTRABAR_PATCH
|
||||||
|
@ -23,12 +23,15 @@ FREETYPEINC = /usr/include/freetype2
|
|||||||
# Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH
|
# Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH
|
||||||
#LMPDCLIENT = -lmpdclient
|
#LMPDCLIENT = -lmpdclient
|
||||||
|
|
||||||
|
# Uncomment this for the rounded corners patch / ROUNDED_CORNERS_PATCH
|
||||||
|
#XEXTLIB = -lXext
|
||||||
|
|
||||||
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
# Uncomment this for the swallow patch / SWALLOW_PATCH
|
||||||
#LXCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
#LXCBLIBS = -lX11-xcb -lxcb -lxcb-res
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
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
|
# flags
|
||||||
|
14
dwm.c
14
dwm.c
@ -652,6 +652,11 @@ arrangemon(Monitor *m)
|
|||||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
||||||
if (m->lt[m->sellt]->arrange)
|
if (m->lt[m->sellt]->arrange)
|
||||||
m->lt[m->sellt]->arrange(m);
|
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
|
void
|
||||||
@ -2261,6 +2266,9 @@ movemouse(const Arg *arg)
|
|||||||
resize(c, nx, ny, c->w, c->h, 1);
|
resize(c, nx, ny, c->w, c->h, 1);
|
||||||
#endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH
|
#endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH
|
||||||
}
|
}
|
||||||
|
#if ROUNDED_CORNERS_PATCH
|
||||||
|
drawroundedcorners(c);
|
||||||
|
#endif // ROUNDED_CORNERS_PATCH
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (ev.type != ButtonRelease);
|
} while (ev.type != ButtonRelease);
|
||||||
@ -2270,6 +2278,9 @@ movemouse(const Arg *arg)
|
|||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
#if ROUNDED_CORNERS_PATCH
|
||||||
|
drawroundedcorners(c);
|
||||||
|
#endif // ROUNDED_CORNERS_PATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
@ -2526,6 +2537,9 @@ resizemouse(const Arg *arg)
|
|||||||
c->sfh = nh;
|
c->sfh = nh;
|
||||||
#endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH
|
#endif // SAVEFLOATS_PATCH / EXRESIZE_PATCH
|
||||||
#endif // RESIZECORNERS_PATCH
|
#endif // RESIZECORNERS_PATCH
|
||||||
|
#if ROUNDED_CORNERS_PATCH
|
||||||
|
drawroundedcorners(c);
|
||||||
|
#endif // ROUNDED_CORNERS_PATCH
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,9 @@
|
|||||||
#if ROTATESTACK_PATCH
|
#if ROTATESTACK_PATCH
|
||||||
#include "rotatestack.c"
|
#include "rotatestack.c"
|
||||||
#endif
|
#endif
|
||||||
|
#if ROUNDED_CORNERS_PATCH
|
||||||
|
#include "roundedcorners.c"
|
||||||
|
#endif
|
||||||
#if SCRATCHPAD_PATCH
|
#if SCRATCHPAD_PATCH
|
||||||
#include "scratchpad.c"
|
#include "scratchpad.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,6 +87,9 @@
|
|||||||
#if ROTATESTACK_PATCH
|
#if ROTATESTACK_PATCH
|
||||||
#include "rotatestack.h"
|
#include "rotatestack.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if ROUNDED_CORNERS_PATCH
|
||||||
|
#include "roundedcorners.h"
|
||||||
|
#endif
|
||||||
#if SCRATCHPAD_PATCH
|
#if SCRATCHPAD_PATCH
|
||||||
#include "scratchpad.h"
|
#include "scratchpad.h"
|
||||||
#endif
|
#endif
|
||||||
|
50
patch/roundedcorners.c
Normal file
50
patch/roundedcorners.c
Normal file
@ -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);
|
||||||
|
}
|
1
patch/roundedcorners.h
Normal file
1
patch/roundedcorners.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void drawroundedcorners(Client *c);
|
@ -382,6 +382,13 @@
|
|||||||
*/
|
*/
|
||||||
#define ROTATESTACK_PATCH 0
|
#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
|
/* 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
|
* into tiled mode. If the window is made floating again then the old dimensions
|
||||||
* will be restored.
|
* will be restored.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user