]> icculus.org git repositories - mikachu/openbox.git/blob - scripts/windowplacement.py
historyplacement!!
[mikachu/openbox.git] / scripts / windowplacement.py
1 ############################################################################
2 ### Window placement algorithms, choose one of these and ebind it to the ###
3 ### ob.EventAction.PlaceWindow event.                                    ###
4 ###                                                                      ###
5 ### Also see historyplacement.py for the history placement module which  ###
6 ### provides an algorithm that can be used in place of, or alongside     ###
7 ### these.                                                               ###
8 ############################################################################
9
10 import otk
11 import ob
12 import random
13
14 _rand = random.Random()
15
16 def random(data):
17     if not data.client: return
18     client_area = data.client.area()
19     frame_size = data.client.frame.size()
20     screen_area = ob.openbox.screen(data.screen).area()
21     width = screen_area.width() - (client_area.width() +
22                                    frame_size.left + frame_size.right)
23     height = screen_area.height() - (client_area.height() + 
24                                      frame_size.top + frame_size.bottom)
25     global _rand
26     x = _rand.randrange(screen_area.x(), width-1)
27     y = _rand.randrange(screen_area.y(), height-1)
28     data.client.move(x, y)
29
30 print "Loaded windowplacement.py"