Merge branch 'dwm-statusallmons-20160731-56a31dc.diff' into patched
authorDaniel <thefekete@gmail.com>
Sat, 29 Dec 2018 01:06:23 +0000 (02:06 +0100)
committerDaniel <thefekete@gmail.com>
Sat, 29 Dec 2018 01:06:23 +0000 (02:06 +0100)
1  2 
dwm.c

diff --cc dwm.c
--- 1/dwm.c
--- 2/dwm.c
+++ b/dwm.c
@@@ -791,17 -714,13 +791,17 @@@ drawbar(Monitor *m
        unsigned int i, occ = 0, urg = 0;
        Client *c;
  
 +      if(showsystray && m == systraytomon(m))
 +              stw = getsystraywidth();
 +
        /* draw status first so it can be overdrawn by tags later */
-       if (m == selmon) { /* status is only drawn on selected monitor */
+       if (m == selmon || 1) { /* status is only drawn on selected monitor */
                drw_setscheme(drw, scheme[SchemeNorm]);
 -              sw = TEXTW(stext) - lrpad / 2; /* no right padding so status text hugs the corner */
 -              drw_text(drw, m->ww - sw, 0, sw, bh, lrpad / 2 - 2, stext, 0);
 +              sw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */
 +              drw_text(drw, m->ww - sw - stw, 0, sw, bh, lrpad / 2 - 2, stext, 0);
        }
  
 +      resizebarwin(m);
        for (c = m->clients; c; c = c->next) {
                occ |= c->tags;
                if (c->isurgent)
@@@ -2206,135 -1991,13 +2206,136 @@@ updatesizehints(Client *c
  void
  updatestatus(void)
  {
+       Monitor* m;
        if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
                strcpy(stext, "dwm-"VERSION);
-       drawbar(selmon);
-       updatesystray();
+       for(m = mons; m; m = m->next)
+               drawbar(m);
  }
  
 +void
 +updatesystrayicongeom(Client *i, int w, int h)
 +{
 +      if (i) {
 +              i->h = bh;
 +              if (w == h)
 +                      i->w = bh;
 +              else if (h == bh)
 +                      i->w = w;
 +              else
 +                      i->w = (int) ((float)bh * ((float)w / (float)h));
 +              applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
 +              /* force icons into the systray dimenons if they don't want to */
 +              if (i->h > bh) {
 +                      if (i->w == i->h)
 +                              i->w = bh;
 +                      else
 +                              i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
 +                      i->h = bh;
 +              }
 +      }
 +}
 +
 +void
 +updatesystrayiconstate(Client *i, XPropertyEvent *ev)
 +{
 +      long flags;
 +      int code = 0;
 +
 +      if (!showsystray || !i || ev->atom != xatom[XembedInfo] ||
 +                      !(flags = getatomprop(i, xatom[XembedInfo])))
 +              return;
 +
 +      if (flags & XEMBED_MAPPED && !i->tags) {
 +              i->tags = 1;
 +              code = XEMBED_WINDOW_ACTIVATE;
 +              XMapRaised(dpy, i->win);
 +              setclientstate(i, NormalState);
 +      }
 +      else if (!(flags & XEMBED_MAPPED) && i->tags) {
 +              i->tags = 0;
 +              code = XEMBED_WINDOW_DEACTIVATE;
 +              XUnmapWindow(dpy, i->win);
 +              setclientstate(i, WithdrawnState);
 +      }
 +      else
 +              return;
 +      sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0,
 +                      systray->win, XEMBED_EMBEDDED_VERSION);
 +}
 +
 +void
 +updatesystray(void)
 +{
 +      XSetWindowAttributes wa;
 +      XWindowChanges wc;
 +      Client *i;
 +      Monitor *m = systraytomon(NULL);
 +      unsigned int x = m->mx + m->mw;
 +      unsigned int w = 1;
 +
 +      if (!showsystray)
 +              return;
 +      if (!systray) {
 +              /* init systray */
 +              if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
 +                      die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
 +              systray->win = XCreateSimpleWindow(dpy, root, x, m->by, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
 +              wa.event_mask        = ButtonPressMask | ExposureMask;
 +              wa.override_redirect = True;
 +              wa.background_pixel  = scheme[SchemeNorm][ColBg].pixel;
 +              XSelectInput(dpy, systray->win, SubstructureNotifyMask);
 +              XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
 +                              PropModeReplace, (unsigned char *)&netatom[NetSystemTrayOrientationHorz], 1);
 +              XChangeWindowAttributes(dpy, systray->win, CWEventMask|CWOverrideRedirect|CWBackPixel, &wa);
 +              XMapRaised(dpy, systray->win);
 +              XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
 +              if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
 +                      sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0);
 +                      XSync(dpy, False);
 +              }
 +              else {
 +                      fprintf(stderr, "dwm: unable to obtain system tray.\n");
 +                      free(systray);
 +                      systray = NULL;
 +                      return;
 +              }
 +      }
 +      for (w = 0, i = systray->icons; i; i = i->next) {
 +              /* make sure the background color stays the same */
 +              wa.background_pixel  = scheme[SchemeNorm][ColBg].pixel;
 +              XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
 +              XMapRaised(dpy, i->win);
 +              w += systrayspacing;
 +              i->x = w;
 +              XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
 +              w += i->w;
 +              if (i->mon != m)
 +                      i->mon = m;
 +      }
 +      w = w ? w + systrayspacing : 1;
 +      x -= w;
 +      XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
 +      wc.x = x; wc.y = m->by; wc.width = w; wc.height = bh;
 +      wc.stack_mode = Above; wc.sibling = m->barwin;
 +      XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
 +      XMapWindow(dpy, systray->win);
 +      XMapSubwindows(dpy, systray->win);
 +      /* redraw background */
 +      XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
 +      XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh);
 +      XSync(dpy, False);
 +}
 +
 +void
 +updatetitle(Client *c)
 +{
 +      if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
 +              gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
 +      if (c->name[0] == '\0') /* hack to mark broken clients */
 +              strcpy(c->name, broken);
 +}
 +
  void
  updatewindowtype(Client *c)
  {