Skip to content

Commit

Permalink
change alpha with keyboard shortcut C-F11/C-F12
Browse files Browse the repository at this point in the history
  • Loading branch information
luquinha.virus committed Aug 19, 2020
1 parent e187610 commit 73a6020
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ static Shortcut shortcuts[] = {
{ MODKEY, XK_Down, kscrolldown, {.i = 1} },
{ MODKEY, XK_u, kscrollup, {.i = -1} },
{ MODKEY, XK_d, kscrolldown, {.i = -1} },
{ ControlMask, XK_F11, changealpha, {.f = -0.05} },
{ ControlMask, XK_F12, changealpha, {.f = +0.05} },
{ TERMMOD, XK_Up, zoom, {.f = +1} },
{ TERMMOD, XK_Down, zoom, {.f = -1} },
{ TERMMOD, XK_K, zoom, {.f = +1} },
Expand Down
15 changes: 15 additions & 0 deletions x.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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 *);
Expand Down Expand Up @@ -303,6 +304,20 @@ numlock(const Arg *dummy)
win.mode ^= MODE_NUMLOCK;
}

void
changealpha(const Arg *arg)
{
if((alpha > 0 && arg->f < 0) || (alpha < 1 && arg->f > 0))

This comment has been minimized.

Copy link
@Farzat07

Farzat07 Dec 29, 2023

Doesn't this line seem redundant?
Even if the value of alpha goes outside the boundary, the next if statements correct it back.
It doesn't seem to really reduce computation either as the conditions still have to be calculated.

alpha += arg->f;
if(alpha < 0)
alpha = 0;
if(alpha > 1)
alpha = 1;

xloadcols();
redraw();
}

void
zoom(const Arg *arg)
{
Expand Down

0 comments on commit 73a6020

Please sign in to comment.