dwm-fadeinactive-20211114-a786211.diff - sites - public wiki contents of suckle… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-fadeinactive-20211114-a786211.diff (5052B) | |
--- | |
1 From dcdb97829cc2bb4e842ca66142eb24b4b4028a9f Mon Sep 17 00:00:00 2001 | |
2 From: BrunoCooper17 <[email protected]> | |
3 Date: Sun, 14 Nov 2021 23:10:08 -0600 | |
4 Subject: [PATCH] fadeinactive Patch | |
5 | |
6 --- | |
7 config.def.h | 4 ++++ | |
8 dwm.c | 27 ++++++++++++++++++++++++++- | |
9 2 files changed, 30 insertions(+), 1 deletion(-) | |
10 | |
11 diff --git a/config.def.h b/config.def.h | |
12 index a2ac963..2e001cf 100644 | |
13 --- a/config.def.h | |
14 +++ b/config.def.h | |
15 @@ -5,6 +5,9 @@ static const unsigned int borderpx = 1; /* borde… | |
16 static const unsigned int snap = 32; /* snap pixel */ | |
17 static const int showbar = 1; /* 0 means no bar */ | |
18 static const int topbar = 1; /* 0 means bottom bar */ | |
19 +static const double activeopacity = 1.0f; /* Window opacity when … | |
20 +static const double inactiveopacity = 0.875f; /* Window opacity when … | |
21 +static Bool bUseOpacity = True; /* Starts with opacity … | |
22 static const char *fonts[] = { "monospace:size=10" }; | |
23 static const char dmenufont[] = "monospace:size=10"; | |
24 static const char col_gray1[] = "#222222"; | |
25 @@ -73,6 +76,7 @@ static Key keys[] = { | |
26 { MODKEY, XK_l, setmfact, {.f … | |
27 { MODKEY, XK_Return, zoom, {0} … | |
28 { MODKEY, XK_Tab, view, {0} … | |
29 + { MODKEY, XK_a, toggleopacity, {0} … | |
30 { MODKEY|ShiftMask, XK_c, killclient, {0} … | |
31 { MODKEY, XK_t, setlayout, {.v … | |
32 { MODKEY, XK_f, setlayout, {.v … | |
33 diff --git a/dwm.c b/dwm.c | |
34 index 5e4d494..d506b1a 100644 | |
35 --- a/dwm.c | |
36 +++ b/dwm.c | |
37 @@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cu… | |
38 enum { SchemeNorm, SchemeSel }; /* color schemes */ | |
39 enum { NetSupported, NetWMName, NetWMState, NetWMCheck, | |
40 NetWMFullscreen, NetActiveWindow, NetWMWindowType, | |
41 - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ | |
42 + NetWMWindowTypeDialog, NetClientList, NetWMWindowsOpacity, NetLa… | |
43 enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* defaul… | |
44 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, | |
45 ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ | |
46 @@ -185,6 +185,7 @@ static void monocle(Monitor *m); | |
47 static void motionnotify(XEvent *e); | |
48 static void movemouse(const Arg *arg); | |
49 static Client *nexttiled(Client *c); | |
50 +static void opacity(Client *c, double opacity); | |
51 static void pop(Client *); | |
52 static void propertynotify(XEvent *e); | |
53 static void quit(const Arg *arg); | |
54 @@ -212,6 +213,7 @@ static void tagmon(const Arg *arg); | |
55 static void tile(Monitor *); | |
56 static void togglebar(const Arg *arg); | |
57 static void togglefloating(const Arg *arg); | |
58 +static void toggleopacity(const Arg *arg); | |
59 static void toggletag(const Arg *arg); | |
60 static void toggleview(const Arg *arg); | |
61 static void unfocus(Client *c, int setfocus); | |
62 @@ -798,6 +800,7 @@ focus(Client *c) | |
63 grabbuttons(c, 1); | |
64 XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBord… | |
65 setfocus(c); | |
66 + opacity(c, activeopacity); | |
67 } else { | |
68 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentT… | |
69 XDeleteProperty(dpy, root, netatom[NetActiveWindow]); | |
70 @@ -1200,6 +1203,18 @@ nexttiled(Client *c) | |
71 return c; | |
72 } | |
73 | |
74 +void | |
75 +opacity(Client *c, double opacity) | |
76 +{ | |
77 + if(bUseOpacity && opacity > 0 && opacity < 1) { | |
78 + unsigned long real_opacity[] = { opacity * 0xffffffff }; | |
79 + XChangeProperty(dpy, c->win, netatom[NetWMWindowsOpacit… | |
80 + 32, PropModeReplace, (unsigned char *)r… | |
81 + 1); | |
82 + } else | |
83 + XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacit… | |
84 +} | |
85 + | |
86 void | |
87 pop(Client *c) | |
88 { | |
89 @@ -1563,6 +1578,7 @@ setup(void) | |
90 netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYP… | |
91 netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WIND… | |
92 netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", F… | |
93 + netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW… | |
94 /* init cursors */ | |
95 cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); | |
96 cursor[CurResize] = drw_cur_create(drw, XC_sizing); | |
97 @@ -1722,6 +1738,14 @@ togglefloating(const Arg *arg) | |
98 arrange(selmon); | |
99 } | |
100 | |
101 +void | |
102 +toggleopacity(const Arg *arg) { | |
103 + bUseOpacity = !bUseOpacity; | |
104 + for (Monitor* m = mons; m; m = m->next) | |
105 + for (Client* c = m->clients; c; c = c->next) | |
106 + opacity(c, (bUseOpacity && c != selmon->sel) ? … | |
107 +} | |
108 + | |
109 void | |
110 toggletag(const Arg *arg) | |
111 { | |
112 @@ -1755,6 +1779,7 @@ unfocus(Client *c, int setfocus) | |
113 if (!c) | |
114 return; | |
115 grabbuttons(c, 0); | |
116 + opacity(c, inactiveopacity); | |
117 XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pix… | |
118 if (setfocus) { | |
119 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentT… | |
120 -- | |
121 2.33.1 | |
122 |