rounded corners ?

This commit is contained in:
WanderingPenwing 2024-07-30 17:54:28 +02:00
parent 0e2d696edb
commit 2274701c80
14 changed files with 213 additions and 458 deletions

View file

@ -1,109 +0,0 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
static const unsigned int borderpx = 32; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "Mononoki Nerd Font:size=20" };
static const char dmenufont[] = "Mononoki Nerd Font:size=20";
static unsigned int baralpha = 0xd0;
static unsigned int borderalpha = OPAQUE;
static const char col_bg[] = "#222222";
static const char col_fg[] = "#cccccc";
static const char col_fga[] = "#eeeeee";
static const char col_bga[] = "#3fb36d";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_fg, col_bg, col_bg },
[SchemeSel] = { col_fga, col_bga, col_bga },
};
/* tagging */
static const char *tags[] = { "", "", "", "uu", "", "a"};
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1},
{ "Firefox", NULL, NULL, 1 << 8, 0, -1},
};
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
};
/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "~/nixos/scripts/dmenu_launcher.sh", NULL };
static const char *termcmd[] = { "kodama", NULL };
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_a, killclient, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
TAGKEYS( XK_ampersand, 0)
TAGKEYS( XK_eacute, 1)
TAGKEYS( XK_quotedbl, 2)
TAGKEYS( XK_apostrophe, 3)
TAGKEYS( XK_parenleft, 4)
TAGKEYS( XK_minus, 5)
TAGKEYS( XK_egrave, 6)
TAGKEYS( XK_underscore, 7)
TAGKEYS( XK_ccedilla, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};

View file

@ -1,10 +0,0 @@
--- config.def.h
+++ config.def.h
@@ -102,7 +102,6 @@ static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
- { ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },

View file

