Skip to content
Browse files

add support for scaling coords based on script vs server resolution

  • Loading branch information...
1 parent c845d23 commit 0fc68fa4640452ddb814ed7d571d2d9dd6ae3699 @sibson committed Jan 21, 2013
Showing with 25 additions and 3 deletions.
  1. +18 −3 vncdotool/client.py
  2. +3 −0 vncdotool/command.py
  3. +4 −0 vncdotool/loggingproxy.py
View
21 vncdotool/client.py
@@ -116,12 +116,15 @@ class VNCDoToolClient(rfb.RFBClient):
x = 0
y = 0
buttons = 0
+ scale = (1.0, 1.0)
+
screen = None
deferred = None
cursor = None
cmask = None
+
def _decodeKey(self, key):
if len(key) == 1:
keys = [key]
@@ -252,15 +255,22 @@ def _expectCompare(self, image, maxrms):
def mouseMove(self, x, y):
""" Move the mouse pointer to position (x, y)
"""
- log.debug('mouseMove', x, y)
- self.x, self.y = x, y
- self.pointerEvent(x, y, self.buttons)
+ log.debug('mouseMove %s %s', x, y)
+ self.x = self.scale[0] * x
+ self.y = self.scale[1] * y
+
+ self.pointerEvent(self.x, self.y, self.buttons)
+
return self
def mouseDrag(self, x, y, step=1):
""" Move the mouse point to position (x, y) in increments of step
"""
log.debug('mouseDrag', x, y)
+
+ x = self.scale[0] * x
+ y = self.scale[1] * y
+
if x < self.x:
xsteps = [self.x - i for i in xrange(step, self.x - x + 1, step)]
else:
@@ -283,6 +293,11 @@ def mouseDrag(self, x, y, step=1):
return self
+ def scaleFrom(self, width, height):
+ self.scale = (float(self.width) / width,
+ float(self.height / height))
+ return self
+
#
# base customizations
#
View
3 vncdotool/command.py
@@ -134,6 +134,9 @@ def build_command_list(factory, args, delay=None, warp=1.0):
lex = shlex.shlex(open(cmd), posix=True)
lex.whitespace_split = True
args = list(lex) + args
+ elif cmd == 'scaleres':
+ w, h = float(args.pop(0)), float(args.pop(0))
+ factory.deferred.addCallback(client.scaleFrom, w, h)
else:
print 'unknown cmd "%s"' % cmd
View
4 vncdotool/loggingproxy.py
@@ -130,6 +130,10 @@ class VNCLoggingClient(VNCDoToolClient):
"""
capture_file = None
+ def vncConnectionMade(self):
+ VNCDoToolClient.vncConnectionMade(self)
+ self.recorder('scaleres %d %d\n' % (self.width, self.height))
+
def commitUpdate(self, rectangles):
if self.capture_file:
self.screen.save(self.capture_file)

0 comments on commit 0fc68fa

Please sign in to comment.
Something went wrong with that request. Please try again.