[wiki] [sites] [dwm][patch][awesomebar] Improve efficiency of hover || G-OD

From: <git_AT_suckless.org>
Date: Fri, 31 Mar 2023 23:15:48 +0200

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
_AT_@ -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
 _AT_@ -50,6 +50,7 @@
_AT_@ -63,15 +63,6 @@ index e5efb6a..a9d28f0 100644
  enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
         NetWMFullscreen, NetActiveWindow, NetWMWindowType,
         NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
-_AT_@ -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;
 _AT_@ -117,6 +118,8 @@ struct Monitor {
          int nmaster;
          int num;
_AT_@ -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;
-_AT_@ -124,6 +127,7 @@ struct Monitor {
+_AT_@ -124,8 +127,10 @@ struct Monitor {
          unsigned int tagset[2];
          int showbar;
          int topbar;
 + int hidsel;
          Client *clients;
          Client *sel;
++ Client *hov;
          Client *stack;
-_AT_@ -168,13 +172,17 @@ static void expose(XEvent *e);
+ Monitor *next;
+ Window barwin;
+_AT_@ -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);
_AT_@ -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);
-_AT_@ -204,6 +212,9 @@ static void setlayout(const Arg *arg);
+_AT_@ -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);
_AT_@ -118,7 +112,7 @@ index e5efb6a..a9d28f0 100644
  static void showhide(Client *c);
  static void sigchld(int unused);
  static void spawn(const Arg *arg);
-_AT_@ -214,6 +225,7 @@ static void togglebar(const Arg *arg);
+_AT_@ -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);
_AT_@ -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);
-_AT_@ -442,10 +454,25 @@ buttonpress(XEvent *e)
+_AT_@ -442,10 +455,25 @@ buttonpress(XEvent *e)
                          arg.ui = 1 << i;
                  } else if (ev->x < x + TEXTW(selmon->ltsymbol))
                          click = ClkLtSymbol;
_AT_@ -155,7 +149,7 @@ index e5efb6a..a9d28f0 100644
          } else if ((c = wintoclient(ev->window))) {
                  focus(c);
                  restack(selmon);
-_AT_@ -455,7 +482,7 @@ buttonpress(XEvent *e)
+_AT_@ -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))
_AT_@ -164,7 +158,7 @@ index e5efb6a..a9d28f0 100644
  }
  
  void
-_AT_@ -699,7 +726,7 @@ dirtomon(int dir)
+_AT_@ -699,7 +727,7 @@ dirtomon(int dir)
  void
  drawbar(Monitor *m)
  {
_AT_@ -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;
-_AT_@ -716,6 +743,8 @@ drawbar(Monitor *m)
+_AT_@ -716,6 +744,8 @@ drawbar(Monitor *m)
          }
  
          for (c = m->clients; c; c = c->next) {
_AT_@ -182,7 +176,7 @@ index e5efb6a..a9d28f0 100644
                  occ |= c->tags;
                  if (c->isurgent)
                          urg |= c->tags;
-_AT_@ -736,16 +765,38 @@ drawbar(Monitor *m)
+_AT_@ -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) {
_AT_@ -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;
_AT_@ -226,7 +220,7 @@ index e5efb6a..a9d28f0 100644
          drw_map(drw, m->barwin, 0, 0, m->ww, bh);
  }
  
-_AT_@ -791,9 +842,17 @@ void
+_AT_@ -791,9 +843,17 @@ void
  focus(Client *c)
  {
          if (!c || !ISVISIBLE(c))
_AT_@ -246,7 +240,7 @@ index e5efb6a..a9d28f0 100644
          if (c) {
                  if (c->mon != selmon)
                          selmon = c->mon;
-_AT_@ -837,28 +896,52 @@ focusmon(const Arg *arg)
+_AT_@ -837,28 +897,52 @@ focusmon(const Arg *arg)
  }
  
  void
_AT_@ -309,7 +303,7 @@ index e5efb6a..a9d28f0 100644
          }
  }
  
-_AT_@ -968,6 +1051,36 @@ grabkeys(void)
+_AT_@ -968,6 +1052,36 @@ grabkeys(void)
          }
  }
  
_AT_@ -346,7 +340,7 @@ index e5efb6a..a9d28f0 100644
  void
  incnmaster(const Arg *arg)
  {
-_AT_@ -1070,12 +1183,14 @@ manage(Window w, XWindowAttributes *wa)
+_AT_@ -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 */
_AT_@ -363,7 +357,7 @@ index e5efb6a..a9d28f0 100644
          focus(NULL);
  }
  
-_AT_@ -1119,18 +1234,68 @@ monocle(Monitor *m)
+_AT_@ -1119,18 +1235,65 @@ monocle(Monitor *m)
  void
  motionnotify(XEvent *e)
  {
_AT_@ -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);
 + }
 +
_AT_@ -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;
_AT_@ -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);
 + }
 + }
_AT_@ -438,7 +429,7 @@ index e5efb6a..a9d28f0 100644
  }
  
  void
-_AT_@ -1196,7 +1361,7 @@ movemouse(const Arg *arg)
+_AT_@ -1196,7 +1359,7 @@ movemouse(const Arg *arg)
  Client *
  nexttiled(Client *c)
  {
_AT_@ -447,7 +438,7 @@ index e5efb6a..a9d28f0 100644
          return c;
  }
  
-_AT_@ -1249,6 +1414,16 @@ propertynotify(XEvent *e)
+_AT_@ -1249,6 +1412,16 @@ propertynotify(XEvent *e)
  void
  quit(const Arg *arg)
  {
_AT_@ -464,7 +455,7 @@ index e5efb6a..a9d28f0 100644
          running = 0;
  }
  
-_AT_@ -1610,6 +1785,42 @@ seturgent(Client *c, int urg)
+_AT_@ -1610,6 +1783,42 @@ seturgent(Client *c, int urg)
          XFree(wmh);
  }
  
_AT_@ -507,7 +498,7 @@ index e5efb6a..a9d28f0 100644
  void
  showhide(Client *c)
  {
-_AT_@ -1744,6 +1955,23 @@ toggleview(const Arg *arg)
+_AT_@ -1744,6 +1953,23 @@ toggleview(const Arg *arg)
          }
  }
  
_AT_@ -531,7 +522,7 @@ index e5efb6a..a9d28f0 100644
  void
  unfocus(Client *c, int setfocus)
  {
-_AT_@ -1815,6 +2043,7 @@ updatebars(void)
+_AT_@ -1815,6 +2041,7 @@ updatebars(void)
                                  CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
                  XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
                  XMapRaised(dpy, m->barwin);
Received on Fri Mar 31 2023 - 23:15:48 CEST

This archive was generated by hypermail 2.3.0 : Fri Mar 31 2023 - 23:24:50 CEST