summaryrefslogtreecommitdiff
path: root/python/windowplacement.py
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-03-16 21:11:39 +0000
committerDana Jansens <danakj@orodu.net>2003-03-16 21:11:39 +0000
commitf8a47de5ec444c452093371e3db16857eb39a490 (patch)
tree31db2567842d98232775f9980f7a8d2586c0ac71 /python/windowplacement.py
parent8ba0586bcbdc7fe9648f1063812126d71a041670 (diff)
merge the C branch into HEAD
Diffstat (limited to 'python/windowplacement.py')
-rw-r--r--python/windowplacement.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/python/windowplacement.py b/python/windowplacement.py
new file mode 100644
index 00000000..56b5320d
--- /dev/null
+++ b/python/windowplacement.py
@@ -0,0 +1,47 @@
+############################################################################
+### Window placement algorithms, choose one of these and ebind it to the ###
+### ob.EventAction.PlaceWindow event. ###
+### ###
+### Also see historyplacement.py for the history placement module which ###
+### provides an algorithm that can be used in place of, or alongside, ###
+### these. ###
+############################################################################
+
+import ob
+from random import Random
+
+def random(client):
+ """Place windows randomly around the screen."""
+ if ob.Openbox.state() == ob.State.Starting: return
+ #if data.client.positionRequested(): return
+ cx, cy, cw, ch = client.area()
+ sx, sy, sw, sh = ob.Openbox.screenArea(client.desktop())
+ global _rand
+ x = Random().randrange(sx, sw - cw - 1)
+ y = Random().randrange(sy, sh - ch - 1)
+ client.setArea((x, y, cw, ch))
+
+def cascade(client):
+ """Place windows in a cascading order from top-left to bottom-right."""
+ if ob.Openbox.state() == ob.State.Starting: return
+ #if data.client.positionRequested(): return
+ cx, cy, cw, ch = client.area()
+ sx, sy, sw, sh = ob.Openbox.screenArea(client.desktop())
+ width = sw - cw
+ height = sh - ch
+ global _cascade_x, _cascade_y
+ if _cascade_x < sx or _cascade_y < sy or \
+ _cascade_x >= width or _cascade_y >= height:
+ _cascade_x = sx
+ _cascade_y = sy
+ client.setArea((_cascade_x, _cascade_y, cw, ch))
+ frame_size = client.frameSize()
+ _cascade_x += frame_size[1]
+ _cascade_y += frame_size[1]
+
+_cascade_x = 0
+_cascade_y = 0
+
+export_functions = random, cascade
+
+print "Loaded windowplacement.py"