Ignore calls with <= width or height.

Mon Jul  3 14:24:16 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
	<= width or height.

	* gtk/gtktable.c (gtk_table_attach): Fix missed merge
	from 1.2 for parent/child states.

	* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
	of typos.

	* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
	event structures, replace with a generic axes field. Replace
	deviceid/source with GdkDevice *device.

	* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
	to extract particular axis use value from event. (Also
	can be used for normal X/Y.)

	* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
	allow for arbitrary number of axes, namespace everything
	as gdk_device_*. Replace guint32 deviceid with GdkDevice *
	everywhere.

	* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
	Get rid of the gdk_input_vtable setup if favor of simply
	defining the functions in gdkinput-none/gxi/xfree.c in
	a similar fashion to the way that the port structure is
	done.

	* gtk/gtkdnd.c: Fix fields of synthesized button press event
	for new event structures.

	* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
	new device interfaces.
This commit is contained in:
Owen Taylor
2000-07-03 19:00:23 +00:00
committed by Owen Taylor
parent 0c2240ba37
commit 01212ce170
26 changed files with 1224 additions and 1080 deletions

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -1,3 +1,39 @@
Mon Jul 3 14:24:16 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_draw): Ignore calls with
<= width or height.
* gtk/gtktable.c (gtk_table_attach): Fix missed merge
from 1.2 for parent/child states.
* gdk/gdkgc.c (gdk_gc_set_rgb_fg/bg_color): Fix a couple
of typos.
* gdk/gdkevents.[ch]: Remove press/xtilt/ytilt fields of
event structures, replace with a generic axes field. Replace
deviceid/sourec with GdkDevice *device.
* gdk/gdkevents.[ch] (gdk_event_get_axis): Add function
to extract particular axis use value from event. (Also
can be used for normal X/Y.)
* gdk/gdkinput.h gdk/x11/gdkinput*: Major revision;
allow for arbitrary number of axes, namespace everything
as gdk_device_*. Replace guint32 deviceid with GdkDevice *
everywhere.
* gdk/x11/{gdkmain-x11.c,gdkevent-x11.c,gdkinput*}:
Get rid of the gdk_input_vtable setup if favor of simply
defining the functions in gdkinput-none/gxi/xfree.c in
a similar fashion to the way that the port structure is
done.
* gtk/gtkdnd.c: Fix fields of synthesized button press event
for new event structures.
* gtk/gtkinputdialog.c gtk/testinput.c: Revise to match
new device interfaces.
Sun Jul 2 18:19:50 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (gtk_widget_create_pango_layout): Add a 'text' argument to

View File

