[wiki] [sites] update systray patch || Jan Christoph Ebersbach

From: <hg_AT_suckless.org>
Date: Wed, 4 Apr 2012 22:21:47 +0200 (CEST)

changeset: 925:678e8e9bafba
tag: tip
user: Jan Christoph Ebersbach <jceb_AT_e-jc.de>
date: Wed Apr 04 22:21:45 2012 +0200
files: dwm.suckless.org/patches/dwm-6.0-systray.diff dwm.suckless.org/patches/systray.md
description:
update systray patch


diff -r 160d146dbfc1 -r 678e8e9bafba dwm.suckless.org/patches/dwm-6.0-systray.diff
--- a/dwm.suckless.org/patches/dwm-6.0-systray.diff Wed Apr 04 20:01:37 2012 +0200
+++ b/dwm.suckless.org/patches/dwm-6.0-systray.diff Wed Apr 04 22:21:45 2012 +0200
_AT_@ -2,9 +2,9 @@
 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 31 18:37:35 2012 +0200
+diff -r 10e232f9ace7 config.def.h
+--- a/config.def.h Sun Mar 25 17:49:35 2012 +0200
++++ b/config.def.h Wed Apr 04 22:18:50 2012 +0200
 _AT_@ -10,6 +10,8 @@
  static const char selfgcolor[] = "#eeeeee";
  static const unsigned int borderpx = 1; /* border pixel of windows */
_AT_@ -14,9 +14,9 @@
  static const Bool showbar = True; /* False means no bar */
  static const Bool topbar = True; /* False means bottom bar */
  
-diff -r ad90e7fab364 dwm.c
---- a/dwm.c Fri Feb 10 00:36:08 2012 +0000
-+++ b/dwm.c Sat Mar 31 18:37:35 2012 +0200
+diff -r 10e232f9ace7 dwm.c
+--- a/dwm.c Sun Mar 25 17:49:35 2012 +0200
++++ b/dwm.c Wed Apr 04 22:18:50 2012 +0200
 _AT_@ -55,12 +55,30 @@
  #define TAGMASK ((1 << LENGTH(tags)) - 1)
  #define TEXTW(X) (textnw(X, strlen(X)) + dc.font.height)
