* Boston, MA 02111-1307, USA.
*/
-#if defined(XINPUT_GXI) || defined(XINPUT_XFREE)
+/*
+ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "gdkinputprivate.h"
+#include "gdkx.h"
/* Forward declarations */
-static void gdk_input_get_root_relative_geometry (Display *dpy, Window w,
- int *x_ret, int *y_ret,
- int *width_ret,
- int *height_ret);
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
gint include_core);
-static void gdk_input_common_find_events(GdkWindow *window,
- GdkDevicePrivate *gdkdev,
- gint mask,
- XEventClass *classes,
- int *num_classes);
-static void gdk_input_common_select_events(GdkWindow *window,
- GdkDevicePrivate *gdkdev);
static void gdk_input_translate_coordinates(GdkDevicePrivate *gdkdev,
GdkInputWindow *input_window,
gint *axis_data,
gdouble *pressure,
gdouble *xtilt, gdouble *ytilt);
static guint gdk_input_translate_state(guint state, guint device_state);
-static gint gdk_input_common_init(gint include_core);
-static gint gdk_input_common_other_event (GdkEvent *event,
- XEvent *xevent,
- GdkInputWindow *input_window,
- GdkDevicePrivate *gdkdev);
-static void gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes);
-static GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
- guint32 deviceid,
- guint32 start,
- guint32 stop,
- gint *nevents_return);
-static void gdk_input_common_get_pointer (GdkWindow *window,
- guint32 deviceid,
- gdouble *x,
- gdouble *y,
- gdouble *pressure,
- gdouble *xtilt,
- gdouble *ytilt,
- GdkModifierType *mask);
-
-#define GDK_MAX_DEVICE_CLASSES 13
+void gdk_input_common_get_pointer (GdkWindow *window,
+ guint32 deviceid,
+ gdouble *x,
+ gdouble *y,
+ gdouble *pressure,
+ gdouble *xtilt,
+ gdouble *ytilt,
+ GdkModifierType *mask);
/* Global variables */
static gint gdk_input_root_width;
static gint gdk_input_root_height;
-static void
+void
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
int *width_ret, int *height_ret)
{
if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
{
gdkdev->info.num_keys = 32;
- gdkdev->min_keycode = 0;
+ gdkdev->min_keycode = 1;
}
else
{
return gdkdev;
}
-static void
+void
gdk_input_common_find_events(GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
*num_classes = i;
}
-static void
+void
gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev)
{
for (loop = 0; loop < num_extensions &&
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
XFreeExtensionList(extensions);
- if (loop == num_extensions) /* XInput extension not found */
- return FALSE;
+ gdk_input_devices = NULL;
+ if (loop < num_extensions)
+ {
+ /* XInput extension found */
- gdk_input_devices = 0;
- devices = XListInputDevices(display, &num_devices);
+ devices = XListInputDevices(display, &num_devices);
- for(loop=0; loop<num_devices; loop++)
- {
- GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
+ for(loop=0; loop<num_devices; loop++)
+ {
+ GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
include_core);
- if (gdkdev)
- gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
+ if (gdkdev)
+ gdk_input_devices = g_list_append(gdk_input_devices, gdkdev);
+ }
+ XFreeDeviceList(devices);
}
- XFreeDeviceList(devices);
- gdk_input_devices = g_list_append (gdk_input_devices, &gdk_input_core_info);
+ gdk_input_devices = g_list_append (gdk_input_devices, (gpointer)&gdk_input_core_info);
return TRUE;
}
gdouble *x, gdouble *y, gdouble *pressure,
gdouble *xtilt, gdouble *ytilt)
{
- GdkWindowPrivate *win_priv;
+ GdkDrawablePrivate *drawable_priv;
int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
double device_width, device_height;
double x_offset, y_offset, x_scale, y_scale;
- win_priv = (GdkWindowPrivate *) input_window->window;
+ drawable_priv = (GdkDrawablePrivate *) input_window->window;
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
(device_width*gdkdev->axes[x_axis].resolution);
- if (device_aspect * win_priv->width >= win_priv->height)
+ if (device_aspect * drawable_priv->width >= drawable_priv->height)
{
/* device taller than window */
- x_scale = win_priv->width / device_width;
+ x_scale = drawable_priv->width / device_width;
y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
/ gdkdev->axes[y_axis].resolution;
x_offset = 0;
y_offset = -(device_height * y_scale -
- win_priv->height)/2;
+ drawable_priv->height)/2;
}
else
{
/* window taller than device */
- y_scale = win_priv->height / device_height;
+ y_scale = drawable_priv->height / device_height;
x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
/ gdkdev->axes[x_axis].resolution;
y_offset = 0;
- x_offset = - (device_width * x_scale - win_priv->width)/2;
+ x_offset = - (device_width * x_scale - drawable_priv->width)/2;
}
}
return device_state | (state & 0xFF);
}
-static gint
-gdk_input_common_other_event (GdkEvent *event,
- XEvent *xevent,
- GdkInputWindow *input_window,
+
+gint
+gdk_input_common_other_event (GdkEvent *event,
+ XEvent *xevent,
+ GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev)
{
if ((xevent->type == gdkdev->buttonpress_type) ||
return -1; /* wasn't one of our event types */
}
-static void
+void
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
{
int i;
}
}
-void gdk_input_common_set_key (guint32 deviceid,
- guint index,
- guint keyval,
- GdkModifierType modifiers)
+void
+gdk_input_common_set_key (guint32 deviceid,
+ guint index,
+ guint keyval,
+ GdkModifierType modifiers)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
gdkdev->info.keys[index].modifiers = modifiers;
}
-static GdkTimeCoord *
+GdkTimeCoord *
gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
return NULL;
}
-static void
+void
gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
}
input_class = (XInputClass *)(((char *)input_class)+input_class->length);
}
+ XFreeDeviceState (state);
}
}
-
-#endif