#include "emotion.h"

using namespace event;

const char* EMotion::eventType="Motion";
const EField* EMotion::eventFields[]=
{
	&EField::SERIAL,
	&EField::ID,
	&EField::TIME,
	&EField::ROOT_WINDOW,
	&EField::SUB_WINDOW,
	&EField::TYPE,
	&EField::WIDGET_PATHNAME,
	&EField::SENDEVENT,

	&EField::STATE,
	&EField::X,
	&EField::Y,
	&EField::X_ROOT,
	&EField::Y_ROOT,

	&EField::END
};

int EMotion::preprocessEvent(EHeader& header,Tcl_Interp* interp,int objc,Tcl_Obj* CONST objv[])
{
	string state;
	int x;
	int y;
	int x_root;
	int y_root;

	int index=10;

	state=Tcl_GetString(objv[index++]);
    
	Tcl_GetIntFromObj(interp,objv[index++],&x);
	Tcl_GetIntFromObj(interp,objv[index++],&y);
	Tcl_GetIntFromObj(interp,objv[index++],&x_root);
	Tcl_GetIntFromObj(interp,objv[index++],&y_root);

	for(t_listeners::iterator it=listeners.begin();it!=listeners.end();it++)
	{
		(*it)->onMotion(header,state,x,y,x_root,y_root);
	}

	return TCL_OK;
}

