new scripts for new script structure
[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
6 import ob
7 import random
8
9 _rand = random.Random()
10
11 def random(data):
12     if not data.client: return
13     client_area = data.client.area()
14     frame_size = data.client.frame.size()
15     screen_area = ob.openbox.screen(data.screen).area()
16     width = screen_area.width() - (client_area.width() +
17                                    frame_size.left + frame_size.right)
18     height = screen_area.height() - (client_area.height() + 
19                                      frame_size.top + frame_size.bottom)
20     global _rand
21     x = _rand.randrange(screen_area.x(), width-1)
22     y = _rand.randrange(screen_area.y(), height-1)
23     data.client.move(x, y)
24
25 print "Loaded windowplacement.py"