diff --git a/Test/Robot/Internal.hs b/Test/Robot/Internal.hs
--- a/Test/Robot/Internal.hs
+++ b/Test/Robot/Internal.hs
@@ -83,17 +83,20 @@
 -- | @clipIntegral x :: T@ converts the value @x@ to type @T@.
 -- If the argument does not fit in @T@, it is clipped, rather than
 -- wrapping around as with 'fromIntegral'.
---
--- The range of the result type must be a subset of the argument type.
--- If not, the behavior of this function is undefined.
---
 clipIntegral :: (Integral a, Integral b, Ord a, Bounded b) => a -> b
-clipIntegral x = result
+clipIntegral = narrow . widen
+
+widen :: Integral a => a -> Integer
+widen = fromIntegral
+
+narrow :: (Integral b, Bounded b) => Integer -> b
+narrow x = result
   where
     result
       | x < fromIntegral (minBound `asTypeOf` result) = minBound
       | x > fromIntegral (maxBound `asTypeOf` result) = maxBound
       | otherwise = fromIntegral x
+
 
 -- | Release all the keys and buttons, in case some were left held down.
 -- This is called automatically before 'runRobot' returns.
diff --git a/Test/Robot/Internal/XTest.hs b/Test/Robot/Internal/XTest.hs
--- a/Test/Robot/Internal/XTest.hs
+++ b/Test/Robot/Internal/XTest.hs
@@ -20,7 +20,7 @@
 import Data.Map (Map)
 import qualified Data.Map as M
 import Data.Tuple (swap)
-import Data.Word (Word16)
+import Data.Int (Int16)
 
 import Graphics.XHB
 import Graphics.XHB.Gen.Test
@@ -40,12 +40,27 @@
     in fakeInput c req
 
 
-motion :: Connection -> Bool -> (Word16, Word16) -> IO ()
+motion :: Connection -> Bool -> (Int16, Int16) -> IO ()
 motion c relative (x, y) =
     let eventType = 6
         isRelative = if relative then 1 else 0
-        req = MkFakeInput eventType isRelative 0 noWindow x y 0
+        req = MkFakeInput eventType isRelative 0 noWindow
+                -- See note [fromIntegral]
+                (fromIntegral x) (fromIntegral y) 0
     in fakeInput c req
+
+{-
+
+Note [fromIntegral]
+~~~~~~~~~~~~~~~~~~~
+
+In xcb-proto < 1.7, the x and y coordinates are declared incorrectly as
+Word16, instead of Int16 as they should be. As a temporary workaround,
+we use fromIntegral to coerce the values.
+
+See <http://cgit.freedesktop.org/~keithp/xcb-proto/commit/src/xtest.xml?id=f3ae971edce37ad96ef0b8a6059c1f853e88fcf3>
+
+ -}
 
 
 noWindow :: WINDOW
diff --git a/robot.cabal b/robot.cabal
--- a/robot.cabal
+++ b/robot.cabal
@@ -1,5 +1,5 @@
 Name:                robot
-Version:             1.0.1
+Version:             1.0.1.1
 Synopsis:            Simulate keyboard and mouse events
 Homepage:            https://github.com/lfairy/robot
 License:             OtherLicense
