]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkdevice.c
Add GdkFrameHistory and GdkFrameTimings, handle _NET_WM_FRAME_TIMINGS
[~andy/gtk] / gdk / gdkdevice.c
index 8c035097fd003be8ee7c8391cba55c29bc34fc2d..3147d9e6a0a5be5e9f6ef08946942b03bd7b90ac 100644 (file)
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
-#include "gdkdevice.h"
+
+#include <math.h>
+
 #include "gdkdeviceprivate.h"
-#include "gdkintl.h"
+#include "gdkdisplayprivate.h"
 #include "gdkinternals.h"
+#include "gdkintl.h"
 
+/**
+ * SECTION:gdkdevice
+ * @Short_description: Object representing an input device
+ * @Title: GdkDevice
+ * @See_also: #GdkDeviceManager
+ *
+ * The #GdkDevice object represents a single input device, such
+ * as a keyboard, a mouse, a touchpad, etc.
+ *
+ * See the #GdkDeviceManager documentation for more information
+ * about the various kinds of master and slave devices, and their
+ * relationships.
+ */
 
 typedef struct _GdkAxisInfo GdkAxisInfo;
 
@@ -33,21 +47,19 @@ struct _GdkAxisInfo
 
   gdouble min_axis;
   gdouble max_axis;
-
   gdouble min_value;
   gdouble max_value;
   gdouble resolution;
 };
 
