]>
Dogcows Code - chaz/openbox/blob - scripts/windowplacement.py
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 import otk
, ob
, random
12 _rand
= random
.Random()
15 """Place windows randomly around the screen."""
16 if not data
.client
: return
17 if data
.client
.positionRequested(): return
18 client_area
= data
.client
.frame
.area()
19 screen_area
= ob
.openbox
.screen(data
.screen
).area(data
.client
.desktop())
20 width
= screen_area
.width() - client_area
.width()
21 height
= screen_area
.height() - client_area
.height()
23 x
= _rand
.randrange(screen_area
.x(), width
-1)
24 y
= _rand
.randrange(screen_area
.y(), height
-1)
25 data
.client
.move(x
, y
)
31 """Place windows in a cascading order from top-left to bottom-right."""
32 if not data
.client
: return
33 if data
.client
.positionRequested(): return
34 client_area
= data
.client
.frame
.area()
35 screen_area
= ob
.openbox
.screen(data
.screen
).area(data
.client
.desktop())
36 width
= screen_area
.width() - client_area
.width()
37 height
= screen_area
.height() - client_area
.height()
38 global _cascade_x
, _cascade_y
39 if _cascade_x
< screen_area
.x() or _cascade_y
< screen_area
.y() or \
40 _cascade_x
>= width
or _cascade_y
>= height
:
41 _cascade_x
= screen_area
.x()
42 _cascade_y
= screen_area
.y()
43 data
.client
.move(_cascade_x
, _cascade_y
)
44 frame_size
= data
.client
.frame
.size()
45 _cascade_x
+= frame_size
.top
46 _cascade_y
+= frame_size
.top
48 export_functions
= random
, cascade
50 print "Loaded windowplacement.py"
This page took 0.040342 seconds and 4 git commands to generate.