diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index c0b71e7..3be28d6 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -40,10 +40,13 @@ static GdkDevicePrivate *gdk_input_device_new            (GdkDisplay       *disp
 							  gint              include_core);
 static void              gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
 							  GdkWindow        *window,
-							  gint             *axis_data,
 							  gdouble          *axis_out,
 							  gdouble          *x_out,
 							  gdouble          *y_out);
+static void              gdk_input_update_axes           (GdkDevicePrivate *gdkdev,
+							  gint             axes_count,
+							  gint             first_axis,
+							  gint             *axis_data);
 static guint             gdk_input_translate_state       (guint             state,
 							  guint             device_state);
 
@@ -176,6 +179,7 @@ gdk_input_device_new (GdkDisplay  *display,
 	  XValuatorInfo *xvi = (XValuatorInfo *)class;
 	  gdkdev->info.num_axes = xvi->num_axes;
 	  gdkdev->axes = g_new (GdkAxisInfo, xvi->num_axes);
+	  gdkdev->axis_data = g_new0 (gint, xvi->num_axes);
 	  gdkdev->info.axes = g_new0 (GdkDeviceAxis, xvi->num_axes);
 	  for (j=0;j<xvi->num_axes;j++)
 	    {
@@ -414,9 +418,21 @@ _gdk_input_common_init (GdkDisplay *display,
 }
 
 static void
+gdk_input_update_axes (GdkDevicePrivate *gdkdev,
+		       gint             axes_count,
+		       gint             first_axis,
+		       gint             *axis_data)
+{
+  int i;
+  for (i = 0; i < axes_count; i++)
+    {
+      gdkdev->axis_data[first_axis + i] = axis_data[i];
+    }
+}
+
+static void
 gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
 				 GdkWindow        *window,
-				 gint             *axis_data,
 				 gdouble          *axis_out,
 				 gdouble          *x_out,
 				 gdouble          *y_out)
@@ -506,21 +522,27 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
       switch (gdkdev->info.axes[i].use)
 	{
 	case GDK_AXIS_X:
-	  axis_out[i] = x_offset + x_scale * (axis_data[x_axis] -
-	    gdkdev->axes[x_axis].min_value);
+          if (device_width > 0)
+            axis_out[i] = x_offset + x_scale * (gdkdev->axis_data[x_axis] -
+              gdkdev->axes[x_axis].min_value);
+          else
+            axis_out[i] = x_offset + gdkdev->axis_data[x_axis];
 	  if (x_out)
 	    *x_out = axis_out[i];
 	  break;
 	case GDK_AXIS_Y:
-	  axis_out[i] = y_offset + y_scale * (axis_data[y_axis] -
-	    gdkdev->axes[y_axis].min_value);
+          if (device_height > 0)
+            axis_out[i] = y_offset + y_scale * (gdkdev->axis_data[y_axis] -
+              gdkdev->axes[y_axis].min_value);
+          else
+            axis_out[i] = y_offset + gdkdev->axis_data[y_axis];
 	  if (y_out)
 	    *y_out = axis_out[i];
 	  break;
 	default:
 	  axis_out[i] =
-	    (gdkdev->info.axes[i].max * (axis_data[i] - gdkdev->axes[i].min_value) +
-	     gdkdev->info.axes[i].min * (gdkdev->axes[i].max_value - axis_data[i])) /
+	    (gdkdev->info.axes[i].max * (gdkdev->axis_data[i] - gdkdev->axes[i].min_value) +
+	     gdkdev->info.axes[i].min * (gdkdev->axes[i].max_value - gdkdev->axis_data[i])) /
 	    (gdkdev->axes[i].max_value - gdkdev->axes[i].min_value);
 	  break;
 	}
@@ -573,7 +595,8 @@ _gdk_input_common_other_event (GdkEvent         *event,
       event->button.time = xdbe->time;
 
       event->button.axes = g_new (gdouble, gdkdev->info.num_axes);
-      gdk_input_translate_coordinates (gdkdev, window, xdbe->axis_data,
+      gdk_input_update_axes (gdkdev, xdbe->axes_count, xdbe->first_axis, xdbe->axis_data);
+      gdk_input_translate_coordinates (gdkdev, window,
 				       event->button.axes,
 				       &event->button.x, &event->button.y);
       event->button.x_root = event->button.x + priv->abs_x + input_window->root_x;
@@ -675,7 +698,8 @@ _gdk_input_common_other_event (GdkEvent         *event,
       event->motion.device = &gdkdev->info;
 
       event->motion.axes = g_new (gdouble, gdkdev->info.num_axes);
-      gdk_input_translate_coordinates(gdkdev,window,xdme->axis_data,
+      gdk_input_update_axes (gdkdev, xdme->axes_count, xdme->first_axis, xdme->axis_data);
+      gdk_input_translate_coordinates(gdkdev,window,
 				      event->motion.axes,
 				      &event->motion.x,&event->motion.y);
       event->motion.x_root = event->motion.x + priv->abs_x + input_window->root_x;
@@ -764,7 +788,6 @@ _gdk_device_get_history (GdkDevice         *device,
 	  coords[i]->time = device_coords[i].time;
 
 	  gdk_input_translate_coordinates (gdkdev, window,
-					   device_coords[i].data,
 					   coords[i]->axes, NULL, NULL);
 	}
 
@@ -821,9 +844,12 @@ gdk_device_get_state (GdkDevice       *device,
 	    {
 	    case ValuatorClass:
 	      if (axes)
-		gdk_input_translate_coordinates (gdkdev, window,
-						 ((XValuatorState *)input_class)->valuators,
-						 axes, NULL, NULL);
+		{
+		  gdk_input_update_axes (gdkdev, gdkdev->info.num_axes, 0,
+						((XValuatorState *)input_class)->valuators);
+		  gdk_input_translate_coordinates (gdkdev, window,
+						axes, NULL, NULL);
+		}
 	      break;
 
 	    case ButtonClass:
diff --git a/gdk/x11/gdkinputprivate.h b/gdk/x11/gdkinputprivate.h
index 217e28c..0c20d0f 100644
--- a/gdk/x11/gdkinputprivate.h
+++ b/gdk/x11/gdkinputprivate.h
@@ -73,6 +73,7 @@ struct _GdkDevicePrivate
 #ifndef XINPUT_NONE
   /* information about the axes */
   GdkAxisInfo *axes;
+  gint *axis_data;
 
   /* Information about XInput device */
   XDevice       *xdevice;
