summaryrefslogtreecommitdiffstats
path: root/extra/arandr/arandr-0.1.3/screenlayout/snap.py
diff options
context:
space:
mode:
authorPRomain GAILLETON <root@nutyx.(none)>2010-05-30 06:18:44 +0200
committerPRomain GAILLETON <root@nutyx.(none)>2010-05-30 06:18:44 +0200
commit4e87e0e05326b4a1de72da67fad56f39e6eab992 (patch)
tree0b3665939d90cf8552c49f8918561a6101e1a3e5 /extra/arandr/arandr-0.1.3/screenlayout/snap.py
parent1b5ca2f66e056b9fc67e864a526175d8b091e7a7 (diff)
downloadnutyx-extra-4e87e0e05326b4a1de72da67fad56f39e6eab992.tar.gz
nutyx-extra-4e87e0e05326b4a1de72da67fad56f39e6eab992.tar.bz2
nutyx-extra-4e87e0e05326b4a1de72da67fad56f39e6eab992.tar.xz
nutyx-extra-4e87e0e05326b4a1de72da67fad56f39e6eab992.zip
Ajout de arandr#0.1.3
Diffstat (limited to 'extra/arandr/arandr-0.1.3/screenlayout/snap.py')
-rw-r--r--extra/arandr/arandr-0.1.3/screenlayout/snap.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/extra/arandr/arandr-0.1.3/screenlayout/snap.py b/extra/arandr/arandr-0.1.3/screenlayout/snap.py
new file mode 100644
index 000000000..b08223f38
--- /dev/null
+++ b/extra/arandr/arandr-0.1.3/screenlayout/snap.py
@@ -0,0 +1,30 @@
+from .auxiliary import Position
+
+class Snap(object):
+ """Snap-to-edges manager"""
+ def __init__(self, size, tolerance, list):
+ self.tolerance = tolerance
+
+ self.horizontal = set()
+ self.vertical = set()
+ for i in list:
+ self.vertical.add(i[0].left)
+ self.vertical.add(i[0].left+i[1].width)
+ self.horizontal.add(i[0].top)
+ self.horizontal.add(i[0].top+i[1].height)
+
+ self.vertical.add(i[0].left-size.width)
+ self.vertical.add(i[0].left+i[1].width-size.width)
+ self.horizontal.add(i[0].top-size.height)
+ self.horizontal.add(i[0].top+i[1].height-size.height)
+
+ def suggest(self, position):
+ vertical = [x for x in self.vertical if abs(x-position[0])<self.tolerance]
+ horizontal = [y for y in self.horizontal if abs(y-position[1])<self.tolerance]
+
+ if vertical:
+ position = Position((vertical[0], position[1]))
+ if horizontal:
+ position = Position((position[0], horizontal[0]))
+
+ return position