X server latency

View: New views
3 Messages — Rating Filter:   Alert me  

X server latency

by rachid2008 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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);


}

_______________________________________________
wm-spec-list mailing list
wm-spec-list@...
http://mail.gnome.org/mailman/listinfo/wm-spec-list

Re: X server latency

by Elijah Newren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On 4/17/07, Rachid KHAZAZ <rachiddelta@...> wrote:
> I have two questions :

You have stumbled across the wrong list.  ;-)  This list is about
standards for communication between window managers, specialized pager
apps, and applications.  It isn't for questions on how X work and
writing Xlib applications.  Since the list is relatively low volume I
will include a quick explanation to your two questions, but please
take any further questions about how X work elsewhere.

Cheers,
Elijah

> 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.

The granularity of motion events is not guaranteed, but a client
selecting for motion events is guaranteed to get at least one event
when the pointer moves and comes to rest.

> 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.

I would guess that your XWarpPointer() call is moving the mouse into a
new window entirely.  MotionNotify events are only generated when the
motion begins and ends in the window.  If pointer motion causes the
pointer to be in a different window than before, EnterNotify and
LeaveNotify events are generated instead of a MotionNotify event.
_______________________________________________
wm-spec-list mailing list
wm-spec-list@...
http://mail.gnome.org/mailman/listinfo/wm-spec-list

Re: X server latency

by Carsten Haitzler (The Rasterman) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 17 Apr 2007 23:17:04 +0200 (CEST) Rachid KHAZAZ <rachiddelta@...>
babbled:

> 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.

the mouse hardware literally is sending "bigger moves" so the mouse says "i
moved 25 units up" when you from from 150 to 125 - x ends up showing this (i'm
dropping the complexity of mouse acceleration etc. for now). so x is literally
showing what it gets as input.

> 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

check for enter/leave events too.

> an idea about that? and how can i produce the detection of a "simulated"
> mouse motion. Thank you all.

you can't detect. motion events (or enter/leave) from XWarpPointer are seen as
the same as a real device being moved.


--
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    raster@...
裸好多
Tokyo, Japan (東京 日本)
_______________________________________________
wm-spec-list mailing list
wm-spec-list@...
http://mail.gnome.org/mailman/listinfo/wm-spec-list