@ -377,6 +377,17 @@ gdk_event_free (GdkEvent *event)
case GDK_DROP_FINISHED:
gdk_drag_context_unref (event->dnd.context);
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
g_free (event->button.axes);
break;
case GDK_MOTION_NOTIFY:
if (event->motion.axes)
g_free (event->motion.axes);
break;
default:
break;
@ -440,6 +451,80 @@ gdk_event_get_time (GdkEvent *event)
return GDK_CURRENT_TIME;
}
/**
* gdk_event_get_axis:
* @event: a #GdkEvent
* @axis_use: the axis use to look for
* @value: location to store the value found
*
* Extract the axis value for a particular axis use from
* an event structure.
*
* Return value: %TRUE if the specified axis was found, otherwise %FALSE
**/
gboolean
gdk_event_get_axis (GdkEvent *event,
GdkAxisUse axis_use,
gdouble *value)
{
gdouble *axes;
GdkDevice *device;
g_return_val_if_fail (event != NULL, FALSE);
if (axis_use == GDK_AXIS_X || axis_use == GDK_AXIS_Y)
{
gdouble x, y;
switch (event->type)
{
case GDK_MOTION_NOTIFY:
x = event->motion.x;
y = event->motion.y;
break;
case GDK_SCROLL:
x = event->scroll.x;
y = event->scroll.y;
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
x = event->button.x;
y = event->button.y;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
x = event->crossing.x;
y = event->crossing.y;
break;
default:
return FALSE;
}
if (axis_use == GDK_AXIS_X && value)
*value = x;
if (axis_use == GDK_AXIS_Y && value)
*value = y;
return TRUE;
}
else if (event->type == GDK_BUTTON_PRESS ||
event->type == GDK_BUTTON_RELEASE)
{
device = event->button.device;
axes = event->button.axes;
}
else if (event->type == GDK_MOTION_NOTIFY)
{
device = event->motion.device;
axes = event->motion.axes;
}
else
return FALSE;
return gdk_device_get_axis (device, axes, axis_use, value);
}
/*
*--------------------------------------------------------------
* gdk_set_show_events

View File

@ -231,13 +231,10 @@ struct _GdkEventMotion
guint32 time;
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
gdouble *axes;
guint state;
gint16 is_hint;
GdkInputSource source;
guint32 deviceid;
GdkDevice *device;
gdouble x_root, y_root;
};
@ -249,13 +246,10 @@ struct _GdkEventButton
guint32 time;
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
gdouble *axes;
guint state;
guint button;
GdkInputSource source;
guint32 deviceid;
GdkDevice *device;
gdouble x_root, y_root;
};
@ -267,13 +261,9 @@ struct _GdkEventScroll
guint32 time;
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
guint state;
GdkScrollDirection direction;
GdkInputSource source;
guint32 deviceid;
GdkDevice *device;
gdouble x_root, y_root;
};
@ -355,8 +345,7 @@ struct _GdkEventProximity
GdkWindow *window;
gint8 send_event;
guint32 time;
GdkInputSource source;
guint32 deviceid;
GdkDevice *device;
};
struct _GdkEventClient
@ -416,6 +405,9 @@ void gdk_event_put (GdkEvent *event);
GdkEvent* gdk_event_copy (GdkEvent *event);
void gdk_event_free (GdkEvent *event);
guint32 gdk_event_get_time (GdkEvent *event);
gboolean gdk_event_get_axis (GdkEvent *event,
GdkAxisUse axis_use,
gdouble *value);
void gdk_event_handler_set (GdkEventFunc func,
gpointer data,

View File

@ -443,7 +443,7 @@ gdk_gc_set_rgb_fg_color (GdkGC *gc, GdkColor *color)
tmp_color = *color;
gdk_rgb_find_color (cmap, &tmp_color);
gdk_gc_set_foreground (cmap, &tmp_color);
gdk_gc_set_foreground (gc, &tmp_color);
}
/**
@ -474,5 +474,5 @@ gdk_gc_set_rgb_bg_color (GdkGC *gc, GdkColor *color)
tmp_color = *color;
gdk_rgb_find_color (cmap, &tmp_color);
gdk_gc_set_foreground (cmap, &tmp_color);
gdk_gc_set_foreground (gc, &tmp_color);
}

View File

@ -8,7 +8,8 @@ extern "C" {
#endif /* __cplusplus */
typedef struct _GdkDeviceKey GdkDeviceKey;
typedef struct _GdkDeviceInfo GdkDeviceInfo;
typedef struct _GdkDeviceAxis GdkDeviceAxis;
typedef struct _GdkDevice GdkDevice;
typedef struct _GdkTimeCoord GdkTimeCoord;
typedef enum
@ -41,66 +42,91 @@ typedef enum
GDK_AXIS_PRESSURE,
GDK_AXIS_XTILT,
GDK_AXIS_YTILT,
GDK_AXIS_WHEEL,
GDK_AXIS_LAST
} GdkAxisUse;
struct _GdkDeviceInfo
{
guint32 deviceid;
gchar *name;
GdkInputSource source;
GdkInputMode mode;
gint has_cursor; /* TRUE if the X pointer follows device motion */
gint num_axes;
GdkAxisUse *axes; /* Specifies use for each axis */
gint num_keys;
GdkDeviceKey *keys;
};
struct _GdkDeviceKey
{
guint keyval;
GdkModifierType modifiers;
};
struct _GdkDeviceAxis
{
GdkAxisUse use;
gdouble min;
gdouble max;
};
struct _GdkDevice
{
/* All fields are read-only */
gchar *name;
GdkInputSource source;
GdkInputMode mode;
gboolean has_cursor; /* TRUE if the X pointer follows device motion */
gint num_axes;
GdkDeviceAxis *axes;
gint num_keys;
GdkDeviceKey *keys;
};
/* We don't allocate each coordinate this big, but we use it to
* be ANSI compliant and avoid accessing past the defined limits.
*/
#define GDK_MAX_TIMECOORD_AXES 128
struct _GdkTimeCoord
{
guint32 time;
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
gdouble axes[GDK_MAX_TIMECOORD_AXES];
};
GList * gdk_input_list_devices (void);
void gdk_input_set_extension_events (GdkWindow *window,
gint mask,
GdkExtensionMode mode);
void gdk_input_set_source (guint32 deviceid,
GdkInputSource source);
gboolean gdk_input_set_mode (guint32 deviceid,
GdkInputMode mode);
void gdk_input_set_axes (guint32 deviceid,
GdkAxisUse *axes);
void gdk_input_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
void gdk_input_window_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
GdkTimeCoord *gdk_input_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
/* Returns a list of GdkDevice * */
GList * gdk_devices_list (void);
/* Functions to configure a device */
void gdk_device_set_source (GdkDevice *device,
GdkInputSource source);
gboolean gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode);
void gdk_device_set_key (GdkDevice *device,
guint index,
guint keyval,
GdkModifierType modifiers);
void gdk_device_set_axis_use (GdkDevice *device,
guint index,
GdkAxisUse use);
void gdk_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask);
gboolean gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
void gdk_device_free_history (GdkTimeCoord **events,
gint n_events);
gboolean gdk_device_get_axis (GdkDevice *device,
gdouble *axes,
GdkAxisUse use,
gdouble *value);
void gdk_input_set_extension_events (GdkWindow *window,
gint mask,
GdkExtensionMode mode);
extern GdkDevice *gdk_core_pointer;
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -283,10 +283,9 @@ gdk_event_translate (GdkEvent *event,
* some circumstances.
*/
if ((xevent->xany.window == None) &&
gdk_input_vtable.window_none_event)
if (xevent->xany.window == None)
{
return_val = gdk_input_vtable.window_none_event (event,xevent);
return_val = _gdk_input_window_none_event (event, xevent);
if (return_val >= 0) /* was handled */
return return_val;
@ -517,12 +516,8 @@ gdk_event_translate (GdkEvent *event,
event->scroll.y = xevent->xbutton.y + yoffset;
event->scroll.x_root = (gfloat)xevent->xbutton.x_root;
event->scroll.y_root = (gfloat)xevent->xbutton.y_root;
event->scroll.pressure = 0.5;
event->scroll.xtilt = 0;
event->scroll.ytilt = 0;
event->scroll.state = (GdkModifierType) xevent->xbutton.state;
event->scroll.source = GDK_SOURCE_MOUSE;
event->scroll.deviceid = GDK_CORE_POINTER;
event->scroll.device = gdk_core_pointer;
}
else
{
@ -533,13 +528,10 @@ gdk_event_translate (GdkEvent *event,
event->button.y = xevent->xbutton.y + yoffset;
event->button.x_root = (gfloat)xevent->xbutton.x_root;
event->button.y_root = (gfloat)xevent->xbutton.y_root;
event->button.pressure = 0.5;
event->button.xtilt = 0;
event->button.ytilt = 0;
event->button.axes = NULL;
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
event->button.source = GDK_SOURCE_MOUSE;
event->button.deviceid = GDK_CORE_POINTER;
event->button.device = gdk_core_pointer;
gdk_event_button_generate (event);
}
@ -575,13 +567,10 @@ gdk_event_translate (GdkEvent *event,
event->button.y = xevent->xbutton.y + yoffset;
event->button.x_root = (gfloat)xevent->xbutton.x_root;
event->button.y_root = (gfloat)xevent->xbutton.y_root;
event->button.pressure = 0.5;
event->button.xtilt = 0;
event->button.ytilt = 0;
event->button.axes = NULL;
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
event->button.source = GDK_SOURCE_MOUSE;
event->button.deviceid = GDK_CORE_POINTER;
event->button.device = gdk_core_pointer;
break;
@ -607,13 +596,10 @@ gdk_event_translate (GdkEvent *event,
event->motion.y = xevent->xmotion.y + yoffset;
event->motion.x_root = (gfloat)xevent->xmotion.x_root;
event->motion.y_root = (gfloat)xevent->xmotion.y_root;
event->motion.pressure = 0.5;
event->motion.xtilt = 0;
event->motion.ytilt = 0;
event->motion.axes = NULL;
event->motion.state = (GdkModifierType) xevent->xmotion.state;
event->motion.is_hint = xevent->xmotion.is_hint;
event->motion.source = GDK_SOURCE_MOUSE;
event->motion.deviceid = GDK_CORE_POINTER;
event->motion.device = gdk_core_pointer;
break;
@ -627,9 +613,8 @@ gdk_event_translate (GdkEvent *event,
/* Tell XInput stuff about it if appropriate */
if (window_private &&
!GDK_WINDOW_DESTROYED (window) &&
(window_private->extension_events != 0) &&
gdk_input_vtable.enter_event)
gdk_input_vtable.enter_event (&xevent->xcrossing, window);
window_private->extension_events != 0)
_gdk_input_enter_event (&xevent->xcrossing, window);
event->crossing.type = GDK_ENTER_NOTIFY;
event->crossing.window = window;
@ -999,9 +984,8 @@ gdk_event_translate (GdkEvent *event,
: ""));
if (window &&
!GDK_WINDOW_DESTROYED (window) &&
(window_private->extension_events != 0) &&
gdk_input_vtable.configure_event)
gdk_input_vtable.configure_event (&xevent->xconfigure, window);
(window_private->extension_events != 0))
_gdk_input_configure_event (&xevent->xconfigure, window);
if (!window || GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
return_val = FALSE;
@ -1180,9 +1164,8 @@ gdk_event_translate (GdkEvent *event,
if (window_private &&
!GDK_WINDOW_DESTROYED (window_private) &&
(window_private->extension_events != 0) &&
gdk_input_vtable.other_event)
return_val = gdk_input_vtable.other_event(event, xevent, window);
(window_private->extension_events != 0))
return_val = _gdk_input_other_event(event, xevent, window);
else
return_val = FALSE;

View File

@ -35,45 +35,13 @@
/* Forward declarations */
static void gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev);
static gint gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode);
static gint gdk_input_is_extension_device (guint32 deviceid);
static void gdk_input_gxi_configure_event (XConfigureEvent *xevent,
GdkWindow *window);
static void gdk_input_gxi_enter_event (XCrossingEvent *xevent,
GdkWindow *window);
static gint gdk_input_gxi_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window);
static gint gdk_input_is_extension_device (GdkDevicePrivate *device_private);
static void gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev);
static gint gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent);
static gint gdk_input_gxi_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_gxi_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
static Window gdk_input_find_root_child(Display *dpy, Window w);
static void gdk_input_compute_obscuring(GdkInputWindow *input_window);
static gint gdk_input_is_obscured(GdkInputWindow *input_window, gdouble x,
gdouble y);
static GdkTimeCoord *gdk_input_gxi_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
static void gdk_input_gxi_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
static gint gdk_input_gxi_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
static void gdk_input_gxi_ungrab_pointer (guint32 time);
/* Local variables */
@ -85,20 +53,6 @@ gdk_input_init(void)
{
GList *tmp_list;
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;
gdk_input_vtable.ungrab_pointer = gdk_input_gxi_ungrab_pointer;
gdk_input_vtable.configure_event = gdk_input_gxi_configure_event;
gdk_input_vtable.enter_event = gdk_input_gxi_enter_event;
gdk_input_vtable.other_event = gdk_input_gxi_other_event;
gdk_input_vtable.window_none_event = gdk_input_gxi_window_none_event;
gdk_input_vtable.enable_window = gdk_input_gxi_enable_window;
gdk_input_vtable.disable_window = gdk_input_gxi_disable_window;
gdk_input_ignore_core = FALSE;
gdk_input_core_pointer = NULL;
@ -120,13 +74,13 @@ gdk_input_init(void)
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdk_input_is_extension_device(gdkdev->info.deviceid))
if (gdk_input_is_extension_device (gdkdev))
{
gdk_input_gxi_select_notify (gdkdev);
}
else
{
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
if (!GDK_IS_CORE (gdkdev))
gdk_input_core_pointer = gdkdev;
}
}
@ -146,19 +100,26 @@ gdk_input_gxi_select_notify (GdkDevicePrivate *gdkdev)
static gint
gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
{
int x_axis,y_axis;
gint x_axis = -1;
gint y_axis = -1;
gint i;
g_return_val_if_fail(gdkdev->xdevice,FALSE);
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
g_return_val_if_fail(x_axis != -1 && y_axis != -1,FALSE);
for (i=0; i<gdkdev->info.num_axes; i++)
{
if (gdkdev->info.axes[i].use == GDK_AXIS_X)
x_axis = i;
else if (gdkdev->info.axes[i].use == GDK_AXIS_Y)
y_axis = i;
}
g_return_val_if_fail (x_axis != -1 && y_axis != -1,FALSE);
/* core_pointer might not be up to date so we check with the server
before change the pointer */
if ( !gdk_input_is_extension_device(gdkdev->info.deviceid) )
if (!gdk_input_is_extension_device (gdkdev))
{
#if 0
if (gdkdev != gdk_input_core_pointer)
@ -181,24 +142,27 @@ gdk_input_gxi_set_core_pointer(GdkDevicePrivate *gdkdev)
}
/* FIXME, merge with gdk_input_xfree_set_mode */
/* FIXME, merge with the XFree implementation */
static gint
gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
gboolean
gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
GdkInputMode old_mode;
GdkInputWindow *input_window;
gdkdev = gdk_input_find_device(deviceid);
g_return_val_if_fail (gdkdev != NULL,FALSE);
old_mode = gdkdev->info.mode;
if (GDK_IS_CORE (device))
return FALSE;
if (gdkdev->info.mode == mode)
gdkdev = (GdkDevicePrivate *)device;
if (device->mode == mode)
return TRUE;
gdkdev->info.mode = mode;
old_mode = device->mode;
device->mode = mode;
if (old_mode != GDK_MODE_DISABLED)
{
@ -206,7 +170,7 @@ gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
gdk_input_disable_window (input_window->window, gdkdev);
_gdk_input_disable_window (input_window->window, gdkdev);
}
}
@ -216,31 +180,31 @@ gdk_input_gxi_set_mode (guint32 deviceid, GdkInputMode mode)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
if (!gdk_input_enable_window(input_window->window, gdkdev))
if (!_gdk_input_enable_window(input_window->window, gdkdev))
{
gdk_input_set_mode(deviceid, old_mode);
gdk_device_set_mode (device, old_mode);
return FALSE;
}
}
}
return TRUE;
}
gint
gdk_input_is_extension_device (guint32 deviceid)
gdk_input_is_extension_device (GdkDevicePrivate *private)
{
XDeviceInfo *devices;
int num_devices, loop;
if (deviceid == GDK_CORE_POINTER)
if (GDK_IS_CORE (private))
return FALSE;
devices = XListInputDevices(gdk_display, &num_devices);
for(loop=0; loop<num_devices; loop++)
{
if ((devices[loop].id == deviceid) && (devices[loop].use == IsXExtensionDevice))
if ((devices[loop].id == private->deviceid) &&
(devices[loop].use == IsXExtensionDevice))
{
XFreeDeviceList(devices);
return TRUE;
@ -251,8 +215,8 @@ gdk_input_is_extension_device (guint32 deviceid)
return FALSE;
}
static void
gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
void
_gdk_input_configure_event (XConfigureEvent *xevent, GdkWindow *window)
{
GdkInputWindow *input_window;
gint root_x, root_y;
@ -267,8 +231,8 @@ gdk_input_gxi_configure_event (XConfigureEvent *xevent, GdkWindow *window)
gdk_input_compute_obscuring(input_window);
}
static void
gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
void
_gdk_input_enter_event (XCrossingEvent *xevent, GdkWindow *window)
{
GdkInputWindow *input_window;
@ -278,28 +242,32 @@ gdk_input_gxi_enter_event (XCrossingEvent *xevent, GdkWindow *window)
gdk_input_compute_obscuring(input_window);
}
static gint
gdk_input_gxi_other_event (GdkEvent *event,
gint
_gdk_input_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
GdkWindowImplX11 *impl;
GdkDevicePrivate *gdkdev;
gint return_val;
input_window = gdk_input_window_find(window);
g_return_val_if_fail (window != NULL, -1);
impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *) input_window->window)->impl);
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
but it's potentially faster than scanning through the types of
every device. If we were deceived, then it won't match any of
the types for the device anyways */
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
if (!gdkdev) {
return -1; /* we don't handle it - not an XInput event */
}
if (!gdkdev)
{
return -1; /* we don't handle it - not an XInput event */
}
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
input_window->mode == GDK_EXTENSION_EVENTS_CURSOR)
@ -317,8 +285,8 @@ gdk_input_gxi_other_event (GdkEvent *event,
if (return_val > 0 && event->type == GDK_MOTION_NOTIFY &&
(!gdkdev->button_state) && (!input_window->grabbed) &&
((event->motion.x < 0) || (event->motion.y < 0) ||
(event->motion.x > ((GdkDrawablePrivate *)window)->width) ||
(event->motion.y > ((GdkDrawablePrivate *)window)->height) ||
(event->motion.x > impl->width) ||
(event->motion.y > impl->height) ||
gdk_input_is_obscured(input_window,event->motion.x,event->motion.y)))
{
#ifdef DEBUG_SWITCHING
@ -341,11 +309,11 @@ gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
{
GList *t;
if (gdk_input_is_extension_device (gdkdev->info.deviceid))
if (gdk_input_is_extension_device (gdkdev))
{
if (!gdkdev->xdevice)
{
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->deviceid);
gdk_input_gxi_select_notify (gdkdev);
gdkdev->needs_update = 1;
}
@ -359,8 +327,8 @@ gdk_input_gxi_update_device (GdkDevicePrivate *gdkdev)
}
}
static gint
gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
gint
_gdk_input_window_none_event (GdkEvent *event, XEvent *xevent)
{
GdkDevicePrivate *gdkdev =
gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
@ -386,8 +354,8 @@ gdk_input_gxi_window_none_event (GdkEvent *event, XEvent *xevent)
return FALSE;
}
static gint
gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
gboolean
_gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
GdkInputWindow *input_window;
@ -397,7 +365,7 @@ gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
if (!gdkdev->claimed)
{
if (gxid_claim_device(gdk_input_gxid_host, gdk_input_gxid_port,
gdkdev->info.deviceid,
gdkdev->deviceid,
GDK_WINDOW_XWINDOW(window), FALSE) !=
GXID_RETURN_OK)
{
@ -415,8 +383,8 @@ gdk_input_gxi_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
return TRUE;
}
static gint
gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
gboolean
_gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
{
GdkInputWindow *input_window;
@ -426,7 +394,7 @@ gdk_input_gxi_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
if (gdkdev->claimed)
{
gxid_release_device(gdk_input_gxid_host, gdk_input_gxid_port,
gdkdev->info.deviceid,
gdkdev->deviceid,
GDK_WINDOW_XWINDOW(window));
gdkdev->claimed = FALSE;
@ -478,7 +446,7 @@ gdk_input_find_root_child(Display *dpy, Window w)
return w;
}
void
static void
gdk_input_compute_obscuring(GdkInputWindow *input_window)
{
int i;
@ -549,57 +517,12 @@ gdk_input_compute_obscuring(GdkInputWindow *input_window)
XFree(children);
}
static void
gdk_input_gxi_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
{
GdkDevicePrivate *gdkdev;
gdkdev = gdk_input_find_device (deviceid);
g_return_if_fail (gdkdev != NULL);
if (gdkdev == gdk_input_core_pointer)
gdk_input_common_get_pointer (window, GDK_CORE_POINTER, x, y,
pressure, xtilt, ytilt, mask);
else
gdk_input_common_get_pointer (window, deviceid, x, y,
pressure, xtilt, ytilt, mask);
}
static GdkTimeCoord *
gdk_input_gxi_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return)
{
GdkDevicePrivate *gdkdev;
gdkdev = gdk_input_find_device (deviceid);
g_return_val_if_fail (gdkdev != NULL, NULL);
if (gdkdev == gdk_input_core_pointer)
return gdk_input_motion_events (window, GDK_CORE_POINTER, start, stop,
nevents_return);
else
return gdk_input_common_motion_events (window, deviceid, start, stop,
nevents_return);
}
static gint
gdk_input_gxi_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
gint
_gdk_input_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
{
GList *tmp_list;
GdkInputWindow *input_window;
@ -622,7 +545,7 @@ gdk_input_gxi_grab_pointer (GdkWindow * window,
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
if (!GDK_IS_CORE (gdkdev) &&
gdkdev->xdevice &&
(gdkdev->button_state != 0))
gdkdev->button_state = 0;
@ -633,8 +556,8 @@ gdk_input_gxi_grab_pointer (GdkWindow * window,
return Success;
}
static void
gdk_input_gxi_ungrab_pointer (guint32 time)
void
_gdk_input_ungrab_pointer (guint32 time)
{
GdkInputWindow *input_window;
GList *tmp_list;

View File

@ -26,54 +26,104 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
static void gdk_input_none_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
void
gdk_input_init (void)
{
gdk_input_vtable.set_mode = NULL;
gdk_input_vtable.set_axes = NULL;
gdk_input_vtable.set_key = NULL;
gdk_input_vtable.motion_events = NULL;
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
gdk_input_vtable.grab_pointer = NULL;
gdk_input_vtable.ungrab_pointer = NULL;
gdk_input_vtable.configure_event = NULL;
gdk_input_vtable.enter_event = NULL;
gdk_input_vtable.other_event = NULL;
gdk_input_vtable.window_none_event = NULL;
gdk_input_vtable.enable_window = NULL;
gdk_input_vtable.disable_window = NULL;
gdk_input_devices = g_list_append (NULL, (GdkDeviceInfo *) &gdk_input_core_info);
gdk_input_devices = g_list_append (NULL, gdk_core_pointer);
gdk_input_ignore_core = FALSE;
}
static void
gdk_input_none_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
void
gdk_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
{
gint x_int, y_int;
g_return_if_fail (device != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
gdk_window_get_pointer (window, &x_int, &y_int, mask);
if (x) *x = x_int;
if (y) *y = y_int;
if (pressure) *pressure = 0.5;
if (xtilt) *xtilt = 0;
if (ytilt) *ytilt = 0;
if (axes)
{
axes[0] = x_int;
axes[1] = y_int;
}
}
gboolean
_gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
g_warning ("gdk_device_get_history() called for invalid device");
return FALSE;
}
gboolean
_gdk_input_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
return TRUE;
}
gboolean
_gdk_input_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
return TRUE;
}
gint
_gdk_input_window_none_event (GdkEvent *event,
XEvent *xevent)
{
return -1;
}
gint
_gdk_input_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window)
{
return -1;
}
void
_gdk_input_configure_event (XConfigureEvent *xevent,
GdkWindow *window)
{
}
void
_gdk_input_enter_event (XCrossingEvent *xevent,
GdkWindow *window)
{
}
gint
_gdk_input_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
{
return Success;
}
void
_gdk_input_ungrab_pointer (guint32 time)
{
}
gboolean
gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode)
{
return FALSE;
}

View File

@ -27,6 +27,7 @@
#include "gdkinputprivate.h"
#include "gdkinternals.h"
#include "gdkx.h"
#include "gdk.h" /* For gdk_error_trap_push()/pop() */
#include <string.h>
@ -34,56 +35,49 @@
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 *x, gdouble *y,
gdouble *pressure,
gdouble *xtilt, gdouble *ytilt);
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);
void gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
/* Global variables */
static gint gdk_input_root_width;
static gint gdk_input_root_height;
GdkDevicePrivate *
gdk_input_find_device (guint32 id)
{
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;
}
void
gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_ret,
int *width_ret, int *height_ret)
int *width_ret, int *height_ret)
{
Window root,parent;
Window root, parent, child;
Window *children;
guint nchildren;
gint x,y;
guint width, height;
gint xc,yc;
guint widthc,heightc,border_widthc,depthc;
guint border_widthc, depthc;
XQueryTree (dpy, w, &root, &parent, &children, &nchildren);
if (children)
XFree(children);
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
if (children) XFree(children);
XGetGeometry(dpy,w,&root,&x,&y,&width,&height,&border_widthc,
&depthc);
x += border_widthc;
y += border_widthc;
while (root != parent)
{
w = parent;
XQueryTree(dpy,w,&root,&parent,&children,&nchildren);
if (children) XFree(children);
XGetGeometry(dpy,w,&root,&xc,&yc,&widthc,&heightc,
&border_widthc,&depthc);
x += xc + border_widthc;
y += yc + border_widthc;
}
XGetGeometry (dpy, w, &root, &x, &y, &width, &height, &border_widthc, &depthc);
XTranslateCoordinates (dpy, w, root, 0, 0, &x, &y, &child);
if (x_ret)
*x_ret = x;
if (y_ret)
@ -95,26 +89,22 @@ gdk_input_get_root_relative_geometry(Display *dpy, Window w, int *x_ret, int *y_
}
static GdkDevicePrivate *
gdk_input_device_new(XDeviceInfo *device, gint include_core)
gdk_input_device_new (XDeviceInfo *device, gint include_core)
{
GdkDevicePrivate *gdkdev;
gchar *tmp_name, *p;
gchar *tmp_name;
XAnyClassPtr class;
gint i,j;
gdkdev = g_new(GdkDevicePrivate,1);
gdkdev->info.deviceid = device->id;
if (device->name[0]) {
gdkdev->info.name = g_new(char, strlen(device->name)+1);
strcpy(gdkdev->info.name,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");
strcpy(gdkdev->info.name,"pointer");
gdkdev->info.source = GDK_SOURCE_MOUSE;
}
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");
gdkdev->info.mode = GDK_MODE_DISABLED;
@ -122,12 +112,8 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
could invite a very, very, long list... Lowercase name
for comparison purposes */
tmp_name = g_strdup(gdkdev->info.name);
for (p = tmp_name; *p; p++)
{
if (*p >= 'A' && *p <= 'Z')
*p += 'a' - 'A';
}
tmp_name = g_strdup (gdkdev->info.name);
g_strdown (tmp_name);
if (!strcmp (tmp_name, "pointer"))
gdkdev->info.source = GDK_SOURCE_MOUSE;
@ -162,9 +148,7 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
{
switch (class->class) {
case ButtonClass:
{
break;
}
break;
case KeyClass:
{
XKeyInfo *xki = (XKeyInfo *)class;
@ -195,8 +179,8 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
{
XValuatorInfo *xvi = (XValuatorInfo *)class;
gdkdev->info.num_axes = xvi->num_axes;
gdkdev->axes = g_new(GdkAxisInfo, xvi->num_axes);
gdkdev->info.axes = g_new(GdkAxisUse, xvi->num_axes);
gdkdev->axes = g_new (GdkAxisInfo, xvi->num_axes);
gdkdev->info.axes = g_new0 (GdkDeviceAxis, xvi->num_axes);
for (j=0;j<xvi->num_axes;j++)
{
gdkdev->axes[j].resolution =
@ -205,27 +189,21 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
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] = GDK_AXIS_IGNORE;
gdkdev->info.axes[j].use = GDK_AXIS_IGNORE;
}
j=0;
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_X;
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_X);
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_Y;
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_Y);
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_PRESSURE;
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_PRESSURE);
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_XTILT;
gdk_device_set_axis_use (&gdkdev->info, j++, GDK_AXIS_XTILT);
if (j<xvi->num_axes)
gdkdev->info.axes[j++] = GDK_AXIS_YTILT;
/* set up reverse lookup on axis use */
for (j=GDK_AXIS_IGNORE;j<GDK_AXIS_LAST;j++)
gdkdev->axis_for_use[j] = -1;
for (j=0;j<xvi->num_axes;j++)
if (gdkdev->info.axes[j] != GDK_AXIS_IGNORE)
gdkdev->axis_for_use[gdkdev->info.axes[j]] = j;
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);
break;
}
@ -235,41 +213,16 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
/* return NULL if no axes */
if (!gdkdev->info.num_axes || !gdkdev->axes ||
(!include_core && device->use == IsXPointer))
{
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_free(gdkdev);
return NULL;
}
goto error;
if (device->use != IsXPointer)
{
int error_warn = gdk_error_warnings;
gdk_error_warnings = 0;
gdk_error_code = 0;
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
gdk_error_warnings = error_warn;
gdk_error_trap_push ();
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->deviceid);
/* return NULL if device is not ready */
if (gdk_error_code)
{
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_free (gdkdev);
return NULL;
}
if (gdk_error_trap_pop ())
goto error;
}
gdkdev->buttonpress_type = 0;
@ -282,6 +235,19 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
gdkdev->changenotify_type = 0;
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_free (gdkdev);
return NULL;
}
void
@ -414,12 +380,6 @@ gdk_input_common_init(gint include_core)
int num_extensions, loop;
Display *display = gdk_display;
/* Init global vars */
gdk_window_get_geometry(NULL, /* use root window */
NULL,NULL,
&gdk_input_root_width,&gdk_input_root_height,
NULL);
/* Init XInput extension */
extensions = XListExtensions(display, &num_extensions);
@ -443,33 +403,44 @@ gdk_input_common_init(gint include_core)
XFreeDeviceList(devices);
}
gdk_input_devices = g_list_append (gdk_input_devices, (gpointer)&gdk_input_core_info);
gdk_input_devices = g_list_append (gdk_input_devices, gdk_core_pointer);
return TRUE;
}
static void
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
GdkInputWindow *input_window,
gint *axis_data,
gdouble *x, gdouble *y, gdouble *pressure,
gdouble *xtilt, gdouble *ytilt)
GdkInputWindow *input_window,
gint *axis_data,
gdouble *axis_out,
gdouble *x_out,
gdouble *y_out)
{
GdkWindowImplX11 *impl;
int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis;
int i;
int x_axis = 0;
int y_axis = 0;
double device_width, device_height;
double x_offset, y_offset, x_scale, y_scale;
impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *) input_window->window)->impl);
x_axis = gdkdev->axis_for_use[GDK_AXIS_X];
y_axis = gdkdev->axis_for_use[GDK_AXIS_Y];
pressure_axis = gdkdev->axis_for_use[GDK_AXIS_PRESSURE];
xtilt_axis = gdkdev->axis_for_use[GDK_AXIS_XTILT];
ytilt_axis = gdkdev->axis_for_use[GDK_AXIS_YTILT];
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;
}
}
device_width = gdkdev->axes[x_axis].max_value -
gdkdev->axes[x_axis].min_value;
device_height = gdkdev->axes[y_axis].max_value -
@ -477,8 +448,8 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
if (gdkdev->info.mode == GDK_MODE_SCREEN)
{
x_scale = gdk_input_root_width / device_width;
y_scale = gdk_input_root_height / device_height;
x_scale = gdk_screen_width() / device_width;
y_scale = gdk_screen_height() / device_height;
x_offset = - input_window->root_x;
y_offset = - input_window->root_y;
@ -510,54 +481,37 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
x_offset = - (device_width * x_scale - impl->width)/2;
}
}
if (x) *x = x_offset + x_scale*axis_data[x_axis];
if (y) *y = y_offset + y_scale*axis_data[y_axis];
if (pressure)
for (i=0; i<gdkdev->info.num_axes; i++)
{
if (pressure_axis != -1)
*pressure = ((double)axis_data[pressure_axis]
- gdkdev->axes[pressure_axis].min_value)
/ (gdkdev->axes[pressure_axis].max_value
- gdkdev->axes[pressure_axis].min_value);
else
*pressure = 0.5;
}
if (xtilt)
{
if (xtilt_axis != -1)
switch (gdkdev->info.axes[i].use)
{
*xtilt = 2. * (double)(axis_data[xtilt_axis] -
(gdkdev->axes[xtilt_axis].min_value +
gdkdev->axes[xtilt_axis].max_value)/2) /
(gdkdev->axes[xtilt_axis].max_value -
gdkdev->axes[xtilt_axis].min_value);
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;
}
else *xtilt = 0;
}
if (ytilt)
{
if (ytilt_axis != -1)
{
*ytilt = 2. * (double)(axis_data[ytilt_axis] -
(gdkdev->axes[ytilt_axis].min_value +
gdkdev->axes[ytilt_axis].max_value)/2) /
(gdkdev->axes[ytilt_axis].max_value -
gdkdev->axes[ytilt_axis].min_value);
}
else
*ytilt = 0;
}
}
/* 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. */
* 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.
*/
static guint
gdk_input_translate_state(guint state, guint device_state)
{
@ -586,16 +540,14 @@ gdk_input_common_other_event (GdkEvent *event,
event->button.type = GDK_BUTTON_RELEASE;
gdkdev->button_state &= ~(1 << xdbe->button);
}
event->button.device = &gdkdev->info;
event->button.window = input_window->window;
event->button.time = xdbe->time;
event->button.source = gdkdev->info.source;
event->button.deviceid = xdbe->deviceid;
event->button.axes = g_new (gdouble, gdkdev->info.num_axes);
gdk_input_translate_coordinates (gdkdev,input_window, xdbe->axis_data,
&event->button.x,&event->button.y,
&event->button.pressure,
&event->button.xtilt,
&event->button.ytilt);
event->button.axes,
&event->button.x,&event->button.y);
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
event->button.button = xdbe->button;
@ -674,21 +626,19 @@ gdk_input_common_other_event (GdkEvent *event,
{
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
event->motion.device = &gdkdev->info;
event->motion.axes = g_new (gdouble, gdkdev->info.num_axes);
gdk_input_translate_coordinates(gdkdev,input_window,xdme->axis_data,
&event->motion.x,&event->motion.y,
&event->motion.pressure,
&event->motion.xtilt,
&event->motion.ytilt);
event->motion.axes,
&event->motion.x,&event->motion.y);
event->motion.type = GDK_MOTION_NOTIFY;
event->motion.window = input_window->window;
event->motion.time = xdme->time;
event->motion.deviceid = xdme->deviceid;
event->motion.state = gdk_input_translate_state(xdme->state,
xdme->device_state);
event->motion.is_hint = xdme->is_hint;
event->motion.source = gdkdev->info.source;
event->motion.deviceid = xdme->deviceid;
GDK_NOTE (EVENTS,
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
@ -707,12 +657,11 @@ gdk_input_common_other_event (GdkEvent *event,
{
XProximityNotifyEvent *xpne = (XProximityNotifyEvent *)(xevent);
event->proximity.device = &gdkdev->info;
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;
event->proximity.source = gdkdev->info.source;
event->proximity.deviceid = xpne->deviceid;
return TRUE;
}
@ -720,128 +669,91 @@ gdk_input_common_other_event (GdkEvent *event,
return -1; /* wasn't one of our event types */
}
void
gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
gboolean
_gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
int i;
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
g_return_if_fail (gdkdev != NULL);
for (i=GDK_AXIS_IGNORE;i<GDK_AXIS_LAST;i++)
{
gdkdev->axis_for_use[i] = -1;
}
for (i=0;i<gdkdev->info.num_axes;i++)
{
gdkdev->info.axes[i] = axes[i];
gdkdev->axis_for_use[axes[i]] = i;
}
}
void
gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
gdkdev = gdk_input_find_device (deviceid);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (index < gdkdev->info.num_keys);
gdkdev->info.keys[index].keyval = keyval;
gdkdev->info.keys[index].modifiers = modifiers;
}
GdkTimeCoord *
gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return)
{
GdkTimeCoord *coords;
GdkTimeCoord **coords;
XDeviceTimeCoord *device_coords;
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
gint mode_return;
gint axis_count_return;
gint i;
int mode_return;
int axis_count_return;
int i;
gdkdev = gdk_input_find_device (deviceid);
gdkdev = (GdkDevicePrivate *)device;
input_window = gdk_input_window_find (window);
g_return_val_if_fail (gdkdev != NULL, NULL);
g_return_val_if_fail (gdkdev->xdevice != NULL, NULL);
g_return_val_if_fail (input_window != NULL, NULL);
g_return_val_if_fail (input_window != NULL, FALSE);
device_coords = XGetDeviceMotionEvents (gdk_display,
gdkdev->xdevice,
start, stop,
nevents_return, &mode_return,
n_events, &mode_return,
&axis_count_return);
if (device_coords)
{
coords = g_new (GdkTimeCoord, *nevents_return);
coords = _gdk_device_allocate_history (device, *n_events);
for (i=0; i<*nevents_return; i++)
{
gdk_input_translate_coordinates (gdkdev, input_window,
device_coords[i].data,
&coords[i].x, &coords[i].y,
&coords[i].pressure,
&coords[i].xtilt, &coords[i].ytilt);
}
for (i=0; i<*n_events; i++)
gdk_input_translate_coordinates (gdkdev, input_window,
device_coords[i].data,
coords[i]->axes, NULL, NULL);
XFreeDeviceMotionEvents (device_coords);
return coords;
*events = coords;
return TRUE;
}
else
return NULL;
{
*events = NULL;
*n_events = 0;
return FALSE;
}
}
void
gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
gdk_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
{
GdkDevicePrivate *gdkdev;
GdkInputWindow *input_window;
XDeviceState *state;
XInputClass *input_class;
gint x_int, y_int;
gint i;
/* we probably need to get the mask in any case */
g_return_if_fail (device != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (deviceid == GDK_CORE_POINTER)
if (GDK_IS_CORE (device))
{
gint x_int, y_int;
gdk_window_get_pointer (window, &x_int, &y_int, mask);
if (x) *x = x_int;
if (y) *y = y_int;
if (pressure) *pressure = 0.5;
if (xtilt) *xtilt = 0;
if (ytilt) *ytilt = 0;
if (axes)
{
axes[0] = x_int;
axes[1] = y_int;
}
}
else
{
GdkDevicePrivate *gdkdev;
GdkInputWindow *input_window;
XDeviceState *state;
XInputClass *input_class;
if (mask)
gdk_window_get_pointer (window, NULL, NULL, mask);
gdkdev = gdk_input_find_device (deviceid);
gdkdev = (GdkDevicePrivate *)device;
input_window = gdk_input_window_find (window);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (gdkdev->xdevice != NULL);
g_return_if_fail (input_window != NULL);
state = XQueryDeviceState (gdk_display, gdkdev->xdevice);
@ -851,13 +763,12 @@ gdk_input_common_get_pointer (GdkWindow *window,
switch (input_class->class)
{
case ValuatorClass:
gdk_input_translate_coordinates (gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
x, y, pressure,
xtilt, ytilt);
break;
if (axes)
gdk_input_translate_coordinates (gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
axes, NULL, NULL);
break;
case ButtonClass:
if (mask)
{

View File

@ -28,83 +28,54 @@
/* forward declarations */
static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode);
static void gdk_input_check_proximity (void);
static void gdk_input_xfree_configure_event (XConfigureEvent *xevent,
GdkWindow *window);
static void gdk_input_xfree_enter_event (XCrossingEvent *xevent,
GdkWindow *window);
static gint gdk_input_xfree_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window);
static gint gdk_input_xfree_enable_window(GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_xfree_disable_window(GdkWindow *window,
GdkDevicePrivate *gdkdev);
static gint gdk_input_xfree_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
static void gdk_input_xfree_ungrab_pointer (guint32 time);
void
gdk_input_init(void)
{
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
gdk_input_vtable.ungrab_pointer = gdk_input_xfree_ungrab_pointer;
gdk_input_vtable.configure_event = gdk_input_xfree_configure_event;
gdk_input_vtable.enter_event = gdk_input_xfree_enter_event;
gdk_input_vtable.other_event = gdk_input_xfree_other_event;
gdk_input_vtable.window_none_event = NULL;
gdk_input_vtable.enable_window = gdk_input_xfree_enable_window;
gdk_input_vtable.disable_window = gdk_input_xfree_disable_window;
gdk_input_ignore_core = FALSE;
gdk_input_common_init(FALSE);
}
static gint
gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
gboolean
gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode)
{
GList *tmp_list;
GdkDevicePrivate *gdkdev;
GdkInputMode old_mode;
GdkInputWindow *input_window;
gdkdev = gdk_input_find_device(deviceid);
g_return_val_if_fail (gdkdev != NULL,FALSE);
old_mode = gdkdev->info.mode;
if (GDK_IS_CORE (device))
return FALSE;
if (gdkdev->info.mode == mode)
gdkdev = (GdkDevicePrivate *)device;
if (device->mode == mode)
return TRUE;
gdkdev->info.mode = mode;
old_mode = device->mode;
device->mode = mode;
if (mode == GDK_MODE_WINDOW)
{
gdkdev->info.has_cursor = FALSE;
device->has_cursor = FALSE;
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
input_window = (GdkInputWindow *)tmp_list->data;
if (input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
gdk_input_enable_window (input_window->window, gdkdev);
_gdk_input_enable_window (input_window->window, gdkdev);
else
if (old_mode != GDK_MODE_DISABLED)
gdk_input_disable_window (input_window->window, gdkdev);
_gdk_input_disable_window (input_window->window, gdkdev);
}
}
else if (mode == GDK_MODE_SCREEN)
{
gdkdev->info.has_cursor = TRUE;
device->has_cursor = TRUE;
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
gdkdev);
_gdk_input_enable_window (((GdkInputWindow *)tmp_list->data)->window,
gdkdev);
}
else /* mode == GDK_MODE_DISABLED */
{
@ -113,7 +84,7 @@ gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode)
input_window = (GdkInputWindow *)tmp_list->data;
if (old_mode != GDK_MODE_WINDOW ||
input_window->mode != GDK_EXTENSION_EVENTS_CURSOR)
gdk_input_disable_window (input_window->window, gdkdev);
_gdk_input_disable_window (input_window->window, gdkdev);
}
}
@ -132,7 +103,7 @@ gdk_input_check_proximity (void)
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.mode != GDK_MODE_DISABLED
&& gdkdev->info.deviceid != GDK_CORE_POINTER
&& !GDK_IS_CORE (gdkdev)
&& gdkdev->xdevice)
{
XDeviceState *state = XQueryDeviceState(GDK_DISPLAY(),
@ -163,8 +134,9 @@ gdk_input_check_proximity (void)
gdk_input_ignore_core = new_proximity;
}
static void
gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
void
_gdk_input_configure_event (XConfigureEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
gint root_x, root_y;
@ -180,9 +152,9 @@ gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window)
input_window->root_y = root_y;
}
static void
gdk_input_xfree_enter_event (XCrossingEvent *xevent,
GdkWindow *window)
void
_gdk_input_enter_event (XCrossingEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
gint root_x, root_y;
@ -200,13 +172,13 @@ gdk_input_xfree_enter_event (XCrossingEvent *xevent,
input_window->root_y = root_y;
}
static gint
gdk_input_xfree_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window)
gint
_gdk_input_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window)
{
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
gint return_val;
@ -217,11 +189,10 @@ gdk_input_xfree_other_event (GdkEvent *event,
but it's potentially faster than scanning through the types of
every device. If we were deceived, then it won't match any of
the types for the device anyways */
gdkdev = gdk_input_find_device(((XDeviceButtonEvent *)xevent)->deviceid);
gdkdev = gdk_input_find_device (((XDeviceButtonEvent *)xevent)->deviceid);
if (!gdkdev) {
if (!gdkdev)
return -1; /* we don't handle it - not an XInput event */
}
/* FIXME: It would be nice if we could just get rid of the events
entirely, instead of having to ignore them */
@ -243,27 +214,27 @@ gdk_input_xfree_other_event (GdkEvent *event,
return return_val;
}
static gint
gdk_input_xfree_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
gboolean
_gdk_input_enable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
/* FIXME: watchout, gdkdev might be core pointer, never opened */
gdk_input_common_select_events (window, gdkdev);
return TRUE;
}
static gint
gdk_input_xfree_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
gboolean
_gdk_input_disable_window(GdkWindow *window, GdkDevicePrivate *gdkdev)
{
gdk_input_common_select_events (window, gdkdev);
return TRUE;
}
static gint
gdk_input_xfree_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
gint
_gdk_input_grab_pointer (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time)
{
GdkInputWindow *input_window, *new_window;
gboolean need_ungrab;
@ -300,8 +271,7 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice)
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice)
{
gdk_input_common_find_events (window, gdkdev,
event_mask,
@ -326,7 +296,7 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice &&
((gdkdev->button_state != 0) || need_ungrab))
{
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
@ -341,8 +311,8 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
}
static void
gdk_input_xfree_ungrab_pointer (guint32 time)
void
_gdk_input_ungrab_pointer (guint32 time)
{
GdkInputWindow *input_window;
GdkDevicePrivate *gdkdev;
@ -365,10 +335,17 @@ gdk_input_xfree_ungrab_pointer (guint32 time)
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice)
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice)
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
tmp_list = tmp_list->next;
}
}
}
gint
_gdk_input_window_none_event (GdkEvent *event,
XEvent *xevent)
{
return -1;
}

