X Window System Core Protocol - Example

Example

The following is a possible example of interaction between a server and a program that creates a window with a black box in it and exits on a keypress. In this example, the server does not send any reply because the client requests do not generate replies. These requests could generate errors.

  1. The client opens the connection with the server and sends the initial packet specifying the byte order it is using.
  2. The server accepts the connection (no authorization is involved in this example) by sending an appropriate packet, which contains other information such as the identifier of the root window (e.g., 0x0000002b) and which identifiers the client can create.
  3. The client requests the creation of a default graphic context with identifier 0x00200000 (this request, like the other requests of this example, does not generate replies from the server)
  4. The client requests the server to create a top-level window (that is, it specifies the parent to be the root window 0x0000002b) with identifier 0x00200001, size 200x200, position (10,10), etc.
  5. The client requests a change in the attributes of the window 0x00200001, specifying it is interested in receiving Expose and KeyPress events.
  6. The client requests the window 0x00200001 to be mapped (shown on the screen)
  7. When the window is made visible and its content has to be drawn, the server sends the client an Expose event
  8. In response to this event, the client requests a box to be drawn by sending a PolyFillRectangle request with window 0x00200001 and graphic context 0x00200000

If the window is covered by another window and uncovered again, assuming that backing store is not maintained:

  1. The server sends another Expose event to tell the client that the window has to be drawn again
  2. The client redraws the window by sending a PolyFillRectangle request

If a key is pressed:

  1. The server sends a KeyPress event to the client to notify it that the user has pressed a key
  2. The client reacts appropriately (in this case, it terminates)

Read more about this topic:  X Window System Core Protocol

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)