update_from_event


Description:

[ Version ( since = "1.2" ) ]
public void update_from_event (Event event, bool update_stage)

Forcibly updates the state of the this using a Event

This function should never be used by applications: it is meant for integration with embedding toolkits, like clutter-gtk

Embedding toolkits that disable the event collection inside Clutter need to use this function to update the state of input devices depending on a Event that they are going to submit to the event handling code in Clutter though do_event. Since the input devices hold the state that is going to be used to fill in fields like the ButtonEvent click count, or to emit synthesized events like ENTER and LEAVE, it is necessary for embedding toolkits to also be responsible of updating the input device state.

For instance, this might be the code to translate an embedding toolkit native motion notification into a Clutter MotionEvent and ask Clutter to process it:

  ClutterEvent c_event;

translate_native_event_to_clutter (native_event, &c_event);

clutter_do_event (&c_event);

Before letting do_event process the event, it is necessary to call update_from_event:

  ClutterEvent c_event;
ClutterDeviceManager *manager;
ClutterInputDevice *device;

translate_native_event_to_clutter (native_event, &c_event);

// get the device manager
manager = clutter_device_manager_get_default ();

// use the default Core Pointer that Clutter backends register by default
device = clutter_device_manager_get_core_device (manager, %CLUTTER_POINTER_DEVICE);

// update the state of the input device
clutter_input_device_update_from_event (device, &c_event, FALSE);

clutter_do_event (&c_event);

The update_stage boolean argument should be used when the input device enters and leaves a Stage; it will use the Stage field of the passed event to update the stage associated to the input device.

Parameters:

this

a InputDevice

event

a Event

update_stage

whether to update the Stage of the this using the stage of the event