x protocol sequence number question - Xwindows

This is a discussion on x protocol sequence number question - Xwindows ; I am writing a program receiving all packages between X server and X client, and try to explain the data according to X Protocol. Now I have a question: How to get the sequence number of a X Request from ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: x protocol sequence number question

  1. x protocol sequence number question

    I am writing a program receiving all packages between X server and X client,
    and try to explain the data according to X Protocol. Now I have a question:

    How to get the sequence number of a X Request from the package?

    In the section 'Request Format' of X Protocol', there's a sentence: "Every
    request on a given connection is implicitly assigned a sequence number,
    starting with one, that is used in replies, errors, and events."
    ( http://www.xfree86.org/snapshot/prot...quest%20Format )

    Does it implies that X server maintains the seq#, instead of receiving
    it from X Client? So I need to write a seq# counter for each X client,
    increment the counter for each package it sents to X Server?

    Thanks for your time reading and reply. (Maybe my question is too simple, sorry)


    Limin

  2. Re: x protocol sequence number question

    wanglimin@gmail.com (Limin Wang) writes:

    > Does it implies that X server maintains the seq#, instead of receiving
    > it from X Client? So I need to write a seq# counter for each X client,
    > increment the counter for each package it sents to X Server?


    That's exactly what it means. The X server maintains the sequence
    number on a per-client basis.

  3. Re: x protocol sequence number question

    Limin Wang wrote:
    >I am writing a program receiving all packages between X server and X client,
    >and try to explain the data according to X Protocol. Now I have a question:
    >
    >How to get the sequence number of a X Request from the package?
    >
    >In the section 'Request Format' of X Protocol', there's a sentence: "Every
    >request on a given connection is implicitly assigned a sequence number,
    >starting with one, that is used in replies, errors, and events."
    >( http://www.xfree86.org/snapshot/prot...quest%20Format )
    >
    >Does it implies that X server maintains the seq#, instead of receiving
    >it from X Client? So I need to write a seq# counter for each X client,
    >increment the counter for each package it sents to X Server?
    >
    >Thanks for your time reading and reply. (Maybe my question is too simple, sorry)
    >
    >
    >Limin



    Xlib and the server maintain counters to determine the request seq#.
    Events are sent with the current value of the server counter.

    You can use this for synchronization purposes.

    unsigned long nr = NextRequest(dpy);
    XResizeWindow(...);
    ---
    while(1) { // the usual event loop
    XNextEvent(&e);
    switch(e.type) {
    case ConfigureNotify:
    if (e.xany.serial < nr) continue; // too old, ignore
    else do_layout(&e); // use latest size for layout

    You can also use LastKnownRequestProcessed(dpy) to get the most recent
    serial number seen on an event.


+ Reply to Thread