From 8b879eb3ebc717d8e312833472c3bd4a8176cbd6 Mon Sep 17 00:00:00 2001 From: speediegq Date: Sat, 3 Sep 2022 18:07:51 +0200 Subject: [PATCH] Add toggle for fading --- options.h | 2 ++ speedwm.c | 18 +++++++++++++++++- toggle.h | 1 + xresources.h | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/options.h b/options.h index 6dd581e..a30d0bd 100644 --- a/options.h +++ b/options.h @@ -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 */ /* Window aesthetic options */ +#if USEFADE static int fadeinactive = 1; /* Fade inactive windows */ 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 Bool bUseOpacity = True; /* Starts with opacity on any unfocused windows */ +#endif /* Rounded corners * In order to use: diff --git a/speedwm.c b/speedwm.c index 7bb6f97..75ad673 100644 --- a/speedwm.c +++ b/speedwm.c @@ -95,7 +95,11 @@ enum { NetSupported, NetWMName, #endif NetWMState, NetWMCheck, 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 { DWMTags, DWMLast }; enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, @@ -368,7 +372,9 @@ static Client *nexttiled(Client *c); #if USEMOUSE static void placemouse(const Arg *arg); #endif +#if USEFADE static void opacity(Client *c, double opacity); +#endif static void pop(Client *); static void propertynotify(XEvent *e); static void quit(const Arg *arg); @@ -1916,7 +1922,9 @@ focus(Client *c) grabbuttons(c, 1); XSetWindowBorder(dpy, c->win, scheme[SchemeSelBorder][ColBorder].pixel); setfocus(c); +#if USEFADE opacity(c, activeopacity); +#endif } else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]); @@ -3139,6 +3147,7 @@ nexttiled(Client *c) return c; } +#if USEFADE void opacity(Client *c, double opacity) { @@ -3150,6 +3159,7 @@ opacity(Client *c, double opacity) } else XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]); } +#endif void placemouse(const Arg *arg) @@ -3945,10 +3955,12 @@ setmfact(const Arg *arg) void toggleopacity(const Arg *arg) { +#if USEFADE bUseOpacity = !bUseOpacity; for (Monitor* m = mons; m; m = m->next) for (Client* c = m->clients; c; c = c->next) opacity(c, (bUseOpacity && c != selmon->sel) ? inactiveopacity : activeopacity); +#endif } void @@ -4005,7 +4017,9 @@ setup(void) dwmatom[DWMTags] = XInternAtom(dpy, "_DWM_TAGS", False); netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False); netatom[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False); +#if USEFADE netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); +#endif netatom[NetDesktopViewport] = XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False); netatom[NetNumberOfDesktops] = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False); netatom[NetCurrentDesktop] = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False); @@ -4426,7 +4440,9 @@ unfocus(Client *c, int setfocus) if (!c) return; grabbuttons(c, 0); +#if USEFADE opacity(c, inactiveopacity); +#endif XSetWindowBorder(dpy, c->win, scheme[SchemeNormBorder][ColBorder].pixel); if (setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); diff --git a/toggle.h b/toggle.h index f2a3c93..24fd933 100644 --- a/toggle.h +++ b/toggle.h @@ -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 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 USEIMLIB2 1 /* Whether or not to use imlib2. Required by USEWINICON and USETAGPREVIEW. */ diff --git a/xresources.h b/xresources.h index b589676..d22f6e9 100644 --- a/xresources.h +++ b/xresources.h @@ -151,7 +151,9 @@ ResourcePref resources[] = { { "hidesticky", INTEGER, &hidesticky }, { "hidefloating", INTEGER, &hidefloating }, { "statusallmons", INTEGER, &statusallmons }, +#if USEFADE { "fadeinactive", INTEGER, &fadeinactive }, +#endif { "stairpx", INTEGER, &stairpx }, { "stairdirection", INTEGER, &stairdirection }, { "stairsamesize", INTEGER, &stairsamesize },