[wiki] [sites] update systray patch to also work with multiple monitors || Jan Christoph Ebersbach

From: <hg_AT_suckless.org>
Date: Sat, 24 Mar 2012 18:07:13 +0100 (CET)

changeset: 907:881ca46fdbea
tag: tip
user: Jan Christoph Ebersbach <jceb_AT_e-jc.de>
date: Sat Mar 24 18:07:11 2012 +0100
files: dwm.suckless.org/patches/dwm-6.0-systray.diff dwm.suckless.org/patches/systray.md
description:
update systray patch to also work with multiple monitors


diff -r 8be3df6237d4 -r 881ca46fdbea dwm.suckless.org/patches/dwm-6.0-systray.diff
--- a/dwm.suckless.org/patches/dwm-6.0-systray.diff Sat Mar 24 16:46:47 2012 +0100
+++ b/dwm.suckless.org/patches/dwm-6.0-systray.diff Sat Mar 24 18:07:11 2012 +0100
_AT_@ -1,10 +1,10 @@
 Author: Jan Christoph Ebersbach <jceb_AT_e-jc.de>, inspired by http://code.google.com/p/dwm-plus
-URL: no URL yet
+URL: http://dwm.suckless.org/patches/systray
 Implements a system tray for dwm.
 
 diff -r ad90e7fab364 config.def.h
 --- a/config.def.h Fri Feb 10 00:36:08 2012 +0000
-+++ b/config.def.h Sat Mar 24 13:41:16 2012 +0100
++++ b/config.def.h Sat Mar 24 18:01:59 2012 +0100
 _AT_@ -10,6 +10,8 @@
  static const char selfgcolor[] = "#eeeeee";
  static const unsigned int borderpx = 1; /* border pixel of windows */
_AT_@ -24,7 +24,7 @@
          { "[]=", tile }, /* first entry is default */
 diff -r ad90e7fab364 dwm.c
 --- a/dwm.c Fri Feb 10 00:36:08 2012 +0000
-+++ b/dwm.c Sat Mar 24 13:41:16 2012 +0100
++++ b/dwm.c Sat Mar 24 18:01:59 2012 +0100
 _AT_@ -55,12 +55,15 @@
  #define TAGMASK ((1 << LENGTH(tags)) - 1)
  #define TEXTW(X) (textnw(X, strlen(X)) + dc.font.height)
_AT_@ -44,9 +44,9 @@
  enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
  enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
         ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
-_AT_@ -145,6 +148,19 @@
- const Layout *lt[2];
- };
+_AT_@ -154,6 +157,19 @@
+ int monitor;
+ } Rule;
  
 +typedef struct SystrayIcon SystrayIcon;
 +struct SystrayIcon {
_AT_@ -55,15 +55,15 @@
 + SystrayIcon *next;
 +};
 +
-+typedef struct Systray Systray;
++typedef struct Systray Systray;
 +struct Systray {
 + Window win;
 + SystrayIcon *icons;
 +};
 +
- typedef struct {
- const char *class;
- const char *instance;
+ /* function declarations */
+ static void applyrules(Client *c);
+ static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
 _AT_@ -189,6 +205,7 @@
  static unsigned long getcolor(const char *colstr);
  static Bool getrootptr(int *x, int *y);
_AT_@ -168,7 +168,15 @@
  }
  
  void
