1997-11-24 22:37:52 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
#include <config.h>
|
2004-08-09 20:14:43 +00:00
|
|
|
#include "gdkalias.h"
|
1999-11-08 20:14:59 +00:00
|
|
|
#include "gdkinputprivate.h"
|
2000-03-28 01:24:44 +00:00
|
|
|
#include "gdkinternals.h"
|
1999-11-08 20:14:59 +00:00
|
|
|
#include "gdkx.h"
|
2000-07-03 19:00:23 +00:00
|
|
|
#include "gdk.h" /* For gdk_error_trap_push()/pop() */
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
Add gdk_rgb_find_color() to get a pixel value using GdkRGB functionality
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
value using GdkRGB functionality given GdkColormap and GdkColor.
(name not final, waiting for inspiration.)
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
set the foreground/background of a GC using the GC's colormap
and GdkRGB. (name not final, waiting for inspiration.)
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
purely a function of the corresponding colormap. Make
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
gdk_pixbuf_*create_from_xpm_* in terms of
gdk_pixbuf_new_from_xpm_data(), move into platform independent
code.
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
advantage of the new draw_rgb_32_image_dithalign.
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
on each created GC.
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
which we initialize from the drawable when the GC is created,
if the drawable has a colormap.
* gdk/x11/gdkgc-x11.c: include string.h for memset.
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
2000-07-02 17:03:21 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
/* Forward declarations */
|
2002-04-25 22:29:14 +00:00
|
|
|
static GdkDevicePrivate *gdk_input_device_new (GdkDisplay *display,
|
|
|
|
XDeviceInfo *device,
|
|
|
|
gint include_core);
|
|
|
|
static void gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
|
|
|
GdkInputWindow *input_window,
|
|
|
|
gint *axis_data,
|
|
|
|
gdouble *axis_out,
|
|
|
|
gdouble *x_out,
|
|
|
|
gdouble *y_out);
|
|
|
|
static guint gdk_input_translate_state (guint state,
|
|
|
|
guint device_state);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkDevicePrivate *
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_find_device (GdkDisplay *display,
|
|
|
|
guint32 id)
|
2000-07-03 19:00:23 +00:00
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
GList *tmp_list = GDK_DISPLAY_X11 (display)->input_devices;
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkDevicePrivate *gdkdev;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
|
|
|
if (gdkdev->deviceid == id)
|
|
|
|
return gdkdev;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1999-11-08 20:14:59 +00:00
|
|
|
void
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_get_root_relative_geometry(Display *display, Window w, int *x_ret, int *y_ret,
|
|
|
|
int *width_ret, int *height_ret)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
Window root, parent, child;
|
1997-11-24 22:37:52 +00:00
|
|
|
Window *children;
|
1998-03-02 23:16:39 +00:00
|
|
|
guint nchildren;
|
|
|
|
gint x,y;
|
|
|
|
guint width, height;
|
2000-07-03 19:00:23 +00:00
|
|
|
guint border_widthc, depthc;
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
XQueryTree (display, w, &root, &parent, &children, &nchildren);
|
2000-07-03 19:00:23 +00:00
|
|
|
if (children)
|
|
|
|
XFree(children);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
XGetGeometry (display, w, &root, &x, &y, &width, &height, &border_widthc, &depthc);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
XTranslateCoordinates (display, w, root, 0, 0, &x, &y, &child);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
if (x_ret)
|
|
|
|
*x_ret = x;
|
|
|
|
if (y_ret)
|
|
|
|
*y_ret = y;
|
|
|
|
if (width_ret)
|
|
|
|
*width_ret = width;
|
|
|
|
if (height_ret)
|
|
|
|
*height_ret = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevicePrivate *
|
2002-04-25 22:29:14 +00:00
|
|
|
gdk_input_device_new (GdkDisplay *display,
|
|
|
|
XDeviceInfo *device,
|
|
|
|
gint include_core)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
GdkDevicePrivate *gdkdev;
|
2000-07-03 19:00:23 +00:00
|
|
|
gchar *tmp_name;
|
1997-11-24 22:37:52 +00:00
|
|
|
XAnyClassPtr class;
|
|
|
|
gint i,j;
|
|
|
|
|
2001-07-03 14:14:30 +00:00
|
|
|
gdkdev = g_object_new (GDK_TYPE_DEVICE, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
gdkdev->deviceid = device->id;
|
2002-04-25 22:29:14 +00:00
|
|
|
gdkdev->display = display;
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
if (device->name[0])
|
|
|
|
gdkdev->info.name = g_strdup (device->name);
|
|
|
|
else
|
|
|
|
/* XFree86 3.2 gives an empty name to the default core devices,
|
|
|
|
(fixed in 3.2A) */
|
|
|
|
gdkdev->info.name = g_strdup ("pointer");
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
gdkdev->info.mode = GDK_MODE_DISABLED;
|
|
|
|
|
|
|
|
/* Try to figure out what kind of device this is by its name -
|
|
|
|
could invite a very, very, long list... Lowercase name
|
|
|
|
for comparison purposes */
|
|
|
|
|
2002-09-25 07:23:55 +00:00
|
|
|
tmp_name = g_ascii_strdown (gdkdev->info.name, -1);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (!strcmp (tmp_name, "pointer"))
|
|
|
|
gdkdev->info.source = GDK_SOURCE_MOUSE;
|
|
|
|
else if (!strcmp (tmp_name, "wacom") ||
|
|
|
|
!strcmp (tmp_name, "pen"))
|
|
|
|
gdkdev->info.source = GDK_SOURCE_PEN;
|
|
|
|
else if (!strcmp (tmp_name, "eraser"))
|
|
|
|
gdkdev->info.source = GDK_SOURCE_ERASER;
|
|
|
|
else if (!strcmp (tmp_name, "cursor"))
|
|
|
|
gdkdev->info.source = GDK_SOURCE_CURSOR;
|
|
|
|
else
|
|
|
|
gdkdev->info.source = GDK_SOURCE_PEN;
|
|
|
|
|
|
|
|
g_free(tmp_name);
|
|
|
|
|
|
|
|
gdkdev->xdevice = NULL;
|
|
|
|
|
|
|
|
/* step through the classes */
|
|
|
|
|
|
|
|
gdkdev->info.num_axes = 0;
|
1997-12-18 02:17:14 +00:00
|
|
|
gdkdev->info.num_keys = 0;
|
2000-03-28 01:24:44 +00:00
|
|
|
gdkdev->info.axes = NULL;
|
1997-12-18 02:17:14 +00:00
|
|
|
gdkdev->info.keys = NULL;
|
1997-11-24 22:37:52 +00:00
|
|
|
gdkdev->axes = 0;
|
|
|
|
gdkdev->info.has_cursor = 0;
|
|
|
|
gdkdev->needs_update = FALSE;
|
|
|
|
gdkdev->claimed = FALSE;
|
|
|
|
gdkdev->button_state = 0;
|
|
|
|
|
|
|
|
class = device->inputclassinfo;
|
|
|
|
for (i=0;i<device->num_classes;i++)
|
|
|
|
{
|
|
|
|
switch (class->class) {
|
|
|
|
case ButtonClass:
|
2000-07-03 19:00:23 +00:00
|
|
|
break;
|
1997-12-18 02:17:14 +00:00
|
|
|
case KeyClass:
|
|
|
|
{
|
|
|
|
XKeyInfo *xki = (XKeyInfo *)class;
|
1998-02-03 20:57:40 +00:00
|
|
|
/* Hack to catch XFree86 3.3.1 bug. Other devices better
|
|
|
|
* not have exactly 25 keys...
|
|
|
|
*/
|
|
|
|
if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
|
|
|
|
{
|
|
|
|
gdkdev->info.num_keys = 32;
|
1998-06-15 21:27:17 +00:00
|
|
|
gdkdev->min_keycode = 1;
|
1998-02-03 20:57:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
|
|
|
|
gdkdev->min_keycode = xki->min_keycode;
|
|
|
|
}
|
1997-12-18 02:17:14 +00:00
|
|
|
gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
|
|
|
|
|
|
|
|
for (j=0; j<gdkdev->info.num_keys; j++)
|
|
|
|
{
|
|
|
|
gdkdev->info.keys[j].keyval = 0;
|
|
|
|
gdkdev->info.keys[j].modifiers = 0;
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ValuatorClass:
|
|
|
|
{
|
|
|
|
XValuatorInfo *xvi = (XValuatorInfo *)class;
|
|
|
|
gdkdev->info.num_axes = xvi->num_axes;
|
2000-07-03 19:00:23 +00:00
|
|
|
gdkdev->axes = g_new (GdkAxisInfo, xvi->num_axes);
|
|
|
|
gdkdev->info.axes = g_new0 (GdkDeviceAxis, xvi->num_axes);
|
1997-11-24 22:37:52 +00:00
|
|
|
for (j=0;j<xvi->num_axes;j++)
|
|
|
|
{
|
|
|
|
gdkdev->axes[j].resolution =
|
|
|
|
gdkdev->axes[j].xresolution = xvi->axes[j].resolution;
|
|
|
|
gdkdev->axes[j].min_value =
|
|
|
|
gdkdev->axes[j].xmin_value = xvi->axes[j].min_value;
|
|
|
|
gdkdev->axes[j].max_value =
|
|
|
|
gdkdev->axes[j].xmax_value = xvi->axes[j].max_value;
|
2000-07-03 19:00:23 +00:00
|
|
|
gdkdev->info.axes[j].use = GDK_AXIS_IGNORE;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
j=0;
|
|
|
|
if (j<xvi->num_axes)
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_X);
|
1997-11-24 22:37:52 +00:00
|
|
|
if (j<xvi->num_axes)
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_Y);
|
1997-11-24 22:37:52 +00:00
|
|
|
if (j<xvi->num_axes)
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_PRESSURE);
|
1997-11-24 22:37:52 +00:00
|
|
|
if (j<xvi->num_axes)
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_XTILT);
|
1997-11-24 22:37:52 +00:00
|
|
|
if (j<xvi->num_axes)
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_YTILT);
|
|
|
|
if (j<xvi->num_axes)
|
|
|
|
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_WHEEL);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class = (XAnyClassPtr)(((char *)class) + class->length);
|
|
|
|
}
|
|
|
|
/* return NULL if no axes */
|
|
|
|
if (!gdkdev->info.num_axes || !gdkdev->axes ||
|
|
|
|
(!include_core && device->use == IsXPointer))
|
2000-07-03 19:00:23 +00:00
|
|
|
goto error;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (device->use != IsXPointer)
|
1998-03-06 23:17:12 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_error_trap_push ();
|
2002-04-25 22:29:14 +00:00
|
|
|
gdkdev->xdevice = XOpenDevice (GDK_DISPLAY_XDISPLAY (display),
|
|
|
|
gdkdev->deviceid);
|
1998-03-06 23:17:12 +00:00
|
|
|
|
|
|
|
/* return NULL if device is not ready */
|
2000-07-03 19:00:23 +00:00
|
|
|
if (gdk_error_trap_pop ())
|
|
|
|
goto error;
|
1998-03-06 23:17:12 +00:00
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
gdkdev->buttonpress_type = 0;
|
|
|
|
gdkdev->buttonrelease_type = 0;
|
|
|
|
gdkdev->keypress_type = 0;
|
|
|
|
gdkdev->keyrelease_type = 0;
|
|
|
|
gdkdev->motionnotify_type = 0;
|
|
|
|
gdkdev->proximityin_type = 0;
|
|
|
|
gdkdev->proximityout_type = 0;
|
|
|
|
gdkdev->changenotify_type = 0;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
return gdkdev;
|
2000-07-03 19:00:23 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
|
|
|
|
g_free (gdkdev->info.name);
|
|
|
|
if (gdkdev->axes)
|
|
|
|
g_free (gdkdev->axes);
|
|
|
|
if (gdkdev->info.keys)
|
|
|
|
g_free (gdkdev->info.keys);
|
|
|
|
if (gdkdev->info.axes)
|
|
|
|
g_free (gdkdev->info.axes);
|
2001-06-30 02:56:50 +00:00
|
|
|
g_object_unref (gdkdev);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
|
|
|
return NULL;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
1999-11-08 20:14:59 +00:00
|
|
|
void
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_find_events(GdkWindow *window,
|
|
|
|
GdkDevicePrivate *gdkdev,
|
|
|
|
gint mask,
|
|
|
|
XEventClass *classes,
|
|
|
|
int *num_classes)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
XEventClass class;
|
|
|
|
|
|
|
|
i = 0;
|
2003-06-03 18:47:20 +00:00
|
|
|
if (mask & GDK_BUTTON_PRESS_MASK)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1997-12-18 02:17:14 +00:00
|
|
|
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
|
|
|
|
class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
|
1997-11-24 22:37:52 +00:00
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
2003-06-03 18:47:20 +00:00
|
|
|
if (mask & GDK_BUTTON_RELEASE_MASK)
|
|
|
|
{
|
|
|
|
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
|
|
|
|
class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
if (mask & GDK_POINTER_MOTION_MASK)
|
|
|
|
{
|
|
|
|
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
1997-12-18 02:17:14 +00:00
|
|
|
else
|
|
|
|
if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
|
|
|
|
GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK))
|
|
|
|
{
|
|
|
|
/* Make sure gdkdev->motionnotify_type is set */
|
|
|
|
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
|
|
|
|
}
|
|
|
|
if (mask & GDK_BUTTON1_MOTION_MASK)
|
|
|
|
{
|
|
|
|
DeviceButton1Motion (gdkdev->xdevice, 0, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
|
|
|
if (mask & GDK_BUTTON2_MOTION_MASK)
|
|
|
|
{
|
|
|
|
DeviceButton2Motion (gdkdev->xdevice, 0, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
|
|
|
if (mask & GDK_BUTTON3_MOTION_MASK)
|
|
|
|
{
|
|
|
|
DeviceButton3Motion (gdkdev->xdevice, 0, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
|
|
|
if (mask & GDK_BUTTON_MOTION_MASK)
|
|
|
|
{
|
|
|
|
DeviceButtonMotion (gdkdev->xdevice, 0, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
if (mask & GDK_POINTER_MOTION_HINT_MASK)
|
|
|
|
{
|
|
|
|
/* We'll get into trouble if the macros change, but at least we'll
|
|
|
|
know about it, and we avoid warnings now */
|
|
|
|
DevicePointerMotionHint (gdkdev->xdevice, 0, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
1997-12-18 02:17:14 +00:00
|
|
|
if (mask & GDK_KEY_PRESS_MASK)
|
|
|
|
{
|
|
|
|
DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
|
|
|
if (mask & GDK_KEY_RELEASE_MASK)
|
|
|
|
{
|
|
|
|
DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
if (mask & GDK_PROXIMITY_IN_MASK)
|
|
|
|
{
|
|
|
|
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
|
|
|
if (mask & GDK_PROXIMITY_OUT_MASK)
|
|
|
|
{
|
|
|
|
ProximityOut (gdkdev->xdevice, gdkdev->proximityout_type, class);
|
|
|
|
if (class != 0)
|
|
|
|
classes[i++] = class;
|
|
|
|
}
|
|
|
|
|
|
|
|
*num_classes = i;
|
|
|
|
}
|
|
|
|
|
1999-11-08 20:14:59 +00:00
|
|
|
void
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_select_events(GdkWindow *window,
|
|
|
|
GdkDevicePrivate *gdkdev)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1997-12-18 02:17:14 +00:00
|
|
|
XEventClass classes[GDK_MAX_DEVICE_CLASSES];
|
1997-11-24 22:37:52 +00:00
|
|
|
gint num_classes;
|
|
|
|
|
|
|
|
if (gdkdev->info.mode == GDK_MODE_DISABLED)
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
|
1997-11-24 22:37:52 +00:00
|
|
|
else
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_find_events(window, gdkdev,
|
|
|
|
((GdkWindowObject *)window)->extension_events,
|
|
|
|
classes, &num_classes);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
XSelectExtensionEvent (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
GDK_WINDOW_XWINDOW (window),
|
1997-11-24 22:37:52 +00:00
|
|
|
classes, num_classes);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_init (GdkDisplay *display,
|
|
|
|
gint include_core)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
XDeviceInfo *devices;
|
2004-08-26 00:23:46 +00:00
|
|
|
int num_devices, loop;
|
2003-07-11 19:57:01 +00:00
|
|
|
int ignore, event_base;
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
/* Init XInput extension */
|
2003-07-11 19:57:01 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
display_x11->input_devices = NULL;
|
2003-07-11 19:57:01 +00:00
|
|
|
if (XQueryExtension (display_x11->xdisplay, "XInputExtension",
|
|
|
|
&ignore, &event_base, &ignore))
|
1998-11-27 19:44:01 +00:00
|
|
|
{
|
2003-12-14 00:28:57 +00:00
|
|
|
gdk_x11_register_standard_event_type (display,
|
2004-03-01 23:59:36 +00:00
|
|
|
event_base, 15 /* Number of events */);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
devices = XListInputDevices(display_x11->xdisplay, &num_devices);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1998-11-27 19:44:01 +00:00
|
|
|
for(loop=0; loop<num_devices; loop++)
|
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDevicePrivate *gdkdev = gdk_input_device_new(display,
|
|
|
|
&devices[loop],
|
|
|
|
include_core);
|
1998-11-27 19:44:01 +00:00
|
|
|
if (gdkdev)
|
2002-04-25 22:29:14 +00:00
|
|
|
display_x11->input_devices = g_list_append(display_x11->input_devices, gdkdev);
|
1998-11-27 19:44:01 +00:00
|
|
|
}
|
|
|
|
XFreeDeviceList(devices);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2002-06-18 23:23:30 +00:00
|
|
|
display_x11->input_devices = g_list_append (display_x11->input_devices, display->core_pointer);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkInputWindow *input_window,
|
|
|
|
gint *axis_data,
|
|
|
|
gdouble *axis_out,
|
|
|
|
gdouble *x_out,
|
|
|
|
gdouble *y_out)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-06-21 16:19:59 +00:00
|
|
|
GdkWindowImplX11 *impl;
|
2000-07-03 19:00:23 +00:00
|
|
|
int i;
|
|
|
|
int x_axis = 0;
|
|
|
|
int y_axis = 0;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
double device_width, device_height;
|
|
|
|
double x_offset, y_offset, x_scale, y_scale;
|
|
|
|
|
2000-06-21 16:19:59 +00:00
|
|
|
impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *) input_window->window)->impl);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
for (i=0; i<gdkdev->info.num_axes; i++)
|
|
|
|
{
|
|
|
|
switch (gdkdev->info.axes[i].use)
|
|
|
|
{
|
|
|
|
case GDK_AXIS_X:
|
|
|
|
x_axis = i;
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_Y:
|
|
|
|
y_axis = i;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
device_width = gdkdev->axes[x_axis].max_value -
|
|
|
|
gdkdev->axes[x_axis].min_value;
|
|
|
|
device_height = gdkdev->axes[y_axis].max_value -
|
|
|
|
gdkdev->axes[y_axis].min_value;
|
|
|
|
|
|
|
|
if (gdkdev->info.mode == GDK_MODE_SCREEN)
|
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
x_scale = gdk_screen_get_width (gdk_drawable_get_screen (input_window->window)) / device_width;
|
|
|
|
y_scale = gdk_screen_get_height (gdk_drawable_get_screen (input_window->window)) / device_height;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
x_offset = - input_window->root_x;
|
|
|
|
y_offset = - input_window->root_y;
|
|
|
|
}
|
|
|
|
else /* GDK_MODE_WINDOW */
|
|
|
|
{
|
2003-12-31 22:00:21 +00:00
|
|
|
double x_resolution = gdkdev->axes[x_axis].resolution;
|
|
|
|
double y_resolution = gdkdev->axes[y_axis].resolution;
|
|
|
|
double device_aspect;
|
|
|
|
/*
|
|
|
|
* Some drivers incorrectly report the resolution of the device
|
|
|
|
* as zero (in partiular linuxwacom < 0.5.3 with usb tablets).
|
|
|
|
* This causes the device_aspect to become NaN and totally
|
|
|
|
* breaks windowed mode. If this is the case, the best we can
|
|
|
|
* do is to assume the resolution is non-zero is equal in both
|
|
|
|
* directions (which is true for many devices). The absolute
|
|
|
|
* value of the resolution doesn't matter since we only use the
|
|
|
|
* ratio.
|
|
|
|
*/
|
|
|
|
if ((x_resolution == 0) || (y_resolution == 0))
|
|
|
|
{
|
|
|
|
x_resolution = 1;
|
|
|
|
y_resolution = 1;
|
|
|
|
}
|
|
|
|
device_aspect = (device_height*y_resolution) /
|
|
|
|
(device_width*x_resolution);
|
2000-06-21 16:19:59 +00:00
|
|
|
if (device_aspect * impl->width >= impl->height)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
/* device taller than window */
|
2000-06-21 16:19:59 +00:00
|
|
|
x_scale = impl->width / device_width;
|
2003-12-31 22:00:21 +00:00
|
|
|
y_scale = (x_scale * x_resolution)
|
|
|
|
/ y_resolution;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
x_offset = 0;
|
|
|
|
y_offset = -(device_height * y_scale -
|
2000-06-21 16:19:59 +00:00
|
|
|
impl->height)/2;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* window taller than device */
|
2000-06-21 16:19:59 +00:00
|
|
|
y_scale = impl->height / device_height;
|
2003-12-31 22:00:21 +00:00
|
|
|
x_scale = (y_scale * y_resolution)
|
|
|
|
/ x_resolution;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
y_offset = 0;
|
2000-06-21 16:19:59 +00:00
|
|
|
x_offset = - (device_width * x_scale - impl->width)/2;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
for (i=0; i<gdkdev->info.num_axes; i++)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
switch (gdkdev->info.axes[i].use)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
case GDK_AXIS_X:
|
2003-12-31 22:00:21 +00:00
|
|
|
axis_out[i] = x_offset + x_scale * axis_data[x_axis];
|
2000-07-03 19:00:23 +00:00
|
|
|
if (x_out)
|
|
|
|
*x_out = axis_out[i];
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_Y:
|
2003-12-31 22:00:21 +00:00
|
|
|
axis_out[i] = y_offset + y_scale * axis_data[y_axis];
|
2000-07-03 19:00:23 +00:00
|
|
|
if (y_out)
|
|
|
|
*y_out = axis_out[i];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
axis_out[i] =
|
|
|
|
(gdkdev->info.axes[i].max * (axis_data[i] - gdkdev->axes[i].min_value) +
|
|
|
|
gdkdev->info.axes[i].min * (gdkdev->axes[i].max_value - axis_data[i])) /
|
|
|
|
(gdkdev->axes[i].max_value - gdkdev->axes[i].min_value);
|
|
|
|
break;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* combine the state of the core device and the device state
|
2000-07-03 19:00:23 +00:00
|
|
|
* into one - for now we do this in a simple-minded manner -
|
|
|
|
* we just take the keyboard portion of the core device and
|
|
|
|
* the button portion (all of?) the device state.
|
|
|
|
* Any button remapping should go on here.
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
static guint
|
|
|
|
gdk_input_translate_state(guint state, guint device_state)
|
|
|
|
{
|
|
|
|
return device_state | (state & 0xFF);
|
|
|
|
}
|
|
|
|
|
1999-11-08 20:14:59 +00:00
|
|
|
|
2003-03-08 21:11:39 +00:00
|
|
|
gboolean
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_other_event (GdkEvent *event,
|
|
|
|
XEvent *xevent,
|
|
|
|
GdkInputWindow *input_window,
|
|
|
|
GdkDevicePrivate *gdkdev)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
if ((xevent->type == gdkdev->buttonpress_type) ||
|
|
|
|
(xevent->type == gdkdev->buttonrelease_type))
|
|
|
|
{
|
|
|
|
XDeviceButtonEvent *xdbe = (XDeviceButtonEvent *)(xevent);
|
|
|
|
|
|
|
|
if (xdbe->type == gdkdev->buttonpress_type)
|
|
|
|
{
|
|
|
|
event->button.type = GDK_BUTTON_PRESS;
|
|
|
|
gdkdev->button_state |= 1 << xdbe->button;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event->button.type = GDK_BUTTON_RELEASE;
|
|
|
|
gdkdev->button_state &= ~(1 << xdbe->button);
|
|
|
|
}
|
2000-07-03 19:00:23 +00:00
|
|
|
event->button.device = &gdkdev->info;
|
1997-11-24 22:37:52 +00:00
|
|
|
event->button.window = input_window->window;
|
|
|
|
event->button.time = xdbe->time;
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
event->button.axes = g_new (gdouble, gdkdev->info.num_axes);
|
1997-11-24 22:37:52 +00:00
|
|
|
gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
|
2000-07-03 19:00:23 +00:00
|
|
|
event->button.axes,
|
|
|
|
&event->button.x,&event->button.y);
|
2004-12-28 01:09:45 +00:00
|
|
|
event->button.x_root = event->button.x + input_window->root_x;
|
|
|
|
event->button.y_root = event->button.y + input_window->root_y;
|
1997-11-24 22:37:52 +00:00
|
|
|
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
|
|
|
|
event->button.button = xdbe->button;
|
|
|
|
|
1998-02-19 06:21:27 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
1997-12-18 02:17:14 +00:00
|
|
|
g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
|
|
|
|
(event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
|
|
|
|
xdbe->window,
|
|
|
|
xdbe->deviceid,
|
|
|
|
event->button.x, event->button.y,
|
1998-02-19 06:21:27 +00:00
|
|
|
xdbe->button));
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2004-04-18 14:33:07 +00:00
|
|
|
/* Update the timestamp of the latest user interaction, if the event has
|
|
|
|
* a valid timestamp.
|
|
|
|
*/
|
|
|
|
if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
|
2004-05-06 02:57:01 +00:00
|
|
|
gdk_x11_window_set_user_time (gdk_window_get_toplevel (input_window->window),
|
|
|
|
gdk_event_get_time (event));
|
1997-11-24 22:37:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
if ((xevent->type == gdkdev->keypress_type) ||
|
|
|
|
(xevent->type == gdkdev->keyrelease_type))
|
|
|
|
{
|
|
|
|
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
|
|
|
|
|
1998-02-19 06:21:27 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
1997-12-18 02:17:14 +00:00
|
|
|
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
|
|
|
|
(event->key.type == GDK_KEY_PRESS) ? "press" : "release",
|
|
|
|
xdke->window,
|
|
|
|
xdke->deviceid,
|
1998-02-19 06:21:27 +00:00
|
|
|
xdke->keycode));
|
1997-12-18 02:17:14 +00:00
|
|
|
|
1998-02-03 20:57:40 +00:00
|
|
|
if (xdke->keycode < gdkdev->min_keycode ||
|
|
|
|
xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys)
|
|
|
|
{
|
|
|
|
g_warning ("Invalid device key code received");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
|
|
|
|
|
1997-12-18 02:17:14 +00:00
|
|
|
if (event->key.keyval == 0)
|
|
|
|
{
|
1998-02-19 06:21:27 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
g_print ("\t\ttranslation - NONE\n"));
|
1997-12-18 02:17:14 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
event->key.type = (xdke->type == gdkdev->keypress_type) ?
|
|
|
|
GDK_KEY_PRESS : GDK_KEY_RELEASE;
|
|
|
|
|
|
|
|
event->key.window = input_window->window;
|
|
|
|
event->key.time = xdke->time;
|
|
|
|
|
|
|
|
event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
|
|
|
|
| gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
|
|
|
|
|
1998-02-03 20:57:40 +00:00
|
|
|
/* Add a string translation for the key event */
|
|
|
|
if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
|
|
|
|
{
|
|
|
|
event->key.length = 1;
|
|
|
|
event->key.string = g_new (gchar, 2);
|
|
|
|
event->key.string[0] = (gchar)event->key.keyval;
|
|
|
|
event->key.string[1] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event->key.length = 0;
|
|
|
|
event->key.string = g_new0 (gchar, 1);
|
|
|
|
}
|
|
|
|
|
1998-02-19 06:21:27 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
1997-12-18 02:17:14 +00:00
|
|
|
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
|
|
|
|
event->key.keyval,
|
1998-02-19 06:21:27 +00:00
|
|
|
event->key.state));
|
1997-12-18 02:17:14 +00:00
|
|
|
|
2004-04-18 14:33:07 +00:00
|
|
|
/* Update the timestamp of the latest user interaction, if the event has
|
|
|
|
* a valid timestamp.
|
|
|
|
*/
|
|
|
|
if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
|
2004-05-06 02:57:01 +00:00
|
|
|
gdk_x11_window_set_user_time (gdk_window_get_toplevel (input_window->window),
|
|
|
|
gdk_event_get_time (event));
|
1997-12-18 02:17:14 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
if (xevent->type == gdkdev->motionnotify_type)
|
|
|
|
{
|
|
|
|
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
event->motion.device = &gdkdev->info;
|
|
|
|
|
|
|
|
event->motion.axes = g_new (gdouble, gdkdev->info.num_axes);
|
1997-11-24 22:37:52 +00:00
|
|
|
gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
|
2000-07-03 19:00:23 +00:00
|
|
|
event->motion.axes,
|
|
|
|
&event->motion.x,&event->motion.y);
|
2004-12-28 01:09:45 +00:00
|
|
|
event->motion.x_root = event->motion.x + input_window->root_x;
|
|
|
|
event->motion.y_root = event->motion.y + input_window->root_y;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
event->motion.type = GDK_MOTION_NOTIFY;
|
|
|
|
event->motion.window = input_window->window;
|
|
|
|
event->motion.time = xdme->time;
|
|
|
|
event->motion.state = gdk_input_translate_state(xdme->state,
|
|
|
|
xdme->device_state);
|
1997-12-18 02:17:14 +00:00
|
|
|
event->motion.is_hint = xdme->is_hint;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1998-02-19 06:21:27 +00:00
|
|
|
GDK_NOTE (EVENTS,
|
1997-12-18 02:17:14 +00:00
|
|
|
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
|
1997-11-24 22:37:52 +00:00
|
|
|
xdme->window,
|
|
|
|
xdme->deviceid,
|
|
|
|
event->motion.x, event->motion.y,
|
1997-12-18 02:17:14 +00:00
|
|
|
event->motion.state,
|
1998-02-19 06:21:27 +00:00
|
|
|
(xdme->is_hint) ? "true" : "false"));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
2004-04-18 14:33:07 +00:00
|
|
|
/* Update the timestamp of the latest user interaction, if the event has
|
|
|
|
* a valid timestamp.
|
|
|
|
*/
|
|
|
|
if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
|
2004-05-06 02:57:01 +00:00
|
|
|
gdk_x11_window_set_user_time (gdk_window_get_toplevel (input_window->window),
|
|
|
|
gdk_event_get_time (event));
|
1997-11-24 22:37:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xevent->type == gdkdev->proximityin_type ||
|
|
|
|
xevent->type == gdkdev->proximityout_type)
|
|
|
|
{
|
|
|
|
XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
event->proximity.device = &gdkdev->info;
|
1997-11-24 22:37:52 +00:00
|
|
|
event->proximity.type = (xevent->type == gdkdev->proximityin_type)?
|
|
|
|
GDK_PROXIMITY_IN:GDK_PROXIMITY_OUT;
|
|
|
|
event->proximity.window = input_window->window;
|
|
|
|
event->proximity.time = xpne->time;
|
|
|
|
|
2004-04-18 14:33:07 +00:00
|
|
|
/* Update the timestamp of the latest user interaction, if the event has
|
|
|
|
* a valid timestamp.
|
|
|
|
*/
|
|
|
|
if (gdk_event_get_time (event) != GDK_CURRENT_TIME)
|
2004-05-06 02:57:01 +00:00
|
|
|
gdk_x11_window_set_user_time (gdk_window_get_toplevel (input_window->window),
|
|
|
|
gdk_event_get_time (event));
|
1997-11-24 22:37:52 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-03-08 21:11:39 +00:00
|
|
|
return FALSE; /* wasn't one of our event types */
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
gboolean
|
|
|
|
_gdk_device_get_history (GdkDevice *device,
|
|
|
|
GdkWindow *window,
|
|
|
|
guint32 start,
|
|
|
|
guint32 stop,
|
|
|
|
GdkTimeCoord ***events,
|
|
|
|
gint *n_events)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkTimeCoord **coords;
|
1997-11-24 22:37:52 +00:00
|
|
|
XDeviceTimeCoord *device_coords;
|
|
|
|
GdkInputWindow *input_window;
|
|
|
|
GdkDevicePrivate *gdkdev;
|
2000-07-03 19:00:23 +00:00
|
|
|
gint mode_return;
|
|
|
|
gint axis_count_return;
|
|
|
|
gint i;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
gdkdev = (GdkDevicePrivate *)device;
|
2002-08-02 20:22:49 +00:00
|
|
|
input_window = _gdk_input_window_find (window);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
g_return_val_if_fail (input_window != NULL, FALSE);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
device_coords = XGetDeviceMotionEvents (GDK_WINDOW_XDISPLAY (window),
|
1997-11-24 22:37:52 +00:00
|
|
|
gdkdev->xdevice,
|
|
|
|
start, stop,
|
2000-07-03 19:00:23 +00:00
|
|
|
n_events, &mode_return,
|
1997-11-24 22:37:52 +00:00
|
|
|
&axis_count_return);
|
|
|
|
|
|
|
|
if (device_coords)
|
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
coords = _gdk_device_allocate_history (device, *n_events);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
for (i=0; i<*n_events; i++)
|
|
|
|
gdk_input_translate_coordinates (gdkdev, input_window,
|
|
|
|
device_coords[i].data,
|
|
|
|
coords[i]->axes, NULL, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
XFreeDeviceMotionEvents (device_coords);
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
*events = coords;
|
|
|
|
|
|
|
|
return TRUE;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
else
|
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
|
|
|
return FALSE;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
1999-11-08 20:14:59 +00:00
|
|
|
void
|
2000-07-03 19:00:23 +00:00
|
|
|
gdk_device_get_state (GdkDevice *device,
|
|
|
|
GdkWindow *window,
|
|
|
|
gdouble *axes,
|
|
|
|
GdkModifierType *mask)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
g_return_if_fail (device != NULL);
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
if (GDK_IS_CORE (device))
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
gint x_int, y_int;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
gdk_window_get_pointer (window, &x_int, &y_int, mask);
|
2000-07-03 19:00:23 +00:00
|
|
|
|
|
|
|
if (axes)
|
|
|
|
{
|
|
|
|
axes[0] = x_int;
|
|
|
|
axes[1] = y_int;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-03 19:00:23 +00:00
|
|
|
GdkDevicePrivate *gdkdev;
|
|
|
|
GdkInputWindow *input_window;
|
|
|
|
XDeviceState *state;
|
|
|
|
XInputClass *input_class;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
if (mask)
|
|
|
|
gdk_window_get_pointer (window, NULL, NULL, mask);
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
gdkdev = (GdkDevicePrivate *)device;
|
2002-08-02 20:22:49 +00:00
|
|
|
input_window = _gdk_input_window_find (window);
|
1997-11-24 22:37:52 +00:00
|
|
|
g_return_if_fail (input_window != NULL);
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
state = XQueryDeviceState (GDK_WINDOW_XDISPLAY (window),
|
|
|
|
gdkdev->xdevice);
|
1997-11-24 22:37:52 +00:00
|
|
|
input_class = state->data;
|
|
|
|
for (i=0; i<state->num_classes; i++)
|
|
|
|
{
|
|
|
|
switch (input_class->class)
|
|
|
|
{
|
|
|
|
case ValuatorClass:
|
2000-07-03 19:00:23 +00:00
|
|
|
if (axes)
|
|
|
|
gdk_input_translate_coordinates (gdkdev, input_window,
|
|
|
|
((XValuatorState *)input_class)->valuators,
|
|
|
|
axes, NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
case ButtonClass:
|
|
|
|
if (mask)
|
|
|
|
{
|
1997-12-18 02:17:14 +00:00
|
|
|
*mask &= 0xFF;
|
|
|
|
if (((XButtonState *)input_class)->num_buttons > 0)
|
|
|
|
*mask |= ((XButtonState *)input_class)->buttons[0] << 7;
|
|
|
|
/* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
|
|
|
|
* in bit 1<<(n%8) in byte n/8. n = 1,2,... */
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
input_class = (XInputClass *)(((char *)input_class)+input_class->length);
|
|
|
|
}
|
1999-11-10 17:15:58 +00:00
|
|
|
XFreeDeviceState (state);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|