clutter: Drop keycode_to_evdev vmethod
This is just used in the native backend, move it to an utility function there. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
parent
c7f989c1e2
commit
71b4c0ee02
@ -114,9 +114,4 @@ CLUTTER_EXPORT
|
|||||||
void _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
|
void _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
|
||||||
ClutterEvent *event);
|
ClutterEvent *event);
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
gboolean clutter_input_device_keycode_to_evdev (ClutterInputDevice *device,
|
|
||||||
guint hardware_keycode,
|
|
||||||
guint *evdev_keycode);
|
|
||||||
|
|
||||||
#endif /* CLUTTER_INPUT_DEVICE_PRIVATE_H */
|
#endif /* CLUTTER_INPUT_DEVICE_PRIVATE_H */
|
||||||
|
@ -813,40 +813,6 @@ _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_keycode_to_evdev:
|
|
||||||
* @device: A #ClutterInputDevice
|
|
||||||
* @hardware_keycode: The hardware keycode from a #ClutterKeyEvent
|
|
||||||
* @evdev_keycode: The return location for the evdev keycode
|
|
||||||
*
|
|
||||||
* Translates a hardware keycode from a #ClutterKeyEvent to the
|
|
||||||
* equivalent evdev keycode. Note that depending on the input backend
|
|
||||||
* used by Clutter this function can fail if there is no obvious
|
|
||||||
* mapping between the key codes. The hardware keycode can be taken
|
|
||||||
* from the #ClutterKeyEvent.hardware_keycode member of #ClutterKeyEvent.
|
|
||||||
*
|
|
||||||
* Return value: %TRUE if the conversion succeeded, %FALSE otherwise.
|
|
||||||
*
|
|
||||||
* Since: 1.10
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
clutter_input_device_keycode_to_evdev (ClutterInputDevice *device,
|
|
||||||
guint hardware_keycode,
|
|
||||||
guint *evdev_keycode)
|
|
||||||
{
|
|
||||||
ClutterInputDeviceClass *device_class;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
||||||
|
|
||||||
device_class = CLUTTER_INPUT_DEVICE_GET_CLASS (device);
|
|
||||||
if (device_class->keycode_to_evdev == NULL)
|
|
||||||
return FALSE;
|
|
||||||
else
|
|
||||||
return device_class->keycode_to_evdev (device,
|
|
||||||
hardware_keycode,
|
|
||||||
evdev_keycode);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_grab_actor_destroy (ClutterActor *actor,
|
on_grab_actor_destroy (ClutterActor *actor,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
|
@ -41,10 +41,6 @@ struct _ClutterInputDeviceClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
gboolean (* keycode_to_evdev) (ClutterInputDevice *device,
|
|
||||||
guint hardware_keycode,
|
|
||||||
guint *evdev_keycode);
|
|
||||||
|
|
||||||
gboolean (* is_mode_switch_button) (ClutterInputDevice *device,
|
gboolean (* is_mode_switch_button) (ClutterInputDevice *device,
|
||||||
guint group,
|
guint group,
|
||||||
guint button);
|
guint button);
|
||||||
|
@ -120,19 +120,6 @@ meta_input_device_native_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
meta_input_device_native_keycode_to_evdev (ClutterInputDevice *device,
|
|
||||||
uint32_t hardware_keycode,
|
|
||||||
uint32_t *evdev_keycode)
|
|
||||||
{
|
|
||||||
/* The hardware keycodes from the evdev backend are almost evdev
|
|
||||||
keycodes: we use the evdev keycode file, but xkb rules have an
|
|
||||||
offset by 8. See the comment in _clutter_key_event_new_from_evdev()
|
|
||||||
*/
|
|
||||||
*evdev_keycode = hardware_keycode - 8;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_input_device_native_is_mode_switch_button (ClutterInputDevice *device,
|
meta_input_device_native_is_mode_switch_button (ClutterInputDevice *device,
|
||||||
uint32_t group,
|
uint32_t group,
|
||||||
@ -1203,7 +1190,6 @@ meta_input_device_native_class_init (MetaInputDeviceNativeClass *klass)
|
|||||||
object_class->set_property = meta_input_device_native_set_property;
|
object_class->set_property = meta_input_device_native_set_property;
|
||||||
object_class->get_property = meta_input_device_native_get_property;
|
object_class->get_property = meta_input_device_native_get_property;
|
||||||
|
|
||||||
device_manager_class->keycode_to_evdev = meta_input_device_native_keycode_to_evdev;
|
|
||||||
device_manager_class->is_mode_switch_button = meta_input_device_native_is_mode_switch_button;
|
device_manager_class->is_mode_switch_button = meta_input_device_native_is_mode_switch_button;
|
||||||
device_manager_class->get_group_n_modes = meta_input_device_native_get_group_n_modes;
|
device_manager_class->get_group_n_modes = meta_input_device_native_get_group_n_modes;
|
||||||
device_manager_class->is_grouped = meta_input_device_native_is_grouped;
|
device_manager_class->is_grouped = meta_input_device_native_is_grouped;
|
||||||
|
@ -538,8 +538,7 @@ apply_level_modifiers (ClutterVirtualInputDevice *virtual_device,
|
|||||||
&keycode, NULL))
|
&keycode, NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clutter_input_device_keycode_to_evdev (virtual_evdev->impl_state->device,
|
evcode = meta_xkb_keycode_to_evdev (keycode);
|
||||||
keycode, &evcode);
|
|
||||||
|
|
||||||
meta_topic (META_DEBUG_INPUT,
|
meta_topic (META_DEBUG_INPUT,
|
||||||
"Emitting virtual key-%s of modifier key 0x%x (device %p)",
|
"Emitting virtual key-%s of modifier key 0x%x (device %p)",
|
||||||
@ -576,8 +575,7 @@ notify_keyval (GTask *task)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
clutter_input_device_keycode_to_evdev (virtual_evdev->impl_state->device,
|
evcode = meta_xkb_keycode_to_evdev (keycode);
|
||||||
keycode, &evcode);
|
|
||||||
|
|
||||||
if (get_button_type (evcode) != EVDEV_BUTTON_TYPE_KEY)
|
if (get_button_type (evcode) != EVDEV_BUTTON_TYPE_KEY)
|
||||||
{
|
{
|
||||||
|
@ -118,3 +118,13 @@ meta_xkb_translate_modifiers (struct xkb_state *state,
|
|||||||
|
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
meta_xkb_keycode_to_evdev (uint32_t xkb_keycode)
|
||||||
|
{
|
||||||
|
/* The keycodes from the evdev backend are almost evdev
|
||||||
|
* keycodes: we use the evdev keycode file, but xkb rules have an
|
||||||
|
* offset by 8. See the comment in _clutter_key_event_new_from_evdev()
|
||||||
|
*/
|
||||||
|
return xkb_keycode - 8;
|
||||||
|
}
|
||||||
|
@ -37,5 +37,6 @@ void meta_xkb_translate_state (ClutterEvent *event,
|
|||||||
uint32_t button_state);
|
uint32_t button_state);
|
||||||
ClutterModifierType meta_xkb_translate_modifiers (struct xkb_state *state,
|
ClutterModifierType meta_xkb_translate_modifiers (struct xkb_state *state,
|
||||||
ClutterModifierType button_state);
|
ClutterModifierType button_state);
|
||||||
|
uint32_t meta_xkb_keycode_to_evdev (uint32_t hardware_keycode);
|
||||||
|
|
||||||
#endif /* META_XKB_UTILS_H */
|
#endif /* META_XKB_UTILS_H */
|
||||||
|
@ -106,20 +106,6 @@ meta_input_device_x11_constructed (GObject *object)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
meta_input_device_x11_keycode_to_evdev (ClutterInputDevice *device,
|
|
||||||
uint32_t hardware_keycode,
|
|
||||||
uint32_t *evdev_keycode)
|
|
||||||
{
|
|
||||||
/* When using evdev under X11 the hardware keycodes are the evdev
|
|
||||||
keycodes plus 8. I haven't been able to find any documentation to
|
|
||||||
know what the +8 is for. FIXME: This should probably verify that
|
|
||||||
X server is using evdev. */
|
|
||||||
*evdev_keycode = hardware_keycode - 8;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_input_device_x11_is_grouped (ClutterInputDevice *device,
|
meta_input_device_x11_is_grouped (ClutterInputDevice *device,
|
||||||
ClutterInputDevice *other_device)
|
ClutterInputDevice *other_device)
|
||||||
@ -296,7 +282,6 @@ meta_input_device_x11_class_init (MetaInputDeviceX11Class *klass)
|
|||||||
gobject_class->set_property = meta_input_device_x11_set_property;
|
gobject_class->set_property = meta_input_device_x11_set_property;
|
||||||
gobject_class->get_property = meta_input_device_x11_get_property;
|
gobject_class->get_property = meta_input_device_x11_get_property;
|
||||||
|
|
||||||
device_class->keycode_to_evdev = meta_input_device_x11_keycode_to_evdev;
|
|
||||||
device_class->is_grouped = meta_input_device_x11_is_grouped;
|
device_class->is_grouped = meta_input_device_x11_is_grouped;
|
||||||
device_class->get_group_n_modes = meta_input_device_x11_get_group_n_modes;
|
device_class->get_group_n_modes = meta_input_device_x11_get_group_n_modes;
|
||||||
device_class->is_mode_switch_button = meta_input_device_x11_is_mode_switch_button;
|
device_class->is_mode_switch_button = meta_input_device_x11_is_mode_switch_button;
|
||||||
|
Loading…
Reference in New Issue
Block a user