clutter: Remove input device grabs
Both device-global and input-sequence-local. These are no longer used, in favor of ClutterGrab. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
This commit is contained in:
parent
b8853b07a5
commit
ac4face82a
@ -53,12 +53,6 @@ struct _ClutterInputDevice
|
|||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
/* the actor that has a grab in place for the device */
|
|
||||||
ClutterActor *pointer_grab_actor;
|
|
||||||
ClutterActor *keyboard_grab_actor;
|
|
||||||
GHashTable *sequence_grab_actors;
|
|
||||||
GHashTable *inv_sequence_grab_actors;
|
|
||||||
|
|
||||||
/* Accessiblity */
|
/* Accessiblity */
|
||||||
ClutterVirtualInputDevice *accessibility_virtual_device;
|
ClutterVirtualInputDevice *accessibility_virtual_device;
|
||||||
ClutterPtrA11yData *ptr_a11y_data;
|
ClutterPtrA11yData *ptr_a11y_data;
|
||||||
|
@ -518,303 +518,6 @@ clutter_input_device_get_device_mode (ClutterInputDevice *device)
|
|||||||
return priv->device_mode;
|
return priv->device_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
on_grab_actor_destroy (ClutterActor *actor,
|
|
||||||
ClutterInputDevice *device)
|
|
||||||
{
|
|
||||||
ClutterInputDevicePrivate *priv =
|
|
||||||
clutter_input_device_get_instance_private (device);
|
|
||||||
|
|
||||||
switch (priv->device_type)
|
|
||||||
{
|
|
||||||
case CLUTTER_POINTER_DEVICE:
|
|
||||||
case CLUTTER_TABLET_DEVICE:
|
|
||||||
device->pointer_grab_actor = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_KEYBOARD_DEVICE:
|
|
||||||
device->keyboard_grab_actor = NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_grab:
|
|
||||||
* @device: a #ClutterInputDevice
|
|
||||||
* @actor: a #ClutterActor
|
|
||||||
*
|
|
||||||
* Acquires a grab on @actor for the given @device.
|
|
||||||
*
|
|
||||||
* Any event coming from @device will be delivered to @actor, bypassing
|
|
||||||
* the usual event delivery mechanism, until the grab is released by
|
|
||||||
* calling clutter_input_device_ungrab().
|
|
||||||
*
|
|
||||||
* The grab is client-side: even if the windowing system used by the Clutter
|
|
||||||
* backend has the concept of "device grabs", Clutter will not use them.
|
|
||||||
*
|
|
||||||
* Only #ClutterInputDevice of types %CLUTTER_POINTER_DEVICE,
|
|
||||||
* %CLUTTER_TABLET_DEVICE and %CLUTTER_KEYBOARD_DEVICE can hold a grab.
|
|
||||||
*
|
|
||||||
* Since: 1.10
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clutter_input_device_grab (ClutterInputDevice *device,
|
|
||||||
ClutterActor *actor)
|
|
||||||
{
|
|
||||||
ClutterActor **grab_actor;
|
|
||||||
ClutterInputDevicePrivate *priv =
|
|
||||||
clutter_input_device_get_instance_private (device);
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
|
||||||
|
|
||||||
switch (priv->device_type)
|
|
||||||
{
|
|
||||||
case CLUTTER_POINTER_DEVICE:
|
|
||||||
case CLUTTER_TABLET_DEVICE:
|
|
||||||
grab_actor = &device->pointer_grab_actor;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_KEYBOARD_DEVICE:
|
|
||||||
grab_actor = &device->keyboard_grab_actor;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
g_critical ("Only pointer and keyboard devices can grab an actor");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*grab_actor != NULL)
|
|
||||||
{
|
|
||||||
g_signal_handlers_disconnect_by_func (*grab_actor,
|
|
||||||
G_CALLBACK (on_grab_actor_destroy),
|
|
||||||
device);
|
|
||||||
}
|
|
||||||
|
|
||||||
*grab_actor = actor;
|
|
||||||
|
|
||||||
g_signal_connect (*grab_actor,
|
|
||||||
"destroy",
|
|
||||||
G_CALLBACK (on_grab_actor_destroy),
|
|
||||||
device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_ungrab:
|
|
||||||
* @device: a #ClutterInputDevice
|
|
||||||
*
|
|
||||||
* Releases the grab on the @device, if one is in place.
|
|
||||||
*
|
|
||||||
* Since: 1.10
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clutter_input_device_ungrab (ClutterInputDevice *device)
|
|
||||||
{
|
|
||||||
ClutterActor **grab_actor;
|
|
||||||
ClutterInputDevicePrivate *priv =
|
|
||||||
clutter_input_device_get_instance_private (device);
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
||||||
|
|
||||||
switch (priv->device_type)
|
|
||||||
{
|
|
||||||
case CLUTTER_POINTER_DEVICE:
|
|
||||||
case CLUTTER_TABLET_DEVICE:
|
|
||||||
grab_actor = &device->pointer_grab_actor;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_KEYBOARD_DEVICE:
|
|
||||||
grab_actor = &device->keyboard_grab_actor;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*grab_actor == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (*grab_actor,
|
|
||||||
G_CALLBACK (on_grab_actor_destroy),
|
|
||||||
device);
|
|
||||||
|
|
||||||
*grab_actor = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_get_grabbed_actor:
|
|
||||||
* @device: a #ClutterInputDevice
|
|
||||||
*
|
|
||||||
* Retrieves a pointer to the #ClutterActor currently grabbing all
|
|
||||||
* the events coming from @device.
|
|
||||||
*
|
|
||||||
* Return value: (transfer none): a #ClutterActor, or %NULL
|
|
||||||
*
|
|
||||||
* Since: 1.10
|
|
||||||
*/
|
|
||||||
ClutterActor *
|
|
||||||
clutter_input_device_get_grabbed_actor (ClutterInputDevice *device)
|
|
||||||
{
|
|
||||||
ClutterInputDevicePrivate *priv =
|
|
||||||
clutter_input_device_get_instance_private (device);
|
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
||||||
|
|
||||||
switch (priv->device_type)
|
|
||||||
{
|
|
||||||
case CLUTTER_POINTER_DEVICE:
|
|
||||||
case CLUTTER_TABLET_DEVICE:
|
|
||||||
return device->pointer_grab_actor;
|
|
||||||
|
|
||||||
case CLUTTER_KEYBOARD_DEVICE:
|
|
||||||
return device->keyboard_grab_actor;
|
|
||||||
|
|
||||||
default:
|
|
||||||
g_critical ("Only pointer and keyboard devices can grab an actor");
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_grab_sequence_actor_destroy (ClutterActor *actor,
|
|
||||||
ClutterInputDevice *device)
|
|
||||||
{
|
|
||||||
ClutterEventSequence *sequence =
|
|
||||||
g_hash_table_lookup (device->inv_sequence_grab_actors, actor);
|
|
||||||
|
|
||||||
if (sequence != NULL)
|
|
||||||
{
|
|
||||||
g_hash_table_remove (device->sequence_grab_actors, sequence);
|
|
||||||
g_hash_table_remove (device->inv_sequence_grab_actors, actor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_sequence_grab:
|
|
||||||
* @device: a #ClutterInputDevice
|
|
||||||
* @sequence: a #ClutterEventSequence
|
|
||||||
* @actor: a #ClutterActor
|
|
||||||
*
|
|
||||||
* Acquires a grab on @actor for the given @device and the given touch
|
|
||||||
* @sequence.
|
|
||||||
*
|
|
||||||
* Any touch event coming from @device and from @sequence will be
|
|
||||||
* delivered to @actor, bypassing the usual event delivery mechanism,
|
|
||||||
* until the grab is released by calling
|
|
||||||
* clutter_input_device_sequence_ungrab().
|
|
||||||
*
|
|
||||||
* The grab is client-side: even if the windowing system used by the Clutter
|
|
||||||
* backend has the concept of "device grabs", Clutter will not use them.
|
|
||||||
*
|
|
||||||
* Since: 1.12
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clutter_input_device_sequence_grab (ClutterInputDevice *device,
|
|
||||||
ClutterEventSequence *sequence,
|
|
||||||
ClutterActor *actor)
|
|
||||||
{
|
|
||||||
ClutterActor *grab_actor;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
|
||||||
|
|
||||||
if (device->sequence_grab_actors == NULL)
|
|
||||||
{
|
|
||||||
grab_actor = NULL;
|
|
||||||
device->sequence_grab_actors = g_hash_table_new (NULL, NULL);
|
|
||||||
device->inv_sequence_grab_actors = g_hash_table_new (NULL, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grab_actor != NULL)
|
|
||||||
{
|
|
||||||
g_signal_handlers_disconnect_by_func (grab_actor,
|
|
||||||
G_CALLBACK (on_grab_sequence_actor_destroy),
|
|
||||||
device);
|
|
||||||
g_hash_table_remove (device->sequence_grab_actors, sequence);
|
|
||||||
g_hash_table_remove (device->inv_sequence_grab_actors, grab_actor);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_insert (device->sequence_grab_actors, sequence, actor);
|
|
||||||
g_hash_table_insert (device->inv_sequence_grab_actors, actor, sequence);
|
|
||||||
g_signal_connect (actor,
|
|
||||||
"destroy",
|
|
||||||
G_CALLBACK (on_grab_sequence_actor_destroy),
|
|
||||||
device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_sequence_ungrab:
|
|
||||||
* @device: a #ClutterInputDevice
|
|
||||||
* @sequence: a #ClutterEventSequence
|
|
||||||
*
|
|
||||||
* Releases the grab on the @device for the given @sequence, if one is
|
|
||||||
* in place.
|
|
||||||
*
|
|
||||||
* Since: 1.12
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clutter_input_device_sequence_ungrab (ClutterInputDevice *device,
|
|
||||||
ClutterEventSequence *sequence)
|
|
||||||
{
|
|
||||||
ClutterActor *grab_actor;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
||||||
|
|
||||||
if (device->sequence_grab_actors == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
||||||
|
|
||||||
if (grab_actor == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (grab_actor,
|
|
||||||
G_CALLBACK (on_grab_sequence_actor_destroy),
|
|
||||||
device);
|
|
||||||
g_hash_table_remove (device->sequence_grab_actors, sequence);
|
|
||||||
g_hash_table_remove (device->inv_sequence_grab_actors, grab_actor);
|
|
||||||
|
|
||||||
if (g_hash_table_size (device->sequence_grab_actors) == 0)
|
|
||||||
{
|
|
||||||
g_hash_table_destroy (device->sequence_grab_actors);
|
|
||||||
device->sequence_grab_actors = NULL;
|
|
||||||
g_hash_table_destroy (device->inv_sequence_grab_actors);
|
|
||||||
device->inv_sequence_grab_actors = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_input_device_sequence_get_grabbed_actor:
|
|
||||||
* @device: a #ClutterInputDevice
|
|
||||||
* @sequence: a #ClutterEventSequence
|
|
||||||
*
|
|
||||||
* Retrieves a pointer to the #ClutterActor currently grabbing the
|
|
||||||
* touch events coming from @device given the @sequence.
|
|
||||||
*
|
|
||||||
* Return value: (transfer none): a #ClutterActor, or %NULL
|
|
||||||
*
|
|
||||||
* Since: 1.12
|
|
||||||
*/
|
|
||||||
ClutterActor *
|
|
||||||
clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device,
|
|
||||||
ClutterEventSequence *sequence)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
||||||
|
|
||||||
if (device->sequence_grab_actors == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_input_device_get_vendor_id:
|
* clutter_input_device_get_vendor_id:
|
||||||
* @device: a physical #ClutterInputDevice
|
* @device: a physical #ClutterInputDevice
|
||||||
|
@ -80,25 +80,6 @@ ClutterInputMode clutter_input_device_get_device_mode (ClutterInputDev
|
|||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
gboolean clutter_input_device_get_has_cursor (ClutterInputDevice *device);
|
gboolean clutter_input_device_get_has_cursor (ClutterInputDevice *device);
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
void clutter_input_device_grab (ClutterInputDevice *device,
|
|
||||||
ClutterActor *actor);
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
void clutter_input_device_ungrab (ClutterInputDevice *device);
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
ClutterActor * clutter_input_device_get_grabbed_actor (ClutterInputDevice *device);
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
void clutter_input_device_sequence_grab (ClutterInputDevice *device,
|
|
||||||
ClutterEventSequence *sequence,
|
|
||||||
ClutterActor *actor);
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
void clutter_input_device_sequence_ungrab (ClutterInputDevice *device,
|
|
||||||
ClutterEventSequence *sequence);
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
ClutterActor * clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device,
|
|
||||||
ClutterEventSequence *sequence);
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
const gchar * clutter_input_device_get_vendor_id (ClutterInputDevice *device);
|
const gchar * clutter_input_device_get_vendor_id (ClutterInputDevice *device);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
|
@ -697,9 +697,6 @@ static inline void
|
|||||||
emit_pointer_event (ClutterEvent *event,
|
emit_pointer_event (ClutterEvent *event,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
if (device != NULL && device->pointer_grab_actor != NULL)
|
|
||||||
clutter_actor_event (device->pointer_grab_actor, event, FALSE);
|
|
||||||
else
|
|
||||||
emit_event_chain (event);
|
emit_event_chain (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,23 +704,6 @@ static inline void
|
|||||||
emit_crossing_event (ClutterEvent *event,
|
emit_crossing_event (ClutterEvent *event,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
|
||||||
ClutterActor *grab_actor = NULL;
|
|
||||||
|
|
||||||
if (sequence)
|
|
||||||
{
|
|
||||||
if (device->sequence_grab_actors != NULL)
|
|
||||||
grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (device != NULL && device->pointer_grab_actor != NULL)
|
|
||||||
grab_actor = device->pointer_grab_actor;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grab_actor != NULL)
|
|
||||||
clutter_actor_event (grab_actor, event, FALSE);
|
|
||||||
else
|
|
||||||
emit_event_chain (event);
|
emit_event_chain (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,25 +711,8 @@ static inline void
|
|||||||
emit_touch_event (ClutterEvent *event,
|
emit_touch_event (ClutterEvent *event,
|
||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
ClutterActor *grab_actor = NULL;
|
|
||||||
|
|
||||||
if (device->sequence_grab_actors != NULL)
|
|
||||||
{
|
|
||||||
grab_actor = g_hash_table_lookup (device->sequence_grab_actors,
|
|
||||||
event->touch.sequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grab_actor != NULL)
|
|
||||||
{
|
|
||||||
/* per-device sequence grab */
|
|
||||||
clutter_actor_event (grab_actor, event, FALSE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* no grab, time to capture and bubble */
|
|
||||||
emit_event_chain (event);
|
emit_event_chain (event);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
process_key_event (ClutterEvent *event,
|
process_key_event (ClutterEvent *event,
|
||||||
@ -757,9 +720,6 @@ process_key_event (ClutterEvent *event,
|
|||||||
{
|
{
|
||||||
cally_snoop_key_event ((ClutterKeyEvent *) event);
|
cally_snoop_key_event ((ClutterKeyEvent *) event);
|
||||||
|
|
||||||
if (device != NULL && device->keyboard_grab_actor != NULL)
|
|
||||||
clutter_actor_event (device->keyboard_grab_actor, event, FALSE);
|
|
||||||
else
|
|
||||||
emit_event_chain (event);
|
emit_event_chain (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user