about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R.Garbe <arg@10ksloc.org>2006-08-08 17:08:45 +0200
committerAnselm R.Garbe <arg@10ksloc.org>2006-08-08 17:08:45 +0200
commit92e55c7c53cb808b584982ac8f6d69112d713fab (patch)
tree6e8ad48b16b5baad43c0e5460deafc2d7dc6b741
parentc86f131681182258208ef97e81206ccc44e718ee (diff)
downloaddwm-92e55c7c53cb808b584982ac8f6d69112d713fab.tar.gz
implemented NET_ACTIVE_WINDOW support
-rw-r--r--client.c5
-rw-r--r--dwm.h2
-rw-r--r--event.c13
-rw-r--r--main.c1
4 files changed, 20 insertions, 1 deletions
diff --git a/client.c b/client.c
index f92df83..9b91ab6 100644
--- a/client.c
+++ b/client.c
@@ -58,6 +58,8 @@ focus(Client *c)
 	drawtitle(c);
 	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
 	XSync(dpy, False);
+	XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
+			PropModeReplace, (unsigned char *)&c->win, 1);
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
 }
 
@@ -459,6 +461,9 @@ unmanage(Client *c)
 	arrange(NULL);
 	if(sel)
 		focus(sel);
+	else
+		XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
+				PropModeReplace, (unsigned char *)NULL, 1);
 }
 
 void
diff --git a/dwm.h b/dwm.h
index 57d628a..efef213 100644
--- a/dwm.h
+++ b/dwm.h
@@ -22,7 +22,7 @@ union Arg {
 };
 
 /* atoms */
-enum { NetSupported, NetWMName, NetLast };
+enum { NetSupported, NetWMName, NetActiveWindow, NetLast };
 enum { WMProtocols, WMDelete, WMLast };
 
 /* cursor */
diff --git a/event.c b/event.c
index 2e4f62e..c3169aa 100644
--- a/event.c
+++ b/event.c
@@ -146,6 +146,18 @@ buttonpress(XEvent *e)
 }
 
 static void
+clientmessage(XEvent *e)
+{
+	Client *c;
+	XClientMessageEvent *ev = &e->xclient;
+
+	if(ev->message_type == netatom[NetActiveWindow]) {
+		if((c = getclient(ev->window)) && c->tags[tsel])
+			focus(c);
+	}
+}
+
+static void
 configurerequest(XEvent *e)
 {
 	Client *c;
@@ -339,6 +351,7 @@ unmapnotify(XEvent *e)
 
 void (*handler[LASTEvent]) (XEvent *) = {
 	[ButtonPress] = buttonpress,
+	[ClientMessage] = clientmessage,
 	[ConfigureRequest] = configurerequest,
 	[DestroyNotify] = destroynotify,
 	[EnterNotify] = enternotify,
diff --git a/main.c b/main.c
index 5efe599..ded4761 100644
--- a/main.c
+++ b/main.c
@@ -201,6 +201,7 @@ main(int argc, char *argv[])
 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
 	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
 	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+	netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
 	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
 			PropModeReplace, (unsigned char *) netatom, NetLast);
 
60 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405