[Xcb] How to handle sync request?

Марк Лаго́дич lgd.mrk at gmail.com
Mon Jun 6 14:47:43 UTC 2022


As I understand, in general, you:
1. Report to WM that you're going to receive _NET_WM_SYNC_REQUEST event.
2. Create a synchronization counter.
3. In the event loop:
- on _NET_WM_SYNC_REQUEST, set the counter to a given value.
- on XCB_CONFIGURE_NOTIFY (which may be the resizing event), paint to the
back buffer and increase the counter by 1.
- on XCB_EXPOSE, swap the buffers and increase the counter by 1.

The three events I've mentioned are sent to your program sequentially in
the same order as I listed.

Increasing the counter points out to WM the drawing state.
In the sync request event an even value is given.
When you increase by 1, it becomes odd. This points out that WM should not
redraw the window on the screen.
When you increase again, it becomes even. This points out that drawing to
the window is done and WM can redraw your window.
Drawing to the front buffer should happen when the counter is odd.

However, if you're updating the window continuously, the order of steps may
be different. I can't tell.
As of now, I only have a static scene that is redrawn only when the window
is resized.

пн, 6 июн. 2022 г. в 16:50, Carlo Wood <carlo at alinoe.com>:

> On Mon, 6 Jun 2022 16:39:08 +0300
> Марк Лаго́дич <lgd.mrk at gmail.com> wrote:
>
> > I was trying to make window resizing in my program just as smooth as
> > in GTK programs.
> > So far I have this:
> > https://github.com/MarkLagodych/xcb-opengl-simple-program
>
> This is interesting; I am just a user, working on a Vulkan engine,
> and resizing doesn't look good here: mostly, during resizing the
> system is so busy with trying to keep up that the window looks empty
> until you stop moving the mouse.
>
> Can you explain to me in simply English what is the idea behind
> what you are doing that makes resize more smooth?
>
> Carlo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20220606/edd976b6/attachment.htm>


More information about the Xcb mailing list