]>
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 ##############################################################################
11 ### Options for the windowplacement module: ###
14 ##############################################################################
20 _rand
= random
.Random()
23 """Place windows randomly around the screen."""
24 if not data
.client
: return
25 if data
.client
.positionRequested(): return
26 client_area
= data
.client
.frame
.area()
27 screen_area
= ob
.openbox
.screen(data
.screen
).area(data
.client
.desktop())
28 width
= screen_area
.width() - client_area
.width()
29 height
= screen_area
.height() - client_area
.height()
31 x
= _rand
.randrange(screen_area
.x(), width
-1)
32 y
= _rand
.randrange(screen_area
.y(), height
-1)
33 data
.client
.move(x
, y
)
39 """Place windows in a cascading order from top-left to bottom-right."""
40 if not data
.client
: return
41 if data
.client
.positionRequested(): return
42 client_area
= data
.client
.frame
.area()
43 screen_area
= ob
.openbox
.screen(data
.screen
).area(data
.client
.desktop())
44 width
= screen_area
.width() - client_area
.width()
45 height
= screen_area
.height() - client_area
.height()
46 global _cascade_x
, _cascade_y
47 if _cascade_x
< screen_area
.x() or _cascade_y
< screen_area
.y() or \
48 _cascade_x
>= width
or _cascade_y
>= height
:
49 _cascade_x
= screen_area
.x()
50 _cascade_y
= screen_area
.y()
51 data
.client
.move(_cascade_x
, _cascade_y
)
52 frame_size
= data
.client
.frame
.size()
53 _cascade_x
+= frame_size
.top
54 _cascade_y
+= frame_size
.top
56 print "Loaded windowplacement.py"
This page took 0.039754 seconds and 4 git commands to generate.