sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ee822c9ee09153801a986f99c69b297342f9127b
parent adb75ea01a9cf3767eb0d8eed1b48f081087b4d5
Author: Jan Christoph Ebersbach <jceb@e-jc.de>
Date:   Wed,  4 Apr 2012 22:21:45 +0200

update systray patch
Diffstat:
Mdwm.suckless.org/patches/dwm-6.0-systray.diff | 113+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mdwm.suckless.org/patches/systray.md | 2+-
2 files changed, 66 insertions(+), 49 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-6.0-systray.diff b/dwm.suckless.org/patches/dwm-6.0-systray.diff @@ -2,9 +2,9 @@ Author: Jan Christoph Ebersbach <jceb@e-jc.de>, inspired by http://code.google.c 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 @@ -10,6 +10,8 @@ static const char selfgcolor[] = "#eeeeee"; static const unsigned int borderpx = 1; /* border pixel of windows */ @@ -14,9 +14,9 @@ diff -r ad90e7fab364 config.def.h 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 @@ -55,12 +55,30 @@ #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (textnw(X, strlen(X)) + dc.font.height) @@ -43,10 +43,10 @@ diff -r ad90e7fab364 dwm.c 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, @@ -72,7 +72,7 @@ diff -r ad90e7fab364 dwm.c 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); @@ -94,7 +94,7 @@ diff -r ad90e7fab364 dwm.c static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); -@@ -241,18 +270,24 @@ +@@ -242,18 +271,24 @@ static void updatenumlockmask(void); static void updatesizehints(Client *c); static void updatestatus(void); @@ -119,7 +119,7 @@ diff -r ad90e7fab364 dwm.c static const char broken[] = "broken"; static char stext[256]; static int screen; -@@ -274,9 +309,10 @@ +@@ -275,9 +310,10 @@ [MapRequest] = maprequest, [MotionNotify] = motionnotify, [PropertyNotify] = propertynotify, @@ -131,22 +131,24 @@ diff -r ad90e7fab364 dwm.c static Bool running = True; static Cursor cursor[CurLast]; static Display *dpy; -@@ -497,6 +533,10 @@ +@@ -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); - } -@@ -530,9 +570,43 @@ + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); +@@ -532,9 +573,48 @@ void clientmessage(XEvent *e) { + XWindowAttributes wa; ++ XSetWindowAttributes swa; XClientMessageEvent *cme = &e->xclient; Client *c = wintoclient(cme->window); @@ -173,7 +175,11 @@ diff -r ad90e7fab364 dwm.c + 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); @@ -186,7 +192,7 @@ diff -r ad90e7fab364 dwm.c if(!c) return; if(cme->message_type == netatom[NetWMState]) { -@@ -583,7 +657,7 @@ +@@ -585,7 +665,7 @@ dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); updatebars(); for(m = mons; m; m = m->next) @@ -195,7 +201,7 @@ diff -r ad90e7fab364 dwm.c focus(NULL); arrange(NULL); } -@@ -667,6 +741,11 @@ +@@ -669,6 +749,11 @@ if((c = wintoclient(ev->window))) unmanage(c, True); @@ -207,7 +213,7 @@ diff -r ad90e7fab364 dwm.c } void -@@ -722,6 +801,7 @@ +@@ -724,6 +809,7 @@ unsigned long *col; Client *c; @@ -215,7 +221,7 @@ diff -r ad90e7fab364 dwm.c for(c = m->clients; c; c = c->next) { occ |= c->tags; if(c->isurgent) -@@ -743,6 +823,9 @@ +@@ -745,6 +831,9 @@ if(m == selmon) { /* status is only drawn on selected monitor */ dc.w = TEXTW(stext); dc.x = m->ww - dc.w; @@ -225,7 +231,15 @@ diff -r ad90e7fab364 dwm.c if(dc.x < x) { dc.x = x; dc.w = m->ww - x; -@@ -917,10 +1000,17 @@ +@@ -773,6 +862,7 @@ + + for(m = mons; m; m = m->next) + drawbar(m); ++ updatesystray(); + } + + void +@@ -921,10 +1011,17 @@ unsigned long dl; unsigned char *p = NULL; Atom da, atom = None; @@ -244,7 +258,7 @@ diff -r ad90e7fab364 dwm.c XFree(p); } return atom; -@@ -962,6 +1052,15 @@ +@@ -966,6 +1063,15 @@ return result; } @@ -254,13 +268,13 @@ diff -r ad90e7fab364 dwm.c + 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; -@@ -1096,7 +1195,7 @@ +@@ -1100,7 +1206,7 @@ killclient(const Arg *arg) { if(!selmon->sel) return; @@ -269,7 +283,7 @@ diff -r ad90e7fab364 dwm.c XGrabServer(dpy); XSetErrorHandler(xerrordummy); XSetCloseDownMode(dpy, DestroyAll); -@@ -1180,6 +1279,12 @@ +@@ -1186,6 +1292,12 @@ maprequest(XEvent *e) { static XWindowAttributes wa; XMapRequestEvent *ev = &e->xmaprequest; @@ -282,7 +296,7 @@ diff -r ad90e7fab364 dwm.c if(!XGetWindowAttributes(dpy, ev->window, &wa)) return; -@@ -1294,6 +1399,16 @@ +@@ -1303,6 +1415,16 @@ Window trans; XPropertyEvent *ev = &e->xproperty; @@ -299,7 +313,7 @@ diff -r ad90e7fab364 dwm.c if((ev->window == root) && (ev->atom == XA_WM_NAME)) updatestatus(); else if(ev->state == PropertyDelete) -@@ -1343,12 +1458,33 @@ +@@ -1352,12 +1474,33 @@ } void @@ -333,7 +347,7 @@ diff -r ad90e7fab364 dwm.c resizeclient(Client *c, int x, int y, int w, int h) { XWindowChanges wc; -@@ -1413,6 +1549,18 @@ +@@ -1425,6 +1568,18 @@ } void @@ -352,7 +366,7 @@ diff -r ad90e7fab364 dwm.c restack(Monitor *m) { Client *c; XEvent ev; -@@ -1496,25 +1644,35 @@ +@@ -1508,25 +1663,35 @@ } Bool @@ -399,16 +413,16 @@ diff -r ad90e7fab364 dwm.c } return exists; } -@@ -1523,7 +1681,7 @@ - setfocus(Client *c) { - if(!c->neverfocus) - XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); +@@ -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 -@@ -1603,11 +1761,17 @@ +@@ -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); @@ -420,13 +434,14 @@ diff -r ad90e7fab364 dwm.c 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); -@@ -1624,6 +1788,8 @@ +@@ -1641,6 +1812,8 @@ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) XSetFont(dpy, dc.gc, dc.font.xfont->fid); @@ -435,12 +450,12 @@ diff -r ad90e7fab364 dwm.c /* init bars */ updatebars(); updatestatus(); -@@ -1732,8 +1898,18 @@ +@@ -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) @@ -452,10 +467,10 @@ diff -r ad90e7fab364 dwm.c + } + XConfigureWindow(dpy, systray->win, CWY, &wc); + } + arrange(selmon); } - void -@@ -1817,11 +1993,18 @@ +@@ -1840,11 +2024,18 @@ else unmanage(c, False); } @@ -474,7 +489,7 @@ diff -r ad90e7fab364 dwm.c XSetWindowAttributes wa = { .override_redirect = True, .background_pixmap = ParentRelative, -@@ -1830,7 +2013,10 @@ +@@ -1853,7 +2044,10 @@ for(m = mons; m; m = m->next) { if (m->barwin) continue; @@ -486,7 +501,7 @@ diff -r ad90e7fab364 dwm.c CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); XDefineCursor(dpy, m->barwin, cursor[CurNormal]); -@@ -2014,6 +2200,102 @@ +@@ -2050,6 +2244,104 @@ } void @@ -551,7 +566,7 @@ diff -r ad90e7fab364 dwm.c + /* 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; @@ -560,7 +575,6 @@ diff -r ad90e7fab364 dwm.c + 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) { @@ -574,22 +588,25 @@ diff -r ad90e7fab364 dwm.c + 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]); -@@ -2083,6 +2365,16 @@ +@@ -2118,6 +2410,16 @@ return selmon; } diff --git a/dwm.suckless.org/patches/systray.md b/dwm.suckless.org/patches/systray.md @@ -8,7 +8,7 @@ is following the selected monitor. 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 ------