summaryrefslogtreecommitdiff
path: root/python/motion.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/motion.py
parent8ba0586bcbdc7fe9648f1063812126d71a041670 (diff)
merge the C branch into HEAD
Diffstat (limited to 'python/motion.py')
-rw-r--r--python/motion.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/python/motion.py b/python/motion.py
new file mode 100644
index 00000000..64e04947
--- /dev/null
+++ b/python/motion.py
@@ -0,0 +1,81 @@
+import config, hooks, ob
+from input import Pointer
+
+config.add('motion',
+ 'edge_resistance',
+ 'Edge Resistance',
+ "The amount of resistance to provide to moving a window past a " + \
+ "screen boundary. Specify a value of 0 to disable edge resistance.",
+ 'integer',
+ 10,
+ min = 0)
+
+def move(ptrdata, client):
+ def mymove(ptrdata, client):
+ global _moving, _last_pos
+ if ptrdata.action == Pointer.Action_Release:
+ _moveclient.setArea(_moveclient.area(), True) # finalize the move
+ _moving = False
+ Pointer.ungrab()
+ elif ptrdata.action == Pointer.Action_Motion:
+ pos = ptrdata.pos
+
+ x = _pcarea[0] + pos[0] - _presspos[0]
+ y = _pcarea[1] + pos[1] - _presspos[1]
+
+ resist = config.get('motion', 'edge_resistance')
+ if resist:
+ ca = _moveclient.area()
+ w, h = ca[2], ca[3]
+ # use the area based on the struts
+ sa = ob.Openbox.screenArea(_moveclient.desktop())
+ l, t = sa[0], sa[1]
+ r = l+ sa[2] - w
+ b = t+ sa[3] - h
+ # left screen edge
+ if _last_pos[0] >= pos[0] and x < l and x >= l - resist:
+ x = l
+ # right screen edge
+ if _last_pos[0] <= pos[0] and x > r and x <= r + resist:
+ x = r
+ # top screen edge
+ if _last_pos[1] >= pos[1] and y < t and y >= t - resist:
+ y = t
+ # right screen edge
+ if _last_pos[1] <= pos[1] and y > b and y <= b + resist:
+ y = b
+
+ _moveclient.setArea((x, y, _pcarea[2], _pcarea[3]), False)
+ _last_pos = pos
+
+ global _last_pos, _moving, _pcarea, _presspos, _moveclient
+ if not _moving:
+ _moving = True
+ _pcarea = ptrdata.pressclientarea
+ _presspos = ptrdata.presspos
+ _last_pos = _presspos
+ _moveclient = client
+ Pointer.grab(mymove)
+ mymove(ptrdata, client)
+
+def resize(ptrdata, client):
+ x, y = ptrdata.pos
+ px, py = ptrdata.presspos
+ cx, cy, cw, ch = ptrdata.pressclientarea
+ dx = x - px
+ dy = y - py
+ if px < cx + cw / 2: # left side
+ dx *= -1
+ cx -= dx
+ if py < cy + ch / 2: # top side
+ dy *= -1
+ cy -= dy
+ cw += dx
+ ch += dy
+ client.setArea((cx, cy, cw, ch))
+
+_moving = False
+_moveclient = 0
+_last_pos = ()
+_pcarea = ()
+_presspos = ()