#include "ebuttonrelease.h"

using namespace event;

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

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

	&EField::END
};

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

	state=Tcl_GetString(objv[11]);

	Tcl_GetIntFromObj(interp,objv[12],&x);
	Tcl_GetIntFromObj(interp,objv[13],&y);
	Tcl_GetIntFromObj(interp,objv[14],&x_root);
	Tcl_GetIntFromObj(interp,objv[15],&y_root);

	for(t_listeners::iterator it=listeners.begin();it!=listeners.end();it++)
	{
		Ptr<ButtonReleaseListener> listener=*it;
		listener->onButtonRelease(header,button,state,x,y,x_root,y_root);
	}
	
	return TCL_OK;
}

