commit 5d1f9d8143a95331dc39714b0442268a0afd76f2
Author: G-OD <G-OD>
Date:   Fri Mar 31 21:11:11 2023 +0100

    [dwm][patch][awesomebar] Improve efficiency of hover

diff --git 
a/dwm.suckless.org/patches/awesomebar/dwm-awesomebarwithhover-20230431-6.4.diff 
b/dwm.suckless.org/patches/awesomebar/dwm-awesomebarwithhover-20230431-6.4.diff
index 2b5f95bd..3ef9434f 100644
--- 
a/dwm.suckless.org/patches/awesomebar/dwm-awesomebarwithhover-20230431-6.4.diff
+++ 
b/dwm.suckless.org/patches/awesomebar/dwm-awesomebarwithhover-20230431-6.4.diff
@@ -43,7 +43,7 @@ index 061ad66..82a3ed2 100644
        { ClkStatusText,        0,              Button2,        spawn,          
{.v = termcmd } },
        { ClkClientWin,         MODKEY,         Button1,        movemouse,      
{0} },
 diff --git a/dwm.c b/dwm.c
-index e5efb6a..a9d28f0 100644
+index e5efb6a..a51f35e 100644
 --- a/dwm.c
 +++ b/dwm.c
 @@ -50,6 +50,7 @@
@@ -63,15 +63,6 @@ index e5efb6a..a9d28f0 100644
  enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
         NetWMFullscreen, NetActiveWindow, NetWMWindowType,
         NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
