*** a/gdk/x11/gdkinput-x11.c	2011-08-15 22:30:52.000000000 -0400
--- b/gdk/x11/gdkinput-x11.c	2012-03-25 14:08:34.000000000 -0400
***************
*** 120,126 ****
    else if (strstr (tmp_name, "cursor"))
      gdkdev->info.source = GDK_SOURCE_CURSOR;
    else if (strstr (tmp_name, "wacom") ||
! 	   strstr (tmp_name, "pen"))
      gdkdev->info.source = GDK_SOURCE_PEN;
    else
      gdkdev->info.source = GDK_SOURCE_MOUSE;
--- 120,127 ----
    else if (strstr (tmp_name, "cursor"))
      gdkdev->info.source = GDK_SOURCE_CURSOR;
    else if (strstr (tmp_name, "wacom") ||
! 		   strstr (tmp_name, "pen") ||
! 		   strstr (tmp_name, "stylus"))
      gdkdev->info.source = GDK_SOURCE_PEN;
    else
      gdkdev->info.source = GDK_SOURCE_MOUSE;
***************
*** 460,465 ****
--- 461,481 ----
        x_offset = - impl_window->input_window->root_x - priv->abs_x;
        y_offset = - impl_window->input_window->root_y - priv->abs_y;
      }
+   else if (gdkdev->info.mode == GDK_MODE_MONITOR)
+     {
+       int core_pointer_x, core_pointer_y, cur_monitor;
+       GdkRectangle mon_geometry;
+       GdkScreen *cur_screen;
+       gdk_display_get_pointer (gdk_drawable_get_display (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 = - impl_window->input_window->root_x - priv->abs_x + mon_geometry.x;
+       y_offset = - impl_window->input_window->root_y - priv->abs_y + mon_geometry.y;
+     }
    else				/* GDK_MODE_WINDOW */
      {
        double x_resolution = gdkdev->axes[x_axis].resolution;
*** a/gdk/x11/gdkinput-xfree.c	2011-08-15 22:30:52.000000000 -0400
--- b/gdk/x11/gdkinput-xfree.c	2012-03-25 14:08:16.000000000 -0400
***************
*** 63,69 ****
  
    if (mode == GDK_MODE_WINDOW)
      device->has_cursor = FALSE;
!   else if (mode == GDK_MODE_SCREEN)
      device->has_cursor = TRUE;
  
    display_impl = GDK_DISPLAY_X11 (gdkdev->display);
--- 63,69 ----
  
    if (mode == GDK_MODE_WINDOW)
      device->has_cursor = FALSE;
!   else if (mode != GDK_MODE_DISABLED)
      device->has_cursor = TRUE;
  
    display_impl = GDK_DISPLAY_X11 (gdkdev->display);
*** a/gdk/win32/gdkinput.c	2011-08-15 22:30:52.000000000 -0400
--- b/gdk/win32/gdkinput.c	2012-03-25 14:08:25.000000000 -0400
***************
*** 500,506 ****
  	      _gdk_input_disable_window (input_window->window, gdkdev);
  	}
      }
!   else if (mode == GDK_MODE_SCREEN)
      {
        device->has_cursor = TRUE;
        for (tmp_list = _gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
--- 500,506 ----
  	      _gdk_input_disable_window (input_window->window, gdkdev);
  	}
      }
!   else if ((mode == GDK_MODE_SCREEN) || (mode == GDK_MODE_MONITOR))
      {
        device->has_cursor = TRUE;
        for (tmp_list = _gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
*** a/gdk/gdkinput.h	2011-08-15 22:30:51.000000000 -0400
--- b/gdk/gdkinput.h	2012-03-25 16:22:30.000000000 -0400
***************
*** 67,73 ****
  {
    GDK_MODE_DISABLED,
    GDK_MODE_SCREEN,
!   GDK_MODE_WINDOW
  } GdkInputMode;
  
  typedef enum
--- 67,74 ----
  {
    GDK_MODE_DISABLED,
    GDK_MODE_SCREEN,
!   GDK_MODE_WINDOW,
!   GDK_MODE_MONITOR
  } GdkInputMode;
  
  typedef enum
*** a/gdk/gdkenumtypes.c	2011-10-17 18:05:32.000000000 -0400
--- b/gdk/gdkenumtypes.c	2012-03-25 16:23:02.000000000 -0400
***************
*** 599,604 ****
--- 599,605 ----
              { GDK_MODE_DISABLED, "GDK_MODE_DISABLED", "disabled" },
              { GDK_MODE_SCREEN, "GDK_MODE_SCREEN", "screen" },
              { GDK_MODE_WINDOW, "GDK_MODE_WINDOW", "window" },
+             { GDK_MODE_MONITOR, "GDK_MODE_MONITOR", "monitor" },
              { 0, NULL, NULL }
          };
          etype = g_enum_register_static (g_intern_static_string ("GdkInputMode"), values);
*** a/docs/reference/gdk/tmpl/input_devices.sgml	2011-10-17 18:50:36.000000000 -0400
--- b/docs/reference/gdk/tmpl/input_devices.sgml	2012-03-25 16:06:17.000000000 -0400
***************
*** 61,67 ****
  The configuration of devices is queried using gdk_devices_list().
  Each device must be activated using gdk_device_set_mode(), which
  also controls whether the device's range is mapped to the
! entire screen or to a single window. The mapping of the valuators of
  the device onto the predefined valuator types is set using
  gdk_device_set_axis_use(). And the source type for each device
  can be set with gdk_device_set_source().
--- 61,71 ----
  The configuration of devices is queried using gdk_devices_list().
  Each device must be activated using gdk_device_set_mode(), which
  also controls whether the device's range is mapped to the
! entire screen, a single monitor, or to a single window.  In this 
! context, the "screen" refers to the entire virtual screen, which
! may extend across multiple monitors on some operating systems.   
! </para> 
! <para>The mapping of the valuators of
  the device onto the predefined valuator types is set using
  gdk_device_set_axis_use(). And the source type for each device
  can be set with gdk_device_set_source().
***************
*** 121,131 ****
  
  @GDK_MODE_DISABLED: the device is disabled and will not report any events.
  @GDK_MODE_SCREEN: the device is enabled. The device's coordinate space
!                     maps to the entire screen.
  @GDK_MODE_WINDOW: the device is enabled. The device's coordinate space
                      is mapped to a single window. The manner in which this window
                      is chosen is undefined, but it will typically be the same
                      way in which the focus window for key events is determined.
  
  <!-- ##### STRUCT GdkDeviceKey ##### -->
  <para>
--- 125,140 ----
  
  @GDK_MODE_DISABLED: the device is disabled and will not report any events.
  @GDK_MODE_SCREEN: the device is enabled. The device's coordinate space
!                     maps to the entire (virtual) screen.  If the virtual screen extends
!                     across multiple monitors, the input device maps across all monitors
!                     as one coordinate space.  The mapping does not change based on 
!                     the currently active monitor.
  @GDK_MODE_WINDOW: the device is enabled. The device's coordinate space
                      is mapped to a single window. The manner in which this window
                      is chosen is undefined, but it will typically be the same
                      way in which the focus window for key events is determined.
+ @GDK_MODE_MONITOR: the device is enabled. The device's coordinate space
+                     maps to the currently active monitor.
  
  <!-- ##### STRUCT GdkDeviceKey ##### -->
  <para>
***************
*** 203,209 ****
  <para>
  Sets a the mode of an input device. The mode controls if the 
  device is active and whether the device's range is mapped to the
! entire screen or to a single window.
  </para>
  
  @device: a #GdkDevice.
--- 212,218 ----
  <para>
  Sets a the mode of an input device. The mode controls if the 
  device is active and whether the device's range is mapped to the
! entire screen, a single monitor, or to a single window.
  </para>
  
  @device: a #GdkDevice.
