applied Peter/Andreas NetActiveWindow patch in a slightly modified version 3c2d303c
Anselm R Garbe · 2011-04-14 13:46 1 file(s) · +22 −9
dwm.c +22 −9
58 58
enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
59 59
enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
60 60
enum { NetSupported, NetWMName, NetWMState,
61 -
       NetWMFullscreen, NetLast };                      /* EWMH atoms */
61 +
       NetWMFullscreen, NetActiveWindow, NetLast };     /* EWMH atoms */
62 62
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
63 63
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
64 64
       ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
1259 1259
void
1260 1260
clientmessage(XEvent *e) {
1261 1261
	XClientMessageEvent *cme = &e->xclient;
1262 -
	Client *c;
1262 +
	Client *c = wintoclient(cme->window);
1263 1263
1264 -
	if((c = wintoclient(cme->window))
1265 -
	&& (cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]))
1266 -
	{
1264 +
	if(!c)
1265 +
		return;
1266 +
	if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) {
1267 1267
		if(cme->data.l[0]) {
1268 1268
			XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
1269 1269
			                PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
1286 1286
			resizeclient(c, c->x, c->y, c->w, c->h);
1287 1287
			arrange(c->mon);
1288 1288
		}
1289 +
	}
1290 +
	else if(cme->message_type == netatom[NetActiveWindow]) {
1291 +
		if(!ISVISIBLE(c)) {
1292 +
			Arg a = { .ui = c->tags };
1293 +
			view(&a); 
1294 +
		}
1295 +
		detach(c);
1296 +
		attach(c);
1297 +
		focus(c);
1298 +
		arrange(c->mon);
1289 1299
	}
1290 1300
}
1291 1301
1460 1470
			exists = protocols[n] == proto;
1461 1471
		XFree(protocols);
1462 1472
	}
1463 -
	if (exists) {
1473 +
	if(exists) {
1464 1474
		ev.type = ClientMessage;
1465 1475
		ev.xclient.window = c->win;
1466 1476
		ev.xclient.message_type = wmatom[WMProtocols];
1474 1484
1475 1485
void
1476 1486
setfocus(Client *c) {
1477 -
	if (!c->neverfocus)
1487 +
	if(!c->neverfocus)
1478 1488
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
1479 1489
	sendevent(c, wmatom[WMTakeFocus]);
1480 1490
}
1525 1535
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
1526 1536
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
1527 1537
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
1538 +
        netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
1528 1539
	wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
1529 1540
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
1530 1541
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
1942 1953
		}
1943 1954
		else
1944 1955
			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
1945 -
		if (wmh->flags & InputHint) c->neverfocus = !wmh->input;
1946 -
		else                        c->neverfocus = False;
1956 +
		if(wmh->flags & InputHint)
1957 +
			c->neverfocus = !wmh->input;
1958 +
		else
1959 +
			c->neverfocus = False;
1947 1960
		XFree(wmh);
1948 1961
	}
1949 1962
}