XRender With Vsync

Ryan McClue re.mcclue at protonmail.com
Thu Sep 23 01:35:04 UTC 2021


I'm trying to use XPresent, however I seem unable to receive GenericEvent. I initialize:
  int present_op = 0, event = 0, error = 0;
  XPresentQueryExtension(xlib_display, &present_op, &event, &error);
  XPresentSelectInput(xlib_display, xlib_window, PresentCompleteNotifyMask);
In my event loop:
  XEvent xlib_event = {};
  while (XPending(xlib_display) > 0)
  {
    XNextEvent(xlib_display, &xlib_event);
    switch (xlib_event.type)
    {
      case GenericEvent:
      {
        XGenericEventCookie *cookie = (XGenericEventCookie *)&xlib_event.xcookie;
        if (cookie->extension == present_op)
        {
          XGetEventData(xlib_display, cookie);
          if (cookie->evtype == PresentCompleteNotify)
          {
            XRenderComposite(display, PictOpSrc, src_pict, 0, dst_pict,
                             0, 0, 0, 0, 0, 0,
                             window_width, window_height);
          }
          XFreeEventData(xlib_display, cookie);
      } break;
    }
  }
I never receive any GenericEvent.
Am I doing something wrong?
--
Ryan McClue, Sydney

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Thursday, September 23rd, 2021 at 3:33 AM, Keith Packard <keithp at keithp.com> wrote:

> Ryan McClue re.mcclue at protonmail.com writes:
>
> > I want this to sync with the monitor's VBLANK, i.e. vsync.
> >
> > How can this be achieved?
>
> Draw to an offscreen pixmap and use the Present extension.
>
> -------------------------------------------------------------
>
> -keith


More information about the xorg mailing list