View File

@ -34,22 +34,29 @@
#include "gdkprivate.h"
#include "gdkinputprivate.h"
static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y };
static GdkDeviceAxis gdk_input_core_axes[] = {
{ GDK_AXIS_X, 0, 0 },
{ GDK_AXIS_Y, 0, 0 }
};
const GdkDeviceInfo gdk_input_core_info =
static const GdkDevice gdk_input_core_info =
{
GDK_CORE_POINTER,
"Core Pointer",
GDK_SOURCE_MOUSE,
GDK_MODE_SCREEN,
TRUE,
2,
gdk_input_core_axes
gdk_input_core_axes,
0,
NULL
};
GdkDevice *gdk_core_pointer = (GdkDevice *)&gdk_input_core_info;
/* Global variables */
GdkInputVTable gdk_input_vtable;
/* information about network port and host for gxid daemon */
gchar *gdk_input_gxid_host;
gint gdk_input_gxid_port;
@ -59,124 +66,138 @@ GList *gdk_input_devices;
GList *gdk_input_windows;
GList *
gdk_input_list_devices (void)
gdk_devices_list (void)
{
return gdk_input_devices;
}
void
gdk_input_set_source (guint32 deviceid, GdkInputSource source)
gdk_device_set_source (GdkDevice *device,
GdkInputSource source)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (device != NULL);
gdkdev->info.source = source;
}
gboolean
gdk_input_set_mode (guint32 deviceid, GdkInputMode mode)
{
if (deviceid == GDK_CORE_POINTER)
return FALSE;
if (gdk_input_vtable.set_mode)
return gdk_input_vtable.set_mode(deviceid,mode);
else
return FALSE;
device->source = source;
}
void
gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
gdk_device_set_key (GdkDevice *device,
guint index,
guint keyval,
GdkModifierType modifiers)
{
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_axes)
gdk_input_vtable.set_axes (deviceid, axes);
g_return_if_fail (device != NULL);
g_return_if_fail (index < device->num_keys);
device->keys[index].keyval = keyval;
device->keys[index].modifiers = modifiers;
}
void gdk_input_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
void
gdk_device_set_axis_use (GdkDevice *device,
guint index,
GdkAxisUse use)
{
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_key)
gdk_input_vtable.set_key (deviceid, index, keyval, modifiers);
g_return_if_fail (device != NULL);
g_return_if_fail (index < device->num_axes);
device->axes[index].use = use;
switch (use)
{
case GDK_AXIS_X:
case GDK_AXIS_Y:
device->axes[index].min = 0.;
device->axes[index].max = 0.;
break;
case GDK_AXIS_XTILT:
case GDK_AXIS_YTILT:
device->axes[index].min = -1.;
device->axes[index].max = 1;
break;
default:
device->axes[index].min = 0.;
device->axes[index].max = 1;
break;
}
}
GdkTimeCoord *
gdk_input_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return)
gboolean
gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
XTimeCoord *xcoords;
GdkTimeCoord *coords;
GdkTimeCoord **coords;
int i;
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
if (GDK_WINDOW_DESTROYED (window))
return NULL;
g_return_val_if_fail (window != NULL, FALSE);
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
g_return_val_if_fail (events != NULL, FALSE);
g_return_val_if_fail (n_events != NULL, FALSE);
if (deviceid == GDK_CORE_POINTER)
*n_events = 0;
*events = NULL;
if (GDK_WINDOW_DESTROYED (window))
return FALSE;
if (GDK_IS_CORE (device))
{
XTimeCoord *xcoords;
xcoords = XGetMotionEvents (GDK_DRAWABLE_XDISPLAY (window),
GDK_DRAWABLE_XID (window),
start, stop, nevents_return);
start, stop, n_events);
if (xcoords)
{
coords = g_new (GdkTimeCoord, *nevents_return);
for (i=0; i<*nevents_return; i++)
coords = _gdk_device_allocate_history (device, *n_events);
for (i=0; i<*n_events; i++)
{
coords[i].time = xcoords[i].time;
coords[i].x = xcoords[i].x;
coords[i].y = xcoords[i].y;
coords[i].pressure = 0.5;
coords[i].xtilt = 0.0;
coords[i].ytilt = 0.0;
coords[i]->time = xcoords[i].time;
coords[i]->axes[0] = xcoords[i].x;
coords[i]->axes[1] = xcoords[i].y;
}
XFree (xcoords);
return coords;
*events = coords;
return TRUE;
}
else
return NULL;
return FALSE;
}
else
{
if (gdk_input_vtable.motion_events)
{
return gdk_input_vtable.motion_events(window,
deviceid, start, stop,
nevents_return);
}
else
{
*nevents_return = 0;
return NULL;
}
}
return _gdk_device_get_history (device, window, start, stop, events, n_events);
}
gint
gdk_input_enable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
GdkTimeCoord **
_gdk_device_allocate_history (GdkDevice *device,
gint n_events)
{
if (gdk_input_vtable.enable_window)
return gdk_input_vtable.enable_window (window, gdkdev);
else
return TRUE;
GdkTimeCoord **result = g_new (GdkTimeCoord *, n_events);
gint i;
for (i=0; i<n_events; i++)
result[i] = g_malloc (sizeof (GdkTimeCoord) -
sizeof (double) * (GDK_MAX_TIMECOORD_AXES - device->num_axes));
return result;
}
gint
gdk_input_disable_window (GdkWindow *window, GdkDevicePrivate *gdkdev)
void
gdk_device_free_history (GdkTimeCoord **events,
gint n_events)
{
if (gdk_input_vtable.disable_window)
return gdk_input_vtable.disable_window(window,gdkdev);
else
return TRUE;
}
gint i;
for (i=0; i<n_events; i++)
g_free (events[i]);
g_free (events);
}
GdkInputWindow *
gdk_input_window_find(GdkWindow *window)
@ -248,15 +269,15 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask,
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
GdkDevicePrivate *gdkdev = tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
if (!GDK_IS_CORE (gdkdev))
{
if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED
&& (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL))
gdk_input_enable_window(window,gdkdev);
_gdk_input_enable_window (window,gdkdev);
else
gdk_input_disable_window(window,gdkdev);
_gdk_input_disable_window (window,gdkdev);
}
}
}
@ -282,9 +303,9 @@ gdk_input_exit (void)
for (tmp_list = gdk_input_devices; tmp_list; tmp_list = tmp_list->next)
{
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.deviceid != GDK_CORE_POINTER)
if (!GDK_IS_CORE (gdkdev))
{
gdk_input_set_mode(gdkdev->info.deviceid,GDK_MODE_DISABLED);
gdk_device_set_mode (&gdkdev->info, GDK_MODE_DISABLED);
g_free(gdkdev->info.name);
#ifndef XINPUT_NONE
@ -299,38 +320,40 @@ gdk_input_exit (void)
g_list_free(gdk_input_devices);
for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next)
{
g_free(tmp_list->data);
}
g_free(tmp_list->data);
g_list_free(gdk_input_windows);
}
GdkDevicePrivate *
gdk_input_find_device(guint32 id)
/**
* gdk_device_get_axis:
* @axis: a #GdkDevice
* @axes: pointer to an array of axes
* @use: the use to look for
* @value: location to store the found value.
*
* Interprets an array of double as axis values for a given device,
* and locates the value in the array for a given axis use.
*
* Return value: %TRUE if the given axis use was found, otherwies %FALSE
**/
gboolean
gdk_device_get_axis (GdkDevice *device, gdouble *axes, GdkAxisUse use, gdouble *value)
{
GList *tmp_list = gdk_input_devices;
GdkDevicePrivate *gdkdev;
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)(tmp_list->data);
if (gdkdev->info.deviceid == id)
return gdkdev;
tmp_list = tmp_list->next;
}
return NULL;
}
gint i;
g_return_val_if_fail (device != NULL, FALSE);
void
gdk_input_window_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask)
{
if (gdk_input_vtable.get_pointer)
gdk_input_vtable.get_pointer (window, deviceid, x, y, pressure,
xtilt, ytilt, mask);
if (axes == NULL)
return FALSE;
for (i=0; i<device->num_axes; i++)
if (device->axes[i].use == use)
{
if (value)
*value = axes[i];
return TRUE;
}
return FALSE;
}