-_AT_@ -743,6 +799,9 @@
+_AT_@ -722,6 +778,7 @@
+ unsigned long *col;
+ Client *c;
+
++ resizebarwin(m);
+ for(c = m->clients; c; c = c->next) {
+ occ |= c->tags;
+ if(c->isurgent)
+_AT_@ -743,6 +800,9 @@
          if(m == selmon) { /* status is only drawn on selected monitor */
                  dc.w = TEXTW(stext);
                  dc.x = m->ww - dc.w;
_AT_@ -178,7 +186,15 @@
                  if(dc.x < x) {
                          dc.x = x;
                          dc.w = m->ww - x;
-_AT_@ -962,6 +1021,14 @@
+_AT_@ -862,6 +922,7 @@
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ selmon->sel = c;
+ drawbars();
++ updatesystray();
+ }
+
+ void
+_AT_@ -962,6 +1023,14 @@
          return result;
  }
  
_AT_@ -193,7 +209,7 @@
  Bool
  gettextprop(Window w, Atom atom, char *text, unsigned int size) {
          char **list = NULL;
-_AT_@ -1180,6 +1247,10 @@
+_AT_@ -1180,6 +1249,10 @@
  maprequest(XEvent *e) {
          static XWindowAttributes wa;
          XMapRequestEvent *ev = &e->xmaprequest;
_AT_@ -204,7 +220,7 @@
  
          if(!XGetWindowAttributes(dpy, ev->window, &wa))
                  return;
-_AT_@ -1291,9 +1362,14 @@
+_AT_@ -1291,9 +1364,14 @@
  void
  propertynotify(XEvent *e) {
          Client *c;
_AT_@ -219,7 +235,7 @@
          if((ev->window == root) && (ev->atom == XA_WM_NAME))
                  updatestatus();
          else if(ev->state == PropertyDelete)
-_AT_@ -1343,12 +1419,32 @@
+_AT_@ -1343,12 +1421,32 @@
  }
  
  void
_AT_@ -252,7 +268,7 @@
  resizeclient(Client *c, int x, int y, int w, int h) {
          XWindowChanges wc;
  
-_AT_@ -1603,6 +1699,9 @@
+_AT_@ -1603,6 +1701,9 @@
          wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
          netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
          netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
_AT_@ -262,7 +278,7 @@
          netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
          netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
          netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
-_AT_@ -1624,6 +1723,8 @@
+_AT_@ -1624,6 +1725,8 @@
          XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
          if(!dc.font.set)
                  XSetFont(dpy, dc.gc, dc.font.xfont->fid);
_AT_@ -271,12 +287,11 @@
          /* init bars */
          updatebars();
          updatestatus();
-_AT_@ -1732,8 +1833,19 @@
+_AT_@ -1732,8 +1835,18 @@
  togglebar(const Arg *arg) {
          selmon->showbar = !selmon->showbar;
          updatebarpos(selmon);
 - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
-+ resizebarwin(selmon);
          arrange(selmon);
 + if(showsystray) {
 + XWindowChanges wc;
_AT_@ -292,7 +307,7 @@
  }
  
  void
-_AT_@ -1809,6 +1921,7 @@
+_AT_@ -1809,6 +1922,7 @@
  void
  unmapnotify(XEvent *e) {
          Client *c;
_AT_@ -300,7 +315,7 @@
          XUnmapEvent *ev = &e->xunmap;
  
          if((c = wintoclient(ev->window))) {
-_AT_@ -1816,12 +1929,17 @@
+_AT_@ -1816,12 +1930,17 @@
                          setclientstate(c, WithdrawnState);
                  else
                          unmanage(c, False);
_AT_@ -318,7 +333,7 @@
          XSetWindowAttributes wa = {
                  .override_redirect = True,
                  .background_pixmap = ParentRelative,
-_AT_@ -1830,7 +1948,10 @@
+_AT_@ -1830,7 +1949,10 @@
          for(m = mons; m; m = m->next) {
                  if (m->barwin)
                          continue;
_AT_@ -330,15 +345,7 @@
                                            CopyFromParent, DefaultVisual(dpy, screen),
                                            CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
                  XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
-_AT_@ -1846,6 +1967,7 @@
- m->wh -= bh;
- m->by = m->topbar ? m->wy : m->wy + m->wh;
- m->wy = m->topbar ? m->wy + bh : m->wy;
-+ resizebarwin(m);
- }
- else
- m->by = -bh;
-_AT_@ -2014,6 +2136,68 @@
+_AT_@ -2014,6 +2136,59 @@
  }
  
  void
_AT_@ -346,11 +353,8 @@
 + XSetWindowAttributes wa;
 + XEvent event;
 + SystrayIcon *i;
++ unsigned int x = selmon->mx + selmon->mw;
 + unsigned int w = 1;
-+ unsigned int pos = selmon->mw;
-+ unsigned int pos_y = 0;
-+ if(!selmon->topbar)
-+ pos_y = selmon->mh - bh;
 +
 + if(!showsystray)
 + return;
_AT_@ -358,7 +362,7 @@
 + /* init systray */
 + if(!(systray = (Systray *)calloc(1, sizeof(Systray))))
 + die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
-+ systray->win = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, dc.norm[ColBG]);
++ systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by, w, bh, 0, 0, dc.norm[ColBG]);
 + wa.event_mask = ButtonPressMask | ExposureMask;
 + wa.override_redirect = True;
 + wa.background_pixmap = ParentRelative;
_AT_@ -388,26 +392,20 @@
 + XSync(dpy, False);
 + }
 + }
-+ updatebarpos(selmon);
-+ if(!systray->icons) {
-+ pos -= 1;
-+ XMoveResizeWindow(dpy, systray->win, pos, 0, 1, 1);
-+ return;
-+ }
 + for(i = systray->icons; i; i = i->next) {
 + XMapWindow(dpy, i->win);
 + XMoveResizeWindow(dpy, i->win, (i->geo.x = w), 0, i->geo.width, i->geo.height);
 + w += i->geo.width + systrayspacing;
 + }
-+ pos -= w;
-+ XMoveResizeWindow(dpy, systray->win, pos, pos_y, w, bh);
++ x -= w;
++ XMoveResizeWindow(dpy, systray->win, x, selmon->by, w, bh);
 +}
 +
 +void
  updatewindowtype(Client *c) {
          Atom state = getatomprop(c, netatom[NetWMState]);
          Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
-_AT_@ -2083,6 +2267,16 @@
+_AT_@ -2083,6 +2258,16 @@
          return selmon;
  }
  
diff -r 8be3df6237d4 -r 881ca46fdbea dwm.suckless.org/patches/systray.md
--- a/dwm.suckless.org/patches/systray.md Sat Mar 24 16:46:47 2012 +0100
+++ b/dwm.suckless.org/patches/systray.md Sat Mar 24 18:07:11 2012 +0100
_AT_@ -3,8 +3,8 @@
 
 Description
 -----------
-A simple system tray implementation. Multi-monitor support is untested - the
-tray should follow the selected monitor.
+A simple system tray implementation. Multi-monitor is also supported. The tray
+is following the selected monitor.
 
 Download
 --------
Received on Sat Mar 24 2012 - 18:07:13 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:32:15 CEST