alwaysontopall-6.2.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       alwaysontopall-6.2.diff (3293B)
       ---
            1 From 9cd160c4ba9c345c24644a7da77cc4f04fc93c4e Mon Sep 17 00:00:00 2001
            2 From: Matt Quintanilla <matt@mattquintanilla.xyz>
            3 Date: Fri, 13 Oct 2023 20:11:08 +0100
            4 Subject: [PATCH] alwaysontop for all
            5 
            6 ---
            7  config.def.h |  1 +
            8  dwm.c        | 45 +++++++++++++++++++++++++++++++++++++++++++--
            9  2 files changed, 44 insertions(+), 2 deletions(-)
           10 
           11 diff --git a/config.def.h b/config.def.h
           12 index 1c0b587..c3c7edd 100644
           13 --- a/config.def.h
           14 +++ b/config.def.h
           15 @@ -78,6 +78,7 @@ static Key keys[] = {
           16          { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
           17          { MODKEY,                       XK_space,  setlayout,      {0} },
           18          { MODKEY|ShiftMask,             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 4465af1..8d54b26 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, 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 @@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
           37  static void tile(Monitor *);
           38  static void togglebar(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 @@ -732,8 +733,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 @@ -1356,6 +1360,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 +                        }
           68 +                }
           69 +        }
           70 +
           71          if (m->lt[m->sellt]->arrange) {
           72                  wc.stack_mode = Below;
           73                  wc.sibling = m->barwin;
           74 @@ -1716,6 +1731,32 @@ togglefloating(const Arg *arg)
           75          if (selmon->sel->isfloating)
           76                  resize(selmon->sel, selmon->sel->x, selmon->sel->y,
           77                          selmon->sel->w, selmon->sel->h, 0);
           78 +        else
           79 +                selmon->sel->isalwaysontop = 0; /* disabled, turn this off too */
           80 +        arrange(selmon);
           81 +}
           82 +
           83 +void
           84 +togglealwaysontop(const Arg *arg)
           85 +{
           86 +        if (!selmon->sel)
           87 +                return;
           88 +        if (selmon->sel->isfullscreen)
           89 +                return;
           90 +
           91 +        if(selmon->sel->isalwaysontop){
           92 +                selmon->sel->isalwaysontop = 0;
           93 +        }else{
           94 +                                c->isalwaysontop = 0;
           95 +
           96 +        }
           97 +
           98          arrange(selmon);
           99  }
          100  
          101 -- 
          102 2.31.1
          103