View File

@ -39,48 +39,9 @@
#endif
typedef struct _GdkAxisInfo GdkAxisInfo;
typedef struct _GdkInputVTable GdkInputVTable;
typedef struct _GdkDevicePrivate GdkDevicePrivate;
typedef struct _GdkInputWindow GdkInputWindow;
struct _GdkInputVTable {
gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
void (*set_key) (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
GdkTimeCoord* (*motion_events) (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
void (*get_pointer) (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
gint (*grab_pointer) (GdkWindow * window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow * confine_to,
guint32 time);
void (*ungrab_pointer) (guint32 time);
void (*configure_event) (XConfigureEvent *xevent, GdkWindow *window);
void (*enter_event) (XCrossingEvent *xevent, GdkWindow *window);
gint (*other_event) (GdkEvent *event, XEvent *xevent, GdkWindow *window);
/* Handle an unidentified event. Returns TRUE if handled, FALSE
otherwise */
gint (*window_none_event) (GdkEvent *event, XEvent *xevent);
gint (*enable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
gint (*disable_window) (GdkWindow *window, GdkDevicePrivate *gdkdev);
};
/* information about a device axis */
struct _GdkAxisInfo
{
@ -100,16 +61,17 @@ struct _GdkAxisInfo
#define GDK_INPUT_NUM_EVENTC 6
struct _GdkDevicePrivate {
GdkDeviceInfo info;
struct _GdkDevicePrivate
{
GdkDevice info;
guint32 deviceid;
#ifndef XINPUT_NONE
/* information about the axes */
GdkAxisInfo *axes;
/* reverse lookup on axis use type */
gint axis_for_use[GDK_AXIS_LAST];
/* Information about XInput device */
XDevice *xdevice;
@ -154,11 +116,11 @@ struct _GdkInputWindow
/* Global data */
extern const GdkDeviceInfo gdk_input_core_info;
#define GDK_IS_CORE(d) (((GdkDevice *)(d)) == gdk_core_pointer)
extern GList *gdk_input_devices;
extern GList *gdk_input_windows;
extern GdkInputVTable gdk_input_vtable;
/* information about network port and host for gxid daemon */
extern gchar *gdk_input_gxid_host;
extern gint gdk_input_gxid_port;
@ -166,63 +128,64 @@ extern gint gdk_input_ignore_core;
/* Function declarations */
GdkDevicePrivate * gdk_input_find_device (guint32 id);
GdkInputWindow * gdk_input_window_find (GdkWindow *window);
void gdk_input_window_destroy (GdkWindow *window);
void gdk_input_init (void);
void gdk_input_exit (void);
gint gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint gdk_input_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
GdkInputWindow *gdk_input_window_find (GdkWindow *window);
void gdk_input_window_destroy (GdkWindow *window);
GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
gint n_events);
/* The following functions are provided by each implementation
* (xfree, gxi, and none)
*/
gint _gdk_input_enable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint _gdk_input_disable_window (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint _gdk_input_window_none_event (GdkEvent *event,
XEvent *xevent);
void _gdk_input_configure_event (XConfigureEvent *xevent,
GdkWindow *window);
void _gdk_input_enter_event (XCrossingEvent *xevent,
GdkWindow *window);
gint _gdk_input_other_event (GdkEvent *event,
XEvent *xevent,
GdkWindow *window);
gint _gdk_input_grab_pointer (GdkWindow *window,
gint owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
guint32 time);
void _gdk_input_ungrab_pointer (guint32 time);
gboolean _gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
#ifndef XINPUT_NONE
#define GDK_MAX_DEVICE_CLASSES 13
gint gdk_input_common_init (gint include_core);
void gdk_input_get_root_relative_geometry (Display *dpy,
Window w,
int *x_ret,
int *y_ret,
int *width_ret,
int *height_ret);
void gdk_input_common_find_events (GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes);
void gdk_input_common_select_events (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev);
void gdk_input_common_get_pointer (GdkWindow *window,
guint32 deviceid,
gdouble *x,
gdouble *y,
gdouble *pressure,
gdouble *xtilt,
gdouble *ytilt,
GdkModifierType *mask);
void gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
void gdk_input_common_set_axes (guint32 deviceid,
GdkAxisUse *axes);
GdkTimeCoord * gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
guint32 start,
guint32 stop,
gint *nevents_return);
gint gdk_input_common_init (gint include_core);
GdkDevicePrivate * gdk_input_find_device (guint32 id);
void gdk_input_get_root_relative_geometry (Display *dpy,
Window w,
int *x_ret,
int *y_ret,
int *width_ret,
int *height_ret);
void gdk_input_common_find_events (GdkWindow *window,
GdkDevicePrivate *gdkdev,
gint mask,
XEventClass *classes,
int *num_classes);
void gdk_input_common_select_events (GdkWindow *window,
GdkDevicePrivate *gdkdev);
gint gdk_input_common_other_event (GdkEvent *event,
XEvent *xevent,
GdkInputWindow *input_window,
GdkDevicePrivate *gdkdev);
#endif /* !XINPUT_NONE */
GdkDevicePrivate *gdk_input_find_device (guint32 id);
GdkInputWindow *gdk_input_window_find (GdkWindow *window);
void gdk_input_window_destroy (GdkWindow *window);
void gdk_input_exit (void);
#endif /* __GDK_INPUTPRIVATE_H__ */

View File

@ -267,15 +267,12 @@ gdk_pointer_grab (GdkWindow * window,
xevent_mask |= gdk_event_mask_table[i];
}
if (gdk_input_vtable.grab_pointer)
return_val = gdk_input_vtable.grab_pointer (window,
owner_events,
event_mask,
confine_to,
time);
else
return_val = Success;
return_val = _gdk_input_grab_pointer (window,
owner_events,
event_mask,
confine_to,
time);
if (return_val == Success)
{
if (!GDK_WINDOW_DESTROYED (window))
@ -315,8 +312,7 @@ gdk_pointer_grab (GdkWindow * window,
void
gdk_pointer_ungrab (guint32 time)
{
if (gdk_input_vtable.ungrab_pointer)
gdk_input_vtable.ungrab_pointer (time);
_gdk_input_ungrab_pointer (time);
XUngrabPointer (gdk_display, time);
gdk_xgrab_window = NULL;

View File

@ -2716,13 +2716,10 @@ gtk_drag_end (GtkDragSourceInfo *info, guint32 time)
send_event.button.time = time;
send_event.button.x = 0;
send_event.button.y = 0;
send_event.button.pressure = 0.;
send_event.button.xtilt = 0.;
send_event.button.ytilt = 0.;
send_event.button.axes = NULL;
send_event.button.state = 0;
send_event.button.button = info->button;
send_event.button.source = GDK_SOURCE_PEN;
send_event.button.deviceid = GDK_CORE_POINTER;
send_event.button.device = gdk_core_pointer;
send_event.button.x_root = 0;
send_event.button.y_root = 0;

View File

@ -77,45 +77,32 @@ enum
/* Forward declarations */
static void gtk_input_dialog_class_init (GtkInputDialogClass *klass);
static void gtk_input_dialog_init (GtkInputDialog *inputd);
static GdkDeviceInfo *gtk_input_dialog_get_device_info(guint32 deviceid);
static void gtk_input_dialog_set_device(GtkWidget *widget, gpointer data);
static void gtk_input_dialog_set_mapping_mode(GtkWidget *w,
gpointer data);
static void gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data);
static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd,
GdkDeviceInfo *info);
static void gtk_input_dialog_set_key (GtkInputKeyInfo *key,
guint keyval,
GdkModifierType modifiers);
static gint gtk_input_dialog_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkInputKeyInfo *key);
static void gtk_input_dialog_clear_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_destroy_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd,
GdkDeviceInfo *info);
static void gtk_input_dialog_class_init (GtkInputDialogClass *klass);
static void gtk_input_dialog_init (GtkInputDialog *inputd);
static void gtk_input_dialog_set_device (GtkWidget *widget,
gpointer data);
static void gtk_input_dialog_set_mapping_mode (GtkWidget *w,
gpointer data);
static void gtk_input_dialog_set_axis (GtkWidget *widget,
gpointer data);
static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd,
GdkDevice *info);
static void gtk_input_dialog_set_key (GtkInputKeyInfo *key,
guint keyval,
GdkModifierType modifiers);
static gint gtk_input_dialog_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkInputKeyInfo *key);
static void gtk_input_dialog_clear_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_destroy_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd,
GdkDevice *info);
static GtkObjectClass *parent_class = NULL;
static guint input_dialog_signals[LAST_SIGNAL] = { 0 };
static GdkDeviceInfo *
gtk_input_dialog_get_device_info(guint32 deviceid)
{
GList *tmp_list = gdk_input_list_devices();
while (tmp_list)
{
if (((GdkDeviceInfo *)tmp_list->data)->deviceid == deviceid)
return (GdkDeviceInfo *)tmp_list->data;
tmp_list = tmp_list->next;
}
return NULL;
}
GtkType
gtk_input_dialog_get_type (void)
{
@ -156,16 +143,16 @@ gtk_input_dialog_class_init (GtkInputDialogClass *klass)
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkInputDialogClass, enable_device),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
input_dialog_signals[DISABLE_DEVICE] =
gtk_signal_new ("disable_device",
GTK_RUN_LAST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkInputDialogClass, disable_device),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, input_dialog_signals,
LAST_SIGNAL);
@ -191,7 +178,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
GList *tmp_list;
GList *device_info;
device_info = gdk_input_list_devices();
device_info = gdk_devices_list ();
/* shell and main vbox */
@ -215,8 +202,8 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
device_menu = gtk_menu_new ();
for (tmp_list = device_info; tmp_list; tmp_list = tmp_list->next) {
GdkDeviceInfo *info = (GdkDeviceInfo *)(tmp_list->data);
if (info->deviceid != GDK_CORE_POINTER)
GdkDevice *info = (GdkDevice *)(tmp_list->data);
if (info != gdk_core_pointer)
{
menuitem = gtk_menu_item_new_with_label(info->name);
@ -225,7 +212,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
gtk_object_set_user_data (GTK_OBJECT (menuitem), inputd);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) gtk_input_dialog_set_device,
GUINT_TO_POINTER(info->deviceid));
info);
}
}
@ -333,8 +320,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
/* ...set_device expects to get input dialog from widget user data */
gtk_object_set_user_data (GTK_OBJECT (inputd), inputd);
gtk_input_dialog_set_device(GTK_WIDGET(inputd),
GUINT_TO_POINTER (((GdkDeviceInfo *)device_info->data)->deviceid));
gtk_input_dialog_set_device (GTK_WIDGET(inputd), device_info->data);
}
@ -374,44 +360,42 @@ gtk_input_dialog_new (void)
static void
gtk_input_dialog_set_device(GtkWidget *widget, gpointer data)
{
guint32 deviceid = GPOINTER_TO_UINT(data);
GdkDeviceInfo *info;
GdkDevice *device = data;
GtkInputDialog *inputd = GTK_INPUT_DIALOG(
gtk_object_get_user_data(GTK_OBJECT(widget)));
inputd->current_device = deviceid;
info = gtk_input_dialog_get_device_info (deviceid);
inputd->current_device = device;
gtk_input_dialog_fill_axes(inputd, info);
gtk_input_dialog_fill_keys(inputd, info);
gtk_input_dialog_fill_axes(inputd, device);
gtk_input_dialog_fill_keys(inputd, device);
gtk_option_menu_set_history(GTK_OPTION_MENU(inputd->mode_optionmenu),
info->mode);
device->mode);
}
static void
gtk_input_dialog_set_mapping_mode(GtkWidget *w,
gpointer data)
gtk_input_dialog_set_mapping_mode (GtkWidget *w,
gpointer data)
{
GtkInputDialog *inputd = GTK_INPUT_DIALOG(
gtk_object_get_user_data(GTK_OBJECT(w)));
GdkDeviceInfo *info = gtk_input_dialog_get_device_info (inputd->current_device);
GdkDevice *info = inputd->current_device;
GdkInputMode old_mode = info->mode;
GdkInputMode mode = GPOINTER_TO_INT (data);
if (mode != old_mode)
{
if (gdk_input_set_mode(inputd->current_device, mode))
if (gdk_device_set_mode (inputd->current_device, mode))
{
if (mode == GDK_MODE_DISABLED)
gtk_signal_emit (GTK_OBJECT (inputd),
input_dialog_signals[DISABLE_DEVICE],
info->deviceid);
info);
else
gtk_signal_emit (GTK_OBJECT (inputd),
input_dialog_signals[ENABLE_DEVICE],
info->deviceid);
info);
}
else
gtk_option_menu_set_history (GTK_OPTION_MENU (inputd->mode_optionmenu),
@ -428,7 +412,7 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
GdkAxisUse old_use;
GdkAxisUse *new_axes;
GtkInputDialog *inputd = GTK_INPUT_DIALOG (gtk_object_get_user_data (GTK_OBJECT (widget)));
GdkDeviceInfo *info = gtk_input_dialog_get_device_info (inputd->current_device);
GdkDevice *info = inputd->current_device;
gint axis = (GPOINTER_TO_INT(data) >> 16) - 1;
gint old_axis;
@ -438,13 +422,13 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
old_axis = -1;
for (i=0;i<info->num_axes;i++)
{
new_axes[i] = info->axes[i];
if (info->axes[i] == use)
new_axes[i] = info->axes[i].use;
if (info->axes[i].use == use)
old_axis = i;
}
if (axis != -1)
old_use = info->axes[axis];
old_use = info->axes[axis].use;
else
old_use = GDK_AXIS_IGNORE;
@ -462,10 +446,10 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
else
{
if (axis != -1)
new_axes[axis] = use;
gdk_device_set_axis_use (info, axis, use);
if (old_axis != -1)
new_axes[old_axis] = old_use;
gdk_device_set_axis_use (info, old_axis, old_use);
if (old_use != GDK_AXIS_IGNORE)
{
@ -473,14 +457,13 @@ gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data)
GTK_OPTION_MENU (inputd->axis_items[old_use]),
old_axis + 1);
}
gdk_input_set_axes (info->deviceid, new_axes);
}
g_free (new_axes);
}
static void
gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDevice *info)
{
static const char *axis_use_strings[GDK_AXIS_LAST] =
{
@ -489,7 +472,8 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
N_("Y"),
N_("Pressure"),
N_("X Tilt"),
N_("Y Tilt")
N_("Y Tilt"),
N_("Wheel")
};
int i,j;
@ -550,7 +534,7 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
gtk_widget_show (option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
for (j = 0; j < info->num_axes; j++)
if (info->axes[j] == (GdkAxisUse) i)
if (info->axes[j].use == (GdkAxisUse) i)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), j+1);
break;
@ -564,7 +548,7 @@ static void
gtk_input_dialog_clear_key (GtkWidget *widget, GtkInputKeyInfo *key)
{
gtk_entry_set_text (GTK_ENTRY(key->entry), _("(disabled)"));
gdk_input_set_key (key->inputd->current_device, key->index, 0, 0);
gdk_device_set_key (key->inputd->current_device, key->index, 0, 0);
}
static void
@ -609,8 +593,8 @@ gtk_input_dialog_key_press (GtkWidget *widget,
GtkInputKeyInfo *key)
{
gtk_input_dialog_set_key (key, event->keyval, event->state & 0xFF);
gdk_input_set_key (key->inputd->current_device, key->index,
event->keyval, event->state & 0xFF);
gdk_device_set_key (key->inputd->current_device, key->index,
event->keyval, event->state & 0xFF);
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
@ -624,7 +608,7 @@ gtk_input_dialog_destroy_key (GtkWidget *widget, GtkInputKeyInfo *key)
}
static void
gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDeviceInfo *info)
gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDevice *info)
{
int i;
GtkWidget *label;

View File

@ -60,7 +60,7 @@ struct _GtkInputDialog
GtkWidget *save_button;
GtkWidget *axis_items[GDK_AXIS_LAST];
guint32 current_device;
GdkDevice *current_device;
GtkWidget *keys_list;
GtkWidget *keys_listbox;
@ -71,9 +71,9 @@ struct _GtkInputDialogClass
GtkDialogClass parent_class;
void (* enable_device) (GtkInputDialog *inputd,
guint32 devid);
GdkDevice *device);
void (* disable_device) (GtkInputDialog *inputd,
guint32 devid);
GdkDevice *device);
};

