about summary refs log tree commit diff stats
diff options
context:
space:
mode:
author2014-10-07 17:15:59 +0200
committer2014-10-14 18:40:59 +0200
commit829980f28aa91f4837e047bd9e3b599bf6d655a6 (patch)
treeb5dd776b8ec39461db9d67888022c2ab8de1bc85
parent5c560f3784971b1a3bbfc7d18af759778f7779d1 (diff)
downloadtabbed-829980f28aa91f4837e047bd9e3b599bf6d655a6.tar.gz
-rw-r--r--tabbed.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/tabbed.c b/tabbed.c
index 68281ac..cdd6bd3 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -795,19 +795,19 @@ movetab(const Arg *arg) {
 	int c;
 	Client *new;
 
-	if(sel < 0 || (arg->i == 0))
-		return;
-
-	c = sel + arg->i;
-	while(c >= nclients)
-		c -= nclients;
-	while(c < 0)
+	c = (sel + arg->i) % nclients;
+	if(c < 0)
 		c += nclients;
 
-	new = clients[c];
-	clients[c] = clients[sel];
-	clients[sel] = new;
+	if(sel < 0 || (c == sel))
+		return;
 
+	new = clients[sel];
+	if(sel < c)
+		memmove(&clients[sel], &clients[sel+1], sizeof(Client *) * (c - sel));
+	else
+		memmove(&clients[c+1], &clients[c], sizeof(Client *) * (sel - c));
+	clients[c] = new;
 	sel = c;
 
 	drawbar();