[gtk+/xi2: 765/1239] Use new axes API in XI2 impl.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 765/1239] Use new axes API in XI2 impl.
- Date: Tue, 29 Sep 2009 10:50:11 +0000 (UTC)
commit a5bc4ab5cf48654a30667a20bb6fe0f9b910ab04
Author: Carlos Garnacho <carlos lanedo com>
Date: Sat Aug 15 17:15:09 2009 +0200
Use new axes API in XI2 impl.
gdk/x11/gdkdevice-xi2.c | 47 +----------------------------------
gdk/x11/gdkdevicemanager-xi2.c | 54 ++++++++++++++++++++++++++++++---------
2 files changed, 42 insertions(+), 59 deletions(-)
---
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 1dd274f..b811b5a 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -46,10 +46,6 @@ static void gdk_device_xi2_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask);
-static gboolean gdk_device_xi2_get_axis (GdkDevice *device,
- gdouble *axes,
- GdkAxisUse use,
- gdouble *value);
static void gdk_device_xi2_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor);
@@ -63,8 +59,7 @@ G_DEFINE_TYPE (GdkDeviceXI2, gdk_device_xi2, GDK_TYPE_DEVICE)
enum {
PROP_0,
- PROP_DEVICE_ID,
- PROP_N_AXES
+ PROP_DEVICE_ID
};
static void
@@ -77,7 +72,6 @@ gdk_device_xi2_class_init (GdkDeviceXI2Class *klass)
object_class->set_property = gdk_device_xi2_set_property;
device_class->get_state = gdk_device_xi2_get_state;
- device_class->get_axis = gdk_device_xi2_get_axis;
device_class->set_window_cursor = gdk_device_xi2_set_window_cursor;
device_class->warp = gdk_device_xi2_warp;
@@ -88,13 +82,6 @@ gdk_device_xi2_class_init (GdkDeviceXI2Class *klass)
P_("Device identifier"),
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_N_AXES,
- g_param_spec_uint ("n-axes",
- P_("Number of axes"),
- P_("Number of axes"),
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof (GdkDeviceXI2Private));
}
@@ -123,9 +110,6 @@ gdk_device_xi2_get_property (GObject *object,
case PROP_DEVICE_ID:
g_value_set_int (value, priv->device_id);
break;
- case PROP_N_AXES:
- g_value_set_uint (value, priv->axes->len);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -161,35 +145,6 @@ gdk_device_xi2_get_state (GdkDevice *device,
{
}
-static gboolean
-gdk_device_xi2_get_axis (GdkDevice *device,
- gdouble *axes,
- GdkAxisUse use,
- gdouble *value)
-{
- GdkDeviceXI2Private *priv;
- gint i;
-
- priv = GDK_DEVICE_XI2_GET_PRIVATE (device);
-
- for (i = 0; i < priv->axes->len; i++)
- {
- GdkDeviceAxis axis_info;
-
- axis_info = g_array_index (priv->axes, GdkDeviceAxis, i);
-
- if (axis_info.use == use)
- {
- if (value)
- *value = axes[i];
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
static void
gdk_device_xi2_set_window_cursor (GdkDevice *device,
GdkWindow *window,
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index fcbc8f5..3a543aa 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -148,10 +148,8 @@ translate_valuator_class (GdkDisplay *display,
{
static gboolean initialized = FALSE;
static Atom label_atoms [GDK_AXIS_LAST] = { 0 };
- GdkDeviceXI2 *device_xi2;
- GdkAxisUse i;
-
- device_xi2 = GDK_DEVICE_XI2 (device);
+ GdkAxisUse use = GDK_AXIS_IGNORE;
+ gint i;
if (!initialized)
{
@@ -168,12 +166,17 @@ translate_valuator_class (GdkDisplay *display,
{
if (label_atoms[i] == info->label)
{
- gdk_device_xi2_add_axis (device_xi2, i);
- return;
+ use = i;
+ break;
}
}
- gdk_device_xi2_add_axis (device_xi2, GDK_AXIS_IGNORE);
+ _gdk_device_add_axis (device,
+ gdk_x11_xatom_to_atom_for_display (display, info->label),
+ use,
+ info->min,
+ info->max,
+ info->resolution);
}
static GdkDevice *
@@ -192,10 +195,10 @@ create_device (GdkDisplay *display,
input_source = GDK_SOURCE_MOUSE;
}
- /* FIXME: set mode */
device = g_object_new (GDK_TYPE_DEVICE_XI2,
"name", dev->name,
"input-source", input_source,
+ "input-mode", (dev->use == XIMasterPointer) ? GDK_MODE_SCREEN : GDK_MODE_DISABLED,
"has-cursor", (dev->use == XIMasterPointer),
"display", display,
"device-id", dev->deviceid,
@@ -680,9 +683,13 @@ handle_focus_change (GdkWindow *window,
static gdouble *
translate_axes (GdkDevice *device,
+ gdouble x,
+ gdouble y,
+ GdkWindow *window,
XIValuatorState *valuators)
{
- guint n_axes, i, n;
+ guint n_axes, i;
+ gint width, height;
gdouble *axes;
double *vals;
@@ -690,12 +697,24 @@ translate_axes (GdkDevice *device,
axes = g_new0 (gdouble, n_axes);
vals = valuators->values;
- n = 0;
+
+ gdk_drawable_get_size (GDK_DRAWABLE (window), &width, &height);
for (i = 0; i <= valuators->mask_len * 8; i++)
{
if (XIMaskIsSet (valuators->mask, i))
- axes[n++] = *vals++;
+ {
+ gdouble value;
+
+ _gdk_device_translate_axis (device,
+ (gdouble) width,
+ (gdouble) height,
+ x, y,
+ i,
+ *vals++,
+ &value);
+ axes[i] = value;
+ }
}
return axes;
@@ -830,7 +849,12 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->button.device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
- event->button.axes = translate_axes (event->button.device, &xev->valuators);
+ event->button.axes = translate_axes (event->button.device,
+ event->button.x,
+ event->button.y,
+ event->button.window,
+ &xev->valuators);
+
event->button.state = translate_state (&xev->mods, &xev->buttons);
event->button.button = xev->detail;
}
@@ -872,7 +896,11 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
/* FIXME: There doesn't seem to be motion hints in XI */
event->motion.is_hint = FALSE;
- event->motion.axes = translate_axes (event->motion.device, &xev->valuators);
+ event->motion.axes = translate_axes (event->motion.device,
+ event->motion.x,
+ event->motion.y,
+ event->motion.window,
+ &xev->valuators);
}
break;
case XI_Enter:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]