+ob_cyc_mask = 0
+ob_cyc_key = 0
+ob_cyc_w = 0 # last window cycled to
+ob_cyc_screen = 0
+
+def do_stacked_cycle(data):
+ global ob_cyc_w
+
+ try:
+ i = ob_clients.index(ob_cyc_w) + 1
+ except ValueError:
+ i = 0
+
+ clients = ob_clients[i:] + ob_clients[:i]
+ for w in clients:
+ client = openbox.findClient(w)
+ if client and (client.desktop() == desktop and \
+ client.normal() and client.focus()):
+ return
+
+def focus_next_stacked_grab(data):
+ global ob_cyc_mask;
+ global ob_cyc_key;
+ global ob_cyc_w;
+ global ob_doing_stacked;
+
+ if data.action == EventKeyRelease:
+ # have all the modifiers this started with been released?
+ if not ob_cyc_mask & data.state:
+ kungrab() # ungrab ourself
+ ob_doing_stacked = 0;
+ print "UNGRABBED!"
+ else:
+ if ob_cyc_key == data.key:
+ # the next window to try focusing in ob_clients[ob_cyc_i]
+ print "CYCLING!!"
+ do_stacked_cycle(data)
+
+def focus_next_stacked(data, forward=1):
+ global ob_cyc_mask
+ global ob_cyc_key
+ global ob_cyc_w
+ global ob_cyc_screen
+ global ob_doing_stacked
+ ob_cyc_mask = data.state
+ ob_cyc_key = data.key
+ ob_cyc_w = 0
+ ob_cyc_screen = data.screen
+ ob_doing_stacked = 1
+
+ kgrab(data.screen, focus_next_stacked_grab)
+ print "GRABBED!"
+ focus_next_stacked_grab(data) # start with the first press
+
+def focus_prev_stacked(data):
+ return
+