wrap around right for focus cycling

This commit is contained in:
Dana Jansens 2003-01-23 23:18:05 +00:00
parent d4e4e25e28
commit 104c1a164b

View file

@ -59,10 +59,11 @@ def focus_next(data, num=1, forward=1):
for i in r: for i in r:
if found: if found:
target = i target = i
found = 2
break break
elif screen.client(i).window() == client_win: elif screen.client(i).window() == client_win:
found = 1 found = 1
if not found: # wraparound if found == 1: # wraparound
if forward: target = 0 if forward: target = 0
else: target = count - 1 else: target = count - 1
@ -80,7 +81,7 @@ def focus_next(data, num=1, forward=1):
t += num t += num
if t >= count: t -= count if t >= count: t -= count
else: else:
t -= 1 t -= num
if t < 0: t += count if t < 0: t += count
if t == target: return # nothing to focus if t == target: return # nothing to focus