View File

@ -538,19 +538,16 @@ gtk_table_attach (GtkTable *table,
gtk_widget_set_parent (child, GTK_WIDGET (table));
if (GTK_WIDGET_VISIBLE (GTK_WIDGET (table)))
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_REALIZED (GTK_WIDGET (table)) &&
!GTK_WIDGET_REALIZED (child))
gtk_widget_realize (child);
if (GTK_WIDGET_MAPPED (GTK_WIDGET (table)) &&
!GTK_WIDGET_MAPPED (child))
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table))
gtk_widget_queue_resize (child);
}
void

View File

@ -1848,7 +1848,12 @@ gtk_widget_draw (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
if (!area)
if (area)
{
if (area->width <= 0 || area->height <= 0)
return;
}
else
{
if (GTK_WIDGET_NO_WINDOW (widget))
{

View File

@ -33,44 +33,19 @@ static GdkPixmap *pixmap = NULL;
/* Information about cursor */
static gint need_cursor = FALSE;
static gint cursor_proximity = TRUE;
static gdouble cursor_x;
static gdouble cursor_y;
/* Unique ID of current device */
static guint32 current_device = GDK_CORE_POINTER;
/* Check to see if we need to draw a cursor for current device */
static void
check_cursor (void)
{
GList *tmp_list;
/* gdk_input_list_devices returns an internal list, so we shouldn't
free it afterwards */
tmp_list = gdk_input_list_devices();
while (tmp_list)
{
GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data;
if (info->deviceid == current_device)
{
need_cursor = !info->has_cursor;
break;
}
tmp_list = tmp_list->next;
}
}
static GdkDevice *current_device;
/* Erase the old cursor, and/or draw a new one, if necessary */
static void
update_cursor (GtkWidget *widget, gdouble x, gdouble y)
{
static gint cursor_present = 0;
gint state = need_cursor && cursor_proximity;
gint state = !current_device->has_cursor && cursor_proximity;
if (pixmap != NULL)
{
@ -170,21 +145,36 @@ draw_brush (GtkWidget *widget, GdkInputSource source,
static guint32 motion_time;
static void
print_axes (GdkDevice *device, gdouble *axes)
{
int i;
if (axes)
{
g_print ("%s ", device->name);
for (i=0; i<device->num_axes; i++)
g_print ("%g ", axes[i]);
g_print ("\n");
}
}
static gint
button_press_event (GtkWidget *widget, GdkEventButton *event)
{
if (event->deviceid != current_device)
{
current_device = event->deviceid;
check_cursor ();
}
current_device = event->device;
cursor_proximity = TRUE;
if (event->button == 1 && pixmap != NULL)
{
draw_brush (widget, event->source, event->x, event->y,
event->pressure);
gdouble pressure = 0.5;
print_axes (event->device, event->axes);
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, event->x, event->y, pressure);
motion_time = event->time;
}
@ -207,47 +197,47 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
static gint
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
GdkTimeCoord *coords;
int nevents;
GdkTimeCoord **events;
int n_events;
int i;
if (event->deviceid != current_device)
{
current_device = event->deviceid;
check_cursor ();
}
current_device = event->device;
cursor_proximity = TRUE;
if (event->state & GDK_BUTTON1_MASK && pixmap != NULL)
{
coords = gdk_input_motion_events (event->window, event->deviceid,
motion_time, event->time,
&nevents);
motion_time = event->time;
if (coords)
if (gdk_device_get_history (event->device, event->window,
motion_time, event->time,
&events, &n_events))
{
for (i=0; i<nevents; i++)
draw_brush (widget, event->source, coords[i].x, coords[i].y,
coords[i].pressure);
g_free (coords);
for (i=0; i<n_events; i++)
{
double x = 0, y = 0, pressure = 0.5;
gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_X, &x);
gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_Y, &y);
gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, x, y, pressure);
print_axes (event->device, events[i]->axes);
}
gdk_device_free_history (events, n_events);
}
else
{
if (event->is_hint)
gdk_input_window_get_pointer (event->window, event->deviceid,
NULL, NULL, NULL, NULL, NULL, NULL);
draw_brush (widget, event->source, event->x, event->y,
event->pressure);
double pressure = 0.5;
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, event->x, event->y, pressure);
}
}
else
{
gdk_input_window_get_pointer (event->window, event->deviceid,
&event->x, &event->y,
NULL, NULL, NULL, NULL);
motion_time = event->time;
}
if (event->is_hint)
gdk_device_get_state (event->device, event->window, NULL, NULL);
print_axes (event->device, event->axes);
update_cursor (widget, event->x, event->y);
return TRUE;
@ -293,10 +283,8 @@ create_input_dialog (void)
"clicked",
(GtkSignalFunc)gtk_widget_hide,
GTK_OBJECT(inputd));
gtk_widget_hide ( GTK_INPUT_DIALOG(inputd)->save_button);
gtk_widget_hide (GTK_INPUT_DIALOG(inputd)->save_button);
gtk_signal_connect (GTK_OBJECT(inputd), "enable_device",
(GtkSignalFunc)check_cursor, NULL);
gtk_widget_show (inputd);
}
else
@ -325,6 +313,8 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
current_device = gdk_core_pointer;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (window, "Test Input");