-struct _GdkDevicePrivate
-{
-  GdkDeviceManager *device_manager;
-  GdkDisplay *display;
-  GdkDevice *associated;
-  GdkDeviceType type;
-  GArray *axes;
+enum {
+  CHANGED,
+  LAST_SIGNAL
 };
 
+static guint signals [LAST_SIGNAL] = { 0 };
+
+
 static void gdk_device_dispose      (GObject      *object);
 static void gdk_device_set_property (GObject      *object,
                                      guint         prop_id,
@@ -92,10 +104,10 @@ gdk_device_class_init (GdkDeviceClass *klass)
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_DISPLAY,
-                                  g_param_spec_object ("display",
+                                   PROP_DISPLAY,
+                                   g_param_spec_object ("display",
                                                         P_("Device Display"),
-                                                        P_("Display to which the device belongs to"),
+                                                        P_("Display which the device belongs to"),
                                                         GDK_TYPE_DISPLAY,
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                                                         G_PARAM_STATIC_STRINGS));
@@ -107,10 +119,10 @@ gdk_device_class_init (GdkDeviceClass *klass)
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_DEVICE_MANAGER,
-                                  g_param_spec_object ("device-manager",
+                                   PROP_DEVICE_MANAGER,
+                                   g_param_spec_object ("device-manager",
                                                         P_("Device manager"),
-                                                        P_("Device manager to which the device belongs to"),
+                                                        P_("Device manager which the device belongs to"),
                                                         GDK_TYPE_DEVICE_MANAGER,
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                                                         G_PARAM_STATIC_STRINGS));
@@ -122,8 +134,8 @@ gdk_device_class_init (GdkDeviceClass *klass)
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_NAME,
-                                  g_param_spec_string ("name",
+                                   PROP_NAME,
+                                   g_param_spec_string ("name",
                                                         P_("Device name"),
                                                         P_("Device name"),
                                                         NULL,
@@ -148,16 +160,16 @@ gdk_device_class_init (GdkDeviceClass *klass)
   /**
    * GdkDevice:associated-device:
    *
-   * Associated pointer or keyboard to this device, if any. Devices of type #GDK_DEVICE_TYPE_MASTER
+   * Associated pointer or keyboard with this device, if any. Devices of type #GDK_DEVICE_TYPE_MASTER
    * always come in keyboard/pointer pairs. Other device types will have a %NULL associated device.
    *
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_ASSOCIATED_DEVICE,
-                                  g_param_spec_object ("associated-device",
+                                   PROP_ASSOCIATED_DEVICE,
+                                   g_param_spec_object ("associated-device",
                                                         P_("Associated device"),
-                                                        P_("Associated pointer or keyboard to this device"),
+                                                        P_("Associated pointer or keyboard with this device"),
                                                         GDK_TYPE_DEVICE,
                                                         G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
   /**
@@ -168,8 +180,8 @@ gdk_device_class_init (GdkDeviceClass *klass)
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_INPUT_SOURCE,
-                                  g_param_spec_enum ("input-source",
+                                   PROP_INPUT_SOURCE,
+                                   g_param_spec_enum ("input-source",
                                                       P_("Input source"),
                                                       P_("Source type for the device"),
                                                       GDK_TYPE_INPUT_SOURCE,
@@ -185,7 +197,7 @@ gdk_device_class_init (GdkDeviceClass *klass)
    */
   g_object_class_install_property (object_class,
                                    PROP_INPUT_MODE,
-                                  g_param_spec_enum ("input-mode",
+                                   g_param_spec_enum ("input-mode",
                                                       P_("Input mode for the device"),
                                                       P_("Input mode for the device"),
                                                       GDK_TYPE_INPUT_MODE,
@@ -200,9 +212,9 @@ gdk_device_class_init (GdkDeviceClass *klass)
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_HAS_CURSOR,
-                                  g_param_spec_boolean ("has-cursor",
-                                                         P_("Whether the device has cursor"),
+                                   PROP_HAS_CURSOR,
+                                   g_param_spec_boolean ("has-cursor",
+                                                         P_("Whether the device has cursor"),
                                                          P_("Whether there is a visible cursor following device motion"),
                                                          FALSE,
                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
@@ -215,57 +227,68 @@ gdk_device_class_init (GdkDeviceClass *klass)
    * Since: 3.0
    */
   g_object_class_install_property (object_class,
-                                  PROP_N_AXES,
-                                  g_param_spec_uint ("n-axes",
+                                   PROP_N_AXES,
+                                   g_param_spec_uint ("n-axes",
                                                       P_("Number of axes in the device"),
                                                       P_("Number of axes in the device"),
                                                       0, G_MAXUINT, 0,
                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
-  g_type_class_add_private (object_class, sizeof (GdkDevicePrivate));
+  /**
+   * GdkDevice::changed:
+   * @device: the #GdkDevice that changed.
+   *
+   * The ::changed signal is emitted either when the #GdkDevice
+   * has changed the number of either axes or keys. For example
+   * In X this will normally happen when the slave device routing
+   * events through the master device changes (for example, user
+   * switches from the USB mouse to a tablet), in that case the
+   * master device will change to reflect the new slave device
+   * axes and keys.
+   */
+  signals[CHANGED] =
+    g_signal_new (g_intern_static_string ("changed"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
 }
 
 static void
 gdk_device_init (GdkDevice *device)
 {
-  GdkDevicePrivate *priv;
-
-  device->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (device,
-                                                     GDK_TYPE_DEVICE,
-                                                     GdkDevicePrivate);
-
-  priv->axes = g_array_new (FALSE, TRUE, sizeof (GdkAxisInfo));
+  device->axes = g_array_new (FALSE, TRUE, sizeof (GdkAxisInfo));
 }
 
 static void
 gdk_device_dispose (GObject *object)
 {
-  GdkDevicePrivate *priv;
-  GdkDevice *device;
+  GdkDevice *device = GDK_DEVICE (object);
 
-  device = GDK_DEVICE (object);
-  priv = device->priv;
+  if (device->type == GDK_DEVICE_TYPE_SLAVE)
+    _gdk_device_remove_slave (device->associated, device);
 
-  if (priv->associated)
+  if (device->associated)
     {
-      _gdk_device_set_associated_device (priv->associated, NULL);
-      g_object_unref (priv->associated);
-      priv->associated = NULL;
+      if (device->type == GDK_DEVICE_TYPE_MASTER)
+        _gdk_device_set_associated_device (device->associated, NULL);
+
+      g_object_unref (device->associated);
+      device->associated = NULL;
     }
 
-  if (priv->axes)
+  if (device->axes)
     {
-      g_array_free (priv->axes, TRUE);
-      priv->axes = NULL;
+      g_array_free (device->axes, TRUE);
+      device->axes = NULL;
     }
 
   g_free (device->name);
   g_free (device->keys);
-  g_free (device->axes);
 
   device->name = NULL;
   device->keys = NULL;
-  device->axes = NULL;
 
   G_OBJECT_CLASS (gdk_device_parent_class)->dispose (object);
 }
@@ -277,15 +300,14 @@ gdk_device_set_property (GObject      *object,
                          GParamSpec   *pspec)
 {
   GdkDevice *device = GDK_DEVICE (object);
-  GdkDevicePrivate *priv = device->priv;
 
   switch (prop_id)
     {
     case PROP_DISPLAY:
-      priv->display = g_value_get_object (value);
+      device->display = g_value_get_object (value);
       break;
     case PROP_DEVICE_MANAGER:
-      priv->device_manager = g_value_get_object (value);
+      device->manager = g_value_get_object (value);
       break;
     case PROP_NAME:
       if (device->name)
@@ -294,7 +316,7 @@ gdk_device_set_property (GObject      *object,
       device->name = g_value_dup_string (value);
       break;
     case PROP_TYPE:
-      priv->type = g_value_get_enum (value);
+      device->type = g_value_get_enum (value);
       break;
     case PROP_INPUT_SOURCE:
       device->source = g_value_get_enum (value);
@@ -318,25 +340,23 @@ gdk_device_get_property (GObject    *object,
                          GParamSpec *pspec)
 {
   GdkDevice *device = GDK_DEVICE (object);
-  GdkDevicePrivate *priv = device->priv;
 
   switch (prop_id)
     {
     case PROP_DISPLAY:
-      g_value_set_object (value, priv->display);
+      g_value_set_object (value, device->display);
       break;
     case PROP_DEVICE_MANAGER:
-      g_value_set_object (value, priv->device_manager);
+      g_value_set_object (value, device->manager);
       break;
     case PROP_ASSOCIATED_DEVICE:
-      g_value_set_object (value, priv->associated);
+      g_value_set_object (value, device->associated);
       break;
     case PROP_NAME:
-      g_value_set_string (value,
-                          device->name);
+      g_value_set_string (value, device->name);
       break;
     case PROP_TYPE:
-      g_value_set_enum (value, priv->type);
+      g_value_set_enum (value, device->type);
       break;
     case PROP_INPUT_SOURCE:
       g_value_set_enum (value, device->source);
@@ -345,11 +365,10 @@ gdk_device_get_property (GObject    *object,
       g_value_set_enum (value, device->mode);
       break;
     case PROP_HAS_CURSOR:
-      g_value_set_boolean (value,
-                           device->has_cursor);
+      g_value_set_boolean (value, device->has_cursor);
       break;
     case PROP_N_AXES:
-      g_value_set_uint (value, priv->axes->len);
+      g_value_set_uint (value, device->axes->len);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -358,14 +377,17 @@ gdk_device_get_property (GObject    *object,
 }
 
 /**
- * gdk_device_get_state:
+ * gdk_device_get_state: (skip)
  * @device: a #GdkDevice.
  * @window: a #GdkWindow.
  * @axes: an array of doubles to store the values of the axes of @device in,
  * or %NULL.
  * @mask: location to store the modifiers, or %NULL.
  *
- * Gets the current state of a device relative to @window.
+ * Gets the current state of a pointer device relative to @window. As a slave
+ * device coordinates are those of its master pointer, This
+ * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
  */
 void
 gdk_device_get_state (GdkDevice       *device,
@@ -374,22 +396,130 @@ gdk_device_get_state (GdkDevice       *device,
                       GdkModifierType *mask)
 {
   g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
   g_return_if_fail (GDK_IS_WINDOW (window));
+  g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
+                    gdk_display_device_is_grabbed (gdk_device_get_display (device), device));
 
   if (GDK_DEVICE_GET_CLASS (device)->get_state)
     GDK_DEVICE_GET_CLASS (device)->get_state (device, window, axes, mask);
 }
 
 /**
- * gdk_device_get_history:
+ * gdk_device_get_position:
+ * @device: pointer device to query status about.
+ * @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
+ *          the @device is on, or %NULL.
+ * @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
+ * @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
+ *
+ * Gets the current location of @device. As a slave device
+ * coordinates are those of its master pointer, This function
+ * may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
+ *
+ * Since: 3.0
+ **/
+void
+gdk_device_get_position (GdkDevice        *device,
+                         GdkScreen       **screen,
+                         gint             *x,
+                         gint             *y)
+{
+  GdkDisplay *display;
+  gint tmp_x, tmp_y;
+  GdkScreen *default_screen;
+  GdkWindow *root;
+
+  g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
+
+  display = gdk_device_get_display (device);
+
+  g_return_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
+                    gdk_display_device_is_grabbed (display, device));
+
+  default_screen = gdk_display_get_default_screen (display);
+
+  _gdk_device_query_state (device,
+                           gdk_screen_get_root_window (default_screen),
+                           &root, NULL,
+                           &tmp_x, &tmp_y,
+                           NULL, NULL, NULL);
+
+  if (screen)
+    *screen = gdk_window_get_screen (root);
+  if (x)
+    *x = tmp_x;
+  if (y)
+    *y = tmp_y;
+}
+
+/**
+ * gdk_device_get_window_at_position:
+ * @device: pointer #GdkDevice to query info to.
+ * @win_x: (out) (allow-none): return location for the X coordinate of the device location,
+ *         relative to the window origin, or %NULL.
+ * @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
+ *         relative to the window origin, or %NULL.
+ *
+ * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
+ * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
+ *
+ * As a slave device coordinates are those of its master pointer, This
+ * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
+ *
+ * Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
+ *
+ * Since: 3.0
+ **/
+GdkWindow *
+gdk_device_get_window_at_position (GdkDevice  *device,
+                                   gint       *win_x,
+                                   gint       *win_y)
+{
+  gint tmp_x, tmp_y;
+  GdkWindow *window;
+
+  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
+  g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_SLAVE ||
+                        gdk_display_device_is_grabbed (gdk_device_get_display (device), device), NULL);
+
+  window = _gdk_device_window_at_position (device, &tmp_x, &tmp_y, NULL, FALSE);
+
+  /* This might need corrections, as the native window returned
+     may contain client side children */
+  if (window)
+    {
+      double xx, yy;
+
+      window = _gdk_window_find_descendant_at (window,
+                                              tmp_x, tmp_y,
+                                              &xx, &yy);
+      tmp_x = floor (xx + 0.5);
+      tmp_y = floor (yy + 0.5);
+    }
+
+  if (win_x)
+    *win_x = tmp_x;
+  if (win_y)
+    *win_y = tmp_y;
+
+  return window;
+}
+
+/**
+ * gdk_device_get_history: (skip)
  * @device: a #GdkDevice
  * @window: the window with respect to which which the event coordinates will be reported
  * @start: starting timestamp for range of events to return
  * @stop: ending timestamp for the range of events to return
- * @events: (array length=n_events) (out) (transfer none): location to store a newly-allocated array of #GdkTimeCoord, or %NULL
+ * @events: (array length=n_events) (out) (transfer full): location to store a newly-allocated array of #GdkTimeCoord, or %NULL
  * @n_events: location to store the length of @events, or %NULL
  *
- * Obtains the motion history for a device; given a starting and
+ * Obtains the motion history for a pointer device; given a starting and
  * ending timestamp, return all events in the motion history for
  * the device in the given range of time. Some windowing systems
  * do not support motion history, in which case, %FALSE will
@@ -405,9 +535,10 @@ gdk_device_get_history (GdkDevice      *device,
                         guint32         start,
                         guint32         stop,
                         GdkTimeCoord ***events,
-                        guint          *n_events)
+                        gint           *n_events)
 {
   g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
   g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
 
   if (n_events)
@@ -429,20 +560,20 @@ gdk_device_get_history (GdkDevice      *device,
 
 GdkTimeCoord **
 _gdk_device_allocate_history (GdkDevice *device,
-                              guint      n_events)
+                              gint       n_events)
 {
   GdkTimeCoord **result = g_new (GdkTimeCoord *, n_events);
   gint i;
 
   for (i = 0; i < n_events; i++)
     result[i] = g_malloc (sizeof (GdkTimeCoord) -
-                         sizeof (double) * (GDK_MAX_TIMECOORD_AXES - device->num_axes));
+                          sizeof (double) * (GDK_MAX_TIMECOORD_AXES - device->axes->len));
   return result;
 }
 
 /**
- * gdk_device_free_history:
- * @events: (inout) (transfer none): an array of #GdkTimeCoord.
+ * gdk_device_free_history: (skip)
+ * @events: an array of #GdkTimeCoord.
  * @n_events: the length of the array.
  *
  * Frees an array of #GdkTimeCoord that was returned by gdk_device_get_history().
@@ -491,6 +622,7 @@ gboolean
 gdk_device_get_has_cursor (GdkDevice *device)
 {
   g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
 
   return device->has_cursor;
 }
@@ -513,22 +645,6 @@ gdk_device_get_source (GdkDevice *device)
   return device->source;
 }
 
-/**
- * gdk_device_set_source:
- * @device: a #GdkDevice.
- * @source: the source type.
- *
- * Sets the source type for an input device.
- **/
-void
-gdk_device_set_source (GdkDevice      *device,
-                      GdkInputSource  source)
-{
-  g_return_if_fail (GDK_IS_DEVICE (device));
-
-  device->source = source;
-}
-
 /**
  * gdk_device_get_mode:
  * @device: a #GdkDevice
@@ -571,23 +687,36 @@ gdk_device_set_mode (GdkDevice    *device,
       gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER)
     return FALSE;
 
-  /* FIXME: setting has_cursor when mode is window? */
-
   device->mode = mode;
   g_object_notify (G_OBJECT (device), "input-mode");
 
-  if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER)
-    _gdk_input_check_extension_events (device);
-
   return TRUE;
 }
 
+/**
+ * gdk_device_get_n_keys:
+ * @device: a #GdkDevice
+ *
+ * Returns the number of keys the device currently has.
+ *
+ * Returns: the number of keys.
+ *
+ * Since: 2.24
+ **/
+gint
+gdk_device_get_n_keys (GdkDevice *device)
+{
+  g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
+
+  return device->num_keys;
+}
+
 /**
  * gdk_device_get_key:
  * @device: a #GdkDevice.
  * @index_: the index of the macro button to get.
- * @keyval: return value for the keyval.
- * @modifiers: return value for modifiers.
+ * @keyval: (out): return value for the keyval.
+ * @modifiers: (out): return value for modifiers.
  *
  * If @index_ has a valid keyval, this function will return %TRUE
  * and fill in @keyval and @modifiers with the keyval settings.
@@ -630,9 +759,9 @@ gdk_device_get_key (GdkDevice       *device,
  **/
 void
 gdk_device_set_key (GdkDevice      *device,
-                   guint           index_,
-                   guint           keyval,
-                   GdkModifierType modifiers)
+                    guint           index_,
+                    guint           keyval,
+                    GdkModifierType modifiers)
 {
   g_return_if_fail (GDK_IS_DEVICE (device));
   g_return_if_fail (index_ < device->num_keys);
@@ -643,7 +772,7 @@ gdk_device_set_key (GdkDevice      *device,
 
 /**
  * gdk_device_get_axis_use:
- * @device: a #GdkDevice.
+ * @device: a pointer #GdkDevice.
  * @index_: the index of the axis.
  *
  * Returns the axis use for @index_.
@@ -656,15 +785,20 @@ GdkAxisUse
 gdk_device_get_axis_use (GdkDevice *device,
                          guint      index_)
 {
+  GdkAxisInfo *info;
+
   g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_AXIS_IGNORE);
-  g_return_val_if_fail (index_ < device->num_axes, GDK_AXIS_IGNORE);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, GDK_AXIS_IGNORE);
+  g_return_val_if_fail (index_ < device->axes->len, GDK_AXIS_IGNORE);
+
+  info = &g_array_index (device->axes, GdkAxisInfo, index_);
 
-  return device->axes[index_].use;
+  return info->use;
 }
 
 /**
  * gdk_device_set_axis_use:
- * @device: a #GdkDevice
+ * @device: a pointer #GdkDevice
  * @index_: the index of the axis
  * @use: specifies how the axis is used
  *
@@ -672,36 +806,33 @@ gdk_device_get_axis_use (GdkDevice *device,
  **/
 void
 gdk_device_set_axis_use (GdkDevice   *device,
-                        guint        index_,
-                        GdkAxisUse   use)
+                         guint        index_,
+                         GdkAxisUse   use)
 {
-  GdkDevicePrivate *priv;
   GdkAxisInfo *info;
 
   g_return_if_fail (GDK_IS_DEVICE (device));
-  g_return_if_fail (index_ < device->num_axes);
+  g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
+  g_return_if_fail (index_ < device->axes->len);
 
-  priv = device->priv;
-  info = &g_array_index (priv->axes, GdkAxisInfo, index_);
+  info = &g_array_index (device->axes, GdkAxisInfo, index_);
   info->use = use;
 
-  device->axes[index_].use = use;
-
   switch (use)
     {
     case GDK_AXIS_X:
     case GDK_AXIS_Y:
-      device->axes[index_].min = info->min_axis = 0;
-      device->axes[index_].max = info->max_axis = 0;
+      info->min_axis = 0;
+      info->max_axis = 0;
       break;
     case GDK_AXIS_XTILT:
     case GDK_AXIS_YTILT:
-      device->axes[index_].min = info->min_axis = -1;
-      device->axes[index_].max = info->max_axis = 1;
+      info->min_axis = -1;
+      info->max_axis = 1;
       break;
     default:
-      device->axes[index_].min = info->min_axis = 0;
-      device->axes[index_].max = info->max_axis = 1;
+      info->min_axis = 0;
+      info->max_axis = 1;
       break;
     }
 }
@@ -712,21 +843,17 @@ gdk_device_set_axis_use (GdkDevice   *device,
  *
  * Returns the #GdkDisplay to which @device pertains.
  *
- * Returns: a #GdkDisplay. This memory is owned by GTK+,
- *          and must not be freed or unreffed.
+ * Returns: (transfer none): a #GdkDisplay. This memory is owned
+ *          by GTK+, and must not be freed or unreffed.
  *
  * Since: 3.0
  **/
 GdkDisplay *
 gdk_device_get_display (GdkDevice *device)
 {
-  GdkDevicePrivate *priv;
-
   g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
 
-  priv = device->priv;
-
-  return priv->display;
+  return device->display;
 }
 
 /**
@@ -743,44 +870,106 @@ gdk_device_get_display (GdkDevice *device)
  * If @device is of type %GDK_DEVICE_TYPE_FLOATING, %NULL will be
  * returned, as there is no associated device.
  *
- * Returns: The associated device, or %NULL
+ * Returns: (transfer none): The associated device, or %NULL
  *
  * Since: 3.0
  **/
 GdkDevice *
 gdk_device_get_associated_device (GdkDevice *device)
 {
-  GdkDevicePrivate *priv;
-
   g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
 
-  priv = device->priv;
+  return device->associated;
+}
+
+static void
+_gdk_device_set_device_type (GdkDevice     *device,
+                             GdkDeviceType  type)
+{
+  if (device->type != type)
+    {
+      device->type = type;
 
-  return priv->associated;
+      g_object_notify (G_OBJECT (device), "type");
+    }
 }
 
 void
 _gdk_device_set_associated_device (GdkDevice *device,
                                    GdkDevice *associated)
 {
-  GdkDevicePrivate *priv;
-
   g_return_if_fail (GDK_IS_DEVICE (device));
-  g_return_if_fail (GDK_IS_DEVICE (associated));
+  g_return_if_fail (associated == NULL || GDK_IS_DEVICE (associated));
 
-  priv = device->priv;
-
-  if (priv->associated == associated)
+  if (device->associated == associated)
     return;
 
-  if (priv->associated)
+  if (device->associated)
     {
-      g_object_unref (priv->associated);
-      priv->associated = NULL;
+      g_object_unref (device->associated);
+      device->associated = NULL;
     }
 
   if (associated)
-    priv->associated = g_object_ref (associated);
+    device->associated = g_object_ref (associated);
+
+  if (device->type != GDK_DEVICE_TYPE_MASTER)
+    {
+      if (device->associated)
+        _gdk_device_set_device_type (device, GDK_DEVICE_TYPE_SLAVE);
+      else
+        _gdk_device_set_device_type (device, GDK_DEVICE_TYPE_FLOATING);
+    }
+}
+
+/**
+ * gdk_device_list_slave_devices:
+ * @device: a #GdkDevice
+ *
+ * If the device if of type %GDK_DEVICE_TYPE_MASTER, it will return
+ * the list of slave devices attached to it, otherwise it will return
+ * %NULL
+ *
+ * Returns: (transfer container) (element-type GdkDevice): the list of
+ *          slave devices, or %NULL. The list must be freed with
+ *          g_list_free(), the contents of the list are owned by GTK+
+ *          and should not be freed.
+ **/
+GList *
+gdk_device_list_slave_devices (GdkDevice *device)
+{
+  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+  g_return_val_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER, NULL);
+
+  return g_list_copy (device->slaves);
+}
+
+void
+_gdk_device_add_slave (GdkDevice *device,
+                       GdkDevice *slave)
+{
+  g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER);
+  g_return_if_fail (gdk_device_get_device_type (slave) != GDK_DEVICE_TYPE_MASTER);
+
+  if (!g_list_find (device->slaves, slave))
+    device->slaves = g_list_prepend (device->slaves, slave);
+}
+
+void
+_gdk_device_remove_slave (GdkDevice *device,
+                          GdkDevice *slave)
+{
+  GList *elem;
+
+  g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER);
+  g_return_if_fail (gdk_device_get_device_type (slave) != GDK_DEVICE_TYPE_MASTER);
+
+  elem = g_list_find (device->slaves, slave);
+
+  if (!elem)
+    return;
+
+  device->slaves = g_list_delete_link (device->slaves, elem);
 }
 
 /**
@@ -796,18 +985,14 @@ _gdk_device_set_associated_device (GdkDevice *device,
 GdkDeviceType
 gdk_device_get_device_type (GdkDevice *device)
 {
-  GdkDevicePrivate *priv;
-
   g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_DEVICE_TYPE_MASTER);
 
-  priv = device->priv;
-
-  return priv->type;
+  return device->type;
 }
 
 /**
  * gdk_device_get_n_axes:
- * @device: a #GdkDevice
+ * @device: a pointer #GdkDevice
  *
  * Returns the number of axes the device currently has.
  *
@@ -815,39 +1000,41 @@ gdk_device_get_device_type (GdkDevice *device)
  *
  * Since: 3.0
  **/
-guint
+gint
 gdk_device_get_n_axes (GdkDevice *device)
 {
   g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, 0);
 
-  return device->num_axes;
+  return device->axes->len;
 }
 
 /**
  * gdk_device_list_axes:
- * @device: a #GdkDevice
+ * @device: a pointer #GdkDevice
  *
  * Returns a #GList of #GdkAtom<!-- -->s, containing the labels for
  * the axes that @device currently has.
  *
- * Returns: A #GList of #GdkAtom<!-- -->s, free with g_list_free().
+ * Returns: (transfer container) (element-type GdkAtom):
+ *     A #GList of #GdkAtom<!-- -->s, free with g_list_free().
  *
  * Since: 3.0
  **/
 GList *
 gdk_device_list_axes (GdkDevice *device)
 {
-  GdkDevicePrivate *priv;
   GList *axes = NULL;
   gint i;
 
-  priv = device->priv;
+  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
 
-  for (i = 0; i < priv->axes->len; i++)
+  for (i = 0; i < device->axes->len; i++)
     {
       GdkAxisInfo axis_info;
 
-      axis_info = g_array_index (priv->axes, GdkAxisInfo, i);
+      axis_info = g_array_index (device->axes, GdkAxisInfo, i);
       axes = g_list_prepend (axes, GDK_ATOM_TO_POINTER (axis_info.label));
     }
 
@@ -855,9 +1042,9 @@ gdk_device_list_axes (GdkDevice *device)
 }
 
 /**
- * gdk_device_get_axis_value:
- * @device: a #GdkDevice.
- * @axes: pointer to an array of axes
+ * gdk_device_get_axis_value: (skip)
+ * @device: a pointer #GdkDevice.
+ * @axes: (array): pointer to an array of axes
  * @axis_label: #GdkAtom with the axis label.
  * @value: location to store the found value.
  *
@@ -875,21 +1062,19 @@ gdk_device_get_axis_value (GdkDevice *device,
                            GdkAtom    axis_label,
                            gdouble   *value)
 {
-  GdkDevicePrivate *priv;
   gint i;
 
   g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
 
   if (axes == NULL)
     return FALSE;
 
-  priv = device->priv;
-
-  for (i = 0; i < priv->axes->len; i++)
+  for (i = 0; i < device->axes->len; i++)
     {
       GdkAxisInfo axis_info;
 
-      axis_info = g_array_index (priv->axes, GdkAxisInfo, i);
+      axis_info = g_array_index (device->axes, GdkAxisInfo, i);
 
       if (axis_info.label != axis_label)
         continue;
@@ -904,11 +1089,11 @@ gdk_device_get_axis_value (GdkDevice *device,
 }
 
 /**
- * gdk_device_get_axis:
+ * gdk_device_get_axis: (skip)
  * @device: a #GdkDevice
- * @axes: pointer to an array of axes
+ * @axes: (array): pointer to an array of axes
  * @use: the use to look for
- * @value: location to store the found value.
+ * @value: (out): location to store the found value.
  *
  * Interprets an array of double as axis values for a given device,
  * and locates the value in the array for a given axis use.
@@ -921,23 +1106,21 @@ gdk_device_get_axis (GdkDevice  *device,
                      GdkAxisUse  use,
                      gdouble    *value)
 {
-  GdkDevicePrivate *priv;
   gint i;
 
   g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
 
   if (axes == NULL)
     return FALSE;
 
-  priv = device->priv;
-
-  g_return_val_if_fail (priv->axes != NULL, FALSE);
+  g_return_val_if_fail (device->axes != NULL, FALSE);
 
-  for (i = 0; i < priv->axes->len; i++)
+  for (i = 0; i < device->axes->len; i++)
     {
       GdkAxisInfo axis_info;
 
-      axis_info = g_array_index (priv->axes, GdkAxisInfo, i);
+      axis_info = g_array_index (device->axes, GdkAxisInfo, i);
 
       if (axis_info.use != use)
         continue;
@@ -970,7 +1153,10 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
 
 /**
  * gdk_device_grab:
- * @device: a #GdkDevice
+ * @device: a #GdkDevice. To get the device you can use gtk_get_current_event_device()
+ *   or gdk_event_get_device() if the grab is in reaction to an event. Also, you can use
+ *   gdk_device_manager_get_client_pointer() but only in code that isn't triggered by a
+ *   #GdkEvent and there aren't other means to get a meaningful #GdkDevice to operate on.
  * @window: the #GdkWindow which will own the grab (the grab window)
  * @grab_ownership: specifies the grab ownership.
  * @owner_events: if %FALSE then all device events are reported with respect to
@@ -981,7 +1167,7 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
  *                @event_mask. In either mode, unreported events are discarded.
  * @event_mask: specifies the event mask, which is used in accordance with
  *              @owner_events.
- * @cursor: the cursor to display while the grab is active if the device is
+ * @cursor: (allow-none): the cursor to display while the grab is active if the device is
  *          a pointer. If this is %NULL then the normal cursors are used for
  *          @window and its descendants, and the cursor for @window is used
  *          elsewhere.
@@ -1025,42 +1211,41 @@ gdk_device_grab (GdkDevice        *device,
   GdkGrabStatus res;
   GdkWindow *native;
 
-  g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
-  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_GRAB_SUCCESS);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_SUCCESS);
 
-  if (_gdk_native_windows)
-    native = window;
-  else
-    native = gdk_window_get_toplevel (window);
+  native = gdk_window_get_toplevel (window);
 
-  while (((GdkWindowObject *) native)->window_type == GDK_WINDOW_OFFSCREEN)
+  while (native->window_type == GDK_WINDOW_OFFSCREEN)
     {
       native = gdk_offscreen_window_get_embedder (native);
 
       if (native == NULL ||
-         (!_gdk_window_has_impl (native) &&
-          !gdk_window_is_viewable (native)))
-       return GDK_GRAB_NOT_VIEWABLE;
+          (!_gdk_window_has_impl (native) &&
+           !gdk_window_is_viewable (native)))
+        return GDK_GRAB_NOT_VIEWABLE;
 
       native = gdk_window_get_toplevel (native);
     }
 
-  res = _gdk_windowing_device_grab (device,
-                                    window,
-                                    native,
-                                    owner_events,
-                                    get_native_grab_event_mask (event_mask),
-                                    NULL,
-                                    cursor,
-                                    time_);
+  if (native == NULL || GDK_WINDOW_DESTROYED (native))
+    return GDK_GRAB_NOT_VIEWABLE;
+
+  res = GDK_DEVICE_GET_CLASS (device)->grab (device,
+                                             native,
+                                             owner_events,
+                                             get_native_grab_event_mask (event_mask),
+                                             NULL,
+                                             cursor,
+                                             time_);
 
   if (res == GDK_GRAB_SUCCESS)
     {
       GdkDisplay *display;
       gulong serial;
 
-      display = gdk_drawable_get_display (window);
-      serial = _gdk_windowing_window_get_next_serial (display);
+      display = gdk_window_get_display (window);
+      serial = _gdk_display_get_next_serial (display);
 
       _gdk_display_add_device_grab (display,
                                     device,
@@ -1077,23 +1262,68 @@ gdk_device_grab (GdkDevice        *device,
   return res;
 }
 
+/**
+ * gdk_device_ungrab:
+ * @device: a #GdkDevice
+ * @time_: a timestap (e.g. %GDK_CURRENT_TIME).
+ *
+ * Release any grab on @device.
+ *
+ * Since: 3.0
+ */
+void
+gdk_device_ungrab (GdkDevice  *device,
+                   guint32     time_)
+{
+  g_return_if_fail (GDK_IS_DEVICE (device));
+
+  GDK_DEVICE_GET_CLASS (device)->ungrab (device, time_);
+}
+
+/**
+ * gdk_device_warp:
+ * @device: the device to warp.
+ * @screen: the screen to warp @device to.
+ * @x: the X coordinate of the destination.
+ * @y: the Y coordinate of the destination.
+ *
+ * Warps @device in @display to the point @x,@y on
+ * the screen @screen, unless the device is confined
+ * to a window by a grab, in which case it will be moved
+ * as far as allowed by the grab. Warping the pointer
+ * creates events as if the user had moved the mouse
+ * instantaneously to the destination.
+ *
+ * Note that the pointer should normally be under the
+ * control of the user. This function was added to cover
+ * some rare use cases like keyboard navigation support
+ * for the color picker in the #GtkColorSelectionDialog.
+ *
+ * Since: 3.0
+ **/
+void
+gdk_device_warp (GdkDevice  *device,
+                 GdkScreen  *screen,
+                 gint        x,
+                 gint        y)
+{
+  g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (GDK_IS_SCREEN (screen));
+  g_return_if_fail (gdk_device_get_display (device) == gdk_screen_get_display (screen));
+
+  GDK_DEVICE_GET_CLASS (device)->warp (device, screen, x, y);
+}
+
 /* Private API */
 void
 _gdk_device_reset_axes (GdkDevice *device)
 {
-  GdkDevicePrivate *priv;
   gint i;
 
-  priv = device->priv;
-
-  for (i = priv->axes->len - 1; i >= 0; i--)
-    g_array_remove_index (priv->axes, i);
+  for (i = device->axes->len - 1; i >= 0; i--)
+    g_array_remove_index (device->axes, i);
 
   g_object_notify (G_OBJECT (device), "n-axes");
-
-  /* This is done for backwards compatibility */
-  g_free (device->axes);
-  device->axes = NULL;
 }
 
 guint
@@ -1104,12 +1334,9 @@ _gdk_device_add_axis (GdkDevice   *device,
                       gdouble      max_value,
                       gdouble      resolution)
 {
-  GdkDevicePrivate *priv;
   GdkAxisInfo axis_info;
   guint pos;
 
-  priv = device->priv;
-
   axis_info.use = use;
   axis_info.label = label_atom;
   axis_info.min_value = min_value;
@@ -1134,23 +1361,37 @@ _gdk_device_add_axis (GdkDevice   *device,
       break;
     }
 
-  priv->axes = g_array_append_val (priv->axes, axis_info);
-  device->num_axes = priv->axes->len;
-  pos = device->num_axes - 1;
-
-  /* This is done for backwards compatibility, since the public
-   * struct doesn't actually store the device data.
-   */
-  device->axes = g_realloc (device->axes, sizeof (GdkDeviceAxis) * priv->axes->len);
-  device->axes[pos].use = axis_info.use;
-  device->axes[pos].min = axis_info.min_axis;
-  device->axes[pos].max = axis_info.max_axis;
+  device->axes = g_array_append_val (device->axes, axis_info);
+  pos = device->axes->len - 1;
 
   g_object_notify (G_OBJECT (device), "n-axes");
 
   return pos;
 }
 
+void
+_gdk_device_get_axis_info (GdkDevice   *device,
+                          guint        index_,
+                          GdkAtom      *label_atom,
+                          GdkAxisUse   *use,
+                          gdouble      *min_value,
+                          gdouble      *max_value,
+                          gdouble      *resolution)
+{
+  GdkAxisInfo *info;
+
+  g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (index_ < device->axes->len);
+
+  info = &g_array_index (device->axes, GdkAxisInfo, index_);
+
+  *label_atom = info->label;
+  *use = info->use;
+  *min_value = info->min_value;
+  *max_value = info->max_value;
+  *resolution = info->resolution;
+}
+
 void
 _gdk_device_set_keys (GdkDevice *device,
                       guint      num_keys)
@@ -1180,19 +1421,6 @@ find_axis_info (GArray     *array,
   return NULL;
 }
 
-GdkAxisUse
-_gdk_device_get_axis_use (GdkDevice *device,
-                          guint      index_)
-{
-  GdkDevicePrivate *priv;
-  GdkAxisInfo info;
-
-  priv = device->priv;
-
-  info = g_array_index (priv->axes, GdkAxisInfo, index_);
-  return info.use;
-}
-
 gboolean
 _gdk_device_translate_window_coord (GdkDevice *device,
                                     GdkWindow *window,
@@ -1200,7 +1428,6 @@ _gdk_device_translate_window_coord (GdkDevice *device,
                                     gdouble    value,
                                     gdouble   *axis_value)
 {
-  GdkDevicePrivate *priv;
   GdkAxisInfo axis_info;
   GdkAxisInfo *axis_info_x, *axis_info_y;
   gdouble device_width, device_height;
@@ -1210,14 +1437,11 @@ _gdk_device_translate_window_coord (GdkDevice *device,
   gdouble x_resolution, y_resolution;
   gdouble device_aspect;
   gint window_width, window_height;
-  GdkWindowObject *window_private;
-
-  priv = device->priv;
 
-  if (index_ >= priv->axes->len)
+  if (index_ >= device->axes->len)
     return FALSE;
 
-  axis_info = g_array_index (priv->axes, GdkAxisInfo, index_);
+  axis_info = g_array_index (device->axes, GdkAxisInfo, index_);
 
   if (axis_info.use != GDK_AXIS_X &&
       axis_info.use != GDK_AXIS_Y)
@@ -1226,11 +1450,11 @@ _gdk_device_translate_window_coord (GdkDevice *device,
   if (axis_info.use == GDK_AXIS_X)
     {
       axis_info_x = &axis_info;
-      axis_info_y = find_axis_info (priv->axes, GDK_AXIS_Y);
+      axis_info_y = find_axis_info (device->axes, GDK_AXIS_Y);
     }
   else
     {
-      axis_info_x = find_axis_info (priv->axes, GDK_AXIS_X);
+      axis_info_x = find_axis_info (device->axes, GDK_AXIS_X);
       axis_info_y = &axis_info;
     }
 
@@ -1241,7 +1465,7 @@ _gdk_device_translate_window_coord (GdkDevice *device,
     x_min = axis_info_x->min_value;
   else
     {
-      device_width = gdk_screen_get_width (gdk_drawable_get_screen (window));
+      device_width = gdk_screen_get_width (gdk_window_get_screen (window));
       x_min = 0;
     }
 
@@ -1249,12 +1473,12 @@ _gdk_device_translate_window_coord (GdkDevice *device,
     y_min = axis_info_y->min_value;
   else
     {
-      device_height = gdk_screen_get_height (gdk_drawable_get_screen (window));
+      device_height = gdk_screen_get_height (gdk_window_get_screen (window));
       y_min = 0;
     }
 
-  window_private = (GdkWindowObject *) window;
-  gdk_drawable_get_size (window, &window_width, &window_height);
+  window_width = gdk_window_get_width (window);
+  window_height = gdk_window_get_height (window);
 
   x_resolution = axis_info_x->resolution;
   y_resolution = axis_info_y->resolution;
@@ -1317,45 +1541,40 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
                                     gdouble    value,
                                     gdouble   *axis_value)
 {
-  GdkDevicePrivate *priv;
   GdkAxisInfo axis_info;
   gdouble axis_width, scale, offset;
-  GdkWindowObject *window_private;
 
   if (device->mode != GDK_MODE_SCREEN)
     return FALSE;
 
-  priv = device->priv;
-
-  if (index_ >= priv->axes->len)
+  if (index_ >= device->axes->len)
     return FALSE;
 
-  axis_info = g_array_index (priv->axes, GdkAxisInfo, index_);
+  axis_info = g_array_index (device->axes, GdkAxisInfo, index_);
 
   if (axis_info.use != GDK_AXIS_X &&
       axis_info.use != GDK_AXIS_Y)
     return FALSE;
 
   axis_width = axis_info.max_value - axis_info.min_value;
-  window_private = (GdkWindowObject *) window;
 
   if (axis_info.use == GDK_AXIS_X)
     {
       if (axis_width > 0)
-        scale = gdk_screen_get_width (gdk_drawable_get_screen (window)) / axis_width;
+        scale = gdk_screen_get_width (gdk_window_get_screen (window)) / axis_width;
       else
         scale = 1;
 
-      offset = - window_root_x - window_private->abs_x;
+      offset = - window_root_x - window->abs_x;
     }
   else
     {
       if (axis_width > 0)
-        scale = gdk_screen_get_height (gdk_drawable_get_screen (window)) / axis_width;
+        scale = gdk_screen_get_height (gdk_window_get_screen (window)) / axis_width;
       else
         scale = 1;
 
-      offset = - window_root_y - window_private->abs_y;
+      offset = - window_root_y - window->abs_y;
     }
 
   if (axis_value)
@@ -1370,16 +1589,13 @@ _gdk_device_translate_axis (GdkDevice *device,
                             gdouble    value,
                             gdouble   *axis_value)
 {
-  GdkDevicePrivate *priv;
   GdkAxisInfo axis_info;
   gdouble axis_width, out;
 
-  priv = device->priv;
-
-  if (index_ >= priv->axes->len)
+  if (index_ >= device->axes->len)
     return FALSE;
 
-  axis_info = g_array_index (priv->axes, GdkAxisInfo, index_);
+  axis_info = g_array_index (device->axes, GdkAxisInfo, index_);
 
   if (axis_info.use == GDK_AXIS_X ||
       axis_info.use == GDK_AXIS_Y)
@@ -1394,3 +1610,39 @@ _gdk_device_translate_axis (GdkDevice *device,
 
   return TRUE;
 }
+
+void
+_gdk_device_query_state (GdkDevice        *device,
+                         GdkWindow        *window,
+                         GdkWindow       **root_window,
+                         GdkWindow       **child_window,
+                         gint             *root_x,
+                         gint             *root_y,
+                         gint             *win_x,
+                         gint             *win_y,
+                         GdkModifierType  *mask)
+{
+  GDK_DEVICE_GET_CLASS (device)->query_state (device,
+                                              window,
+                                              root_window,
+                                              child_window,
+                                              root_x,
+                                              root_y,
+                                              win_x,
+                                              win_y,
+                                              mask);
+}
+
+GdkWindow *
+_gdk_device_window_at_position (GdkDevice        *device,
+                                gint             *win_x,
+                                gint             *win_y,
+                                GdkModifierType  *mask,
+                                gboolean          get_toplevel)
+{
+  return GDK_DEVICE_GET_CLASS (device)->window_at_position (device,
+                                                            win_x,
+                                                            win_y,
+                                                            mask,
+                                                            get_toplevel);
+}