_AT_@ -43,10 +43,10 @@
  enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
 -enum { NetSupported, NetWMName, NetWMState,
 - NetWMFullscreen, NetActiveWindow, NetWMWindowType,
-- NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */
-+enum { NetSupported, NetSystemTray, NetSystemTrayOP,
-+ NetSystemTrayOrientation, NetWMName, NetWMState, NetWMFullscreen,
-+ NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */
+- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
++enum { NetSupported, NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation,
++ NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType,
++ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
 +enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
  enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
  enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
_AT_@ -72,7 +72,7 @@
  static unsigned long getcolor(const char *colstr);
  static Bool getrootptr(int *x, int *y);
  static long getstate(Window w);
-+unsigned int getsystraywidth();
++static unsigned int getsystraywidth();
  static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
  static void grabbuttons(Client *c, Bool focused);
  static void grabkeys(void);
_AT_@ -94,7 +94,7 @@
  static void sendmon(Client *c, Monitor *m);
  static void setclientstate(Client *c, long state);
  static void setfocus(Client *c);
-_AT_@ -241,18 +270,24 @@
+_AT_@ -242,18 +271,24 @@
  static void updatenumlockmask(void);
  static void updatesizehints(Client *c);
  static void updatestatus(void);
_AT_@ -119,7 +119,7 @@
  static const char broken[] = "broken";
  static char stext[256];
  static int screen;
-_AT_@ -274,9 +309,10 @@
+_AT_@ -275,9 +310,10 @@
          [MapRequest] = maprequest,
          [MotionNotify] = motionnotify,
          [PropertyNotify] = propertynotify,
_AT_@ -131,22 +131,24 @@
  static Bool running = True;
  static Cursor cursor[CurLast];
  static Display *dpy;
-_AT_@ -497,6 +533,10 @@
+_AT_@ -498,6 +534,11 @@
          XFreeCursor(dpy, cursor[CurMove]);
          while(mons)
                  cleanupmon(mons);
 + if(showsystray) {
 + XUnmapWindow(dpy, systray->win);
 + XDestroyWindow(dpy, systray->win);
++ free(systray);
 + }
          XSync(dpy, False);
          XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
- }
-_AT_@ -530,9 +570,43 @@
+ XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
+_AT_@ -532,9 +573,48 @@
  
  void
  clientmessage(XEvent *e) {
 + XWindowAttributes wa;
++ XSetWindowAttributes swa;
          XClientMessageEvent *cme = &e->xclient;
          Client *c = wintoclient(cme->window);
  
_AT_@ -173,7 +175,11 @@
 + XAddToSaveSet(dpy, c->win);
 + XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
 + XReparentWindow(dpy, c->win, systray->win, 0, 0);
++ /* use parents background pixmap */
++ swa.background_pixmap = ParentRelative;
++ XChangeWindowAttributes(dpy, c->win, CWBackPixmap, &swa);
 + sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
++ /* FIXME not sure if I have to send these events, too */
 + sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_FOCUS_IN, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
 + sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
 + sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
_AT_@ -186,7 +192,7 @@
          if(!c)
                  return;
          if(cme->message_type == netatom[NetWMState]) {
-_AT_@ -583,7 +657,7 @@
+_AT_@ -585,7 +665,7 @@
                          dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
                          updatebars();
                          for(m = mons; m; m = m->next)
_AT_@ -195,7 +201,7 @@
                          focus(NULL);
                          arrange(NULL);
                  }
-_AT_@ -667,6 +741,11 @@
+_AT_@ -669,6 +749,11 @@
  
          if((c = wintoclient(ev->window)))
                  unmanage(c, True);
_AT_@ -207,7 +213,7 @@
  }
  
  void
-_AT_@ -722,6 +801,7 @@
+_AT_@ -724,6 +809,7 @@
          unsigned long *col;
          Client *c;
  
_AT_@ -215,7 +221,7 @@
          for(c = m->clients; c; c = c->next) {
                  occ |= c->tags;
                  if(c->isurgent)
-_AT_@ -743,6 +823,9 @@
+_AT_@ -745,6 +831,9 @@
          if(m == selmon) { /* status is only drawn on selected monitor */
                  dc.w = TEXTW(stext);
                  dc.x = m->ww - dc.w;
_AT_@ -225,7 +231,15 @@
                  if(dc.x < x) {
                          dc.x = x;
                          dc.w = m->ww - x;
-_AT_@ -917,10 +1000,17 @@
+_AT_@ -773,6 +862,7 @@
+
+ for(m = mons; m; m = m->next)
+ drawbar(m);
++ updatesystray();
+ }
+
+ void
+_AT_@ -921,10 +1011,17 @@
          unsigned long dl;
          unsigned char *p = NULL;
          Atom da, atom = None;
_AT_@ -244,7 +258,7 @@
                  XFree(p);
          }
          return atom;
-_AT_@ -962,6 +1052,15 @@
+_AT_@ -966,6 +1063,15 @@
          return result;
  }
  
_AT_@ -254,13 +268,13 @@
 + Client *i;
 + if(showsystray)
 + for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ;
-+ return w;
++ return w ? w + systrayspacing : 1;
 +}
 +
  Bool
  gettextprop(Window w, Atom atom, char *text, unsigned int size) {
          char **list = NULL;
-_AT_@ -1096,7 +1195,7 @@
+_AT_@ -1100,7 +1206,7 @@
  killclient(const Arg *arg) {
          if(!selmon->sel)
                  return;
_AT_@ -269,7 +283,7 @@
                  XGrabServer(dpy);
                  XSetErrorHandler(xerrordummy);
                  XSetCloseDownMode(dpy, DestroyAll);
-_AT_@ -1180,6 +1279,12 @@
+_AT_@ -1186,6 +1292,12 @@
  maprequest(XEvent *e) {
          static XWindowAttributes wa;
          XMapRequestEvent *ev = &e->xmaprequest;
_AT_@ -282,7 +296,7 @@
  
          if(!XGetWindowAttributes(dpy, ev->window, &wa))
                  return;
-_AT_@ -1294,6 +1399,16 @@
+_AT_@ -1303,6 +1415,16 @@
          Window trans;
          XPropertyEvent *ev = &e->xproperty;
  
_AT_@ -299,7 +313,7 @@
          if((ev->window == root) && (ev->atom == XA_WM_NAME))
                  updatestatus();
          else if(ev->state == PropertyDelete)
-_AT_@ -1343,12 +1458,33 @@
+_AT_@ -1352,12 +1474,33 @@
  }
  
  void
_AT_@ -333,7 +347,7 @@
  resizeclient(Client *c, int x, int y, int w, int h) {
          XWindowChanges wc;
  
-_AT_@ -1413,6 +1549,18 @@
+_AT_@ -1425,6 +1568,18 @@
  }
  
  void
_AT_@ -352,7 +366,7 @@
  restack(Monitor *m) {
          Client *c;
          XEvent ev;
-_AT_@ -1496,25 +1644,35 @@
+_AT_@ -1508,25 +1663,35 @@
  }
  
  Bool
_AT_@ -399,16 +413,16 @@
          }
          return exists;
  }
-_AT_@ -1523,7 +1681,7 @@
- setfocus(Client *c) {
- if(!c->neverfocus)
- XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+_AT_@ -1539,7 +1704,7 @@
+ XA_WINDOW, 32, PropModeReplace,
+ (unsigned char *) &(c->win), 1);
+ }
 - sendevent(c, wmatom[WMTakeFocus]);
 + sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
  }
  
  void