@ -3,6 +3,7 @@
/* appearance */
static const unsigned int borderpx = 6; /* border pixel of windows */
static const unsigned int gappx = 6;
static const unsigned int CORNER_RADIUS = 24;
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
@ -13,7 +14,7 @@ static unsigned int borderalpha = OPAQUE;
static const char col_bg[] = "#222222";
static const char col_fg[] = "#cccccc";
static const char col_fga[] = "#eeeeee";
static const char col_bga[] = "#3fb36d";
static const char col_bga[] = "#318d56"; //#3fb36d
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_fg, col_bg, col_bg },
@ -21,7 +22,7 @@ static const char *colors[][3] = {
};
/* tagging */
static const char *tags[] = { "", "", "", " ", "", " "};
static const char *tags[] = { "", "", "", " ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 "};
static const Rule rules[] = {
/* xprop(1):
@ -31,9 +32,9 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
{ "Chromium-browser", NULL, NULL, 0, 0, -1},
{ "Jellyfin Media Player", NULL, NULL, 0, 0, -1},
{ "calcifer", NULL, NULL, 1<<3, 0, -1},
{ "jiji", NULL, NULL, 1<<5, 0, -1},
{ "discord", NULL, NULL, 1<<5, 0, -1},
{ "calcifer", NULL, NULL, 1<<2, 0, -1},
{ "jiji", NULL, NULL, 1<<3, 0, -1},
{ "discord", NULL, NULL, 1<<3, 0, -1},
};
/* layout(s) */
@ -44,8 +45,8 @@ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen win
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "[M]", monocle },
{ "", tile }, /* first entry is default */
{ "", monocle },
};
/* key definitions */
@ -63,8 +64,8 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "/home/penwing/nixos/scripts/dmenu_launcher.sh", NULL };
static const char *termcmd[] = { "kodama", NULL };
static const char *chromium[] = { "chromium --wm-window-animations-disabled --animation-duration-scale=0", NULL };
static const char *screenlock[] = { "betterlockscreen -l", NULL };
static const char *chromium[] = { "chromium", "--wm-window-animations-disabled", "--animation-duration-scale=0", NULL };
static const char *screenlock[] = { "betterlockscreen", "-l", NULL };
static const Key keys[] = {
@ -104,15 +105,16 @@ static const Key keys[] = {
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
// { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
// { ClkWinTitle, 0, Button2, zoom, {0} },
// { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
// { ClkClientWin, MODKEY, Button1, movemouse, {0} },
// { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
// { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
// { ClkTagBar, 0, Button1, view, {0} },
//
// { ClkTagBar, 0, Button3, toggleview, {0} },
// { ClkTagBar, MODKEY, Button1, tag, {0} },
// { ClkTagBar, MODKEY, Button3, toggletag, {0} },

View file

@ -23,7 +23,7 @@ FREETYPEINC = /usr/include/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lXext
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}

View file

@ -1,94 +0,0 @@
diff -up a/config.def.h b/config.def.h
--- a/config.def.h
+++ b/config.def.h
@@ -2,6 +2,7 @@
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int gappx = 5; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
@@ -85,6 +86,9 @@ static const Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ { MODKEY, XK_minus, setgaps, {.i = -1 } },
+ { MODKEY, XK_equal, setgaps, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff -up a/dwm.c b/dwm.c
--- a/dwm.c 2023-04-30
+++ b/dwm.c 2023-04-30
@@ -119,6 +119,7 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
+ int gappx; /* gaps between windows */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
+static void setgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -641,6 +643,7 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
+ m->gappx = gappx;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@@ -1508,6 +1511,16 @@ setfullscreen(Client *c, int fullscreen)
}
void
+setgaps(const Arg *arg)
+{
+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
+ selmon->gappx = 0;
+ else
+ selmon->gappx += arg->i;
+ arrange(selmon);
+}
+
+void
setlayout(const Arg *arg)
{
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
@@ -1697,18 +1710,18 @@ tile(Monitor *m)
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
- mw = m->ww;
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
- if (i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
- if (my + HEIGHT(c) < m->wh)
- my += HEIGHT(c);
+ mw = m->ww - m->gappx;
+ for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
+ resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
+ if (my + HEIGHT(c) + m->gappx < m->wh)
+ my += HEIGHT(c) + m->gappx;
} else {
- h = (m->wh - ty) / (n - i);
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
- if (ty + HEIGHT(c) < m->wh)
- ty += HEIGHT(c);
+ h = (m->wh - ty) / (n - i) - m->gappx;
+ resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
+ if (ty + HEIGHT(c) + m->gappx < m->wh)
+ ty += HEIGHT(c) + m->gappx;
}
}

View file

@ -1,56 +0,0 @@
From 54719285bd1a984e2efce6e8a8eab184fec11abf Mon Sep 17 00:00:00 2001
From: Sermak <sermak@jarvis.com>
Date: Mon, 8 Jul 2019 01:06:44 +0200
Subject: [PATCH] Simulate toggleable fullscreen mode
---
config.def.h | 1 +
dwm.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/config.def.h b/config.def.h
index 1c0b587..f774cc5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -76,6 +76,7 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY|ShiftMask, XK_f, fullscreen, {0} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/dwm.c b/dwm.c
index 4465af1..04b1e06 100644
--- a/dwm.c
+++ b/dwm.c
@@ -199,6 +199,7 @@ 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 fullscreen(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -1497,6 +1498,19 @@ setfullscreen(Client *c, int fullscreen)
}
}
+Layout *last_layout;
+void
+fullscreen(const Arg *arg)
+{
+ if (selmon->showbar) {
+ for(last_layout = (Layout *)layouts; last_layout != selmon->lt[selmon->sellt]; last_layout++);
+ setlayout(&((Arg) { .v = &layouts[2] }));
+ } else {
+ setlayout(&((Arg) { .v = last_layout }));
+ }
+ togglebar(arg);
+}
+
void
setlayout(const Arg *arg)
{
--
2.22.0

View file

@ -1,48 +0,0 @@
:100644 100644 f1d86b2 0000000 M dwm.c
diff --git a/dwm.c b/dwm.c
index f1d86b2..d41cc14 100644
--- a/dwm.c
+++ b/dwm.c
@@ -433,9 +433,15 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
- do
+ unsigned int occ = 0;
+ for(c = m->clients; c; c=c->next)
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
+ do {
+ /* Do not reserve space for vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
+ } while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -715,19 +721,18 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
- occ |= c->tags;
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* Do not draw vacant tags */
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
x += w;
}
w = TEXTW(m->ltsymbol);

View file

@ -1,81 +0,0 @@
From 969dbbc548f16da5d94630e3d54e9c96c5296520 Mon Sep 17 00:00:00 2001
From: Ryan Kes <alrayyes@gmail.com>
Date: Thu, 28 Mar 2019 14:36:07 +0100
Subject: [PATCH] dwm-notitle-6.2
---
config.def.h | 1 -
dwm.c | 20 ++++----------------
2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..19330cd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -102,7 +102,6 @@ static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
- { ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
diff --git a/dwm.c b/dwm.c
index 4465af1..bcf5cb1 100644
--- a/dwm.c
+++ b/dwm.c
@@ -64,8 +64,8 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
- ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkClientWin,
+ ClkRootWin, ClkLast }; /* clicks */
typedef union {
int i;
@@ -439,10 +439,8 @@ buttonpress(XEvent *e)
arg.ui = 1 << i;
} else if (ev->x < x + blw)
click = ClkLtSymbol;
- else if (ev->x > selmon->ww - TEXTW(stext))
- click = ClkStatusText;
else
- click = ClkWinTitle;
+ click = ClkStatusText;
} else if ((c = wintoclient(ev->window))) {
focus(c);
restack(selmon);
@@ -729,15 +727,8 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - x) > bh) {
- if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
- if (m->sel->isfloating)
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
- } else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
- }
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}
@@ -1235,11 +1226,8 @@ propertynotify(XEvent *e)
drawbars();
break;
}
- if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
+ if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName])
updatetitle(c);
- if (c == c->mon->sel)
- drawbar(c->mon);
- }
if (ev->atom == netatom[NetWMWindowType])
updatewindowtype(c);
}
--
2.21.0

58
dwm.c
View file

