Add invert patch
This commit is contained in:
parent
dd8edca4b6
commit
482279846d
|
@ -218,6 +218,7 @@ static Shortcut shortcuts[] = {
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
||||||
|
{ TERMMOD, XK_X, invert, { } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
37
x.c
37
x.c
|
@ -59,6 +59,7 @@ static void zoom(const Arg *);
|
||||||
static void zoomabs(const Arg *);
|
static void zoomabs(const Arg *);
|
||||||
static void zoomreset(const Arg *);
|
static void zoomreset(const Arg *);
|
||||||
static void ttysend(const Arg *);
|
static void ttysend(const Arg *);
|
||||||
|
static void invert(const Arg *);
|
||||||
|
|
||||||
/* config.h for applying patches and the configuration. */
|
/* config.h for applying patches and the configuration. */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -258,9 +259,29 @@ static char *opt_line = NULL;
|
||||||
static char *opt_name = NULL;
|
static char *opt_name = NULL;
|
||||||
static char *opt_title = NULL;
|
static char *opt_title = NULL;
|
||||||
|
|
||||||
|
static int invertcolors = 0;
|
||||||
static int oldbutton = 3; /* button event on startup: 3 = release */
|
static int oldbutton = 3; /* button event on startup: 3 = release */
|
||||||
static int cursorblinks = 0;
|
static int cursorblinks = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
invert(const Arg *dummy)
|
||||||
|
{
|
||||||
|
invertcolors = !invertcolors;
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
Color
|
||||||
|
invertedcolor(Color *clr) {
|
||||||
|
XRenderColor rc;
|
||||||
|
Color inverted;
|
||||||
|
rc.red = ~clr->color.red;
|
||||||
|
rc.green = ~clr->color.green;
|
||||||
|
rc.blue = ~clr->color.blue;
|
||||||
|
rc.alpha = clr->color.alpha;
|
||||||
|
XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &rc, &inverted);
|
||||||
|
return inverted;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
clipcopy(const Arg *dummy)
|
clipcopy(const Arg *dummy)
|
||||||
{
|
{
|
||||||
|
@ -838,9 +859,12 @@ xsetcolorname(int x, const char *name)
|
||||||
void
|
void
|
||||||
xclear(int x1, int y1, int x2, int y2)
|
xclear(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
XftDrawRect(xw.draw,
|
Color c;
|
||||||
&dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg],
|
c = dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg];
|
||||||
x1, y1, x2-x1, y2-y1);
|
if (invertcolors) {
|
||||||
|
c = invertedcolor(&c);
|
||||||
|
}
|
||||||
|
XftDrawRect(xw.draw, &c, x1, y1, x2-x1, y2-y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1453,6 +1477,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||||
if (base.mode & ATTR_INVISIBLE)
|
if (base.mode & ATTR_INVISIBLE)
|
||||||
fg = bg;
|
fg = bg;
|
||||||
|
|
||||||
|
if (invertcolors) {
|
||||||
|
revfg = invertedcolor(fg);
|
||||||
|
revbg = invertedcolor(bg);
|
||||||
|
fg = &revfg;
|
||||||
|
bg = &revbg;
|
||||||
|
}
|
||||||
|
|
||||||
/* Intelligent cleaning up of the borders. */
|
/* Intelligent cleaning up of the borders. */
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
xclear(0, (y == 0)? 0 : winy, win.vborderpx,
|
xclear(0, (y == 0)? 0 : winy, win.vborderpx,
|
||||||
|
|
Loading…
Reference in New Issue