about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config.arg.h2
-rw-r--r--config.default.h6
-rw-r--r--dwm.h2
-rw-r--r--event.c3
-rw-r--r--screen.c37
5 files changed, 29 insertions, 21 deletions
diff --git a/config.arg.h b/config.arg.h
index 0e044bf..423e935 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -63,7 +63,7 @@ static Key key[] = { \
 	{ MODKEY|ControlMask|ShiftMask,	XK_8,		toggletag,	{ .i = 7 } }, \
 	{ MODKEY|ControlMask|ShiftMask,	XK_9,		toggletag,	{ .i = 8 } }, \
 	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
-	{ MODKEY,			XK_space,	togglelayout,	{ 0 } }, \
+	{ MODKEY,			XK_space,	setlayout,	{ .i = -1 } }, \
 	{ MODKEY|ShiftMask,		XK_space,	toggleversatile,{ 0 } }, \
 	{ MODKEY,			XK_0,		view,		{ .i = -1 } }, \
 	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
diff --git a/config.default.h b/config.default.h
index 8bf674f..b29d1a4 100644
--- a/config.default.h
+++ b/config.default.h
@@ -58,8 +58,8 @@ static Key key[] = { \
 	{ MODKEY|ControlMask|ShiftMask,	XK_8,		toggletag,	{ .i = 7 } }, \
 	{ MODKEY|ControlMask|ShiftMask,	XK_9,		toggletag,	{ .i = 8 } }, \
 	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
-	{ MODKEY,			XK_space,	togglelayout,	{ 0 } }, \
-	{ MODKEY|ShiftMask,		XK_space,	toggleversatile	{ 0 } }, \
+	{ MODKEY,			XK_space,	setlayout,	{ .i = -1 } }, \
+	{ MODKEY|ShiftMask,		XK_space,	toggleversatile,{ 0 } }, \
 	{ MODKEY,			XK_0,		view,		{ .i = -1 } }, \
 	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
 	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \
@@ -86,7 +86,7 @@ static Key key[] = { \
  * xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/ { printf("%s\n",$2) }' */
 #define RULES \
 static Rule rule[] = { \
-	/* class:instance:title regex	tags regex	versatile */ \
+	/* class:instance:title regex	tags regex	isversatile */ \
 	{ "Gimp",			NULL,		True }, \
 	{ "MPlayer",			NULL,		True }, \
 	{ "Acroread",			NULL,		True }, \
diff --git a/dwm.h b/dwm.h
index c8546d8..d4cc1fa 100644
--- a/dwm.h
+++ b/dwm.h
@@ -134,10 +134,10 @@ extern void initlayouts(void);			/* initialize layout array */
 extern Bool isvisible(Client *c);		/* returns True if client is visible */
 extern void resizemaster(Arg *arg);		/* resizes the master percent with arg's index value */
 extern void restack(void);			/* restores z layers of all clients */
+extern void setlayout(Arg *arg);		/* sets layout, -1 toggles */
 extern void settags(Client *c, Client *trans);	/* sets tags of c */
 extern void tag(Arg *arg);			/* tags c with arg's index */
 extern void toggleversatile(Arg *arg);		/* toggles focusesd client between versatile/and non-versatile state */
-extern void togglelayout(Arg *arg);		/* toggles layout */
 extern void toggletag(Arg *arg);		/* toggles c tags with arg's index */
 extern void toggleview(Arg *arg);		/* toggles the tag with arg's index (in)visible */
 extern void versatile(void);			/* arranges all windows versatile */
diff --git a/event.c b/event.c
index b6a77fd..3086284 100644
--- a/event.c
+++ b/event.c
@@ -140,7 +140,8 @@ buttonpress(XEvent *e) {
 		if(ev->x < x + blw)
 			switch(ev->button) {
 			case Button1:
-				togglelayout(NULL);
+				a.i = -1;
+				setlayout(&a);
 				break;
 			case Button4:
 				a.i = 1;
diff --git a/screen.c b/screen.c
index 5907ba7..8abe3d7 100644
--- a/screen.c
+++ b/screen.c
@@ -191,6 +191,28 @@ restack(void) {
 }
 
 void
+setlayout(Arg *arg) {
+	unsigned int i;
+
+	if(arg->i == -1) {
+		for(i = 0; i < nlayouts && lt != &layout[i]; i++);
+		if(i == nlayouts - 1)
+			lt = &layout[0];
+		else
+			lt = &layout[++i];
+	}
+	else {
+		if(arg->i < 0 || arg->i >= nlayouts)
+			return;
+		lt = &layout[arg->i];
+	}
+	if(sel)
+		lt->arrange();
+	else
+		drawstatus();
+}
+
+void
 settags(Client *c, Client *trans) {
 	char prop[512];
 	unsigned int i, j;
@@ -253,21 +275,6 @@ toggletag(Arg *arg) {
 }
 
 void
-togglelayout(Arg *arg) {
-	unsigned int i;
-
-	for(i = 0; i < nlayouts && lt != &layout[i]; i++);
-	if(i == nlayouts - 1)
-		lt = &layout[0];
-	else
-		lt = &layout[++i];
-	if(sel)
-		lt->arrange();
-	else
-		drawstatus();
-}
-
-void
 toggleversatile(Arg *arg) {
 	if(!sel || lt->arrange == versatile)
 		return;
ref='#n352'>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 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495