sites

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

alwaysontop-6.2.diff (3451B)


      1 From 9cd160c4ba9c345c24644a7da77cc4f04fc93c4e Mon Sep 17 00:00:00 2001
      2 From: Rob Pilling <robpilling@gmail.com>
      3 Date: Mon, 27 Jul 2020 20:11:08 +0100
      4 Subject: [PATCH] alwaysontop
      5 
      6 ---
      7  config.h |  1 +
      8  dwm.c    | 45 +++++++++++++++++++++++++++++++++++++++++++--
      9  2 files changed, 44 insertions(+), 2 deletions(-)
     10 
     11 diff --git a/config.h b/config.h
     12 index 7283a2d..c10bd8b 100644
     13 --- a/config.h
     14 +++ b/config.h
     15 @@ -178,6 +178,7 @@ static Key keys[] = {
     16  	{ MODKEY,                       XK_e,      setlayout,      {.v = &layouts[LAYOUT_I_grid]} },
     17  
     18  	{ MODKEY,                       XK_space,  togglefloating, {0} },
     19 +	{ MODKEY|ShiftMask,             XK_space,  togglealwaysontop, {0} },
     20  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     21  	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
     22  	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
     23 diff --git a/dwm.c b/dwm.c
     24 index cc36b03..95e69e1 100644
     25 --- a/dwm.c
     26 +++ b/dwm.c
     27 @@ -92,7 +92,7 @@ struct Client {
     28  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     29  	int bw, oldbw;
     30  	unsigned int tags;
     31 -	int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     32 +	int isfixed, iscentered, isfloating, isalwaysontop, isurgent, neverfocus, oldstate, isfullscreen;
     33  	Client *next;
     34  	Client *snext;
     35  	Monitor *mon;
     36 @@ -220,6 +220,7 @@ static void bstack(Monitor *);
     37  static void togglebar(const Arg *arg);
     38  static void togglebartrans(const Arg *arg);
     39  static void togglefloating(const Arg *arg);
     40 +static void togglealwaysontop(const Arg *arg);
     41  static void toggletag(const Arg *arg);
     42  static void toggleview(const Arg *arg);
     43  static void unfocus(Client *c, int setfocus);
     44 @@ -801,8 +802,11 @@ drawbar(Monitor *m)
     45  		if (m->sel) {
     46  			drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
     47  			drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
     48 -			if (m->sel->isfloating)
     49 +			if (m->sel->isfloating) {
     50  				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
     51 +				if (m->sel->isalwaysontop)
     52 +					drw_rect(drw, x + boxs, bh - boxw, boxw, boxw, 0, 0);
     53 +			}
     54  		} else {
     55  			drw_setscheme(drw, scheme[SchemeNorm]);
     56  			drw_rect(drw, x, 0, w, bh, 1, 1);
     57 @@ -1430,6 +1434,17 @@ restack(Monitor *m)
     58  		return;
     59  	if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
     60  		XRaiseWindow(dpy, m->sel->win);
     61 +
     62 +	/* raise the aot window */
     63 +	for(Monitor *m_search = mons; m_search; m_search = m_search->next){
     64 +		for(c = m_search->clients; c; c = c->next){
     65 +			if(c->isalwaysontop){
     66 +				XRaiseWindow(dpy, c->win);
     67 +				break;
     68 +			}
     69 +		}
     70 +	}
     71 +
     72  	if (m->lt[m->sellt]->arrange) {
     73  		wc.stack_mode = Below;
     74  		wc.sibling = m->barwin;
     75 @@ -1800,6 +1815,32 @@ togglefloating(const Arg *arg)
     76  	if (selmon->sel->isfloating)
     77  		resize(selmon->sel, selmon->sel->x, selmon->sel->y,
     78  			selmon->sel->w, selmon->sel->h, 0);
     79 +	else
     80 +		selmon->sel->isalwaysontop = 0; /* disabled, turn this off too */
     81 +	arrange(selmon);
     82 +}
     83 +
     84 +void
     85 +togglealwaysontop(const Arg *arg)
     86 +{
     87 +	if (!selmon->sel)
     88 +		return;
     89 +	if (selmon->sel->isfullscreen)
     90 +		return;
     91 +
     92 +	if(selmon->sel->isalwaysontop){
     93 +		selmon->sel->isalwaysontop = 0;
     94 +	}else{
     95 +		/* disable others */
     96 +		for(Monitor *m = mons; m; m = m->next)
     97 +			for(Client *c = m->clients; c; c = c->next)
     98 +				c->isalwaysontop = 0;
     99 +
    100 +		/* turn on, make it float too */
    101 +		selmon->sel->isfloating = 1;
    102 +		selmon->sel->isalwaysontop = 1;
    103 +	}
    104 +
    105  	arrange(selmon);
    106  }
    107  
    108 -- 
    109 2.27.0
    110