about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-19 18:39:54 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-19 18:39:54 +0200
commitfc109ea8f72e662ed58ef45329b6ca9e91d61d3b (patch)
treeb9151a8d6abf70dd33b232d265304c5ec1c9e666
parentb975c4728046052a32626378df193217a96fbefc (diff)
downloaddwm-fc109ea8f72e662ed58ef45329b6ca9e91d61d3b.tar.gz
fixed misappearance of iconified windows on SIGKILL
-rw-r--r--main.c27
-rw-r--r--screen.c6
2 files changed, 29 insertions, 4 deletions
diff --git a/main.c b/main.c
index b56e333..79b301d 100644
--- a/main.c
+++ b/main.c
@@ -111,6 +111,24 @@ initfont(const char *fontstr) {
 	dc.font.height = dc.font.ascent + dc.font.descent;
 }
 
+static long
+getstate(Window w) {
+	int format, status;
+	long result = -1;
+	unsigned char *p = NULL;
+	unsigned long n, extra;
+	Atom real;
+
+	status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
+			&real, &format, &n, &extra, (unsigned char **)&p);
+	if(status != Success)
+		return -1;
+	if(n != 0)
+		result = *p;
+	XFree(p);
+	return result;
+}
+
 static void
 scan(void) {
 	unsigned int i, num;
@@ -123,7 +141,14 @@ scan(void) {
 			if(!XGetWindowAttributes(dpy, wins[i], &wa)
 			|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
 				continue;
-			if(wa.map_state == IsViewable)
+			if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
+				manage(wins[i], &wa);
+		}
+		for(i = 0; i < num; i++) { /* now the transients */
+			if(!XGetWindowAttributes(dpy, wins[i], &wa))
+				continue;
+			if(XGetTransientForHint(dpy, wins[i], &d1)
+			&& (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
 				manage(wins[i], &wa);
 		}
 	}
diff --git a/screen.c b/screen.c
index 022633b..a8b093c 100644
--- a/screen.c
+++ b/screen.c
@@ -60,7 +60,7 @@ setdwmprops(void) {
 	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
 		prop[i] = seltags[i] ? '1' : '0';
 	if(i < sizeof prop - 1)
-		prop[i++] = (char)ltidx;
+		prop[i++] = (char)ltidx + '0';
 	prop[i] = '\0';
 	XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
 			PropModeReplace, (unsigned char *)prop, i);
@@ -223,8 +223,8 @@ getdwmprops(void) {
 		for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
 			seltags[i] = prop[i] == '1';
 		if(i < sizeof prop - 1 && prop[i] != '\0') {
-			if(prop[i] < nlayouts)
-				ltidx = prop[i];
+			if((unsigned int)(prop[i] - '0') < nlayouts)
+				ltidx = prop[i] - '0';
 		}
 	}
 }
='#n238'>238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 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 406 407 408 409 410