Add toggle for fading

This commit is contained in:
speediegq 2022-09-03 18:07:51 +02:00
parent cbdd11a538
commit 8b879eb3eb
4 changed files with 22 additions and 1 deletions

View file

@ -124,10 +124,12 @@ static unsigned int smartgapsize = 0; /* Gaps for smartgaps. If set
static int smartgaps = 0; /* 1 means use different gap size when there is only one window */ static int smartgaps = 0; /* 1 means use different gap size when there is only one window */
/* Window aesthetic options */ /* Window aesthetic options */
#if USEFADE
static int fadeinactive = 1; /* Fade inactive windows */ static int fadeinactive = 1; /* Fade inactive windows */
static double activeopacity = 1.0f; /* Window opacity when it's focused (0 <= opacity <= 1) */ static double activeopacity = 1.0f; /* Window opacity when it's focused (0 <= opacity <= 1) */
static double inactiveopacity = 0.875f; /* Window opacity when it's inactive (0 <= opacity <= 1) */ static double inactiveopacity = 0.875f; /* Window opacity when it's inactive (0 <= opacity <= 1) */
static Bool bUseOpacity = True; /* Starts with opacity on any unfocused windows */ static Bool bUseOpacity = True; /* Starts with opacity on any unfocused windows */
#endif
/* Rounded corners /* Rounded corners
* In order to use: * In order to use:

View file

@ -95,7 +95,11 @@ enum { NetSupported, NetWMName,
#endif #endif
NetWMState, NetWMCheck, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDesktop, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDesktop,
NetWMWindowTypeDialog, NetClientList, NetDesktopNames, NetDesktopViewport, NetNumberOfDesktops, NetCurrentDesktop, NetWMWindowsOpacity, NetClientListStacking, NetClientInfo, NetLast }; /* EWMH atoms */ NetWMWindowTypeDialog, NetClientList, NetDesktopNames, NetDesktopViewport, NetNumberOfDesktops, NetCurrentDesktop,
#if USEFADE
NetWMWindowsOpacity,
#endif
NetClientListStacking, NetClientInfo, NetLast }; /* EWMH atoms */
enum { WMClass, WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { WMClass, WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { DWMTags, DWMLast }; enum { DWMTags, DWMLast };
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
@ -368,7 +372,9 @@ static Client *nexttiled(Client *c);
#if USEMOUSE #if USEMOUSE
static void placemouse(const Arg *arg); static void placemouse(const Arg *arg);
#endif #endif
#if USEFADE
static void opacity(Client *c, double opacity); static void opacity(Client *c, double opacity);
#endif
static void pop(Client *); static void pop(Client *);
static void propertynotify(XEvent *e); static void propertynotify(XEvent *e);
static void quit(const Arg *arg); static void quit(const Arg *arg);
@ -1916,7 +1922,9 @@ focus(Client *c)
grabbuttons(c, 1); grabbuttons(c, 1);
XSetWindowBorder(dpy, c->win, scheme[SchemeSelBorder][ColBorder].pixel); XSetWindowBorder(dpy, c->win, scheme[SchemeSelBorder][ColBorder].pixel);
setfocus(c); setfocus(c);
#if USEFADE
opacity(c, activeopacity); opacity(c, activeopacity);
#endif
} else { } else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]); XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
@ -3139,6 +3147,7 @@ nexttiled(Client *c)
return c; return c;
} }
#if USEFADE
void void
opacity(Client *c, double opacity) opacity(Client *c, double opacity)
{ {
@ -3150,6 +3159,7 @@ opacity(Client *c, double opacity)
} else } else
XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]); XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]);
} }
#endif
void void
placemouse(const Arg *arg) placemouse(const Arg *arg)
@ -3945,10 +3955,12 @@ setmfact(const Arg *arg)
void void
toggleopacity(const Arg *arg) { toggleopacity(const Arg *arg) {
#if USEFADE
bUseOpacity = !bUseOpacity; bUseOpacity = !bUseOpacity;
for (Monitor* m = mons; m; m = m->next) for (Monitor* m = mons; m; m = m->next)
for (Client* c = m->clients; c; c = c->next) for (Client* c = m->clients; c; c = c->next)
opacity(c, (bUseOpacity && c != selmon->sel) ? inactiveopacity : activeopacity); opacity(c, (bUseOpacity && c != selmon->sel) ? inactiveopacity : activeopacity);
#endif
} }
void void
@ -4005,7 +4017,9 @@ setup(void)
dwmatom[DWMTags] = XInternAtom(dpy, "_DWM_TAGS", False); dwmatom[DWMTags] = XInternAtom(dpy, "_DWM_TAGS", False);
netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False); netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
netatom[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False); netatom[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False);
#if USEFADE
netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False);
#endif
netatom[NetDesktopViewport] = XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False); netatom[NetDesktopViewport] = XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False);
netatom[NetNumberOfDesktops] = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False); netatom[NetNumberOfDesktops] = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False);
netatom[NetCurrentDesktop] = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False); netatom[NetCurrentDesktop] = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False);
@ -4426,7 +4440,9 @@ unfocus(Client *c, int setfocus)
if (!c) if (!c)
return; return;
grabbuttons(c, 0); grabbuttons(c, 0);
#if USEFADE
opacity(c, inactiveopacity); opacity(c, inactiveopacity);
#endif
XSetWindowBorder(dpy, c->win, scheme[SchemeNormBorder][ColBorder].pixel); XSetWindowBorder(dpy, c->win, scheme[SchemeNormBorder][ColBorder].pixel);
if (setfocus) { if (setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);

View file

@ -3,6 +3,7 @@
*/ */
#define USEIPC 1 /* Whether or not to use IPC. If you set this to 1, set USEIPC to true in toggle.mk and comment the YAJLLIBS and YAJLINC lines in config.mk. Not compatible with BSDs so for those, set this to 0. */ #define USEIPC 1 /* Whether or not to use IPC. If you set this to 1, set USEIPC to true in toggle.mk and comment the YAJLLIBS and YAJLINC lines in config.mk. Not compatible with BSDs so for those, set this to 0. */
#define USEALPHA 1 /* Whether or not to use transparency for the bar */ #define USEALPHA 1 /* Whether or not to use transparency for the bar */
#define USEFADE 1 /* Whether or not to use fading windows */
#define USEMOUSE 1 /* Whether or not to use mouse binds */ #define USEMOUSE 1 /* Whether or not to use mouse binds */
#define USEIMLIB2 1 /* Whether or not to use imlib2. Required by USEWINICON and USETAGPREVIEW. */ #define USEIMLIB2 1 /* Whether or not to use imlib2. Required by USEWINICON and USETAGPREVIEW. */

View file

@ -151,7 +151,9 @@ ResourcePref resources[] = {
{ "hidesticky", INTEGER, &hidesticky }, { "hidesticky", INTEGER, &hidesticky },
{ "hidefloating", INTEGER, &hidefloating }, { "hidefloating", INTEGER, &hidefloating },
{ "statusallmons", INTEGER, &statusallmons }, { "statusallmons", INTEGER, &statusallmons },
#if USEFADE
{ "fadeinactive", INTEGER, &fadeinactive }, { "fadeinactive", INTEGER, &fadeinactive },
#endif
{ "stairpx", INTEGER, &stairpx }, { "stairpx", INTEGER, &stairpx },
{ "stairdirection", INTEGER, &stairdirection }, { "stairdirection", INTEGER, &stairdirection },
{ "stairsamesize", INTEGER, &stairsamesize }, { "stairsamesize", INTEGER, &stairsamesize },