diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index c0b71e7..f2b0c84 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -506,14 +506,20 @@ 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 * (axis_data[x_axis] -
+              gdkdev->axes[x_axis].min_value);
+          else
+            axis_out[i] = x_offset + 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 * (axis_data[y_axis] -
+              gdkdev->axes[y_axis].min_value);
+          else
+            axis_out[i] = y_offset + axis_data[y_axis];
 	  if (y_out)
 	    *y_out = axis_out[i];
 	  break;
