1 ############################################################################
2 ### Window placement algorithms, choose one of these and ebind it to the ###
3 ### ob.EventAction.PlaceWindow event. ###
5 ### Also see historyplacement.py for the history placement module which ###
6 ### provides an algorithm that can be used in place of, or alongside, ###
8 ############################################################################
11 from random import Random
14 """Place windows randomly around the screen."""
15 if ob.Openbox.state() == ob.State.Starting: return
16 #if data.client.positionRequested(): return
17 cx, cy, cw, ch = client.area()
18 sx, sy, sw, sh = ob.Openbox.screenArea(client.desktop())
19 xr = sw - cw - 1 # x range
20 yr = sh - ch - 1 # y range
22 else: x = Random().randrange(sx, xr)
24 else: y = Random().randrange(sy, yr)
25 client.setArea((x, y, cw, ch))
28 """Place windows in a cascading order from top-left to bottom-right."""
29 if ob.Openbox.state() == ob.State.Starting: return
30 #if data.client.positionRequested(): return
31 cx, cy, cw, ch = client.area()
32 sx, sy, sw, sh = ob.Openbox.screenArea(client.desktop())
35 global _cascade_x, _cascade_y
36 if _cascade_x < sx or _cascade_y < sy or \
37 _cascade_x >= width or _cascade_y >= height:
40 client.setArea((_cascade_x, _cascade_y, cw, ch))
41 frame_size = client.frameSize()
42 _cascade_x += frame_size[1]
43 _cascade_y += frame_size[1]
48 export_functions = random, cascade
50 print "Loaded windowplacement.py"