[gtk+/events-refactor: 431/1085] Replace GdkInput with GdkDevice.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/events-refactor: 431/1085] Replace GdkInput with GdkDevice.
- Date: Tue, 29 Sep 2009 10:46:15 +0000 (UTC)
commit 456d028b4f6ca2e0b33ad54b1d197fcb59606ad2
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jul 2 22:46:24 2009 +0200
Replace GdkInput with GdkDevice.
* This "new" object now lives in its own files, allowing different
implementations.
* There's also a GdkDeviceCore implementation, representing the core pointer.
* All of gdk/x11/gdkinput* is now removed from autofoo, will be completely
removed in a close future.
* There are some features left to implement, mostly related to GdkInputWindow
and extended devices grabs.
* gdk_input_set_extension_events() is now an empty stub, will be reimplemented
on top of the newer API, when it's done.
* gdk/gdkinput.c was added to contain the to-be-deprecated functions.
* GdkDeviceManagerCore now creates a GdkDeviceCore
gdk/Makefile.am | 3 +
gdk/gdk.h | 1 +
gdk/gdk.symbols | 51 +++-----
gdk/gdkdevice.c | 284 +++++++++++++++++++++++++++++++++++++++
gdk/gdkdevice.h | 181 +++++++++++++++++++++++++
gdk/gdkdevicemanager.c | 4 +
gdk/gdkdevicemanager.h | 2 +-
gdk/gdkevents.h | 2 +-
gdk/gdkinput.c | 40 ++++++
gdk/gdkinput.h | 131 +-----------------
gdk/x11/Makefile.am | 4 +-
gdk/x11/gdkdevice-core.c | 68 +++++++++
gdk/x11/gdkdevice-core.h | 51 +++++++
gdk/x11/gdkdevicemanager-core.c | 34 ++----
gdk/x11/gdkdisplay-x11.c | 46 ++++++-
gdk/x11/gdkevents-x11.c | 8 +-
gdk/x11/gdkmain-x11.c | 5 +-
gdk/x11/gdkprivate-x11.h | 1 -
gdk/x11/gdkwindow-x11.c | 4 +-
19 files changed, 728 insertions(+), 192 deletions(-)
---
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 5a7ed7d..358422d 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -67,6 +67,7 @@ gdk_public_h_sources = \
gdkcairo.h \
gdkcolor.h \
gdkcursor.h \
+ gdkdevice.h \
gdkdevicemanager.h \
gdkdisplay.h \
gdkdisplaymanager.h \
@@ -108,6 +109,7 @@ gdk_c_sources = \
gdkcairo.c \
gdkcolor.c \
gdkcursor.c \
+ gdkdevice.c \
gdkdevicemanager.c \
gdkdisplay.c \
gdkdisplaymanager.c \
@@ -118,6 +120,7 @@ gdk_c_sources = \
gdkgc.c \
gdkglobals.c \
gdkimage.c \
+ gdkinput.c \
gdkinternals.h \
gdkintl.h \
gdkkeys.c \
diff --git a/gdk/gdk.h b/gdk/gdk.h
index c47a82d..31a0ea5 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -33,6 +33,7 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcolor.h>
#include <gdk/gdkcursor.h>
+#include <gdk/gdkdevice.h>
#include <gdk/gdkdevicemanager.h>
#include <gdk/gdkdisplay.h>
#include <gdk/gdkdisplaymanager.h>
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index cfb54c2..5b49829 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -79,6 +79,8 @@ gdk_pointer_grab_info_libgtk_only
#if IN_HEADER(__GDK_H__)
#if IN_FILE(__GDK_DISPLAY_C__)
gdk_beep
+gdk_device_get_core_pointer
+gdk_display_get_core_pointer
gdk_set_pointer_hooks
gdk_keyboard_ungrab
gdk_pointer_is_grabbed
@@ -107,6 +109,7 @@ gdk_flush
#if IN_HEADER(__GDK_H__)
#if IN_FILE(__GDK_DISPLAY_X11_C__)
+gdk_display_list_devices
gdk_notify_startup_complete
gdk_notify_startup_complete_with_id
#endif
@@ -376,42 +379,33 @@ gdk_cursor_get_image
#endif
#endif
-#if IN_HEADER(__GDK_INPUT_H__)
-#if IN_FILE(__GDK_INPUT_C__)
+#if IN_HEADER(__GDK_DEVICE_MANAGER_H__)
+#if IN_FILE(__GDK_DEVICE_MANAGER_C__)
+gdk_device_manager_get_display
+gdk_device_manager_get_for_display
+gdk_device_manager_get_type G_GNUC_CONST
+gdk_device_manager_set_window_events
+#endif
+#endif
+
+#if IN_HEADER(__GDK_DEVICE_H__)
+#if IN_FILE(__GDK_DEVICE_C__)
gdk_device_free_history
gdk_device_get_axis
gdk_device_get_history
+gdk_device_get_state
gdk_device_get_type G_GNUC_CONST
gdk_device_set_axis_use
gdk_device_set_key
-gdk_device_set_source
-gdk_devices_list
-gdk_input_set_extension_events
-#endif
-#endif
-
-#if IN_HEADER(__GDK_INPUT_H__)
-#if IN_FILE(__GDK_DISPLAY_C__)
-gdk_device_get_core_pointer
-#endif
-#endif
-
-#if IN_HEADER(__GDK_INPUT_H__)
-#if IN_FILE(__GDK_INPUT_X11_C__)
-gdk_device_get_state
-#endif
-#endif
-
-#if IN_HEADER(__GDK_INPUT_H__)
-#if IN_FILE(__GDK_INPUT_XFREE_C__)
gdk_device_set_mode
+gdk_device_set_source
#endif
#endif
#if IN_HEADER(__GDK_INPUT_H__)
-#if IN_FILE(__GDK_INPUT_NONE_C__)
-gdk_device_get_state
-gdk_device_set_mode
+#if IN_FILE(__GDK_INPUT_C__)
+gdk_devices_list
+gdk_input_set_extension_events
#endif
#endif
@@ -424,7 +418,6 @@ gdk_display_add_client_message_filter
#if IN_HEADER(__GDK_DISPLAY_H__)
#if IN_FILE(__GDK_DISPLAY_C__)
gdk_display_close
-gdk_display_get_core_pointer
gdk_display_get_event
gdk_display_get_pointer
gdk_display_get_type G_GNUC_CONST
@@ -481,12 +474,6 @@ gdk_display_supports_composite
#endif
#if IN_HEADER(__GDK_DISPLAY_H__)
-#if IN_FILE(__GDK_INPUT_C__)
-gdk_display_list_devices
-#endif
-#endif
-
-#if IN_HEADER(__GDK_DISPLAY_H__)
#if IN_FILE(__GDK_C__)
gdk_display_open_default_libgtk_only
#endif
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
new file mode 100644
index 0000000..54debf9
--- /dev/null
+++ b/gdk/gdkdevice.c
@@ -0,0 +1,284 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * 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.
+ */
+
+#include "gdkdevice.h"
+#include "gdkintl.h"
+#include "gdkinternals.h"
+#include "gdkalias.h"
+
+#define GDK_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDK_TYPE_DEVICE, GdkDevicePrivate))
+
+typedef struct _GdkDevicePrivate GdkDevicePrivate;
+
+struct _GdkDevicePrivate
+{
+ GdkDisplay *display;
+};
+
+static void gdk_device_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gdk_device_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+
+G_DEFINE_ABSTRACT_TYPE (GdkDevice, gdk_device, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ PROP_DISPLAY,
+ PROP_NAME,
+ PROP_INPUT_SOURCE,
+ PROP_HAS_CURSOR,
+};
+
+
+static void
+gdk_device_class_init (GdkDeviceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = gdk_device_set_property;
+ object_class->get_property = gdk_device_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY,
+ g_param_spec_object ("display",
+ P_("Device Display"),
+ P_("Display to which the device belongs to"),
+ GDK_TYPE_DISPLAY,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ P_("Device name"),
+ P_("Device name"),
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_INPUT_SOURCE,
+ g_param_spec_enum ("input-source",
+ P_("Input source"),
+ P_("Source type for the device"),
+ GDK_TYPE_INPUT_SOURCE,
+ GDK_SOURCE_MOUSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ 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));
+
+ g_type_class_add_private (object_class, sizeof (GdkDevicePrivate));
+}
+
+static void
+gdk_device_init (GdkDevice *device)
+{
+}
+
+static void
+gdk_device_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdkDevice *device = GDK_DEVICE (object);
+ GdkDevicePrivate *priv = GDK_DEVICE_GET_PRIVATE (object);
+
+ switch (prop_id)
+ {
+ case PROP_DISPLAY:
+ priv->display = g_value_get_object (value);
+ break;
+ case PROP_NAME:
+ if (device->name)
+ g_free (device->name);
+
+ device->name = g_value_dup_string (value);
+ break;
+ case PROP_INPUT_SOURCE:
+ device->source = g_value_get_enum (value);
+ break;
+ case PROP_HAS_CURSOR:
+ device->has_cursor = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdk_device_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdkDevice *device = GDK_DEVICE (object);
+ GdkDevicePrivate *priv = GDK_DEVICE_GET_PRIVATE (object);
+
+ switch (prop_id)
+ {
+ case PROP_DISPLAY:
+ g_value_set_object (value, priv->display);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value,
+ device->name);
+ break;
+ case PROP_INPUT_SOURCE:
+ g_value_set_enum (value,
+ device->source);
+ break;
+ case PROP_HAS_CURSOR:
+ g_value_set_boolean (value,
+ device->has_cursor);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+void
+gdk_device_get_state (GdkDevice *device,
+ GdkWindow *window,
+ gdouble *axes,
+ GdkModifierType *mask)
+{
+ g_return_if_fail (GDK_IS_DEVICE (device));
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_DEVICE_GET_CLASS (device)->get_state)
+ GDK_DEVICE_GET_CLASS (device)->get_state (device, window, axes, mask);
+}
+
+gboolean
+gdk_device_get_history (GdkDevice *device,
+ GdkWindow *window,
+ guint32 start,
+ guint32 stop,
+ GdkTimeCoord ***events,
+ guint *n_events)
+{
+ g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+
+ if (!GDK_DEVICE_GET_CLASS (device)->get_history)
+ return FALSE;
+
+ return GDK_DEVICE_GET_CLASS (device)->get_history (device, window,
+ start, stop,
+ events, n_events);
+}
+
+void
+gdk_device_free_history (GdkTimeCoord **events,
+ gint n_events)
+{
+ gint i;
+
+ for (i = 0; i < n_events; i++)
+ g_free (events[i]);
+
+ g_free (events);
+}
+
+gboolean
+gdk_device_get_axis (GdkDevice *device,
+ gdouble *axes,
+ GdkAxisUse use,
+ gdouble *value)
+{
+ g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (axes != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ if (!GDK_DEVICE_GET_CLASS (device)->get_axis)
+ return FALSE;
+
+ return GDK_DEVICE_GET_CLASS (device)->get_axis (device, axes, use, value);
+}
+
+void
+gdk_device_set_source (GdkDevice *device,
+ GdkInputSource source)
+{
+ g_return_if_fail (GDK_IS_DEVICE (device));
+
+ device->source = source;
+}
+
+gboolean
+gdk_device_set_mode (GdkDevice *device,
+ GdkInputMode mode)
+{
+ return FALSE;
+}
+
+void
+gdk_device_set_key (GdkDevice *device,
+ guint index,
+ guint keyval,
+ GdkModifierType modifiers)
+{
+ g_return_if_fail (GDK_IS_DEVICE (device));
+ g_return_if_fail (index < device->num_keys);
+
+ device->keys[index].keyval = keyval;
+ device->keys[index].modifiers = modifiers;
+}
+
+void
+gdk_device_set_axis_use (GdkDevice *device,
+ guint index,
+ GdkAxisUse use)
+{
+ g_return_if_fail (GDK_IS_DEVICE (device));
+ g_return_if_fail (index < device->num_axes);
+
+ device->axes[index].use = use;
+
+ switch (use)
+ {
+ case GDK_AXIS_X:
+ case GDK_AXIS_Y:
+ device->axes[index].min = 0.;
+ device->axes[index].max = 0.;
+ break;
+ case GDK_AXIS_XTILT:
+ case GDK_AXIS_YTILT:
+ device->axes[index].min = -1.;
+ device->axes[index].max = 1;
+ break;
+ default:
+ device->axes[index].min = 0.;
+ device->axes[index].max = 1;
+ break;
+ }
+}
+
+#define __GDK_DEVICE_C__
+#include "gdkaliasdef.c"
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
new file mode 100644
index 0000000..ba225d0
--- /dev/null
+++ b/gdk/gdkdevice.h
@@ -0,0 +1,181 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * 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.
+ */
+
+#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#ifndef __GDK_DEVICE_H__
+#define __GDK_DEVICE_H__
+
+#include <gdk/gdktypes.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_DEVICE (gdk_device_get_type ())
+#define GDK_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE, GdkDevice))
+#define GDK_DEVICE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE, GdkDeviceClass))
+#define GDK_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE))
+#define GDK_IS_DEVICE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE))
+#define GDK_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE, GdkDeviceClass))
+
+typedef struct _GdkDevice GdkDevice;
+typedef struct _GdkDeviceClass GdkDeviceClass;
+
+typedef struct _GdkDeviceKey GdkDeviceKey;
+typedef struct _GdkDeviceAxis GdkDeviceAxis;
+typedef struct _GdkTimeCoord GdkTimeCoord;
+
+typedef enum
+{
+ GDK_EXTENSION_EVENTS_NONE,
+ GDK_EXTENSION_EVENTS_ALL,
+ GDK_EXTENSION_EVENTS_CURSOR
+} GdkExtensionMode;
+
+typedef enum
+{
+ GDK_SOURCE_MOUSE,
+ GDK_SOURCE_PEN,
+ GDK_SOURCE_ERASER,
+ GDK_SOURCE_CURSOR,
+ GDK_SOURCE_KEYBOARD
+} GdkInputSource;
+
+typedef enum
+{
+ GDK_MODE_DISABLED,
+ GDK_MODE_SCREEN,
+ GDK_MODE_WINDOW
+} GdkInputMode;
+
+typedef enum
+{
+ GDK_AXIS_IGNORE,
+ GDK_AXIS_X,
+ GDK_AXIS_Y,
+ GDK_AXIS_PRESSURE,
+ GDK_AXIS_XTILT,
+ GDK_AXIS_YTILT,
+ GDK_AXIS_WHEEL,
+ GDK_AXIS_LAST
+} GdkAxisUse;
+
+struct _GdkDeviceKey
+{
+ guint keyval;
+ GdkModifierType modifiers;
+};
+
+struct _GdkDeviceAxis
+{
+ GdkAxisUse use;
+ gdouble min;
+ gdouble max;
+};
+
+/* We don't allocate each coordinate this big, but we use it to
+ * be ANSI compliant and avoid accessing past the defined limits.
+ */
+#define GDK_MAX_TIMECOORD_AXES 128
+
+struct _GdkTimeCoord
+{
+ guint32 time;
+ gdouble axes[GDK_MAX_TIMECOORD_AXES];
+};
+
+struct _GdkDevice
+{
+ GObject parent_instance;
+
+ /* All fields are read-only */
+ gchar *name;
+ GdkInputSource source;
+ GdkInputMode mode;
+ gboolean has_cursor; /* TRUE if the X pointer follows device motion */
+
+ gint num_axes;
+ GdkDeviceAxis *axes;
+
+ gint num_keys;
+ GdkDeviceKey *keys;
+};
+
+struct _GdkDeviceClass
+{
+ GObjectClass parent_class;
+
+ gboolean (* get_history) (GdkDevice *device,
+ GdkWindow *window,
+ guint32 start,
+ guint32 stop,
+ GdkTimeCoord ***events,
+ guint *n_events);
+
+ void (* get_state) (GdkDevice *device,
+ GdkWindow *window,
+ gdouble *axes,
+ GdkModifierType *mask);
+
+ gboolean (* get_axis) (GdkDevice *device,
+ gdouble *axes,
+ GdkAxisUse use,
+ gdouble *value);
+};
+
+GType gdk_device_get_type (void) G_GNUC_CONST;
+
+/* Functions to configure a device */
+void gdk_device_set_source (GdkDevice *device,
+ GdkInputSource source);
+
+gboolean gdk_device_set_mode (GdkDevice *device,
+ GdkInputMode mode);
+
+void gdk_device_set_key (GdkDevice *device,
+ guint index_,
+ guint keyval,
+ GdkModifierType modifiers);
+
+void gdk_device_set_axis_use (GdkDevice *device,
+ guint index_,
+ GdkAxisUse use);
+
+
+void gdk_device_get_state (GdkDevice *device,
+ GdkWindow *window,
+ gdouble *axes,
+ GdkModifierType *mask);
+gboolean gdk_device_get_history (GdkDevice *device,
+ GdkWindow *window,
+ guint32 start,
+ guint32 stop,
+ GdkTimeCoord ***events,
+ guint *n_events);
+void gdk_device_free_history (GdkTimeCoord **events,
+ gint n_events);
+gboolean gdk_device_get_axis (GdkDevice *device,
+ gdouble *axes,
+ GdkAxisUse use,
+ gdouble *value);
+
+G_END_DECLS
+
+#endif /* __GDK_DEVICE_H__ */
diff --git a/gdk/gdkdevicemanager.c b/gdk/gdkdevicemanager.c
index cda7f3a..2b3b54d 100644
--- a/gdk/gdkdevicemanager.c
+++ b/gdk/gdkdevicemanager.c
@@ -20,6 +20,7 @@
#include "gdkdevicemanager.h"
#include "gdkintl.h"
#include "gdkinternals.h"
+#include "gdkalias.h"
static void gdk_device_manager_set_property (GObject *object,
@@ -236,3 +237,6 @@ gdk_device_manager_set_window_events (GdkDeviceManager *device_manager,
if (GDK_DEVICE_MANAGER_GET_CLASS (device_manager)->set_window_events)
GDK_DEVICE_MANAGER_GET_CLASS (device_manager)->set_window_events (device_manager, window, event_mask);
}
+
+#define __GDK_DEVICE_MANAGER_C__
+#include "gdkaliasdef.c"
diff --git a/gdk/gdkdevicemanager.h b/gdk/gdkdevicemanager.h
index 3ff0677..204245c 100644
--- a/gdk/gdkdevicemanager.h
+++ b/gdk/gdkdevicemanager.h
@@ -25,7 +25,7 @@
#define __GDK_DEVICE_MANAGER_H__
#include <gdk/gdktypes.h>
-#include <gdk/gdkinput.h>
+#include <gdk/gdkdevice.h>
#include <gdk/gdkdisplay.h>
G_BEGIN_DECLS
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index e64acb7..4f415f6 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -34,7 +34,7 @@
#include <gdk/gdkcolor.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkdnd.h>
-#include <gdk/gdkinput.h>
+#include <gdk/gdkdevice.h>
G_BEGIN_DECLS
diff --git a/gdk/gdkinput.c b/gdk/gdkinput.c
new file mode 100644
index 0000000..6383eee
--- /dev/null
+++ b/gdk/gdkinput.c
@@ -0,0 +1,40 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * 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.
+ */
+
+#include "gdkinput.h"
+#include "gdkdevicemanager.h"
+#include "gdkdisplay.h"
+#include "gdkalias.h"
+
+GList *
+gdk_devices_list (void)
+{
+ return gdk_display_list_devices (gdk_display_get_default ());
+}
+
+void
+gdk_input_set_extension_events (GdkWindow *window,
+ gint mask,
+ GdkExtensionMode mode)
+{
+ /* FIXME: Not implemented */
+}
+
+#define __GDK_INPUT_C__
+#include "gdkaliasdef.c"
diff --git a/gdk/gdkinput.h b/gdk/gdkinput.h
index 454def8..2d3f949 100644
--- a/gdk/gdkinput.h
+++ b/gdk/gdkinput.h
@@ -32,144 +32,25 @@
#define __GDK_INPUT_H__
#include <gdk/gdktypes.h>
+#include <gdk/gdkdevice.h>
G_BEGIN_DECLS
-#define GDK_TYPE_DEVICE (gdk_device_get_type ())
-#define GDK_DEVICE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DEVICE, GdkDevice))
-#define GDK_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DEVICE, GdkDeviceClass))
-#define GDK_IS_DEVICE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DEVICE))
-#define GDK_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DEVICE))
-#define GDK_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DEVICE, GdkDeviceClass))
-
-typedef struct _GdkDeviceKey GdkDeviceKey;
-typedef struct _GdkDeviceAxis GdkDeviceAxis;
-typedef struct _GdkDevice GdkDevice;
-typedef struct _GdkDeviceClass GdkDeviceClass;
-typedef struct _GdkTimeCoord GdkTimeCoord;
-
-typedef enum
-{
- GDK_EXTENSION_EVENTS_NONE,
- GDK_EXTENSION_EVENTS_ALL,
- GDK_EXTENSION_EVENTS_CURSOR
-} GdkExtensionMode;
-
-typedef enum
-{
- GDK_SOURCE_MOUSE,
- GDK_SOURCE_PEN,
- GDK_SOURCE_ERASER,
- GDK_SOURCE_CURSOR
-} GdkInputSource;
-
-typedef enum
-{
- GDK_MODE_DISABLED,
- GDK_MODE_SCREEN,
- GDK_MODE_WINDOW
-} GdkInputMode;
-
-typedef enum
-{
- GDK_AXIS_IGNORE,
- GDK_AXIS_X,
- GDK_AXIS_Y,
- GDK_AXIS_PRESSURE,
- GDK_AXIS_XTILT,
- GDK_AXIS_YTILT,
- GDK_AXIS_WHEEL,
- GDK_AXIS_LAST
-} GdkAxisUse;
-
-struct _GdkDeviceKey
-{
- guint keyval;
- GdkModifierType modifiers;
-};
-
-struct _GdkDeviceAxis
-{
- GdkAxisUse use;
- gdouble min;
- gdouble max;
-};
-
-struct _GdkDevice
-{
- GObject parent_instance;
- /* All fields are read-only */
-
- gchar *name;
- GdkInputSource source;
- GdkInputMode mode;
- gboolean has_cursor; /* TRUE if the X pointer follows device motion */
-
- gint num_axes;
- GdkDeviceAxis *axes;
-
- gint num_keys;
- GdkDeviceKey *keys;
-};
-
-/* We don't allocate each coordinate this big, but we use it to
- * be ANSI compliant and avoid accessing past the defined limits.
- */
-#define GDK_MAX_TIMECOORD_AXES 128
+#ifndef GDK_MULTIHEAD_SAFE
-struct _GdkTimeCoord
-{
- guint32 time;
- gdouble axes[GDK_MAX_TIMECOORD_AXES];
-};
+/* Returns a list of GdkDevice * */
+GList * gdk_devices_list (void);
-GType gdk_device_get_type (void) G_GNUC_CONST;
+GdkDevice *gdk_device_get_core_pointer (void);
-#ifndef GDK_MULTIHEAD_SAFE
-/* Returns a list of GdkDevice * */
-GList * gdk_devices_list (void);
#endif /* GDK_MULTIHEAD_SAFE */
-/* Functions to configure a device */
-void gdk_device_set_source (GdkDevice *device,
- GdkInputSource source);
-
-gboolean gdk_device_set_mode (GdkDevice *device,
- GdkInputMode mode);
-
-void gdk_device_set_key (GdkDevice *device,
- guint index_,
- guint keyval,
- GdkModifierType modifiers);
-
-void gdk_device_set_axis_use (GdkDevice *device,
- guint index_,
- GdkAxisUse use);
-void gdk_device_get_state (GdkDevice *device,
- GdkWindow *window,
- gdouble *axes,
- GdkModifierType *mask);
-gboolean gdk_device_get_history (GdkDevice *device,
- GdkWindow *window,
- guint32 start,
- guint32 stop,
- GdkTimeCoord ***events,
- gint *n_events);
-void gdk_device_free_history (GdkTimeCoord **events,
- gint n_events);
-gboolean gdk_device_get_axis (GdkDevice *device,
- gdouble *axes,
- GdkAxisUse use,
- gdouble *value);
+GdkDevice *gdk_display_get_core_pointer (GdkDisplay *display);
void gdk_input_set_extension_events (GdkWindow *window,
gint mask,
GdkExtensionMode mode);
-#ifndef GDK_MULTIHEAD_SAFE
-GdkDevice *gdk_device_get_core_pointer (void);
-#endif
-
G_END_DECLS
#endif /* __GDK_INPUT_H__ */
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
index 93b18cf..4913b8a 100644
--- a/gdk/x11/Makefile.am
+++ b/gdk/x11/Makefile.am
@@ -40,7 +40,6 @@ libgdk_x11_la_SOURCES = \
gdkglobals-x11.c \
gdkim-x11.c \
gdkimage-x11.c \
- gdkinput.c \
gdkkeys-x11.c \
gdkmain-x11.c \
gdkpixmap-x11.c \
@@ -58,7 +57,6 @@ libgdk_x11_la_SOURCES = \
gdkxid.c \
gdkx.h \
gdkprivate-x11.h \
- gdkinputprivate.h \
xsettings-client.h \
xsettings-client.c \
xsettings-common.h \
@@ -67,7 +65,7 @@ libgdk_x11_la_SOURCES = \
if XINPUT_XFREE
libgdk_x11_la_SOURCES += gdkinput-x11.c gdkinput-xfree.c
else
-libgdk_x11_la_SOURCES += gdkinput-none.c gdkdevicemanager-core.c
+libgdk_x11_la_SOURCES += gdkdevicemanager-core.c gdkdevice-core.c
endif
diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c
new file mode 100644
index 0000000..e991f25
--- /dev/null
+++ b/gdk/x11/gdkdevice-core.c
@@ -0,0 +1,68 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * 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.
+ */
+
+#include "gdkdevice-core.h"
+
+static void gdk_device_core_get_state ();
+
+G_DEFINE_TYPE (GdkDeviceCore, gdk_device_core, GDK_TYPE_DEVICE)
+
+static GdkDeviceAxis gdk_device_core_axes[] = {
+ { GDK_AXIS_X, 0, 0 },
+ { GDK_AXIS_Y, 0, 0 }
+};
+
+static void
+gdk_device_core_class_init (GdkDeviceCoreClass *klass)
+{
+ GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
+
+ device_class->get_state = gdk_device_core_get_state;
+}
+
+static void
+gdk_device_core_init (GdkDeviceCore *device_core)
+{
+ GdkDevice *device;
+
+ device = GDK_DEVICE (device_core);
+
+ device->num_axes = G_N_ELEMENTS (gdk_device_core_axes);
+ device->axes = gdk_device_core_axes;
+
+ device->num_keys = 0;
+ device->keys = NULL;
+}
+
+static void
+gdk_device_core_get_state (GdkDevice *device,
+ GdkWindow *window,
+ gdouble *axes,
+ GdkModifierType *mask)
+{
+ gint x_int, y_int;
+
+ gdk_window_get_pointer (window, &x_int, &y_int, mask);
+
+ if (axes)
+ {
+ axes[0] = x_int;
+ axes[1] = y_int;
+ }
+}
diff --git a/gdk/x11/gdkdevice-core.h b/gdk/x11/gdkdevice-core.h
new file mode 100644
index 0000000..6efa760
--- /dev/null
+++ b/gdk/x11/gdkdevice-core.h
@@ -0,0 +1,51 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * 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.
+ */
+
+#ifndef __GDK_DEVICE_CORE_H__
+#define __GDK_DEVICE_CORE_H__
+
+#include <gdk/gdkdevice.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_DEVICE_CORE (gdk_device_core_get_type ())
+#define GDK_DEVICE_CORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_CORE, GdkDeviceCore))
+#define GDK_DEVICE_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_DEVICE_CORE, GdkDeviceCoreClass))
+#define GDK_IS_DEVICE_CORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_CORE))
+#define GDK_IS_DEVICE_CORE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_DEVICE_CORE))
+#define GDK_DEVICE_CORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_DEVICE_CORE, GdkDeviceCoreClass))
+
+typedef struct _GdkDeviceCore GdkDeviceCore;
+typedef struct _GdkDeviceCoreClass GdkDeviceCoreClass;
+
+struct _GdkDeviceCore
+{
+ GdkDevice parent_instance;
+};
+
+struct _GdkDeviceCoreClass
+{
+ GdkDeviceClass parent_class;
+};
+
+GType gdk_device_core_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_DEVICE_CORE_H__ */
diff --git a/gdk/x11/gdkdevicemanager-core.c b/gdk/x11/gdkdevicemanager-core.c
index 8c19493..c56cec3 100644
--- a/gdk/x11/gdkdevicemanager-core.c
+++ b/gdk/x11/gdkdevicemanager-core.c
@@ -21,7 +21,7 @@
#include <gdk/gdkdevicemanager.h>
#include "gdkdevicemanager-core.h"
#include "gdkeventtranslator.h"
-#include "gdkinputprivate.h"
+#include "gdkdevice-core.h"
#include "gdkkeysyms.h"
#ifdef HAVE_XKB
@@ -32,11 +32,6 @@
#define HAS_FOCUS(toplevel) \
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
-static GdkDeviceAxis gdk_input_core_axes[] = {
- { GDK_AXIS_X, 0, 0 },
- { GDK_AXIS_Y, 0, 0 }
-};
-
static GList * gdk_device_manager_core_get_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
@@ -69,24 +64,13 @@ gdk_device_manager_event_translator_init (GdkEventTranslatorIface *iface)
static GdkDevice *
create_core_pointer (GdkDisplay *display)
{
- GdkDevice *core_pointer;
- GdkDevicePrivate *private;
-
- core_pointer = g_object_new (GDK_TYPE_DEVICE, NULL);
- private = (GdkDevicePrivate *) core_pointer;
-
- core_pointer->name = "Core Pointer";
- core_pointer->source = GDK_SOURCE_MOUSE;
- core_pointer->mode = GDK_MODE_SCREEN;
- core_pointer->has_cursor = TRUE;
- core_pointer->num_axes = G_N_ELEMENTS (gdk_input_core_axes);
- core_pointer->axes = gdk_input_core_axes;
- core_pointer->num_keys = 0;
- core_pointer->keys = NULL;
-
- private->display = display;
-
- return core_pointer;
+ /* FIXME: set mode */
+ return g_object_new (GDK_TYPE_DEVICE_CORE,
+ "name", "Core Pointer",
+ "input-source", GDK_SOURCE_MOUSE,
+ "has-cursor", TRUE,
+ "display", display,
+ NULL);
}
static void
@@ -677,11 +661,13 @@ gdk_device_manager_translate_event (GdkEventTranslator *translator,
}
}
+#if 0
/* Tell XInput stuff about it if appropriate */
if (window_private &&
!GDK_WINDOW_DESTROYED (window) &&
window_private->extension_events != 0)
_gdk_input_enter_event (&xevent->xcrossing, window);
+#endif
event->crossing.type = GDK_ENTER_NOTIFY;
event->crossing.window = window;
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 30e824f..c2260fd 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -38,7 +38,6 @@
#include "gdkscreen.h"
#include "gdkscreen-x11.h"
#include "gdkinternals.h"
-#include "gdkinputprivate.h"
#include "xsettings-client.h"
#include "gdkalias.h"
@@ -663,11 +662,13 @@ gdk_display_x11_translate_event (GdkEventTranslator *translator,
_gdk_x11_screen_size_changed (screen, xevent);
}
+#if 0
if (window &&
xevent->xconfigure.event == xevent->xconfigure.window &&
!GDK_WINDOW_DESTROYED (window) &&
(window_private->extension_events != 0))
_gdk_input_configure_event (&xevent->xconfigure, window);
+#endif
#ifdef HAVE_XSYNC
if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
@@ -994,6 +995,29 @@ _gdk_event_init (GdkDisplay *display)
GDK_EVENT_TRANSLATOR (device_manager));
}
+static void
+_gdk_input_init (GdkDisplay *display)
+{
+ GdkDisplayX11 *display_x11;
+ GdkDeviceManager *device_manager;
+ GList *list;
+
+ display_x11 = GDK_DISPLAY_X11 (display);
+ device_manager = gdk_device_manager_get_for_display (display);
+
+ /* Add all devices */
+ display_x11->input_devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
+
+ list = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_SLAVE);
+ display_x11->input_devices = g_list_concat (display_x11->input_devices, list);
+
+ list = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
+ display_x11->input_devices = g_list_concat (display_x11->input_devices, list);
+
+ /* Now set "core" pointer to the first master device */
+ display->core_pointer = display_x11->input_devices->data;
+}
+
/**
* gdk_display_open:
* @display_name: the name of the display to open
@@ -1464,7 +1488,9 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
display_x11 = GDK_DISPLAY_X11 (display);
xdisplay = GDK_DISPLAY_XDISPLAY (display);
+#if 0
_gdk_input_ungrab_pointer (display, time);
+#endif
XUngrabPointer (xdisplay, time);
XFlush (xdisplay);
@@ -2324,6 +2350,24 @@ gdk_display_supports_composite (GdkDisplay *display)
x11_display->have_xfixes;
}
+/**
+ * gdk_display_list_devices:
+ * @display: a #GdkDisplay
+ *
+ * Returns the list of available input devices attached to @display.
+ * The list is statically allocated and should not be freed.
+ *
+ * Return value: a list of #GdkDevice
+ *
+ * Since: 2.2
+ **/
+GList *
+gdk_display_list_devices (GdkDisplay *display)
+{
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+ return GDK_DISPLAY_X11 (display)->input_devices;
+}
#define __GDK_DISPLAY_X11_C__
#include "gdkaliasdef.c"
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index d600328..fe4d862 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -42,7 +42,6 @@
#include <string.h>
-#include "gdkinputprivate.h"
#include "gdksettings.c"
#include "gdkalias.h"
@@ -1289,11 +1288,13 @@ gdk_event_translate (GdkDisplay *display,
}
}
+#if 0
/* Tell XInput stuff about it if appropriate */
if (window_private &&
!GDK_WINDOW_DESTROYED (window) &&
window_private->extension_events != 0)
_gdk_input_enter_event (&xevent->xcrossing, window);
+#endif
event->crossing.type = GDK_ENTER_NOTIFY;
event->crossing.window = window;
@@ -1836,11 +1837,13 @@ gdk_event_translate (GdkDisplay *display,
_gdk_x11_screen_size_changed (screen, xevent);
}
+#if 0
if (window &&
xevent->xconfigure.event == xevent->xconfigure.window &&
!GDK_WINDOW_DESTROYED (window) &&
(window_private->extension_events != 0))
_gdk_input_configure_event (&xevent->xconfigure, window);
+#endif
#ifdef HAVE_XSYNC
if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
@@ -2152,12 +2155,13 @@ gdk_event_translate (GdkDisplay *display,
#endif
{
/* something else - (e.g., a Xinput event) */
-
+#if 0
if (window_private &&
!GDK_WINDOW_DESTROYED (window_private) &&
(window_private->extension_events != 0))
return_val = _gdk_input_other_event(event, xevent, window);
else
+#endif
return_val = FALSE;
break;
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index 7bede22..97bd920 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -48,7 +48,6 @@
#include "gdkinternals.h"
#include "gdkintl.h"
#include "gdkregion-generic.h"
-#include "gdkinputprivate.h"
#include "gdkalias.h"
typedef struct _GdkPredicate GdkPredicate;
@@ -230,11 +229,15 @@ gdk_pointer_grab (GdkWindow * window,
xevent_mask |= _gdk_event_mask_table[i];
}
+#if 0
return_val = _gdk_input_grab_pointer (window,
owner_events,
event_mask,
confine_to,
time);
+#else
+ return_val = GrabSuccess;
+#endif
if (return_val == GrabSuccess ||
G_UNLIKELY (!display_x11->trusted_client && return_val == AlreadyGrabbed))
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index f24a0df..920f152 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -185,7 +185,6 @@ void _gdk_windowing_window_init (GdkScreen *screen);
void _gdk_visual_init (GdkScreen *screen);
void _gdk_dnd_init (GdkDisplay *display);
void _gdk_windowing_image_init (GdkDisplay *display);
-void _gdk_input_init (GdkDisplay *display);
PangoRenderer *_gdk_x11_renderer_get (GdkDrawable *drawable,
GdkGC *gc);
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 6a888d4..6966229 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -39,11 +39,11 @@
#include <unistd.h>
#include "gdk.h"
+#include "gdkx.h"
#include "gdkwindow.h"
#include "gdkwindowimpl.h"
#include "gdkasync.h"
-#include "gdkinputprivate.h"
#include "gdkdisplay-x11.h"
#include "gdkprivate-x11.h"
#include "gdkregion.h"
@@ -1158,8 +1158,10 @@ _gdk_windowing_window_destroy (GdkWindow *window,
_gdk_selection_window_destroyed (window);
+#if 0
if (private->extension_events != 0)
_gdk_input_window_destroy (window);
+#endif
toplevel = _gdk_x11_window_get_toplevel (window);
if (toplevel)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]