mirror of
https://github.com/ralsina/xrandroll.git
synced 2024-11-21 18:42:22 +00:00
Fix #12
This commit is contained in:
parent
eb17909563
commit
30860034f5
@ -76,15 +76,16 @@ class MonitorItem(QGraphicsRectItem, QObject):
|
||||
current_pos = event.screenPos()
|
||||
new_pos = view.mapFromScene(self.orig_pos) + current_pos - click_pos
|
||||
new_pos = view.mapToScene(new_pos)
|
||||
delta = view.mapToScene(0, 20).y()
|
||||
if not event.modifiers() & Qt.AltModifier:
|
||||
# Check for snaps
|
||||
x = new_pos.x()
|
||||
delta_x = min((abs(x - sx), i) for i, sx in enumerate(snaps_x))
|
||||
if delta_x[0] < 50: # snap
|
||||
if delta_x[0] < delta: # snap
|
||||
new_pos.setX(int(snaps_x[delta_x[1]]))
|
||||
y = new_pos.y()
|
||||
delta_y = min((abs(y - sy), i) for i, sy in enumerate(snaps_y))
|
||||
if delta_y[0] < 50: # snap
|
||||
if delta_y[0] < delta: # snap
|
||||
new_pos.setY(int(snaps_y[delta_y[1]]))
|
||||
self.setPos(new_pos)
|
||||
self.window.show_pos(int(self.pos().x()), int(self.pos().y()))
|
||||
|
Loading…
Reference in New Issue
Block a user