Class Dispatcher

The dispatcher object in the MilleFeuille library establish connection between graphic requests received from murals or input events received from the iwork infrastructure and feuilles which handle them. It also provide a mechanism to post simple finalization jobs used to free graphics resources.
If graphic requests dispatch is straitforward input events dispatch is more complex since the dispatcher manage a focus grab queue for each devices: a feuille who grabs a device is guaranty to receive this device events first before any other clients registered for the device. Only one feuille can grab a given device at a given time. Note that bounding box based dispatch is not managed by the dispatcher but by object of type Collage. The collage at the root of the hierarchy is just yet another client.

Public type

class GraphicEvent
  {
  public:
    Mural *mural;
    IWorkEvent *iwork_event;
  };
GraphicEvent describes a redraw request.
mural is the mural generating the request
iwork_event is the original event received by the dispatcher.
class GraphicFinalization
  {
  public:
    virtual void finalize() {};
  };
GraphicFinalization is used to post graphic resources finalization job to the dispatcher. When posted jobs are run once by calling finalize() the next time a graphic request it received and before the request is dispatched. These jobs can be used to free server resources like display lists of textures.
class InteractionEvent
  {
  public:
    MuralU32 input_ID;
    MuralU32 sequence_number;
    bool button_1;
    Point<Mural32> absolute_position;
    Point<Mural32> relative_position;
    Mural *mural;
    IWorkEvent *iwork_event;
  };
InteractionEvent decribes an interaction event.
input_ID is the ID of the device enerating the event,
sequence_number is the event sequence number for its device,
button_1 reflect the state of the button #1 if the device has such a button. Note that for a laser pointer and by convention button_1 is true if the laser is lock-on (laser shinning on the screen surface) and false otherwise.
absolute_position for event with an associated position, this is the absolute position of the event in the screen coordinate system ((0,0) being at the lower left of the screen).
relative_position for event with an associated position, this is the relative position of the event in the feuille coordinate system ((0,0) being at the lower left of the screen). Note that container must update this field as they propagate InteractionEvent.
mural is the mural generating the request.
iwork_event is the original event received by the dispatcher.
enum InputDevice {Mouse = 0, LaserPointer = 1, Unistroke = 2};
InputDevice is used to identify the different possible input device in the system.
enum DispatchType {NamedDevice, Dispatched, FocusGrab, Grabbed,
                   NamedDeviceGrabbed, DispatchedGrabbed};
DispatchType describes the different dispatch type:
NamedDevice means that the event come from device queue
NamedDeviceGrabbed means that the event come the device queue but has been grabbed before,
Dispatched means that the event come from window dispatch (i.e. the event location is in the window bounding box extended by 30 pixels in all directions)
DispatchedGrabbed means that the event come from window dispatch but has been grabbed before,
FocusGrab means that the event come from one of the device focus grab queue,
Grabbed ?.

Constructor and destructor

Dispatcher(IWorkPluginNode *new_iwork_node);
new_iwork_node is the node to be used by the dispatcher to received events (See IWork documentation for further detail.

~Dispatcher();

Public methods

void add_graphic_dispatch(Mural *mural,
			  MuralLayer layer,
			  GraphicPtr feuille);
add_graphic_dispatch is used to bind layer layer of mural mural to feuille. All graphics requests from layer will be dispatched to feuille.
void remove_graphic_dispatch(Mural *mural,
			     MuralLayer layer,
			     GraphicPtr feuille);
remove_graphic_dispatch is used to remove the binding between layer layer of mural mural and feuille.
void add_interaction_dispatch(Mural *mural,
			      MuralU32 device_id,
			      InteractionPtr feuille);
add_interaction_dispatch is used to bind events from device device_id to feuille. All events received from device_id will be dispatched to feuille.
void remove_interaction_dispatch(Mural *mural,
				 MuralU32 device_id,
				 InteractionPtr feuille);
remove_interaction_dispatch is used to remove the binding between device device_id and feuille.
bool add_focus_grab(Mural *mural,
		    MuralU32 device_ID,
		    InteractionPtr feuille);
After a call to add_focus_grab feuille will be the first to received events from device_id. Note that events may be dispatched to other feuilles after. The system maintain one grab per device but only one feuille can grab a specific device at a time. If add_focus_grab return true the grab was successful otherwise it failled.
void remove_focus_grab(Mural *mural,
		       MuralU32 device_ID,
		       InteractionPtr feuille);
remove_focus_grab removes feuille from device_id grab.
void add_graphic_finalization(Mural * mural,
			      GraphicFinalizationPtr new_job);
add_graphic_finalization post new_job a graphic finalization job to the queue for mural mural. When posted jobs are run once by calling finalize() the next time a graphic request it received from mural and before the request is dispatched. These jobs can be used to free server resources like display lists of textures.

Protected Methods

None

Public fields

None

Protected fields

None