Move all GdkDevice members to private and add one missing accessor

This commit is contained in:
Michael Natterer 2010-11-23 20:25:13 +01:00
parent fad1bc0de4
commit fb5dd9f72f
25 changed files with 150 additions and 145 deletions

View File

@ -43,6 +43,12 @@ struct _GdkAxisInfo
struct _GdkDevicePrivate
{
gchar *name;
GdkInputSource source;
GdkInputMode mode;
gboolean has_cursor;
gint num_keys;
GdkDeviceKey *keys;
GdkDeviceManager *device_manager;
GdkDisplay *display;
GdkDevice *associated;
@ -261,13 +267,11 @@ gdk_device_dispose (GObject *object)
priv->axes = NULL;
}
g_free (device->name);
g_free (device->keys);
g_free (device->axes);
g_free (priv->name);
g_free (priv->keys);
device->name = NULL;
device->keys = NULL;
device->axes = NULL;
priv->name = NULL;
priv->keys = NULL;
G_OBJECT_CLASS (gdk_device_parent_class)->dispose (object);
}
@ -290,22 +294,22 @@ gdk_device_set_property (GObject *object,
priv->device_manager = g_value_get_object (value);
break;
case PROP_NAME:
if (device->name)
g_free (device->name);
if (priv->name)
g_free (priv->name);
device->name = g_value_dup_string (value);
priv->name = g_value_dup_string (value);
break;
case PROP_TYPE:
priv->type = g_value_get_enum (value);
break;
case PROP_INPUT_SOURCE:
device->source = g_value_get_enum (value);
priv->source = g_value_get_enum (value);
break;
case PROP_INPUT_MODE:
gdk_device_set_mode (device, g_value_get_enum (value));
break;
case PROP_HAS_CURSOR:
device->has_cursor = g_value_get_boolean (value);
priv->has_cursor = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -334,21 +338,19 @@ gdk_device_get_property (GObject *object,
g_value_set_object (value, priv->associated);
break;
case PROP_NAME:
g_value_set_string (value,
device->name);
g_value_set_string (value, priv->name);
break;
case PROP_TYPE:
g_value_set_enum (value, priv->type);
break;
case PROP_INPUT_SOURCE:
g_value_set_enum (value, device->source);
g_value_set_enum (value, priv->source);
break;
case PROP_INPUT_MODE:
g_value_set_enum (value, device->mode);
g_value_set_enum (value, priv->mode);
break;
case PROP_HAS_CURSOR:
g_value_set_boolean (value,
device->has_cursor);
g_value_set_boolean (value, priv->has_cursor);
break;
case PROP_N_AXES:
g_value_set_uint (value, priv->axes->len);
@ -438,7 +440,7 @@ _gdk_device_allocate_history (GdkDevice *device,
for (i = 0; i < n_events; i++)
result[i] = g_malloc (sizeof (GdkTimeCoord) -
sizeof (double) * (GDK_MAX_TIMECOORD_AXES - device->num_axes));
sizeof (double) * (GDK_MAX_TIMECOORD_AXES - device->priv->axes->len));
return result;
}
@ -476,7 +478,7 @@ gdk_device_get_name (GdkDevice *device)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
return device->name;
return device->priv->name;
}
/**
@ -494,7 +496,7 @@ gdk_device_get_has_cursor (GdkDevice *device)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
return device->has_cursor;
return device->priv->has_cursor;
}
/**
@ -512,7 +514,7 @@ gdk_device_get_source (GdkDevice *device)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
return device->source;
return device->priv->source;
}
/**
@ -528,7 +530,8 @@ gdk_device_set_source (GdkDevice *device,
{
g_return_if_fail (GDK_IS_DEVICE (device));
device->source = source;
device->priv->source = source;
g_object_notify (G_OBJECT (device), "input-source");
}
/**
@ -546,7 +549,7 @@ gdk_device_get_mode (GdkDevice *device)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
return device->mode;
return device->priv->mode;
}
/**
@ -566,7 +569,7 @@ gdk_device_set_mode (GdkDevice *device,
{
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
if (device->mode == mode)
if (device->priv->mode == mode)
return TRUE;
if (mode == GDK_MODE_DISABLED &&
@ -575,7 +578,7 @@ gdk_device_set_mode (GdkDevice *device,
/* FIXME: setting has_cursor when mode is window? */
device->mode = mode;
device->priv->mode = mode;
g_object_notify (G_OBJECT (device), "input-mode");
if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER)
@ -584,6 +587,24 @@ gdk_device_set_mode (GdkDevice *device,
return TRUE;
}
/**
* gdk_device_get_n_keys:
* @device: a #GdkDevice
*
* Returns the number of keys the device currently has.
*
* Returns: the number of keys.
*
* Since: 3.0
**/
gint
gdk_device_get_n_keys (GdkDevice *device)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
return device->priv->num_keys;
}
/**
* gdk_device_get_key:
* @device: a #GdkDevice.
@ -605,17 +626,17 @@ gdk_device_get_key (GdkDevice *device,
GdkModifierType *modifiers)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
g_return_val_if_fail (index_ < device->num_keys, FALSE);
g_return_val_if_fail (index_ < device->priv->num_keys, FALSE);
if (!device->keys[index_].keyval &&
!device->keys[index_].modifiers)
if (!device->priv->keys[index_].keyval &&
!device->priv->keys[index_].modifiers)
return FALSE;
if (keyval)
*keyval = device->keys[index_].keyval;
*keyval = device->priv->keys[index_].keyval;
if (modifiers)
*modifiers = device->keys[index_].modifiers;
*modifiers = device->priv->keys[index_].modifiers;
return TRUE;
}
@ -637,10 +658,10 @@ gdk_device_set_key (GdkDevice *device,
GdkModifierType modifiers)
{
g_return_if_fail (GDK_IS_DEVICE (device));
g_return_if_fail (index_ < device->num_keys);
g_return_if_fail (index_ < device->priv->num_keys);
device->keys[index_].keyval = keyval;
device->keys[index_].modifiers = modifiers;
device->priv->keys[index_].keyval = keyval;
device->priv->keys[index_].modifiers = modifiers;
}
/**
@ -658,10 +679,14 @@ GdkAxisUse
gdk_device_get_axis_use (GdkDevice *device,
guint index_)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_AXIS_IGNORE);
g_return_val_if_fail (index_ < device->num_axes, GDK_AXIS_IGNORE);
GdkAxisInfo *info;
return device->axes[index_].use;
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_AXIS_IGNORE);
g_return_val_if_fail (index_ < device->priv->axes->len, GDK_AXIS_IGNORE);
info = &g_array_index (device->priv->axes, GdkAxisInfo, index_);
return info->use;
}
/**
@ -681,29 +706,27 @@ gdk_device_set_axis_use (GdkDevice *device,
GdkAxisInfo *info;
g_return_if_fail (GDK_IS_DEVICE (device));
g_return_if_fail (index_ < device->num_axes);
g_return_if_fail (index_ < device->priv->axes->len);
priv = device->priv;
info = &g_array_index (priv->axes, GdkAxisInfo, index_);
info->use = use;
device->axes[index_].use = use;
switch (use)
{
case GDK_AXIS_X:
case GDK_AXIS_Y:
device->axes[index_].min = info->min_axis = 0;
device->axes[index_].max = info->max_axis = 0;
info->min_axis = 0;
info->max_axis = 0;
break;
case GDK_AXIS_XTILT:
case GDK_AXIS_YTILT:
device->axes[index_].min = info->min_axis = -1;
device->axes[index_].max = info->max_axis = 1;
info->min_axis = -1;
info->max_axis = 1;
break;
default:
device->axes[index_].min = info->min_axis = 0;
device->axes[index_].max = info->max_axis = 1;
info->min_axis = 0;
info->max_axis = 1;
break;
}
}
@ -817,12 +840,12 @@ gdk_device_get_device_type (GdkDevice *device)
*
* Since: 3.0
**/
guint
gint
gdk_device_get_n_axes (GdkDevice *device)
{
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
return device->num_axes;
return device->priv->axes->len;
}
/**
@ -1093,10 +1116,6 @@ _gdk_device_reset_axes (GdkDevice *device)
g_array_remove_index (priv->axes, i);
g_object_notify (G_OBJECT (device), "n-axes");
/* This is done for backwards compatibility */
g_free (device->axes);
device->axes = NULL;
}
guint
@ -1138,16 +1157,7 @@ _gdk_device_add_axis (GdkDevice *device,
}
priv->axes = g_array_append_val (priv->axes, axis_info);
device->num_axes = priv->axes->len;
pos = device->num_axes - 1;
/* This is done for backwards compatibility, since the public
* struct doesn't actually store the device data.
*/
device->axes = g_realloc (device->axes, sizeof (GdkDeviceAxis) * priv->axes->len);
device->axes[pos].use = axis_info.use;
device->axes[pos].min = axis_info.min_axis;
device->axes[pos].max = axis_info.max_axis;
pos = device->priv->axes->len - 1;
g_object_notify (G_OBJECT (device), "n-axes");
@ -1158,11 +1168,11 @@ void
_gdk_device_set_keys (GdkDevice *device,
guint num_keys)
{
if (device->keys)
g_free (device->keys);
if (device->priv->keys)
g_free (device->priv->keys);
device->num_keys = num_keys;
device->keys = g_new0 (GdkDeviceKey, num_keys);
device->priv->num_keys = num_keys;
device->priv->keys = g_new0 (GdkDeviceKey, num_keys);
}
static GdkAxisInfo *
@ -1321,16 +1331,14 @@ _gdk_device_translate_screen_coord (GdkDevice *device,
gdouble value,
gdouble *axis_value)
{
GdkDevicePrivate *priv;
GdkDevicePrivate *priv = device->priv;
GdkAxisInfo axis_info;
gdouble axis_width, scale, offset;
GdkWindowObject *window_private;
if (device->mode != GDK_MODE_SCREEN)
if (priv->mode != GDK_MODE_SCREEN)
return FALSE;
priv = device->priv;
if (index_ >= priv->axes->len)
return FALSE;

View File

@ -194,18 +194,6 @@ struct _GdkDevice
{
GObject parent_instance;
/* All fields are read-only */
gchar *GSEAL (name);
GdkInputSource GSEAL (source);
GdkInputMode GSEAL (mode);
gboolean GSEAL (has_cursor); /* TRUE if a X pointer follows device motion */
gint GSEAL (num_axes);
GdkDeviceAxis *GSEAL (axes);
gint GSEAL (num_keys);
GdkDeviceKey *GSEAL (keys);
/*< private >*/
GdkDevicePrivate *priv;
};
@ -224,6 +212,7 @@ GdkInputMode gdk_device_get_mode (GdkDevice *device);
gboolean gdk_device_set_mode (GdkDevice *device,
GdkInputMode mode);
gint gdk_device_get_n_keys (GdkDevice *device);
gboolean gdk_device_get_key (GdkDevice *device,
guint index_,
guint *keyval,
@ -253,7 +242,7 @@ gboolean gdk_device_get_history (GdkDevice *device,
void gdk_device_free_history (GdkTimeCoord **events,
gint n_events);
guint gdk_device_get_n_axes (GdkDevice *device);
gint gdk_device_get_n_axes (GdkDevice *device);
GList * gdk_device_list_axes (GdkDevice *device);
gboolean gdk_device_get_axis_value (GdkDevice *device,
gdouble *axes,

View File

@ -494,7 +494,7 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
{
device = dev->data;
if (device->source != GDK_SOURCE_MOUSE)
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
continue;
gdk_device_ungrab (device, time_);
@ -570,7 +570,7 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
{
device = dev->data;
if (device->source != GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
continue;
gdk_device_ungrab (device, time);
@ -1209,7 +1209,7 @@ generate_grab_broken_event (GdkWindow *window,
event->grab_broken.implicit = implicit;
event->grab_broken.grab_window = grab_window;
gdk_event_set_device (event, device);
event->grab_broken.keyboard = (device->source == GDK_SOURCE_KEYBOARD) ? TRUE : FALSE;
event->grab_broken.keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) ? TRUE : FALSE;
gdk_event_put (event);
gdk_event_free (event);
@ -1538,7 +1538,7 @@ _gdk_display_device_grab_update (GdkDisplay *display,
if (!current_grab->activated)
{
if (device->source != GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
switch_to_pointer_grab (display, device, current_grab, NULL, time, current_serial);
}
@ -1566,7 +1566,7 @@ _gdk_display_device_grab_update (GdkDisplay *display,
grabs = g_list_delete_link (grabs, grabs);
g_hash_table_insert (display->device_grabs, device, grabs);
if (device->source != GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
switch_to_pointer_grab (display, device,
next_grab, current_grab,
time, current_serial);
@ -1663,7 +1663,7 @@ _gdk_display_check_grab_ownership (GdkDisplay *display,
g_hash_table_iter_init (&iter, display->device_grabs);
higher_ownership = device_ownership = GDK_OWNERSHIP_NONE;
device_is_keyboard = (device->source == GDK_SOURCE_KEYBOARD);
device_is_keyboard = (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
while (g_hash_table_iter_next (&iter, &key, &value))
{
@ -1679,8 +1679,8 @@ _gdk_display_check_grab_ownership (GdkDisplay *display,
continue;
/* Discard device if it's not of the same type */
if ((device_is_keyboard && dev->source != GDK_SOURCE_KEYBOARD) ||
(!device_is_keyboard && dev->source == GDK_SOURCE_KEYBOARD))
if ((device_is_keyboard && gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD) ||
(!device_is_keyboard && gdk_device_get_source (dev) == GDK_SOURCE_KEYBOARD))
continue;
grab = grabs->data;
@ -1813,7 +1813,7 @@ gdk_display_pointer_is_grabbed (GdkDisplay *display)
{
device = dev->data;
if (device->source == GDK_SOURCE_MOUSE &&
if (gdk_device_get_source (device) == GDK_SOURCE_MOUSE &&
gdk_display_device_is_grabbed (display, device))
return TRUE;
}

View File

@ -499,17 +499,16 @@ gdk_event_copy (const GdkEvent *event)
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->button.axes)
new_event->button.axes = g_memdup (event->button.axes,
sizeof (gdouble) * event->button.device->num_axes);
new_event->button.axes = g_memdup (event->button.axes,
sizeof (gdouble) * gdk_device_get_n_axes (event->button.device));
break;
case GDK_MOTION_NOTIFY:
if (event->motion.axes)
new_event->motion.axes = g_memdup (event->motion.axes,
sizeof (gdouble) * event->motion.device->num_axes);
new_event->motion.axes = g_memdup (event->motion.axes,
sizeof (gdouble) * gdk_device_get_n_axes (event->motion.device));
break;
default:
break;
}

View File

@ -8589,7 +8589,7 @@ send_crossing_event (GdkDisplay *display,
}
if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER &&
device->mode != GDK_MODE_DISABLED &&
gdk_device_get_mode (device) != GDK_MODE_DISABLED &&
!g_list_find (window->devices_inside, device))
window->devices_inside = g_list_prepend (window->devices_inside, device);
}
@ -8955,7 +8955,7 @@ gdk_pointer_grab (GdkWindow * window,
{
device = dev->data;
if (device->source != GDK_SOURCE_MOUSE)
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
continue;
res = _gdk_windowing_device_grab (device,
@ -9060,7 +9060,7 @@ gdk_keyboard_grab (GdkWindow *window,
{
device = dev->data;
if (device->source != GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
continue;
res = _gdk_windowing_device_grab (device,
@ -9448,7 +9448,7 @@ proxy_pointer_event (GdkDisplay *display,
event->motion.is_hint = is_hint;
event->motion.device = source_event->motion.device;
event->motion.axes = g_memdup (source_event->motion.axes,
sizeof (gdouble) * source_event->motion.device->num_axes);
sizeof (gdouble) * gdk_device_get_n_axes (source_event->motion.device));
}
}
@ -9557,7 +9557,7 @@ proxy_button_event (GdkEvent *source_event,
event->button.state = state;
event->button.device = source_event->button.device;
event->button.axes = g_memdup (source_event->button.axes,
sizeof (gdouble) * source_event->button.device->num_axes);
sizeof (gdouble) * gdk_device_get_n_axes (source_event->button.device));
if (type == GDK_BUTTON_PRESS)
_gdk_event_button_generate (display, event);

View File

@ -313,7 +313,7 @@ gdk_device_core_grab (GdkDevice *device,
else
xconfine_to = GDK_WINDOW_XID (confine_to);
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
/* Device is a keyboard */
status = XGrabKeyboard (GDK_DISPLAY_XDISPLAY (display),
@ -371,7 +371,7 @@ gdk_device_core_ungrab (GdkDevice *device,
display = gdk_device_get_display (device);
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
XUngrabKeyboard (GDK_DISPLAY_XDISPLAY (display), time_);
else
XUngrabPointer (GDK_DISPLAY_XDISPLAY (display), time_);

View File

@ -155,7 +155,8 @@ gdk_device_xi_constructed (GObject *object)
device->device_id);
if (gdk_error_trap_pop ())
g_warning ("Device %s can't be opened", GDK_DEVICE (device)->name);
g_warning ("Device %s can't be opened",
gdk_device_get_name (GDK_DEVICE (device)));
if (G_OBJECT_CLASS (gdk_device_xi_parent_class)->constructed)
G_OBJECT_CLASS (gdk_device_xi_parent_class)->constructed (object);
@ -556,10 +557,11 @@ gdk_device_xi_update_axes (GdkDevice *device,
int i;
device_xi = GDK_DEVICE_XI (device);
g_return_if_fail (first_axis >= 0 && first_axis + axes_count <= device->num_axes);
g_return_if_fail (first_axis >= 0 &&
first_axis + axes_count <= gdk_device_get_n_axes (device));
if (!device_xi->axis_data)
device_xi->axis_data = g_new0 (gint, device->num_axes);
device_xi->axis_data = g_new0 (gint, gdk_device_get_n_axes (device));
for (i = 0; i < axes_count; i++)
device_xi->axis_data[first_axis + i] = axis_data[i];
@ -577,6 +579,7 @@ gdk_device_xi_translate_axes (GdkDevice *device,
GdkWindow *impl_window;
gdouble root_x, root_y;
gdouble temp_x, temp_y;
gint n_axes;
gint i;
device_xi = GDK_DEVICE_XI (device);
@ -586,7 +589,9 @@ gdk_device_xi_translate_axes (GdkDevice *device,
if (!gdk_device_xi_get_window_info (impl_window, &root_x, &root_y))
return;
for (i = 0; i < device->num_axes; i++)
n_axes = gdk_device_get_n_axes (device);
for (i = 0; i < n_axes; i++)
{
GdkAxisUse use;
@ -596,7 +601,7 @@ gdk_device_xi_translate_axes (GdkDevice *device,
{
case GDK_AXIS_X:
case GDK_AXIS_Y:
if (device->mode == GDK_MODE_WINDOW)
if (gdk_device_get_mode (device) == GDK_MODE_WINDOW)
_gdk_device_translate_window_coord (device, window,
i, axis_data[i],
&axes[i]);

View File

@ -205,7 +205,7 @@ gdk_device_xi2_get_state (GdkDevice *device,
case GDK_AXIS_X:
case GDK_AXIS_Y:
case GDK_AXIS_IGNORE:
if (device->mode == GDK_MODE_WINDOW)
if (gdk_device_get_mode (device) == GDK_MODE_WINDOW)
_gdk_device_translate_window_coord (device, window, j, value, &axes[j]);
else
{

View File

@ -441,7 +441,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->button.x_root = (gdouble) xdbe->x_root;
event->button.y_root = (gdouble) xdbe->y_root;
event->button.axes = g_new0 (gdouble, device->num_axes);
event->button.axes = g_new0 (gdouble, gdk_device_get_n_axes (device));
gdk_device_xi_update_axes (device, xdbe->axes_count,
xdbe->first_axis, xdbe->axis_data);
gdk_device_xi_translate_axes (device, window,
@ -487,13 +487,15 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
xdke->keycode));
if (xdke->keycode < device_xi->min_keycode ||
xdke->keycode >= device_xi->min_keycode + device->num_keys)
xdke->keycode >= device_xi->min_keycode + gdk_device_get_n_keys (device))
{
g_warning ("Invalid device key code received");
return FALSE;
}
event->key.keyval = device->keys[xdke->keycode - device_xi->min_keycode].keyval;
gdk_device_get_key (device, xdke->keycode - device_xi->min_keycode,
&event->key.keyval,
&event->key.state);
if (event->key.keyval == 0)
{
@ -509,8 +511,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->key.window = g_object_ref (window);
event->key.time = xdke->time;
event->key.state = translate_state (xdke->state, xdke->device_state)
| device->keys[xdke->keycode - device_xi->min_keycode].modifiers;
event->key.state |= translate_state (xdke->state, xdke->device_state);
/* Add a string translation for the key event */
if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
@ -552,7 +553,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
event->motion.x_root = (gdouble) xdme->x_root;
event->motion.y_root = (gdouble) xdme->y_root;
event->motion.axes = g_new0 (gdouble, device->num_axes);
event->motion.axes = g_new0 (gdouble, gdk_device_get_n_axes (device));
gdk_device_xi_update_axes (device, xdme->axes_count,
xdme->first_axis, xdme->axis_data);
gdk_device_xi_translate_axes (device, window,
@ -626,7 +627,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator,
for (i = 0; i < xdse->num_classes; i++)
{
if (input_class->class == ValuatorClass)
gdk_device_xi_update_axes (device, device->num_axes, 0,
gdk_device_xi_update_axes (device, gdk_device_get_n_axes (device), 0,
((XValuatorState *)input_class)->valuators);
input_class = (XInputClass *)(((char *)input_class)+input_class->length);

View File

@ -268,7 +268,7 @@ add_device (GdkDeviceManagerXI2 *device_manager,
else if (dev->use == XIFloatingSlave)
device_manager->floating_devices = g_list_append (device_manager->floating_devices, device);
else
g_warning ("Unhandled device: %s\n", device->name);
g_warning ("Unhandled device: %s\n", gdk_device_get_name (device));
if (emit_signal)
g_signal_emit_by_name (device_manager, "device-added", device);
@ -755,7 +755,7 @@ translate_axes (GdkDevice *device,
{
case GDK_AXIS_X:
case GDK_AXIS_Y:
if (device->mode == GDK_MODE_WINDOW)
if (gdk_device_get_mode (device) == GDK_MODE_WINDOW)
_gdk_device_translate_window_coord (device, window, i, val, &axes[i]);
else
{
@ -1010,7 +1010,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->button.window,
&xev->valuators);
if (event->button.device->mode == GDK_MODE_WINDOW)
if (gdk_device_get_mode (event->button.device) == GDK_MODE_WINDOW)
{
GdkDevice *device = event->button.device;
@ -1061,7 +1061,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->motion.window,
&xev->valuators);
if (event->motion.device->mode == GDK_MODE_WINDOW)
if (gdk_device_get_mode (event->motion.device) == GDK_MODE_WINDOW)
{
GdkDevice *device = event->motion.device;

View File

@ -1152,7 +1152,7 @@ _gdk_input_init (GdkDisplay *display)
{
device = l->data;
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
continue;
display_x11->input_devices = g_list_prepend (display_x11->input_devices,
@ -1170,7 +1170,7 @@ _gdk_input_init (GdkDisplay *display)
{
device = list->data;
if (device->source != GDK_SOURCE_MOUSE)
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
continue;
display->core_pointer = device;

View File

@ -1827,10 +1827,10 @@ gtk_real_button_activate (GtkButton *button)
device = gtk_get_current_event_device ();
if (device && device->source != GDK_SOURCE_KEYBOARD)
if (device && gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
g_return_if_fail (device && device->source == GDK_SOURCE_KEYBOARD);
g_return_if_fail (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
if (gtk_widget_get_realized (widget) && !priv->activate_timeout)
{

View File

@ -616,7 +616,7 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
if (!device)
return NULL;
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
keyb = device;
pointer = gdk_device_get_associated_device (device);

View File

@ -1912,7 +1912,7 @@ get_screen_color (GtkWidget *button)
device = gtk_get_current_event_device ();
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
keyb_device = device;
pointer_device = gdk_device_get_associated_device (device);

View File

@ -2199,7 +2199,7 @@ gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
time = gtk_get_current_event_time ();
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
keyboard = device;
pointer = gdk_device_get_associated_device (device);

View File

@ -2329,7 +2329,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
pointer = gdk_event_get_device (event);
if (pointer->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (pointer) == GDK_SOURCE_KEYBOARD)
{
keyboard = pointer;
pointer = gdk_device_get_associated_device (keyboard);

View File

@ -9710,7 +9710,7 @@ gtk_entry_completion_changed (GtkWidget *widget,
device = gtk_get_current_event_device ();
if (device && device->source == GDK_SOURCE_KEYBOARD)
if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
if (device)

View File

@ -1469,7 +1469,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
menu_shell = GTK_MENU_SHELL (menu);
priv = gtk_menu_get_private (menu);
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
keyboard = device;
pointer = gdk_device_get_associated_device (device);

View File

@ -1807,7 +1807,7 @@ _gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
if (!device)
priv->grab_pointer = NULL;
else if (device->source == GDK_SOURCE_KEYBOARD)
else if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
priv->grab_pointer = gdk_device_get_associated_device (device);
else
priv->grab_pointer = device;

View File

@ -378,7 +378,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
{
GdkDevice *device = d->data;
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
keyboard = device;
}

View File

@ -1027,7 +1027,7 @@ gtk_scale_popup (GtkWidget *widget,
device = gdk_event_get_device (event);
if (device->source == GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
keyboard = device;
pointer = gdk_device_get_associated_device (device);

View File

@ -1350,7 +1350,7 @@ _gtk_tooltip_focus_in (GtkWidget *widget)
device = gtk_get_current_event_device ();
if (device && device->source == GDK_SOURCE_KEYBOARD)
if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
/* This function should be called by either a focus in event,

View File

@ -10407,7 +10407,7 @@ send_focus_change (GtkWidget *widget,
GdkEvent *fevent;
GdkWindow *window;
if (dev->source != GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD)
continue;
window = gtk_widget_get_window (widget);

View File

@ -5923,7 +5923,7 @@ do_focus_change (GtkWidget *widget,
GdkDevice *dev = d->data;
GdkEvent *fevent;
if (dev->source != GDK_SOURCE_KEYBOARD)
if (gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD)
continue;
/* Skip non-master keyboards that haven't

View File

@ -46,7 +46,7 @@ static void
update_cursor (GtkWidget *widget, gdouble x, gdouble y)
{
static gint cursor_present = 0;
gint state = !current_device->has_cursor && cursor_proximity;
gint state = !gdk_device_get_has_cursor (current_device) && cursor_proximity;
if (surface != NULL)
{
@ -167,9 +167,9 @@ print_axes (GdkDevice *device, gdouble *axes)
if (axes)
{
g_print ("%s ", device->name);
for (i=0; i<device->num_axes; i++)
g_print ("%s ", gdk_device_get_name (device));
for (i = 0; i < gdk_device_get_n_axes (device); i++)
g_print ("%g ", axes[i]);
g_print ("\n");
@ -188,8 +188,9 @@ button_press_event (GtkWidget *widget, GdkEventButton *event)
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);
draw_brush (widget, gdk_device_get_source (event->device),
event->x, event->y, pressure);
motion_time = event->time;
}
@ -232,7 +233,8 @@ motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
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);
draw_brush (widget, gdk_device_get_source (event->device),
x, y, pressure);
print_axes (event->device, events[i]->axes);
}
@ -244,7 +246,8 @@ motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, event->device->source, event->x, event->y, pressure);
draw_brush (widget, gdk_device_get_source (event->device),
event->x, event->y, pressure);
}
motion_time = event->time;
}