sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-fadeinactive-20200607-67d76bd.diff (3689B)


      1 From ff573f7c27aa31d898498ae2a9bf368879ae2c3d Mon Sep 17 00:00:00 2001
      2 From: BrunoCooper17 <BrunoCooper17@outlook.com>
      3 Date: Mon, 7 Jun 2021 19:12:41 -0500
      4 Subject: [PATCH] fadeinactive Patch
      5 
      6 ---
      7  config.def.h                   |  2 +
      8  dwm.c                          | 18 +++++++-
      9  2 files changed, 19 insertions(+), 1 deletion(-)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 1c0b587..6485e7a 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -5,6 +5,8 @@ static const unsigned int borderpx  = 1;        /* border pixel of windows */
     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 it's focused (0 <= opacity <= 1) */
     20 +static const double inactiveopacity = 0.875f;   /* Window opacity when it's inactive (0 <= opacity <= 1) */
     21  static const char *fonts[]          = { "monospace:size=10" };
     22  static const char dmenufont[]       = "monospace:size=10";
     23  static const char col_gray1[]       = "#222222";
     24 diff --git a/dwm.c b/dwm.c
     25 index b0b3466..157659f 100644
     26 --- a/dwm.c
     27 +++ b/dwm.c
     28 @@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
     29  enum { SchemeNorm, SchemeSel }; /* color schemes */
     30  enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
     31         NetWMFullscreen, NetActiveWindow, NetWMWindowType,
     32 -       NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
     33 +       NetWMWindowTypeDialog, NetClientList, NetWMWindowsOpacity, NetLast }; /* EWMH atoms */
     34  enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
     35  enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
     36         ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
     37 @@ -185,6 +185,7 @@ static void monocle(Monitor *m);
     38  static void motionnotify(XEvent *e);
     39  static void movemouse(const Arg *arg);
     40  static Client *nexttiled(Client *c);
     41 +static void opacity(Client *c, double opacity);
     42  static void pop(Client *);
     43  static void propertynotify(XEvent *e);
     44  static void quit(const Arg *arg);
     45 @@ -798,6 +799,7 @@ focus(Client *c)
     46  		grabbuttons(c, 1);
     47  		XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
     48  		setfocus(c);
     49 +		opacity(c, activeopacity);
     50  	} else {
     51  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
     52  		XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
     53 @@ -1200,6 +1202,18 @@ nexttiled(Client *c)
     54  	return c;
     55  }
     56  
     57 +void
     58 +opacity(Client *c, double opacity)
     59 +{
     60 +	if(opacity > 0 && opacity < 1) {
     61 +		unsigned long real_opacity[] = { opacity * 0xffffffff };
     62 +		XChangeProperty(dpy, c->win, netatom[NetWMWindowsOpacity], XA_CARDINAL,
     63 +				32, PropModeReplace, (unsigned char *)real_opacity,
     64 +				1);
     65 +	} else
     66 +		XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]);
     67 +}
     68 +
     69  void
     70  pop(Client *c)
     71  {
     72 @@ -1563,6 +1577,7 @@ setup(void)
     73  	netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
     74  	netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
     75  	netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
     76 +	netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False);
     77  	/* init cursors */
     78  	cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
     79  	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
     80 @@ -1755,6 +1770,7 @@ unfocus(Client *c, int setfocus)
     81  	if (!c)
     82  		return;
     83  	grabbuttons(c, 0);
     84 +	opacity(c, inactiveopacity);
     85  	XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
     86  	if (setfocus) {
     87  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
     88 -- 
     89 2.32.0
     90