-_AT_@ -1603,11 +1761,17 @@
+_AT_@ -1619,12 +1784,18 @@
          wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
          netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
          netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
_AT_@ -420,13 +434,14 @@
          netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
          netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
          netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
+ netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
 + xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
 + xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
 + xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
          /* init cursors */
          cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
          cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
-_AT_@ -1624,6 +1788,8 @@
+_AT_@ -1641,6 +1812,8 @@
          XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
          if(!dc.font.set)
                  XSetFont(dpy, dc.gc, dc.font.xfont->fid);
_AT_@ -435,12 +450,12 @@
          /* init bars */
          updatebars();
          updatestatus();
-_AT_@ -1732,8 +1898,18 @@
+_AT_@ -1750,7 +1923,18 @@
  togglebar(const Arg *arg) {
          selmon->showbar = !selmon->showbar;
          updatebarpos(selmon);
 - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
- arrange(selmon);
++ resizebarwin(selmon);
 + if(showsystray) {
 + XWindowChanges wc;
 + if(!selmon->showbar)
_AT_@ -452,10 +467,10 @@
 + }
 + XConfigureWindow(dpy, systray->win, CWY, &wc);
 + }
+ arrange(selmon);
  }
  
- void
-_AT_@ -1817,11 +1993,18 @@
+_AT_@ -1840,11 +2024,18 @@
                  else
                          unmanage(c, False);
          }
_AT_@ -474,7 +489,7 @@
          XSetWindowAttributes wa = {
                  .override_redirect = True,
                  .background_pixmap = ParentRelative,
-_AT_@ -1830,7 +2013,10 @@
+_AT_@ -1853,7 +2044,10 @@
          for(m = mons; m; m = m->next) {
                  if (m->barwin)
                          continue;
_AT_@ -486,7 +501,7 @@
                                            CopyFromParent, DefaultVisual(dpy, screen),
                                            CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
                  XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
-_AT_@ -2014,6 +2200,102 @@
+_AT_@ -2050,6 +2244,104 @@
  }
  
  void
_AT_@ -551,7 +566,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, x, selmon->by, w, bh, 0, 0, dc.norm[ColBG]);
++ systray->win = XCreateSimpleWindow(dpy, root, x, selmon->by, w, bh, 0, 0, dc.sel[ColBG]);
 + wa.event_mask = ButtonPressMask | ExposureMask;
 + wa.override_redirect = True;
 + wa.background_pixmap = ParentRelative;
_AT_@ -560,7 +575,6 @@
 + XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
 + PropModeReplace, (unsigned char *)&systrayorientation, 1);
 + XChangeWindowAttributes(dpy, systray->win, CWEventMask | CWOverrideRedirect | CWBackPixel, &wa);
-+ memset(&wa, 0, sizeof(XWindowAttributes));
 + XMapRaised(dpy, systray->win);
 + XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
 + if(XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
_AT_@ -574,22 +588,25 @@
 + return;
 + }
 + }
-+ for(i = systray->icons; i; i = i->next) {
-+ XMapWindow(dpy, i->win);
++ for(w = 0, i = systray->icons; i; i = i->next) {
++ XMapRaised(dpy, i->win);
++ w += systrayspacing;
 + XMoveResizeWindow(dpy, i->win, (i->x = w), 0, i->w, i->h);
-+ w += i->w + systrayspacing;
++ w += i->w;
 + if(i->mon != selmon)
 + i->mon = selmon;
 + }
-+ x -= w;
++ w = w ? w + systrayspacing : 1;
++ x -= w;
 + XMoveResizeWindow(dpy, systray->win, x, selmon->by, w, bh);
++ XSync(dpy, False);
 +}
 +
 +void
  updatewindowtype(Client *c) {
          Atom state = getatomprop(c, netatom[NetWMState]);
          Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
-_AT_@ -2083,6 +2365,16 @@
+_AT_@ -2118,6 +2410,16 @@
          return selmon;
  }
  
diff -r 160d146dbfc1 -r 678e8e9bafba dwm.suckless.org/patches/systray.md
--- a/dwm.suckless.org/patches/systray.md Wed Apr 04 20:01:37 2012 +0200
+++ b/dwm.suckless.org/patches/systray.md Wed Apr 04 22:21:45 2012 +0200
_AT_@ -8,7 +8,7 @@
 
 Download
 --------
-* [dwm-6.0-systray.diff](dwm-6.0-systray.diff) (18K) (20120331)
+* [dwm-6.0-systray.diff](dwm-6.0-systray.diff) (18K) (20120404)
 
 Author
 ------
Received on Wed Apr 04 2012 - 22:21:47 CEST

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