Message ordering from X server - Xwindows

This is a discussion on Message ordering from X server - Xwindows ; Are all message from X in the order of the function calls in XLib like the Expose messages? For example if I call a function that may produce Error messages from X then send a custom message after it will ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Message ordering from X server

  1. Message ordering from X server

    Are all message from X in the order of the function calls in XLib like the
    Expose messages? For example if I call a function that may produce Error
    messages from X then send a custom message after it will the error messages
    come before the custom message comes back?

    I am using XLib X11 on a local Linux machine.

    Thanks in advance,
    Charlie


  2. Re: Message ordering from X server

    CharlieB wrote:
    >Are all message from X in the order of the function calls in XLib like the
    >Expose messages? For example if I call a function that may produce Error
    >messages from X then send a custom message after it will the error messages
    >come before the custom message comes back?
    >
    >I am using XLib X11 on a local Linux machine.
    >
    >Thanks in advance,
    >Charlie
    >


    The situation is similar to that in other areas of computing. For
    example, a DBMS is allowed to process transactions in parallel, but it
    must _appear_ to be processing them sequentially. Or, a CPU can
    process instructions in a pipeline, but often must interlock so as to
    _appear_ that the order is strictly sequential.

    X requests must _appear_ to be done sequentially (by the server) and
    any replies, events, or errors must carry the sequence number of the
    request with which they were associated.

    The following piece of nonsense illustrates the point:

    unsigned long nr = NextRequest(dpy);
    XConfigureWindow(dpy, win, ...);
    while(1) {
    XNextEvent(dpy, &e);
    if (e.xany.type != ConfigureNotify) continue;
    if (e.xany.sequence != nr) continue;
    break;
    }
    // e represents the event associated with the request

    The complication comes in that certain requests -- the "round trip"
    variety -- will wait for their replies, and those replies can be
    removed from the event queue out of order.

    XConfigureWindow(...); // generates a ConfigureNotify
    win = XGetSelectionOwner(...); // reply processed out of order

    To make it really nasty, suppose the XConfigureWindow produces an
    error. The error handler will be entered as part of the wait for the
    XGet reply, that is, before 'win' has been set. Errors can be
    processed out of order, as part of servicing a "round trip" request.

    In your example, if I understand it, you are doing the equivalent of

    XConfigureWindow(...); // may produce error
    XSendEvent(...);
    while(1) {
    XNextEvent(...);
    ...
    }

    In this case, XSendEvent is a "one way" request so there is no
    re-ordering of the event queue. The order you will see is either
    ConfigNotify or error, followed by your custom event.

    Whew! Now I hope that's clear ...


  3. Re: Message ordering from X server

    Kip Rugger wrote:

    >
    > Whew! Now I hope that's clear ...


    Yes, that explains it. Thank you.


+ Reply to Thread