-@@ -92,7 +93,7 @@ struct Client {
-       int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
-       int bw, oldbw;
-       unsigned int tags;
--      int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
-+      int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, 
ishovering;
-       Client *next;
-       Client *snext;
-       Monitor *mon;
 @@ -117,6 +118,8 @@ struct Monitor {
        int nmaster;
        int num;
@@ -81,15 +72,18 @@ index e5efb6a..a9d28f0 100644
        int mx, my, mw, mh;   /* screen size */
        int wx, wy, ww, wh;   /* window area  */
        unsigned int seltags;
-@@ -124,6 +127,7 @@ struct Monitor {
+@@ -124,8 +127,10 @@ struct Monitor {
        unsigned int tagset[2];
        int showbar;
        int topbar;
 +      int hidsel;
        Client *clients;
        Client *sel;
++      Client *hov;
        Client *stack;
-@@ -168,13 +172,17 @@ static void expose(XEvent *e);
+       Monitor *next;
+       Window barwin;
+@@ -168,13 +173,17 @@ static void expose(XEvent *e);
  static void focus(Client *c);
  static void focusin(XEvent *e);
  static void focusmon(const Arg *arg);
@@ -108,7 +102,7 @@ index e5efb6a..a9d28f0 100644
  static void incnmaster(const Arg *arg);
  static void keypress(XEvent *e);
  static void killclient(const Arg *arg);
-@@ -204,6 +212,9 @@ static void setlayout(const Arg *arg);
+@@ -204,6 +213,9 @@ static void setlayout(const Arg *arg);
  static void setmfact(const Arg *arg);
  static void setup(void);
  static void seturgent(Client *c, int urg);
@@ -118,7 +112,7 @@ index e5efb6a..a9d28f0 100644
  static void showhide(Client *c);
  static void sigchld(int unused);
  static void spawn(const Arg *arg);
-@@ -214,6 +225,7 @@ static void togglebar(const Arg *arg);
+@@ -214,6 +226,7 @@ static void togglebar(const Arg *arg);
  static void togglefloating(const Arg *arg);
  static void toggletag(const Arg *arg);
  static void toggleview(const Arg *arg);
@@ -126,7 +120,7 @@ index e5efb6a..a9d28f0 100644
  static void unfocus(Client *c, int setfocus);
  static void unmanage(Client *c, int destroyed);
  static void unmapnotify(XEvent *e);
-@@ -442,10 +454,25 @@ buttonpress(XEvent *e)
+@@ -442,10 +455,25 @@ buttonpress(XEvent *e)
                        arg.ui = 1 << i;
                } else if (ev->x < x + TEXTW(selmon->ltsymbol))
                        click = ClkLtSymbol;
@@ -155,7 +149,7 @@ index e5efb6a..a9d28f0 100644
        } else if ((c = wintoclient(ev->window))) {
                focus(c);
                restack(selmon);
-@@ -455,7 +482,7 @@ buttonpress(XEvent *e)
+@@ -455,7 +483,7 @@ buttonpress(XEvent *e)
        for (i = 0; i < LENGTH(buttons); i++)
                if (click == buttons[i].click && buttons[i].func && 
buttons[i].button == ev->button
                && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@@ -164,7 +158,7 @@ index e5efb6a..a9d28f0 100644
  }
  
  void
-@@ -699,7 +726,7 @@ dirtomon(int dir)
+@@ -699,7 +727,7 @@ dirtomon(int dir)
  void
  drawbar(Monitor *m)
  {
@@ -173,7 +167,7 @@ index e5efb6a..a9d28f0 100644
        int boxs = drw->fonts->h / 9;
        int boxw = drw->fonts->h / 6 + 2;
        unsigned int i, occ = 0, urg = 0;
-@@ -716,6 +743,8 @@ drawbar(Monitor *m)
+@@ -716,6 +744,8 @@ drawbar(Monitor *m)
        }
  
        for (c = m->clients; c; c = c->next) {
@@ -182,7 +176,7 @@ index e5efb6a..a9d28f0 100644
                occ |= c->tags;
                if (c->isurgent)
                        urg |= c->tags;
-@@ -736,16 +765,38 @@ drawbar(Monitor *m)
+@@ -736,16 +766,38 @@ drawbar(Monitor *m)
        x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
  
        if ((w = m->ww - tw - x) > bh) {
@@ -197,7 +191,7 @@ index e5efb6a..a9d28f0 100644
 +                      for (c = m->clients; c; c = c->next) {
 +                              if (!ISVISIBLE(c))
 +                                      continue;
-+                              if (c->ishovering)
++                              if (m->hov == c)
 +                                      scm = SchemeHov;
 +                              else if (m->sel == c)
 +                                      scm = SchemeSel;
@@ -226,7 +220,7 @@ index e5efb6a..a9d28f0 100644
        drw_map(drw, m->barwin, 0, 0, m->ww, bh);
  }
  
-@@ -791,9 +842,17 @@ void
+@@ -791,9 +843,17 @@ void
  focus(Client *c)
  {
        if (!c || !ISVISIBLE(c))
@@ -246,7 +240,7 @@ index e5efb6a..a9d28f0 100644
        if (c) {
                if (c->mon != selmon)
                        selmon = c->mon;
-@@ -837,28 +896,52 @@ focusmon(const Arg *arg)
+@@ -837,28 +897,52 @@ focusmon(const Arg *arg)
  }
  
  void
@@ -309,7 +303,7 @@ index e5efb6a..a9d28f0 100644
        }
  }
  
-@@ -968,6 +1051,36 @@ grabkeys(void)
+@@ -968,6 +1052,36 @@ grabkeys(void)
        }
  }
  
@@ -346,7 +340,7 @@ index e5efb6a..a9d28f0 100644
  void
  incnmaster(const Arg *arg)
  {
-@@ -1070,12 +1183,14 @@ manage(Window w, XWindowAttributes *wa)
+@@ -1070,12 +1184,14 @@ manage(Window w, XWindowAttributes *wa)
        XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, 
PropModeAppend,
                (unsigned char *) &(c->win), 1);
        XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* 
some windows require this */
@@ -363,7 +357,7 @@ index e5efb6a..a9d28f0 100644
        focus(NULL);
  }
  
-@@ -1119,18 +1234,68 @@ monocle(Monitor *m)
+@@ -1119,18 +1235,65 @@ monocle(Monitor *m)
  void
  motionnotify(XEvent *e)
  {
@@ -374,19 +368,16 @@ index e5efb6a..a9d28f0 100644
        XMotionEvent *ev = &e->xmotion;
  
 -      if (ev->window != root)
-+      c = wintoclient(ev->window);
-+      m = c ? c->mon : wintomon(ev->window);
-+      c = m->clients;
-+
 +      if (ev->window != selmon->barwin) {
-+              if (c) {
-+                      do {
-+                              c->ishovering = 0;
-+                              if (selmon->sel != c)
-+                                      XSetWindowBorder(dpy, c->win, 
scheme[SchemeNorm][ColBorder].pixel);
-+                              else
-+                                      XSetWindowBorder(dpy, c->win, 
scheme[SchemeSel][ColBorder].pixel);
-+                      } while ((c = c->next));
++              if (selmon->hov) {
++                      if (selmon->hov != selmon->sel)
++                              XSetWindowBorder(dpy, selmon->hov->win, 
scheme[SchemeNorm][ColBorder].pixel);
++                      else
++                              XSetWindowBorder(dpy, selmon->hov->win, 
scheme[SchemeSel][ColBorder].pixel);
++                      
++                      selmon->hov = NULL;
++                      c = wintoclient(ev->window);
++                      m = c ? c->mon : wintomon(ev->window);
 +                      drawbar(m);
 +              }
 +
@@ -407,22 +398,16 @@ index e5efb6a..a9d28f0 100644
        }
 -      mon = m;
 +
++      c = wintoclient(ev->window);
++      m = c ? c->mon : wintomon(ev->window);
++      c = m->clients;
++
 +      x = 0, i = 0;
 +      do
 +              x += TEXTW(tags[i]);
 +      while (ev->x >= x && ++i < LENGTH(tags));
 +      x += TEXTW(selmon->ltsymbol);
-+
 +      if (c) {
-+              Client *start = c;
-+              do {
-+                      c->ishovering = 0;
-+                      if (selmon->sel != c)
-+                              XSetWindowBorder(dpy, c->win, 
scheme[SchemeNorm][ColBorder].pixel);
-+                      else
-+                              XSetWindowBorder(dpy, c->win, 
scheme[SchemeSel][ColBorder].pixel);
-+              } while ((c = c->next));
-+              c = start;
 +              do {
 +                      if (!ISVISIBLE(c))
 +                              continue;
@@ -430,7 +415,13 @@ index e5efb6a..a9d28f0 100644
 +                              x +=(1.0 / (double)m->bt) * m->btw;
 +              } while (ev->x > x && (c = c->next));
 +              if (c) {
-+                      c->ishovering = 1;
++                      if (selmon->hov) {
++                              if (selmon->hov != selmon->sel)
++                                      XSetWindowBorder(dpy, selmon->hov->win, 
scheme[SchemeNorm][ColBorder].pixel);
++                              else
++                                      XSetWindowBorder(dpy, selmon->hov->win, 
scheme[SchemeSel][ColBorder].pixel);
++                      }
++                      selmon->hov = c;
 +                      XSetWindowBorder(dpy, c->win, 
scheme[SchemeHov][ColBorder].pixel);
 +              }
 +      }
@@ -438,7 +429,7 @@ index e5efb6a..a9d28f0 100644
  }
  
  void
-@@ -1196,7 +1361,7 @@ movemouse(const Arg *arg)
+@@ -1196,7 +1359,7 @@ movemouse(const Arg *arg)
  Client *
  nexttiled(Client *c)
  {
@@ -447,7 +438,7 @@ index e5efb6a..a9d28f0 100644
        return c;
  }
  
-@@ -1249,6 +1414,16 @@ propertynotify(XEvent *e)
+@@ -1249,6 +1412,16 @@ propertynotify(XEvent *e)
  void
  quit(const Arg *arg)
  {
@@ -464,7 +455,7 @@ index e5efb6a..a9d28f0 100644
        running = 0;
  }
  
-@@ -1610,6 +1785,42 @@ seturgent(Client *c, int urg)
+@@ -1610,6 +1783,42 @@ seturgent(Client *c, int urg)
        XFree(wmh);
  }
  
@@ -507,7 +498,7 @@ index e5efb6a..a9d28f0 100644
  void
  showhide(Client *c)
  {
-@@ -1744,6 +1955,23 @@ toggleview(const Arg *arg)
+@@ -1744,6 +1953,23 @@ toggleview(const Arg *arg)
        }
  }
  
@@ -531,7 +522,7 @@ index e5efb6a..a9d28f0 100644
  void
  unfocus(Client *c, int setfocus)
  {
-@@ -1815,6 +2043,7 @@ updatebars(void)
+@@ -1815,6 +2041,7 @@ updatebars(void)
                                CWOverrideRedirect|CWBackPixmap|CWEventMask, 
&wa);
                XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
                XMapRaised(dpy, m->barwin);


Reply via email to