--- gtk+-2.8.18/gdk/x11/gdkinput-x11.c.org	2006-03-04 06:25:45.000000000 +0100
+++ gtk+-2.8.18/gdk/x11/gdkinput-x11.c	2006-05-29 16:38:24.000000000 +0200
@@ -455,11 +455,19 @@
 
   if (gdkdev->info.mode == GDK_MODE_SCREEN) 
     {
-      x_scale = gdk_screen_get_width (gdk_drawable_get_screen (input_window->window)) / device_width;
-      y_scale = gdk_screen_get_height (gdk_drawable_get_screen (input_window->window)) / device_height;
-
-      x_offset = - input_window->root_x;
-      y_offset = - input_window->root_y;
+      int core_pointer_x, core_pointer_y, cur_monitor;
+      GdkRectangle mon_geometry;
+      GdkScreen *cur_screen;
+      gdk_display_get_pointer(gdk_drawable_get_display(input_window->window),
+			      &cur_screen,&core_pointer_x,&core_pointer_y,0);
+      cur_monitor= gdk_screen_get_monitor_at_point(cur_screen,
+						   core_pointer_x,
+						   core_pointer_y);
+      gdk_screen_get_monitor_geometry(cur_screen,cur_monitor,&mon_geometry);
+      x_scale = mon_geometry.width / device_width;
+      y_scale = mon_geometry.height / device_height;
+      x_offset = mon_geometry.x - input_window->root_x;
+      y_offset = mon_geometry.y - input_window->root_y;
     }
   else				/* GDK_MODE_WINDOW */
     {