@ -39,6 +39,7 @@
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
#include <X11/extensions/shape.h>
#include <X11/Xft/Xft.h>
#include "drw.h"
@ -241,6 +242,7 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void xinitvisual();
static void zoom(const Arg *arg);
static void drawroundedcorners(Client *c);
/* variables */
static const char broken[] = "broken";
@ -1094,6 +1096,9 @@ manage(Window w, XWindowAttributes *wa)
unfocus(selmon->sel, 0);
c->mon->sel = c;
arrange(c->mon);
drawroundedcorners(c);
XMapWindow(dpy, c->win);
focus(NULL);
}
@ -1304,6 +1309,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)
{
@ -1348,6 +1402,9 @@ resizemouse(const Arg *arg)
}
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
resize(c, c->x, c->y, nw, nh, 1);
drawroundedcorners(c);
break;
}
} while (ev.type != ButtonRelease);
@ -1359,6 +1416,7 @@ resizemouse(const Arg *arg)
selmon = m;
focus(NULL);
}
drawroundedcorners(c);
}
void

View file

@ -68,8 +68,8 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkClientWin,
ClkRootWin, ClkLast }; /* clicks */
typedef union {
int i;
@ -460,10 +460,8 @@ buttonpress(XEvent *e)
arg.ui = 1 << i;
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
click = ClkLtSymbol;
else if (ev->x > selmon->ww - (int)TEXTW(stext))
else
click = ClkStatusText;
else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
focus(c);
restack(selmon);
@ -754,15 +752,8 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - tw - x) > bh) {
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}
@ -1264,11 +1255,8 @@ propertynotify(XEvent *e)
drawbars();
break;
}
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName])
updatetitle(c);
if (c == c->mon->sel)
drawbar(c->mon);
}
if (ev->atom == netatom[NetWMWindowType])
updatewindowtype(c);
}

View file

@ -1,30 +1,20 @@
--- dwm.c
+++ dwm.c
@@ -439,10 +439,8 @@ buttonpress(XEvent *e)
arg.ui = 1 << i;
} else if (ev->x < x + blw)
click = ClkLtSymbol;
- else if (ev->x > selmon->ww - TEXTW(stext))
- click = ClkStatusText;
else
- click = ClkWinTitle;
+ click = ClkStatusText;
} else if ((c = wintoclient(ev->window))) {
focus(c);
restack(selmon);
@@ -729,15 +727,8 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
--- dwm.c Mon Feb 24 21:41:55 2020
+++ dwm.c Mon Feb 24 21:48:42 2020
@@ -242,6 +243,7 @@
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void xinitvisual();
+static void drawroundedcorners(Client *c);
if ((w = m->ww - sw - x) > bh) {
- if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
- if (m->sel->isfloating)
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
- } else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
- }
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}
/* variables */
static const char broken[] = "broken";
@@ -1446,6 +1500,9 @@
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
resize(c, nx, ny, nw, nh, 1);
+
+ drawroundedcorners(c);
+
break;
}
} while (ev.type != ButtonRelease);

BIN
dwm.o

Binary file not shown.

View file

@ -0,0 +1,114 @@
/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* */
/* Back by popular demand, the dwm rounded corners patch. */
/* http://github.com/mitchweaver/suckless */
/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* */
/* Things to know about this patch: */
/* 1. You need to add '-lXext' to the libraries linked in config.mk */
/* LIBS = -L${X11LIB} -lX11 -lXext */
/* 2. You need to set a CORNER_RADIUS integer in your config.h: */
/* static const int CORNER_RADIUS = 10; */
/* 3. You must have "borderpx = 0;" in your config.h */
/* 4. This patch assumes ALL other "OFFICIAL" and "mitch" patches have been applied. */
/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* */
--- dwm/dwm.c Mon Feb 24 21:41:55 2020
+++ dwm/dwm.c Mon Feb 24 21:48:42 2020
@@ -39,6 +39,7 @@
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
+#include <X11/extensions/shape.h>
#include <X11/Xft/Xft.h>
#include "drw.h"
@@ -241,6 +242,7 @@
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void xinitvisual();
+static void drawroundedcorners(Client *c);
/* variables */
static const char broken[] = "broken";
@@ -1133,6 +1135,9 @@
unfocus(selmon->sel, 0);
c->mon->sel = c;
arrange(c->mon);
+
+ drawroundedcorners(c);
+
XMapWindow(dpy, c->win);
focus(NULL);
}
@@ -1337,6 +1342,55 @@
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)
{
@@ -1393,6 +1447,9 @@
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
resize(c, nx, ny, nw, nh, 1);
+
+ drawroundedcorners(c);
+
break;
}
} while (ev.type != ButtonRelease);
@@ -1406,6 +1463,7 @@
selmon = m;
focus(NULL);
}
+ drawroundedcorners(c);
}
void

View file

@ -8,6 +8,7 @@ pkgs.mkShell {
pkgs.xorg.libX11
pkgs.xorg.libXft
pkgs.xorg.libXinerama
pkgs.xorg.libXext
pkgs.fontconfig
pkgs.freetype
];