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 ############################################################################
10 ##############################################################################
11 ### Options for the windowplacement module: ###
13 # ignore_requested_positions - When true, the placement algorithm will ###
14 ### attempt to place windows even when they ###
15 ### request a position (like XMMS). ###
16 ### Note this only applies to normal windows, ###
17 ### not to special cases like desktops and ###
19 ignore_requested_positions
= 0 ###
21 ##############################################################################
27 _rand
= random
.Random()
30 """Place windows randomly around the screen."""
31 if not data
.client
: return
32 if not (ignore_requested_positions
and data
.client
.normal()):
33 if data
.client
.positionRequested(): return
34 client_area
= data
.client
.area()
35 frame_size
= data
.client
.frame
.size()
36 screen_area
= ob
.openbox
.screen(data
.screen
).area()
37 width
= screen_area
.width() - (client_area
.width() +
38 frame_size
.left
+ frame_size
.right
)
39 height
= screen_area
.height() - (client_area
.height() +
40 frame_size
.top
+ frame_size
.bottom
)
42 x
= _rand
.randrange(screen_area
.x(), width
-1)
43 y
= _rand
.randrange(screen_area
.y(), height
-1)
44 data
.client
.move(x
, y
)
50 """Place windows in a cascading order from top-left to bottom-right."""
51 if not data
.client
: return
52 if not (ignore_requested_positions
and data
.client
.normal()):
53 if data
.client
.positionRequested(): return
54 client_area
= data
.client
.area()
55 frame_size
= data
.client
.frame
.size()
56 screen_area
= ob
.openbox
.screen(data
.screen
).area()
57 width
= screen_area
.width() - (client_area
.width() +
58 frame_size
.left
+ frame_size
.right
)
59 height
= screen_area
.height() - (client_area
.height() +
60 frame_size
.top
+ frame_size
.bottom
)
61 global _cascade_x
, _cascade_y
62 if _cascade_x
< screen_area
.x() or _cascade_y
< screen_area
.y() or \
63 _cascade_x
>= width
or _cascade_y
>= height
:
64 _cascade_x
= screen_area
.x()
65 _cascade_y
= screen_area
.y()
66 data
.client
.move(_cascade_x
, _cascade_y
)
67 _cascade_x
+= frame_size
.top
68 _cascade_y
+= frame_size
.top
70 print "Loaded windowplacement.py"