]>
Dogcows Code - chaz/openbox/blob - windowplacement.py
e7ba187ded2741ddb230748e5ce71b899227a55a
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
.area()
27 frame_size
= data
.client
.frame
.size()
28 screen_area
= ob
.openbox
.screen(data
.screen
).area()
29 width
= screen_area
.width() - (client_area
.width() +
30 frame_size
.left
+ frame_size
.right
)
31 height
= screen_area
.height() - (client_area
.height() +
32 frame_size
.top
+ frame_size
.bottom
)
34 x
= _rand
.randrange(screen_area
.x(), width
-1)
35 y
= _rand
.randrange(screen_area
.y(), height
-1)
36 data
.client
.move(x
, y
)
42 """Place windows in a cascading order from top-left to bottom-right."""
43 if not data
.client
: return
44 if data
.client
.positionRequested(): return
45 client_area
= data
.client
.area()
46 frame_size
= data
.client
.frame
.size()
47 screen_area
= ob
.openbox
.screen(data
.screen
).area()
48 width
= screen_area
.width() - (client_area
.width() +
49 frame_size
.left
+ frame_size
.right
)
50 height
= screen_area
.height() - (client_area
.height() +
51 frame_size
.top
+ frame_size
.bottom
)
52 global _cascade_x
, _cascade_y
53 if _cascade_x
< screen_area
.x() or _cascade_y
< screen_area
.y() or \
54 _cascade_x
>= width
or _cascade_y
>= height
:
55 _cascade_x
= screen_area
.x()
56 _cascade_y
= screen_area
.y()
57 data
.client
.move(_cascade_x
, _cascade_y
)
58 _cascade_x
+= frame_size
.top
59 _cascade_y
+= frame_size
.top
61 print "Loaded windowplacement.py"
This page took 0.040741 seconds and 3 git commands to generate.