gtk/gdk/x11/gdkinput-x11.c

788 lines
21 KiB
C
Raw Normal View History

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
* 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
* Lesser General Public License for more details.
1997-11-24 22:37:52 +00:00
*
* 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.
1997-11-24 22:37:52 +00:00
*/
/*
* Modified by the GTK+ Team and others 1997-2000. 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/.
*/
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
#include "gdkinputprivate.h"
2000-03-28 01:24:44 +00:00
#include "gdkinternals.h"
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
#include "gdkx.h"
#include "gdk.h" /* For gdk_error_trap_push()/pop() */
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 */
static GdkDevicePrivate *gdk_input_device_new(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);
1997-11-24 22:37:52 +00:00
static guint gdk_input_translate_state(guint state, guint device_state);
1997-11-24 22:37:52 +00:00
/* Global variables */
GdkDevicePrivate *
gdk_input_find_device (guint32 id)
{
Make gdkx.h the only installed header from gdk/x11. All structures in Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com> Make gdkx.h the only installed header from gdk/x11. All structures in gdk/x11 are opaque. * gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h: Don't install gdk{drawable,pixmap,window}-x11.h. * gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c: Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11, GdkVisualClass into C files. * gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static. * gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c, gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c} Add public functions to replace previously exported direct structure access. gdk_x11_colormap_get_{xdisplay,xcolormap} gdk_x11_cursor_get_{xdisplay,xcursor}, gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual, gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage}, gdk_x11_gc_get_{xdisplay,ximage} * gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo, GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals. Fix a number of variables and functions that were exported "accidentally" from GDK. * gdk/**.[ch]: gdk => _gdk for gdk_visual_init, gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit, gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data, gdk_event_notify, gdk_queued_events, gdk_queued_tail, gdk_event_new, gdk_events_queue, gdk_events_unqueue, gdk_event_queue_find_first, gdk_event_queue_remove_link, gdk_event_queue_append, gdk_event_button_generate, gdk_debug_flags, gdk_default_filters, gdk_parent_root. * gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c, gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}: gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks, gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window, gdk_use_xshm, gdk_input_ignore_core. * gdk/x11/xsettings-common.h (xsettings_list_insert): Add #defines to namespace functions into the private _gdk_ namespace. * gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window () to replace gdk_parent_root exported variable. Adjust and deprecate GDK_ROOT_PARENT(). * demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix GDK_ROOT_PARENT usage, remove includes of port-specific headers. * gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for _gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core, gdk_input_devices, _gdk_input_windows, gdk_init_input_core. * gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c} docs/Changes-2.0.txt: Remove gdk_wm_protocols, gdk_wm_delete_window functions, gdk_wm_take_focus, use gdk_atom_intern() instead. * gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h} gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h} gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h} gtk/gtkselection.c Unexport gdk_selection_property, just use gdk_atom_intern ("GDK_SELECTION"). * gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}: Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type, GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate, GdkVisualprivate, gdk_x11_gc_flush. Make a number of public exports of variables into functions to increase encapsulation. * gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer, move to gdkinternals.h. Add gdk_device_get_core_pointer (). * gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code, gdk_error_warnings. * gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h} docs/Changes-2.0.txt: s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen() s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow() Add gdk_x11_get_default_xdisplay(). * gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class, Don't export gdk_progclass, move --class command line option and handling to common portion of GDK. Miscellaneous fixes: * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix g_return_val_if_fail that should have been g_return_if_fail. * gdk/gdkinternals.h gdk/gdkprivate.h: Move gdk_synthesize_window_state() to the semi-public gdkprivate.h. * gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded X11 dependency. * gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO: Remove unused gdk_key_repeat_disable/restore. * linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def: Remove unused gdk_null_window_warnings variable. * gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox; it can be retrieved from the repository; it is too far from functional to be worth having people check out; it would be easier to start from scratch, I suspect. * gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID(). * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. Add some space for future expansion to multihead. * gdk/gdkdrawable.h: Add four reserved function pointers for future expansion of GdkDrawableClass. * gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
GList *tmp_list = _gdk_input_devices;
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
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
void
1997-11-24 22:37:52 +00:00
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
int *width_ret, int *height_ret)
1997-11-24 22:37:52 +00:00
{
Window root, parent, child;
1997-11-24 22:37:52 +00:00
Window *children;
guint nchildren;
gint x,y;
guint width, height;
guint border_widthc, depthc;
XQueryTree (dpy, w, &root, &parent, &children, &nchildren);
if (children)
XFree(children);
1997-11-24 22:37:52 +00:00
XGetGeometry (dpy, w, &root, &x, &y, &width, &height, &border_widthc, &depthc);
1997-11-24 22:37:52 +00:00
XTranslateCoordinates (dpy, w, root, 0, 0, &x, &y, &child);
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 *
gdk_input_device_new (XDeviceInfo *device, gint include_core)
1997-11-24 22:37:52 +00:00
{
GdkDevicePrivate *gdkdev;
gchar *tmp_name;
1997-11-24 22:37:52 +00:00
XAnyClassPtr class;
gint i,j;
For XEMBED embedding add a _XEMBED_INFO property to the client with Mon Jul 2 16:53:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/xembed.h gtk/gtkplug.c gtk/gtksocket.c: For XEMBED embedding add a _XEMBED_INFO property to the client with version number and a "mapped" flags. Use the mapped flag instead of the racy MapRequestEvent * gtk/gtksocket.c: Clean up the gtk_socket_steal() code to reliably set things (when the child is a passive embedder participating in the XEMBED protocol) intead of just being a hack for embedding non-participating programs. Fix various bugs and race conditions. * gtk/gtksocket.[ch] gtk/gtkplug.[ch]: Make local embedding work by simply making the GtkSocket the gtk parent of the GtkPlug. Set a flag in this case and make the GtkPlug work like a normal container by overriding methods such as check_resize and "chaining past" GtkWindow to GtkBin. * gtk/gtkentry.c (gtk_entry_real_activate) gtk/gtkmain.c (gtk_propagate_event): Eliminate use of gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW). * gtk/gtkwidget.c (gtk_widget_get_toplevel, gtk_widget_get_ancestor): Explain why gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) might not give the expected result and recommend an alternative. * tests/testsocket.c tests/testsocket_child.c tests/testsocket_common.c tests/Makefile.am: Extended to test different type of adding plugs to sockets (local,active,passive), and to test mapping/unmapping the plug. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Don't mark the window as destroyed until after we called _gdk_windowing_window_destroy(). (_gdk_windowing_window_destroy() may use GDK functions on the window.) * gdk/x11/gdkinput.c: Remove the check for finalization - devices can be finalized under some circumnstances. * gdk/x11/gdkinput-x11.c (gdk_input_device_new): Fix small problem with GDK_TYPE_DEVICE.
2001-07-03 14:14:30 +00:00
gdkdev = g_object_new (GDK_TYPE_DEVICE, NULL);
1997-11-24 22:37:52 +00:00
gdkdev->deviceid = device->id;
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 */
tmp_name = g_strdup (gdkdev->info.name);
g_strdown (tmp_name);
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;
gdkdev->info.num_keys = 0;
2000-03-28 01:24:44 +00:00
gdkdev->info.axes = NULL;
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:
break;
case KeyClass:
{
XKeyInfo *xki = (XKeyInfo *)class;
/* 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;
gdkdev->min_keycode = 1;
}
else
{
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
gdkdev->min_keycode = xki->min_keycode;
}
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;
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;
gdkdev->info.axes[j].use = GDK_AXIS_IGNORE;
1997-11-24 22:37:52 +00:00
}
j=0;
if (j<xvi->num_axes)
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_X);
1997-11-24 22:37:52 +00:00
if (j<xvi->num_axes)
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_Y);
1997-11-24 22:37:52 +00:00
if (j<xvi->num_axes)
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_PRESSURE);
1997-11-24 22:37:52 +00:00
if (j<xvi->num_axes)
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_XTILT);
1997-11-24 22:37:52 +00:00
if (j<xvi->num_axes)
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))
goto error;
1997-11-24 22:37:52 +00:00
if (device->use != IsXPointer)
{
gdk_error_trap_push ();
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->deviceid);
/* return NULL if device is not ready */
if (gdk_error_trap_pop ())
goto error;
}
1997-11-24 22:37:52 +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;
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);
g_object_unref (gdkdev);
return NULL;
1997-11-24 22:37:52 +00:00
}
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
void
1997-11-24 22:37:52 +00:00
gdk_input_common_find_events(GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes)
{
gint i;
XEventClass class;
i = 0;
/* We have to track press and release events in pairs to keep
track of button state correctly and implement grabbing for
the gxi support */
1997-11-24 22:37:52 +00:00
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
{
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;
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_POINTER_MOTION_MASK)
{
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
if (class != 0)
classes[i++] = class;
}
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;
}
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;
}
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
void
1997-11-24 22:37:52 +00:00
gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev)
{
XEventClass classes[GDK_MAX_DEVICE_CLASSES];
1997-11-24 22:37:52 +00:00
gint num_classes;
if (gdkdev->info.mode == GDK_MODE_DISABLED)
gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes);
else
gdk_input_common_find_events(window, gdkdev,
((GdkWindowObject *)window)->extension_events,
1997-11-24 22:37:52 +00:00
classes, &num_classes);
XSelectExtensionEvent (gdk_display,
GDK_WINDOW_XWINDOW(window),
classes, num_classes);
}
gint
gdk_input_common_init(gint include_core)
{
char **extensions;
XDeviceInfo *devices;
int num_devices;
int num_extensions, loop;
Display *display = gdk_display;
/* Init XInput extension */
extensions = XListExtensions(display, &num_extensions);
for (loop = 0; loop < num_extensions &&
(strcmp(extensions[loop], "XInputExtension") != 0); loop++);
XFreeExtensionList(extensions);
Make gdkx.h the only installed header from gdk/x11. All structures in Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com> Make gdkx.h the only installed header from gdk/x11. All structures in gdk/x11 are opaque. * gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h: Don't install gdk{drawable,pixmap,window}-x11.h. * gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c: Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11, GdkVisualClass into C files. * gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static. * gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c, gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c} Add public functions to replace previously exported direct structure access. gdk_x11_colormap_get_{xdisplay,xcolormap} gdk_x11_cursor_get_{xdisplay,xcursor}, gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual, gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage}, gdk_x11_gc_get_{xdisplay,ximage} * gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo, GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals. Fix a number of variables and functions that were exported "accidentally" from GDK. * gdk/**.[ch]: gdk => _gdk for gdk_visual_init, gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit, gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data, gdk_event_notify, gdk_queued_events, gdk_queued_tail, gdk_event_new, gdk_events_queue, gdk_events_unqueue, gdk_event_queue_find_first, gdk_event_queue_remove_link, gdk_event_queue_append, gdk_event_button_generate, gdk_debug_flags, gdk_default_filters, gdk_parent_root. * gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c, gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}: gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks, gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window, gdk_use_xshm, gdk_input_ignore_core. * gdk/x11/xsettings-common.h (xsettings_list_insert): Add #defines to namespace functions into the private _gdk_ namespace. * gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window () to replace gdk_parent_root exported variable. Adjust and deprecate GDK_ROOT_PARENT(). * demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix GDK_ROOT_PARENT usage, remove includes of port-specific headers. * gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for _gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core, gdk_input_devices, _gdk_input_windows, gdk_init_input_core. * gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c} docs/Changes-2.0.txt: Remove gdk_wm_protocols, gdk_wm_delete_window functions, gdk_wm_take_focus, use gdk_atom_intern() instead. * gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h} gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h} gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h} gtk/gtkselection.c Unexport gdk_selection_property, just use gdk_atom_intern ("GDK_SELECTION"). * gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}: Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type, GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate, GdkVisualprivate, gdk_x11_gc_flush. Make a number of public exports of variables into functions to increase encapsulation. * gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer, move to gdkinternals.h. Add gdk_device_get_core_pointer (). * gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code, gdk_error_warnings. * gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h} docs/Changes-2.0.txt: s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen() s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow() Add gdk_x11_get_default_xdisplay(). * gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class, Don't export gdk_progclass, move --class command line option and handling to common portion of GDK. Miscellaneous fixes: * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix g_return_val_if_fail that should have been g_return_if_fail. * gdk/gdkinternals.h gdk/gdkprivate.h: Move gdk_synthesize_window_state() to the semi-public gdkprivate.h. * gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded X11 dependency. * gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO: Remove unused gdk_key_repeat_disable/restore. * linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def: Remove unused gdk_null_window_warnings variable. * gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox; it can be retrieved from the repository; it is too far from functional to be worth having people check out; it would be easier to start from scratch, I suspect. * gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID(). * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. Add some space for future expansion to multihead. * gdk/gdkdrawable.h: Add four reserved function pointers for future expansion of GdkDrawableClass. * gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
_gdk_input_devices = NULL;
if (loop < num_extensions)
{
/* XInput extension found */
1997-11-24 22:37:52 +00:00
devices = XListInputDevices(display, &num_devices);
1997-11-24 22:37:52 +00:00
for(loop=0; loop<num_devices; loop++)
{
GdkDevicePrivate *gdkdev = gdk_input_device_new(&devices[loop],
1997-11-24 22:37:52 +00:00
include_core);
if (gdkdev)
Make gdkx.h the only installed header from gdk/x11. All structures in Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com> Make gdkx.h the only installed header from gdk/x11. All structures in gdk/x11 are opaque. * gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h: Don't install gdk{drawable,pixmap,window}-x11.h. * gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c: Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11, GdkVisualClass into C files. * gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static. * gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c, gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c} Add public functions to replace previously exported direct structure access. gdk_x11_colormap_get_{xdisplay,xcolormap} gdk_x11_cursor_get_{xdisplay,xcursor}, gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual, gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage}, gdk_x11_gc_get_{xdisplay,ximage} * gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo, GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals. Fix a number of variables and functions that were exported "accidentally" from GDK. * gdk/**.[ch]: gdk => _gdk for gdk_visual_init, gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit, gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data, gdk_event_notify, gdk_queued_events, gdk_queued_tail, gdk_event_new, gdk_events_queue, gdk_events_unqueue, gdk_event_queue_find_first, gdk_event_queue_remove_link, gdk_event_queue_append, gdk_event_button_generate, gdk_debug_flags, gdk_default_filters, gdk_parent_root. * gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c, gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}: gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks, gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window, gdk_use_xshm, gdk_input_ignore_core. * gdk/x11/xsettings-common.h (xsettings_list_insert): Add #defines to namespace functions into the private _gdk_ namespace. * gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window () to replace gdk_parent_root exported variable. Adjust and deprecate GDK_ROOT_PARENT(). * demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix GDK_ROOT_PARENT usage, remove includes of port-specific headers. * gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for _gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core, gdk_input_devices, _gdk_input_windows, gdk_init_input_core. * gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c} docs/Changes-2.0.txt: Remove gdk_wm_protocols, gdk_wm_delete_window functions, gdk_wm_take_focus, use gdk_atom_intern() instead. * gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h} gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h} gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h} gtk/gtkselection.c Unexport gdk_selection_property, just use gdk_atom_intern ("GDK_SELECTION"). * gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}: Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type, GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate, GdkVisualprivate, gdk_x11_gc_flush. Make a number of public exports of variables into functions to increase encapsulation. * gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer, move to gdkinternals.h. Add gdk_device_get_core_pointer (). * gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code, gdk_error_warnings. * gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h} docs/Changes-2.0.txt: s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen() s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow() Add gdk_x11_get_default_xdisplay(). * gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class, Don't export gdk_progclass, move --class command line option and handling to common portion of GDK. Miscellaneous fixes: * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix g_return_val_if_fail that should have been g_return_if_fail. * gdk/gdkinternals.h gdk/gdkprivate.h: Move gdk_synthesize_window_state() to the semi-public gdkprivate.h. * gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded X11 dependency. * gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO: Remove unused gdk_key_repeat_disable/restore. * linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def: Remove unused gdk_null_window_warnings variable. * gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox; it can be retrieved from the repository; it is too far from functional to be worth having people check out; it would be easier to start from scratch, I suspect. * gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID(). * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. Add some space for future expansion to multihead. * gdk/gdkdrawable.h: Add four reserved function pointers for future expansion of GdkDrawableClass. * gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
_gdk_input_devices = g_list_append(_gdk_input_devices, gdkdev);
}
XFreeDeviceList(devices);
1997-11-24 22:37:52 +00:00
}
Make gdkx.h the only installed header from gdk/x11. All structures in Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com> Make gdkx.h the only installed header from gdk/x11. All structures in gdk/x11 are opaque. * gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h: Don't install gdk{drawable,pixmap,window}-x11.h. * gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c: Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11, GdkVisualClass into C files. * gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static. * gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c, gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c} Add public functions to replace previously exported direct structure access. gdk_x11_colormap_get_{xdisplay,xcolormap} gdk_x11_cursor_get_{xdisplay,xcursor}, gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual, gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage}, gdk_x11_gc_get_{xdisplay,ximage} * gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo, GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals. Fix a number of variables and functions that were exported "accidentally" from GDK. * gdk/**.[ch]: gdk => _gdk for gdk_visual_init, gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit, gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data, gdk_event_notify, gdk_queued_events, gdk_queued_tail, gdk_event_new, gdk_events_queue, gdk_events_unqueue, gdk_event_queue_find_first, gdk_event_queue_remove_link, gdk_event_queue_append, gdk_event_button_generate, gdk_debug_flags, gdk_default_filters, gdk_parent_root. * gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c, gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}: gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks, gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window, gdk_use_xshm, gdk_input_ignore_core. * gdk/x11/xsettings-common.h (xsettings_list_insert): Add #defines to namespace functions into the private _gdk_ namespace. * gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window () to replace gdk_parent_root exported variable. Adjust and deprecate GDK_ROOT_PARENT(). * demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix GDK_ROOT_PARENT usage, remove includes of port-specific headers. * gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for _gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core, gdk_input_devices, _gdk_input_windows, gdk_init_input_core. * gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c} docs/Changes-2.0.txt: Remove gdk_wm_protocols, gdk_wm_delete_window functions, gdk_wm_take_focus, use gdk_atom_intern() instead. * gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h} gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h} gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h} gtk/gtkselection.c Unexport gdk_selection_property, just use gdk_atom_intern ("GDK_SELECTION"). * gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}: Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type, GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate, GdkVisualprivate, gdk_x11_gc_flush. Make a number of public exports of variables into functions to increase encapsulation. * gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer, move to gdkinternals.h. Add gdk_device_get_core_pointer (). * gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code, gdk_error_warnings. * gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h} docs/Changes-2.0.txt: s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen() s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow() Add gdk_x11_get_default_xdisplay(). * gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class, Don't export gdk_progclass, move --class command line option and handling to common portion of GDK. Miscellaneous fixes: * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix g_return_val_if_fail that should have been g_return_if_fail. * gdk/gdkinternals.h gdk/gdkprivate.h: Move gdk_synthesize_window_state() to the semi-public gdkprivate.h. * gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded X11 dependency. * gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO: Remove unused gdk_key_repeat_disable/restore. * linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def: Remove unused gdk_null_window_warnings variable. * gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox; it can be retrieved from the repository; it is too far from functional to be worth having people check out; it would be easier to start from scratch, I suspect. * gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID(). * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. * gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c: Fix some accidentally global variables and unused global variables. Add some space for future expansion to multihead. * gdk/gdkdrawable.h: Add four reserved function pointers for future expansion of GdkDrawableClass. * gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
_gdk_input_devices = g_list_append (_gdk_input_devices, _gdk_core_pointer);
1997-11-24 22:37:52 +00:00
return TRUE;
}
static void
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
GdkInputWindow *input_window,
gint *axis_data,
gdouble *axis_out,
gdouble *x_out,
gdouble *y_out)
1997-11-24 22:37:52 +00:00
{
GdkWindowImplX11 *impl;
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;
impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *) input_window->window)->impl);
1997-11-24 22:37:52 +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)
{
x_scale = gdk_screen_width() / device_width;
y_scale = gdk_screen_height() / 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 */
{
double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) /
(device_width*gdkdev->axes[x_axis].resolution);
if (device_aspect * impl->width >= impl->height)
1997-11-24 22:37:52 +00:00
{
/* device taller than window */
x_scale = impl->width / device_width;
1997-11-24 22:37:52 +00:00
y_scale = (x_scale * gdkdev->axes[x_axis].resolution)
/ gdkdev->axes[y_axis].resolution;
x_offset = 0;
y_offset = -(device_height * y_scale -
impl->height)/2;
1997-11-24 22:37:52 +00:00
}
else
{
/* window taller than device */
y_scale = impl->height / device_height;
1997-11-24 22:37:52 +00:00
x_scale = (y_scale * gdkdev->axes[y_axis].resolution)
/ gdkdev->axes[x_axis].resolution;
y_offset = 0;
x_offset = - (device_width * x_scale - impl->width)/2;
1997-11-24 22:37:52 +00:00
}
}
for (i=0; i<gdkdev->info.num_axes; i++)
1997-11-24 22:37:52 +00:00
{
switch (gdkdev->info.axes[i].use)
1997-11-24 22:37:52 +00:00
{
case GDK_AXIS_X:
axis_out[i] = x_offset + x_scale*axis_data[x_axis];
if (x_out)
*x_out = axis_out[i];
break;
case GDK_AXIS_Y:
axis_out[i] = y_offset + y_scale*axis_data[y_axis];
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
* 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);
}
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
gint
gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
1997-11-24 22:37:52 +00:00
GdkDevicePrivate *gdkdev)
{
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);
}
event->button.device = &gdkdev->info;
1997-11-24 22:37:52 +00:00
event->button.window = input_window->window;
event->button.time = xdbe->time;
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,
event->button.axes,
&event->button.x,&event->button.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;
GDK_NOTE (EVENTS,
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,
xdbe->button));
1997-11-24 22:37:52 +00:00
return TRUE;
}
if ((xevent->type == gdkdev->keypress_type) ||
(xevent->type == gdkdev->keyrelease_type))
{
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
GDK_NOTE (EVENTS,
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
(event->key.type == GDK_KEY_PRESS) ? "press" : "release",
xdke->window,
xdke->deviceid,
xdke->keycode));
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;
if (event->key.keyval == 0)
{
GDK_NOTE (EVENTS,
g_print ("\t\ttranslation - NONE\n"));
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;
/* 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);
}
GDK_NOTE (EVENTS,
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
event->key.keyval,
event->key.state));
return TRUE;
}
1997-11-24 22:37:52 +00:00
if (xevent->type == gdkdev->motionnotify_type)
{
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
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,
event->motion.axes,
&event->motion.x,&event->motion.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);
event->motion.is_hint = xdme->is_hint;
1997-11-24 22:37:52 +00:00
GDK_NOTE (EVENTS,
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,
event->motion.state,
(xdme->is_hint) ? "true" : "false"));
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);
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;
return TRUE;
}
return -1; /* wasn't one of our event types */
}
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
{
GdkTimeCoord **coords;
1997-11-24 22:37:52 +00:00
XDeviceTimeCoord *device_coords;
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
gint mode_return;
gint axis_count_return;
gint i;
1997-11-24 22:37:52 +00:00
gdkdev = (GdkDevicePrivate *)device;
1997-11-24 22:37:52 +00:00
input_window = gdk_input_window_find (window);
g_return_val_if_fail (input_window != NULL, FALSE);
1997-11-24 22:37:52 +00:00
device_coords = XGetDeviceMotionEvents (gdk_display,
gdkdev->xdevice,
start, stop,
n_events, &mode_return,
1997-11-24 22:37:52 +00:00
&axis_count_return);
if (device_coords)
{
coords = _gdk_device_allocate_history (device, *n_events);
1997-11-24 22:37:52 +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);
*events = coords;
return TRUE;
1997-11-24 22:37:52 +00:00
}
else
{
*events = NULL;
*n_events = 0;
return FALSE;
}
1997-11-24 22:37:52 +00:00
}
Move all X specific code into the x11/ directory. Aside from shuffling Mon Nov 8 14:47:04 1999 Owen Taylor <otaylor@redhat.com> Move all X specific code into the x11/ directory. Aside from shuffling things around, did the following: * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add gdk_arg_context_* - a simple argument parsing system in the style of popt. * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch] gdk/x11/gdkprivate-x11.h: Remove X specific stuff from GdkDrawable and GdkWindowPrivate - add ->klass and ->klass_data fields. The klass_data field points to an auxilliary structure that is windowing system dependent. * gdk/gdkfont.c: Make most of the measurement functions simply wrappers around gdk_text_extents(). * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a _gdk_font_strlen() function that hides the weird behavior in gtk+-1.[02] where a string is interpreted differently for 8-bit and 16-bit fonts. * gdk/gdkevents.c: Add a new function gdk_event_button_generate() to store common code for synthesizing double/triple press events. * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h. Make all the function that modify an existing GC simply wrappers around gdk_gc_set_values(). * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation for throwing out later. * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate, GdkImagePrivate and GdkColormapPrivate to have a windowing system dependent part (GdkFontPrivateX etc.) that "derives" from the system-independent part. * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c: Got rid of the included-source-files for XInput in favor of automake conditionals. (Which didn't exist when XInput support was originally added.) * gdk/gdkrgb.c: Remove the visual id from the debugging statements since that is X11 specific; print out type/depth info instead.
1999-11-08 20:14:59 +00:00
void
gdk_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
1997-11-24 22:37:52 +00:00
{
gint i;
g_return_if_fail (device != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
1997-11-24 22:37:52 +00:00
if (GDK_IS_CORE (device))
1997-11-24 22:37:52 +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);
if (axes)
{
axes[0] = x_int;
axes[1] = y_int;
}
1997-11-24 22:37:52 +00:00
}
else
{
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);
gdkdev = (GdkDevicePrivate *)device;
1997-11-24 22:37:52 +00:00
input_window = gdk_input_window_find (window);
g_return_if_fail (input_window != NULL);
state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
input_class = state->data;
for (i=0; i<state->num_classes; i++)
{
switch (input_class->class)
{
case ValuatorClass:
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)
{
*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);
}
XFreeDeviceState (state);
1997-11-24 22:37:52 +00:00
}
}