1
0
Fork 0

device/x11: Store min/max keycode in the XI device class

The generic device class shouldn't have the minimum and maximum keycode,
since no other input backend provides those.
This commit is contained in:
Emmanuele Bassi 2011-01-21 10:24:34 +00:00
parent a277b4091a
commit 6da51f6ed3
5 changed files with 20 additions and 31 deletions

View file

@ -100,8 +100,6 @@ struct _ClutterInputDevice
guint n_keys;
GArray *keys;
gint min_keycode;
gint max_keycode;
guint has_cursor : 1;
guint is_enabled : 1;
@ -140,10 +138,8 @@ void _clutter_input_device_set_stage (ClutterInputDev
void _clutter_input_device_set_actor (ClutterInputDevice *device,
ClutterActor *actor);
ClutterActor * _clutter_input_device_update (ClutterInputDevice *device);
void _clutter_input_device_set_keys (ClutterInputDevice *device,
guint n_keys,
gint min_keycode,
gint max_keycode);
void _clutter_input_device_set_n_keys (ClutterInputDevice *device,
guint n_keys);
guint _clutter_input_device_add_axis (ClutterInputDevice *device,
ClutterInputAxis axis,
gdouble min_value,

View file

@ -364,9 +364,6 @@ clutter_input_device_init (ClutterInputDevice *self)
self->current_y = self->previous_y = -1;
self->current_button_number = self->previous_button_number = -1;
self->current_state = self->previous_state = 0;
self->min_keycode = 0;
self->max_keycode = G_MAXUINT;
}
/*< private >
@ -1192,11 +1189,9 @@ clutter_input_device_get_n_axes (ClutterInputDevice *device)
}
/*< private >
* clutter_input_device_set_keys:
* clutter_input_device_set_n_keys:
* @device: a #ClutterInputDevice
* @n_keys: the number of keys of the device
* @min_keycode: the minimum key code
* @max_keycode: the maximum key code
*
* Initializes the keys of @device.
*
@ -1204,10 +1199,8 @@ clutter_input_device_get_n_axes (ClutterInputDevice *device)
* and modifiers.
*/
void
_clutter_input_device_set_keys (ClutterInputDevice *device,
guint n_keys,
gint min_keycode,
gint max_keycode)
_clutter_input_device_set_n_keys (ClutterInputDevice *device,
guint n_keys)
{
if (device->keys != NULL)
g_array_free (device->keys, TRUE);
@ -1216,9 +1209,6 @@ _clutter_input_device_set_keys (ClutterInputDevice *device,
device->keys = g_array_sized_new (FALSE, TRUE,
sizeof (ClutterKeyInfo),
n_keys);
device->min_keycode = min_keycode;
device->max_keycode = max_keycode;
}
/**
@ -1263,8 +1253,6 @@ clutter_input_device_set_key (ClutterInputDevice *device,
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
g_return_if_fail (index_ < device->n_keys);
g_return_if_fail (keyval >= device->min_keycode &&
keyval <= device->max_keycode);
key_info = &g_array_index (device->keys, ClutterKeyInfo, index_);
key_info->keyval = keyval;

View file

@ -86,12 +86,16 @@ translate_class_info (ClutterInputDevice *device,
case KeyClass:
{
XKeyInfo *xk_info = (XKeyInfo *) any_class;
ClutterInputDeviceX11 *device_x11;
guint n_keys;
device_x11 = CLUTTER_INPUT_DEVICE_X11 (device);
n_keys = xk_info->max_keycode - xk_info->min_keycode + 1;
_clutter_input_device_set_keys (device, n_keys,
xk_info->min_keycode,
xk_info->max_keycode);
_clutter_input_device_set_n_keys (device, n_keys);
device_x11->min_keycode = xk_info->min_keycode;
device_x11->max_keycode = xk_info->max_keycode;
}
break;

View file

@ -126,10 +126,8 @@ translate_device_classes (Display *xdisplay,
XIKeyClassInfo *key_info = (XIKeyClassInfo *) class_info;
gint j;
_clutter_input_device_set_keys (device,
key_info->num_keycodes,
0,
G_MAXUINT);
_clutter_input_device_set_n_keys (device,
key_info->num_keycodes);
for (j = 0; j < key_info->num_keycodes; j++)
{

View file

@ -61,6 +61,9 @@ struct _ClutterInputDeviceX11
#endif /* HAVE_XINPUT */
gint *axis_data;
gint min_keycode;
gint max_keycode;
};
#define clutter_input_device_x11_get_type _clutter_input_device_x11_get_type
@ -349,15 +352,15 @@ _clutter_input_device_x11_translate_xi_event (ClutterInputDeviceX11 *device_x11,
{
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *) xevent;
if (xdke->keycode < device->min_keycode ||
xdke->keycode >= device->max_keycode)
if (xdke->keycode < device_x11->min_keycode ||
xdke->keycode >= device_x11->max_keycode)
{
g_warning ("Invalid device key code received: %d", xdke->keycode);
return FALSE;
}
clutter_input_device_get_key (device,
xdke->keycode - device->min_keycode,
xdke->keycode - device_x11->min_keycode,
&event->key.keyval,
&event->key.modifier_state);
if (event->key.keyval == 0)