movetab(): Move selected tab instead of switching
Before this patch, movetab() just switched positions of the selected tab with the new position. This resulted in unexpected behaviour when „moving“ a tab over one end of the list. Now tabs are moved correctly by the specified amount of indizes. Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
5c560f3784
commit
829980f28a
20
tabbed.c
20
tabbed.c
|
@ -795,19 +795,19 @@ movetab(const Arg *arg) {
|
||||||
int c;
|
int c;
|
||||||
Client *new;
|
Client *new;
|
||||||
|
|
||||||
if(sel < 0 || (arg->i == 0))
|
c = (sel + arg->i) % nclients;
|
||||||
return;
|
if(c < 0)
|
||||||
|
|
||||||
c = sel + arg->i;
|
|
||||||
while(c >= nclients)
|
|
||||||
c -= nclients;
|
|
||||||
while(c < 0)
|
|
||||||
c += nclients;
|
c += nclients;
|
||||||
|
|
||||||
new = clients[c];
|
if(sel < 0 || (c == sel))
|
||||||
clients[c] = clients[sel];
|
return;
|
||||||
clients[sel] = new;
|
|
||||||
|
|
||||||
|
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;
|
sel = c;
|
||||||
|
|
||||||
drawbar();
|
drawbar();
|
||||||
|
|
Loading…
Reference in a new issue