All pastes #487489 Raw Edit

man_in_shack

public text v1 · immutable
·published 2007-05-14 14:25 UTC
rendered paste body
static XEvent event;
static char needinitxev=1;

... value of needinitxev does not change ...
if(needinitxev)
{
	memset(&event, 0, sizeof(event));
	event.xkey.type=KeyPress;
	event.xkey.root=RootWindow(thedisp, thescreen);
	event.xkey.window=thewindow;
	/*event.xkey.subwindow=thewindow;*/
	event.xkey.subwindow=0; /* My code, based on results from xev */
	event.xkey.same_screen=True;
	event.xkey.time=CurrentTime;
	event.xkey.display=thedisp;
	needinitxev=0;
}
/* PoR is a variable passed to the function. It is of type:
 * enum {PRESS,RELEASE} */
event.xkey.type=PoR==PRESS ? KeyPress : KeyRelease;
event.xkey.state=PoR==PRESS ? KeyPressMask : KeyReleaseMask;
/* keycode is passed to the function */
event.xkey.keycode=keycode;
event.xkey.x=50;
event.xkey.y=50;
XSendEvent(thedisp, thewindow, False, event.xkey.state, &event);