]> Dogcows Code - chaz/openbox/blob - scripts/windowplacement.py
let clients be remaximized to adjust to new surroundings/struts
[chaz/openbox] / 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 ##############################################################################
11 ### Options for the windowplacement module: ###
12 ### ###
13 # ignore_requested_positions - When true, the placement algorithm will ###
14 ### attempt to place windows even when they ###
15 ### request a position (like XMMS). ###
16 ### Note this only applies to normal windows, ###
17 ### not to special cases like desktops and ###
18 ### docks. ###
19 ignore_requested_positions = 0 ###
20 ### ###
21 ##############################################################################
22
23 import otk
24 import ob
25 import random
26
27 _rand = random.Random()
28
29 def random(data):
30 """Place windows randomly around the screen."""
31 if not data.client: return
32 if not (ignore_requested_positions and data.client.normal()):
33 if data.client.positionRequested(): return
34 client_area = data.client.area()
35 frame_size = data.client.frame.size()
36 screen_area = ob.openbox.screen(data.screen).area()
37 width = screen_area.width() - (client_area.width() +
38 frame_size.left + frame_size.right)
39 height = screen_area.height() - (client_area.height() +
40 frame_size.top + frame_size.bottom)
41 global _rand
42 x = _rand.randrange(screen_area.x(), width-1)
43 y = _rand.randrange(screen_area.y(), height-1)
44 data.client.move(x, y)
45
46 _cascade_x = 0
47 _cascade_y = 0
48
49 def cascade(data):
50 """Place windows in a cascading order from top-left to bottom-right."""
51 if not data.client: return
52 if not (ignore_requested_positions and data.client.normal()):
53 if data.client.positionRequested(): return
54 client_area = data.client.area()
55 frame_size = data.client.frame.size()
56 screen_area = ob.openbox.screen(data.screen).area()
57 width = screen_area.width() - (client_area.width() +
58 frame_size.left + frame_size.right)
59 height = screen_area.height() - (client_area.height() +
60 frame_size.top + frame_size.bottom)
61 global _cascade_x, _cascade_y
62 if _cascade_x < screen_area.x() or _cascade_y < screen_area.y() or \
63 _cascade_x >= width or _cascade_y >= height:
64 _cascade_x = screen_area.x()
65 _cascade_y = screen_area.y()
66 data.client.move(_cascade_x, _cascade_y)
67 _cascade_x += frame_size.top
68 _cascade_y += frame_size.top
69
70 print "Loaded windowplacement.py"
This page took 0.042785 seconds and 4 git commands to generate.