GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 51a3e49c authored by Emmanuele Bassi's avatar Emmanuele Bassi

device: Allow updating devices from embedding toolkits

Embedding toolkits most likely will disable the event handling, so all
the input device code will not be executed. Unfortunately, the newly
added synthetic event generation of ENTER and LEAVE event pairs depends
on having input devices.

In order to unbreak things without reintroducing the madness of the
previous code we should allow embedding toolkits to just update the
state of an InputDevice by using the data contained inside the
ClutterEvent. This strategy has two obvious reasons:

  • the embedding toolkit is creating a ClutterEvent by translating
    a toolkit-native event anyway

  • this is exactly what ClutterStage does when processing events

We are, essentially, deferring input device handling to the embedding
toolkits, just like we're deferring event handling to them.
parent b3982920
......@@ -192,8 +192,6 @@ typedef enum
} ClutterStageState;
typedef union _ClutterEvent ClutterEvent;
typedef struct _ClutterAnyEvent ClutterAnyEvent;
typedef struct _ClutterButtonEvent ClutterButtonEvent;
typedef struct _ClutterKeyEvent ClutterKeyEvent;
......@@ -526,6 +526,25 @@ clutter_input_device_get_pointer_actor (ClutterInputDevice *device)
return device->cursor_actor;
* clutter_input_device_get_pointer_stage:
* @device: a #ClutterInputDevice of type %CLUTTER_POINTER_DEVICE
* Retrieves the #ClutterStage underneath the pointer of @device
* Return value: (transfer none): a pointer to the #ClutterStage or %NULL
* Since: 1.2
ClutterStage *
clutter_input_device_get_pointer_stage (ClutterInputDevice *device)
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
g_return_val_if_fail (device->device_type == CLUTTER_POINTER_DEVICE, NULL);
return device->stage;
* clutter_input_device_get_device_name:
* @device: a #ClutterInputDevice
......@@ -545,3 +564,43 @@ clutter_input_device_get_device_name (ClutterInputDevice *device)
return device->device_name;
* clutter_input_device_update_from_event:
* @device: a #ClutterInputDevice
* @event: a #ClutterEvent
* @update_stage: whether to update the #ClutterStage of the @device
* using the stage of the event
* Forcibly updates the state of the @device using a #ClutterEvent
* This function should never be used by applications: it is meant
* for integration with embedding toolkits, like clutter-gtk
* Since: 1.2
clutter_input_device_update_from_event (ClutterInputDevice *device,
ClutterEvent *event,
gboolean update_stage)
ClutterModifierType event_state;
ClutterStage *event_stage;
gfloat event_x, event_y;
guint32 event_time;
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
g_return_if_fail (event != NULL);
event_state = clutter_event_get_state (event);
event_time = clutter_event_get_time (event);
event_stage = clutter_event_get_stage (event);
clutter_event_get_coords (event, &event_x, &event_y);
_clutter_input_device_set_coords (device, event_x, event_y);
_clutter_input_device_set_state (device, event_state);
_clutter_input_device_set_time (device, event_time);
if (update_stage)
_clutter_input_device_set_stage (device, event_stage);
......@@ -92,8 +92,13 @@ void clutter_input_device_get_device_coords (ClutterInputDevic
gint *x,
gint *y);
ClutterActor * clutter_input_device_get_pointer_actor (ClutterInputDevice *device);
ClutterStage * clutter_input_device_get_pointer_stage (ClutterInputDevice *device);
G_CONST_RETURN gchar * clutter_input_device_get_device_name (ClutterInputDevice *device);
void clutter_input_device_update_from_event (ClutterInputDevice *device,
ClutterEvent *event,
gboolean update_stage);
#endif /* __CLUTTER_INPUT_DEVICE_H__ */
......@@ -46,6 +46,8 @@ typedef struct _ClutterChildMeta ClutterChildMeta;
typedef struct _ClutterLayoutMeta ClutterLayoutMeta;
typedef struct _ClutterAnimator ClutterAnimator;
typedef union _ClutterEvent ClutterEvent;
* ClutterGravity:
* @CLUTTER_GRAVITY_NONE: Do not apply any gravity
......@@ -1005,6 +1005,8 @@ clutter_input_device_get_device_type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment