diff options
| -rw-r--r-- | config.h | 5 | ||||
| -rw-r--r-- | config.h.rej | 10 | ||||
| -rw-r--r-- | config.mk.rej | 11 | ||||
| -rwxr-xr-x | st | bin | 106912 -> 107048 bytes | |||
| -rw-r--r-- | st.h.rej | 7 | ||||
| -rw-r--r-- | x.c | 24 | ||||
| -rw-r--r-- | x.c.rej | 140 | ||||
| -rw-r--r-- | x.o | bin | 78808 -> 79648 bytes |
8 files changed, 28 insertions, 169 deletions
@@ -97,7 +97,8 @@ unsigned int tabspaces = 4; /* bg opacity */ float alpha = 0.9; -float alphaUnfocused = 0.9; +float alphaOffset = 0.0; +float alphaUnfocused; /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { @@ -213,6 +214,8 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Y, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + { MODKEY, XK_s, changealpha, {.f = -0.05} }, + { MODKEY, XK_a, changealpha, {.f = +0.05} }, { MODKEY, XK_o, externalpipe, {.v = openurlcmd } }, { MODKEY, XK_c, externalpipe, {.v = copyurlcmd } }, }; diff --git a/config.h.rej b/config.h.rej deleted file mode 100644 index df5f094..0000000 --- a/config.h.rej +++ /dev/null @@ -1,10 +0,0 @@ ---- config.def.h -+++ config.def.h -@@ -114,6 +117,7 @@ static const char *colorname[] = { - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", -+ "black", - }; - - diff --git a/config.mk.rej b/config.mk.rej deleted file mode 100644 index ad62275..0000000 --- a/config.mk.rej +++ /dev/null @@ -1,11 +0,0 @@ ---- config.mk -+++ config.mk -@@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config - INCS = -I$(X11INC) \ - `$(PKG_CONFIG) --cflags fontconfig` \ - `$(PKG_CONFIG) --cflags freetype2` --LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ -+LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\ - `$(PKG_CONFIG) --libs fontconfig` \ - `$(PKG_CONFIG) --libs freetype2` - Binary files differdiff --git a/st.h.rej b/st.h.rej deleted file mode 100644 index b0b8fb8..0000000 --- a/st.h.rej +++ /dev/null @@ -1,7 +0,0 @@ ---- st.h -+++ st.h -@@ -123,3 +124,4 @@ extern char *termname; - extern unsigned int tabspaces; - extern unsigned int defaultfg; - extern unsigned int defaultbg; -+extern float alpha, alphaUnfocused; @@ -55,6 +55,7 @@ static void clipcopy(const Arg *); static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); +static void changealpha(const Arg *); static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); @@ -166,6 +167,7 @@ static void xsetenv(void); static void xseturgency(int); static int evcol(XEvent *); static int evrow(XEvent *); +static float clamp(float, float, float); static void expose(XEvent *); static void visibility(XEvent *); @@ -299,6 +301,18 @@ numlock(const Arg *dummy) } void +changealpha(const Arg *arg) +{ + if((alpha > 0 && arg->f < 0) || (alpha < 1 && arg->f > 0)) + alpha += arg->f; + alpha = clamp(alpha, 0.0, 1.0); + alphaUnfocused = clamp(alpha-alphaOffset, 0.0, 1.0); + + xloadcols(); + redraw(); +} + +void zoom(const Arg *arg) { Arg larg; @@ -351,6 +365,15 @@ evrow(XEvent *e) return y / win.ch; } +float +clamp(float value, float lower, float upper) { + if(value < lower) + return lower; + if(value > upper) + return upper; + return value; +} + void mousesel(XEvent *e, int done) { @@ -2228,6 +2251,7 @@ run: cols = MAX(cols, 1); rows = MAX(rows, 1); defaultbg = MAX(LEN(colorname), 256); + alphaUnfocused = alpha-alphaOffset; tnew(cols, rows); xinit(cols, rows); xsetenv(); diff --git a/x.c.rej b/x.c.rej deleted file mode 100644 index 9f60899..0000000 --- a/x.c.rej +++ /dev/null @@ -1,140 +0,0 @@ ---- x.c -+++ x.c -@@ -105,6 +105,7 @@ typedef struct { - XSetWindowAttributes attrs; - int scr; - int isfixed; /* is fixed geometry? */ -+ int depth; /* bit depth */ - int l, t; /* left and top offset */ - int gm; /* geometry mask */ - } XWindow; -@@ -243,6 +244,7 @@ static char *usedfont = NULL; - static double usedfontsize = 0; - static double defaultfontsize = 0; - -+static char *opt_alpha = NULL; - static char *opt_class = NULL; - static char **opt_cmd = NULL; - static char *opt_embed = NULL; -@@ -252,6 +254,8 @@ static char *opt_line = NULL; - static char *opt_name = NULL; - static char *opt_title = NULL; - -+static int focused = 0; -+ - static int oldbutton = 3; /* button event on startup: 3 = release */ - - void -@@ -734,7 +738,7 @@ xresize(int col, int row) - - XFreePixmap(xw.dpy, xw.buf); - xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, -- DefaultDepth(xw.dpy, xw.scr)); -+ xw.depth); - XftDrawChange(xw.draw, xw.buf); - xclear(0, 0, win.w, win.h); - -@@ -772,28 +776,38 @@ xloadcolor(int i, const char *name, Color *ncolor) - return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); - } - -+void -+xloadalpha(void) -+{ -+ float const usedAlpha = focused ? alpha : alphaUnfocused; -+ if (opt_alpha) alpha = strtof(opt_alpha, NULL); -+ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha); -+ dc.col[defaultbg].pixel &= 0x00FFFFFF; -+ dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24; -+} -+ - void - xloadcols(void) - { -- int i; - static int loaded; - Color *cp; - -- if (loaded) { -- for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) -- XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); -- } else { -- dc.collen = MAX(LEN(colorname), 256); -- dc.col = xmalloc(dc.collen * sizeof(Color)); -+ if (!loaded) { -+ dc.collen = 1 + (defaultbg = MAX(LEN(colorname), 256)); -+ dc.col = xmalloc((dc.collen) * sizeof(Color)); - } - -- for (i = 0; i < dc.collen; i++) -+ for (int i = 0; i+1 < dc.collen; ++i) - if (!xloadcolor(i, NULL, &dc.col[i])) { - if (colorname[i]) - die("could not allocate color '%s'\n", colorname[i]); - else - die("could not allocate color %d\n", i); - } -+ if (dc.collen) // cannot die, as the color is already loaded. -+ xloadcolor(focused ?bg :bgUnfocused, NULL, &dc.col[defaultbg]); -+ -+ xloadalpha(); - loaded = 1; - } - -@@ -1103,11 +1117,23 @@ xinit(int cols, int rows) - Window parent; - pid_t thispid = getpid(); - XColor xmousefg, xmousebg; -+ XWindowAttributes attr; -+ XVisualInfo vis; - - if (!(xw.dpy = XOpenDisplay(NULL))) - die("can't open display\n"); - xw.scr = XDefaultScreen(xw.dpy); -- xw.vis = XDefaultVisual(xw.dpy, xw.scr); -+ -+ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) { -+ parent = XRootWindow(xw.dpy, xw.scr); -+ xw.depth = 32; -+ } else { -+ XGetWindowAttributes(xw.dpy, parent, &attr); -+ xw.depth = attr.depth; -+ } -+ -+ XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis); -+ xw.vis = vis.visual; - - /* font */ - if (!FcInit()) -@@ -1117,7 +1143,7 @@ xinit(int cols, int rows) - xloadfonts(usedfont, 0); - - /* colors */ -- xw.cmap = XDefaultColormap(xw.dpy, xw.scr); -+ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); - xloadcols(); - - /* adjust fixed window geometry */ -@@ -1137,19 +1163,15 @@ xinit(int cols, int rows) - | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; - xw.attrs.colormap = xw.cmap; - -- if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) -- parent = XRootWindow(xw.dpy, xw.scr); - xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, -- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, -+ win.w, win.h, 0, xw.depth, InputOutput, - xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity - | CWEventMask | CWColormap, &xw.attrs); - - memset(&gcvalues, 0, sizeof(gcvalues)); - gcvalues.graphics_exposures = False; -- dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, -- &gcvalues); -- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, -- DefaultDepth(xw.dpy, xw.scr)); -+ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth); -+ dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues); - XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); - XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); - Binary files differ |
