Update: Rounded corners can now be used with borderpx set to <0, add

mouse keybind to move up/down tags, more color options for window
borders
This commit is contained in:
speediegq 2022-10-03 01:36:47 +02:00
parent 0109ef2845
commit a32677a6cc
6 changed files with 51 additions and 50 deletions

View file

@ -43,14 +43,15 @@ static char *colstatus[] = {
/* Colors to use for opacity /* Colors to use for opacity
*/ */
static const unsigned int alphas[][3] = { static const unsigned int alphas[][3] = {
/* fg bg border/unused */ /* fg bg border/unused */
[SchemeBar] = { OPAQUE, baropacity, baropacity }, [SchemeBar] = { OPAQUE, baropacity, baropacity },
[SchemeNormTitle] = { OPAQUE, normtitleopacity, normtitleopacity }, [SchemeNormTitle] = { OPAQUE, normtitleopacity, normtitleopacity },
[SchemeSelTitle] = { OPAQUE, seltitleopacity, seltitleopacity }, [SchemeSelTitle] = { OPAQUE, seltitleopacity, seltitleopacity },
[SchemeLayout] = { OPAQUE, layoutopacity, layoutopacity }, [SchemeLayout] = { OPAQUE, layoutopacity, layoutopacity },
[SchemeStatus] = { OPAQUE, statusopacity, statusopacity }, [SchemeStatus] = { OPAQUE, statusopacity, statusopacity },
[SchemeHiddenTitle] = { OPAQUE, hiddenopacity, hiddenopacity }, [SchemeHiddenTitle] = { OPAQUE, hiddenopacity, hiddenopacity },
[SchemeTags] = { tagselopacity, tagselopacity, tagnormopacity }, [SchemeNormBorder] = { OPAQUE, normborderopacity, selborderopacity },
[SchemeTags] = { tagselopacity, tagselopacity, tagnormopacity },
}; };
/* Colors to use for tags /* Colors to use for tags

View file

@ -364,7 +364,6 @@
- speedwm.deckformat: [%d] - speedwm.deckformat: [%d]
!! !!
!! Rounded corners. If set to 1, rounded corners will be drawn. Otherwise sharp corners will be used instead. (1/0) !! Rounded corners. If set to 1, rounded corners will be drawn. Otherwise sharp corners will be used instead. (1/0)
!! Note that this requires border size (borderpx) to be set to 0, otherwise rounded corners will automatically be disabled.
!! !!
- speedwm.roundedcorners: 0 - speedwm.roundedcorners: 0
!! !!

View file

@ -155,6 +155,7 @@
These binds can be activated using your mouse These binds can be activated using your mouse
- Tag <num> (Left click) | Switch to tag <num> - Tag <num> (Left click) | Switch to tag <num>
- Tag (Scrolling up/down) | Switch to the next/previous tag
- Layout indicator (Left click) | Switch to the next layout - Layout indicator (Left click) | Switch to the next layout
- Layout indicator (Middle click) | Switch to the next layout - Layout indicator (Middle click) | Switch to the next layout
- Layout indicator (Right click) | Open a dmenu list of all layouts - Layout indicator (Right click) | Open a dmenu list of all layouts

View file

@ -25,6 +25,8 @@ static const Button buttons[] = {
{ ClkWinTitle, 0, Button3, spawn, RCMD("speedwm-utils") }, { ClkWinTitle, 0, Button3, spawn, RCMD("speedwm-utils") },
{ ClkRootWin, 0, Button3, spawn, RCMD(RUN_DESKTOP) }, { ClkRootWin, 0, Button3, spawn, RCMD(RUN_DESKTOP) },
{ ClkTagBar, 0, Button1, view, {0} }, { ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button4, view, {0} },
{ ClkTagBar, 0, Button5, view, {0} },
}; };
/* Commands that will run when a part of the status bar is pressed /* Commands that will run when a part of the status bar is pressed

View file

@ -134,8 +134,6 @@ static Bool bUseOpacity = True; /* Starts with opacity on
#endif #endif
/* Rounded corners /* Rounded corners
* In order to use:
* - borderpx must also be set to 0 or else rounded corners will be disabled.
*/ */
#if USEROUNDCORNERS #if USEROUNDCORNERS
static int roundedcorners = 0; /* Enable (1) rounded corners or disable (0) rounded corners. */ static int roundedcorners = 0; /* Enable (1) rounded corners or disable (0) rounded corners. */
@ -337,6 +335,8 @@ static const unsigned int tagnormopacity = OPAQUE; /* Opacity for other tag
static const unsigned int tagselopacity = 160; /* Opacity for the selected tag */ static const unsigned int tagselopacity = 160; /* Opacity for the selected tag */
static const unsigned int normtitleopacity = 160; /* Opacity for all other windows in the speedwm bar */ static const unsigned int normtitleopacity = 160; /* Opacity for all other windows in the speedwm bar */
static const unsigned int seltitleopacity = 160; /* Opacity for the focused window in the speedwm bar */ static const unsigned int seltitleopacity = 160; /* Opacity for the focused window in the speedwm bar */
static const unsigned int normborderopacity = OPAQUE; /* Opacity for the all window borders except selected */
static const unsigned int selborderopacity = OPAQUE; /* Opacity for the selected window border */
static const unsigned int hiddenopacity = 0; /* Opacity for hidden/minimized windows */ static const unsigned int hiddenopacity = 0; /* Opacity for hidden/minimized windows */
static const unsigned int statusopacity = 160; /* Opacity for speedwm status bar */ static const unsigned int statusopacity = 160; /* Opacity for speedwm status bar */

View file

@ -1099,6 +1099,16 @@ buttonpress(XEvent *e)
selmon->mouseactivated = 1; selmon->mouseactivated = 1;
#endif #endif
click = ClkTagBar; click = ClkTagBar;
if ( ev->button == Button4 || ev->button == Button5 ) {
arg.ui = selmon->tagset[selmon->seltags];
if ( !(arg.ui & ((1 << (LENGTH(tags) - 1)) + 1)) ) {
arg.ui = (ev->button == Button4) ? (arg.ui >> 1) : (arg.ui << 1);
} else if ( arg.ui & 1 ) {
arg.ui = (ev->button == Button4) ? arg.ui : (arg.ui << 1);
} else if ( arg.ui & (1 << (LENGTH(tags) - 1)) ) {
arg.ui = (ev->button == Button4) ? (arg.ui >> 1) : arg.ui;
}
} else
arg.ui = 1 << i; arg.ui = 1 << i;
} else if (ev->x < x + TEXTW(selmon->ltsymbol) && !layoutposition && !selmon->isreset) // right layout } else if (ev->x < x + TEXTW(selmon->ltsymbol) && !layoutposition && !selmon->isreset) // right layout
click = ClkLtSymbol; // right layout click = ClkLtSymbol; // right layout
@ -1391,56 +1401,44 @@ configurenotify(XEvent *e)
#if USEROUNDCORNERS #if USEROUNDCORNERS
void drawroundedcorners(Client *c) void drawroundedcorners(Client *c)
{ {
if (cornerradius <= 0 || !c || c->isfullscreen) {
return;
}
if (borderpx >= 1)
return;
if (!roundedcorners) Window w = c->win;
return; XWindowAttributes wa;
XGetWindowAttributes(dpy, w, &wa);
Window win;
win = c->win;
if (!win)
return;
XWindowAttributes win_attr; if(!XGetWindowAttributes(dpy, w, &wa))
if (!XGetWindowAttributes(dpy, win, &win_attr)) return;
return;
int dia = 2 * cornerradius; int width = borderpx * 2 + wa.width;
int w = c->w; int height = borderpx * 2 + wa.height;
int h = c->h; int rad = cornerradius * enablegaps;
if (w < dia || h < dia) int dia = 2 * rad;
return;
Pixmap mask; if(width < dia || height < dia)
mask = XCreatePixmap(dpy, win, w, h, 1); return;
if (!mask)
return; Pixmap mask = XCreatePixmap(dpy, w, width, height, 1);
if(!mask)
return;
XGCValues xgcv; XGCValues xgcv;
GC shape_gc; GC shape_gc = XCreateGC(dpy, mask, 0, &xgcv);
shape_gc = XCreateGC(dpy, mask, 0, &xgcv); if(!shape_gc) {
if (!shape_gc) {
XFreePixmap(dpy, mask); XFreePixmap(dpy, mask);
free(shape_gc);
return; return;
} }
XSetForeground(dpy, shape_gc, 0); XSetForeground(dpy, shape_gc, 0);
XFillRectangle(dpy, mask, shape_gc, 0, 0, w, h); XFillRectangle(dpy, mask, shape_gc, 0, 0, width, height);
XSetForeground(dpy, shape_gc, 1); XSetForeground(dpy, shape_gc, 1);
XFillArc(dpy, mask, shape_gc, 0, 0, dia, dia, 0, 23040); 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, width-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, 0, height-dia-1, dia, dia, 0, 23040);
XFillArc(dpy, mask, shape_gc, w-dia-1, h-dia-1, dia, dia, 0, 23040); XFillArc(dpy, mask, shape_gc, width-dia-1, height-dia-1, dia, dia, 0, 23040);
XFillRectangle(dpy, mask, shape_gc, cornerradius, 0, w-dia, h); XFillRectangle(dpy, mask, shape_gc, rad, 0, width-dia, height);
XFillRectangle(dpy, mask, shape_gc, 0, cornerradius, w, h-dia); XFillRectangle(dpy, mask, shape_gc, 0, rad, width, height-dia);
XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, mask, ShapeSet); XShapeCombineMask(dpy, w, ShapeBounding, 0-wa.border_width, 0-wa.border_width, mask, ShapeSet);
XFreePixmap(dpy, mask); XFreePixmap(dpy, mask);
XFreeGC(dpy, shape_gc); XFreeGC(dpy, shape_gc);
} }
@ -5783,8 +5781,8 @@ updatesystray(void)
XMapSubwindows(dpy, systray->win); XMapSubwindows(dpy, systray->win);
/* redraw background */ /* redraw background */
XSetForeground(dpy, drw->gc, scheme[SchemeBar][ColBg].pixel); XSetForeground(dpy, drw->gc, scheme[SchemeBar][ColBg].pixel);
//XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh); // Without alpha //XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh); // vanilla
XFillRectangle(dpy, systray->win, XCreateGC(dpy, root, 0 , NULL), 0, 0, w, bh); // With alpha XFillRectangle(dpy, systray->win, XCreateGC(dpy, root, 0 , NULL), 0, 0, w, bh);
XSync(dpy, False); XSync(dpy, False);
} }