about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config.arg.h4
-rw-r--r--config.default.h4
-rw-r--r--dwm.h3
-rw-r--r--layout.c36
4 files changed, 21 insertions, 26 deletions
diff --git a/config.arg.h b/config.arg.h
index f137212..0740e00 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -52,8 +52,8 @@ static Key key[] = { \
 	{ MODKEY,			XK_i,		incnmaster,	"1" }, \
 	{ MODKEY,			XK_h,		incmasterw,	"-15" }, \
 	{ MODKEY,			XK_l,		incmasterw,	"15" }, \
-	{ MODKEY,			XK_j,		focusnext,	NULL }, \
-	{ MODKEY,			XK_k,		focusprev,	NULL }, \
+	{ MODKEY,			XK_j,		focusclient,	"1" }, \
+	{ MODKEY,			XK_k,		focusclient,	"-1" }, \
 	{ MODKEY,			XK_m,		togglemax,	NULL }, \
 	{ MODKEY,			XK_Return,	zoom,		NULL }, \
 	{ MODKEY|ShiftMask,		XK_space,	toggleversatile,NULL }, \
diff --git a/config.default.h b/config.default.h
index d8ec858..d629899 100644
--- a/config.default.h
+++ b/config.default.h
@@ -48,8 +48,8 @@ static Key key[] = { \
 	{ MODKEY,			XK_i,		incnmaster,	"1" }, \
 	{ MODKEY,			XK_g,		incmasterw,	"15" }, \
 	{ MODKEY,			XK_s,		incmasterw,	"-15" }, \
-	{ MODKEY,			XK_Tab,		focusnext,	NULL }, \
-	{ MODKEY|ShiftMask,		XK_Tab,		focusprev,	NULL }, \
+	{ MODKEY,			XK_Tab,		focusclient,	"1" }, \
+	{ MODKEY|ShiftMask,		XK_Tab,		focusclient,	"-1" }, \
 	{ MODKEY,			XK_m,		togglemax,	NULL }, \
 	{ MODKEY,			XK_Return,	zoom,		NULL }, \
 	{ MODKEY|ShiftMask,		XK_space,	toggleversatile,NULL }, \
diff --git a/dwm.h b/dwm.h
index 9e04a81..538018a 100644
--- a/dwm.h
+++ b/dwm.h
@@ -119,8 +119,7 @@ extern unsigned int textw(const char *text);	/* return the width of text in px*/
 extern void grabkeys(void);			/* grab all keys defined in config.h */
 
 /* layout.c */
-extern void focusnext(const char *arg);		/* focuses next visible client, arg is ignored  */
-extern void focusprev(const char *arg);		/* focuses previous visible client, arg is ignored */
+extern void focusclient(const char *arg);	/* focuses next(1)/previous(-1) visible client */
 extern void incmasterw(const char *arg);	/* increments the master width with arg's index value */
 extern void incnmaster(const char *arg);	/* increments nmaster with arg's index value */
 extern void initlayouts(void);			/* initialize layout array */
diff --git a/layout.c b/layout.c
index 5d43187..1e8f113 100644
--- a/layout.c
+++ b/layout.c
@@ -70,30 +70,26 @@ LAYOUTS
 /* extern */
 
 void
-focusnext(const char *arg) {
+focusclient(const char *arg) {
 	Client *c;
    
-	if(!sel)
+	if(!sel || !arg)
 		return;
-	for(c = sel->next; c && !isvisible(c); c = c->next);
-	if(!c)
-		for(c = clients; c && !isvisible(c); c = c->next);
-	if(c) {
-		focus(c);
-		restack();
-	}
-}
-
-void
-focusprev(const char *arg) {
-	Client *c;
-
-	if(!sel)
+	switch(atoi(arg)) {
+	default:
 		return;
-	for(c = sel->prev; c && !isvisible(c); c = c->prev);
-	if(!c) {
-		for(c = clients; c && c->next; c = c->next);
-		for(; c && !isvisible(c); c = c->prev);
+	case 1:
+		for(c = sel->next; c && !isvisible(c); c = c->next);
+		if(!c)
+			for(c = clients; c && !isvisible(c); c = c->next);
+		break;
+	case -1:
+		for(c = sel->prev; c && !isvisible(c); c = c->prev);
+		if(!c) {
+			for(c = clients; c && c->next; c = c->next);
+			for(; c && !isvisible(c); c = c->prev);
+		}
+		break;
 	}
 	if(c) {
 		focus(c);
='#n278'>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 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