View File

@ -33,44 +33,19 @@ static GdkPixmap *pixmap = NULL;
/* Information about cursor */
static gint need_cursor = FALSE;
static gint cursor_proximity = TRUE;
static gdouble cursor_x;
static gdouble cursor_y;
/* Unique ID of current device */
static guint32 current_device = GDK_CORE_POINTER;
/* Check to see if we need to draw a cursor for current device */
static void
check_cursor (void)
{
GList *tmp_list;
/* gdk_input_list_devices returns an internal list, so we shouldn't
free it afterwards */
tmp_list = gdk_input_list_devices();
while (tmp_list)
{
GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data;
if (info->deviceid == current_device)
{
need_cursor = !info->has_cursor;
break;
}
tmp_list = tmp_list->next;
}
}
static GdkDevice *current_device;
/* Erase the old cursor, and/or draw a new one, if necessary */
static void
update_cursor (GtkWidget *widget, gdouble x, gdouble y)
{
static gint cursor_present = 0;
gint state = need_cursor && cursor_proximity;
gint state = !current_device->has_cursor && cursor_proximity;
if (pixmap != NULL)
{
@ -170,21 +145,36 @@ draw_brush (GtkWidget *widget, GdkInputSource source,
static guint32 motion_time;
static void
print_axes (GdkDevice *device, gdouble *axes)
{
int i;
if (axes)
{
g_print ("%s ", device->name);
for (i=0; i<device->num_axes; i++)
g_print ("%g ", axes[i]);
g_print ("\n");
}
}
static gint
button_press_event (GtkWidget *widget, GdkEventButton *event)
{
if (event->deviceid != current_device)
{
current_device = event->deviceid;
check_cursor ();
}
current_device = event->device;
cursor_proximity = TRUE;
if (event->button == 1 && pixmap != NULL)
{
draw_brush (widget, event->source, event->x, event->y,
event->pressure);
gdouble pressure = 0.5;
print_axes (event->device, event->axes);
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, event->x, event->y, pressure);
motion_time = event->time;
}
@ -207,47 +197,47 @@ key_press_event (GtkWidget *widget, GdkEventKey *event)
static gint
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
GdkTimeCoord *coords;
int nevents;
GdkTimeCoord **events;
int n_events;
int i;
if (event->deviceid != current_device)
{
current_device = event->deviceid;
check_cursor ();
}
current_device = event->device;
cursor_proximity = TRUE;
if (event->state & GDK_BUTTON1_MASK && pixmap != NULL)
{
coords = gdk_input_motion_events (event->window, event->deviceid,
motion_time, event->time,
&nevents);
motion_time = event->time;
if (coords)
if (gdk_device_get_history (event->device, event->window,
motion_time, event->time,
&events, &n_events))
{
for (i=0; i<nevents; i++)
draw_brush (widget, event->source, coords[i].x, coords[i].y,
coords[i].pressure);
g_free (coords);
for (i=0; i<n_events; i++)
{
double x = 0, y = 0, pressure = 0.5;
gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_X, &x);
gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_Y, &y);
gdk_device_get_axis (event->device, events[i]->axes, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, x, y, pressure);
print_axes (event->device, events[i]->axes);
}
gdk_device_free_history (events, n_events);
}
else
{
if (event->is_hint)
gdk_input_window_get_pointer (event->window, event->deviceid,
NULL, NULL, NULL, NULL, NULL, NULL);
draw_brush (widget, event->source, event->x, event->y,
event->pressure);
double pressure = 0.5;
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, event->x, event->y, pressure);
}
}
else
{
gdk_input_window_get_pointer (event->window, event->deviceid,
&event->x, &event->y,
NULL, NULL, NULL, NULL);
motion_time = event->time;
}
if (event->is_hint)
gdk_device_get_state (event->device, event->window, NULL, NULL);
print_axes (event->device, event->axes);
update_cursor (widget, event->x, event->y);
return TRUE;
@ -293,10 +283,8 @@ create_input_dialog (void)
"clicked",
(GtkSignalFunc)gtk_widget_hide,
GTK_OBJECT(inputd));
gtk_widget_hide ( GTK_INPUT_DIALOG(inputd)->save_button);
gtk_widget_hide (GTK_INPUT_DIALOG(inputd)->save_button);
gtk_signal_connect (GTK_OBJECT(inputd), "enable_device",
(GtkSignalFunc)check_cursor, NULL);
gtk_widget_show (inputd);
}
else
@ -325,6 +313,8 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
current_device = gdk_core_pointer;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_name (window, "Test Input");