X server latency



Hi all,
I have two questions :
1) I have written a program (see the attached file) that displays the x coordinates of the pointer when the MotionNotify event is catched.
When moving the mouse very slowly, the coodinates shown like 150,149,148......
But when I move the mouse very quicly, the coordinates like 150, 125, 80....
How do you explain the difference between the two sets of results.
2) I have written an X client which moves the pointer by XWrapPointer() function, when executing this program and the program of 1), the last one doesnot detect the pointer motion caused by the XWrapPointer(). Do you have an idea about that? and how can i produce the detection of a "simulated" mouse motion.
Thank you all.
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <string.h>

#define VRAI True
#define FAUX False

char *pas_message = "Pas de message!";
char *ici = "Ici";

main(int argc, char **argv)
{

	Display	*display;
	Window	fenetre;
	GC	cont_graph;
	XEvent	evenement;
	KeySym	touche;
	XSizeHints indic;
	XSetWindowAttributes	attributs;
	unsigned long masque_valeur;
	int	ecran;
	unsigned long	noir, blanc;
	int	i;
	char	caractere[11];
	int	encore;
	unsigned long compt=0;
	char	*texte;
	XColor couleur;
	unsigned long temps;
	unsigned long tempsavant;
	unsigned long pixelvalue;
	Bool saisie = True;
	XImage *image;
	if(argc >1)
		texte = argv[1];
	else texte = pas_message;
	
	display = XOpenDisplay(NULL);
	
	ecran = DefaultScreen(display);
	blanc = WhitePixel(display,ecran);
	noir = BlackPixel(display,ecran);
	temps = 0;
	tempsavant = 0;
	indic.x = 200; indic.y = 200;
	indic.width = 200; indic.height = 200;
	indic.flags = PPosition | PSize;

	fenetre = XCreateSimpleWindow(display,DefaultRootWindow(display),indic.x,indic.y,indic.width,indic.height,5,noir,blanc);
	cont_graph = XCreateGC(display,fenetre,0,NULL);
	XSelectInput(display,fenetre,ButtonPressMask|PointerMotionMask);
	XChangePointerControl(display,True,True,1,1,1);
	XMapRaised(display,fenetre);
	
	while(1)
	{
		XNextEvent(display,&evenement);
	
		
		switch(evenement.type){

			case MotionNotify:
			printf("déplacement au %u \n",evenement.xmotion.x);
			break;				
		}
		
		
	}
	XDestroyWindow(display,fenetre);	
	XCloseDisplay(display);


}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]