- xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
-
- /* Check to see if any configuration changes have occurred
- * since we were last invoked
- */
- if (priv->special_event) {
- xcb_generic_event_t *ev;
-
- while ((ev = xcb_poll_for_special_event(c, priv->special_event)) != NULL) {
- xcb_present_generic_event_t *ge = (void *) ev;
- dri3_handle_present_event(priv, ge);
- }
- }
-}
-
-/** dri3_update_drawable
- *
- * Called the first time we use the drawable and then
- * after we receive present configure notify events to
- * track the geometry of the drawable
- */
-static int
-dri3_update_drawable(__DRIdrawable *driDrawable, void *loaderPrivate)
-{
- struct dri3_drawable *priv = loaderPrivate;
- xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
-
- /* First time through, go get the current drawable geometry
- */
- if (priv->width == 0 || priv->height == 0 || priv->depth == 0) {
- xcb_get_geometry_cookie_t geom_cookie;
- xcb_get_geometry_reply_t *geom_reply;
- xcb_void_cookie_t cookie;
- xcb_generic_error_t *error;
-
- /* Try to select for input on the window.
- *
- * If the drawable is a window, this will get our events
- * delivered.
- *
- * Otherwise, we'll get a BadWindow error back from this request which
- * will let us know that the drawable is a pixmap instead.
- */
-
-
- cookie = xcb_present_select_input_checked(c,
- (priv->eid = xcb_generate_id(c)),
- priv->base.xDrawable,
- XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY|
- XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY|
- XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
-
- /* Create an XCB event queue to hold present events outside of the usual
- * application event queue
- */
- priv->special_event = xcb_register_for_special_xge(c,
- &xcb_present_id,
- priv->eid,
- priv->stamp);
-
- geom_cookie = xcb_get_geometry(c, priv->base.xDrawable);
-
- geom_reply = xcb_get_geometry_reply(c, geom_cookie, NULL);
-
- if (!geom_reply)
- return false;
-
- priv->width = geom_reply->width;
- priv->height = geom_reply->height;
- priv->depth = geom_reply->depth;
- priv->is_pixmap = false;
-
- free(geom_reply);
-
- /* Check to see if our select input call failed. If it failed with a
- * BadWindow error, then assume the drawable is a pixmap. Destroy the
- * special event queue created above and mark the drawable as a pixmap
- */
-
- error = xcb_request_check(c, cookie);
-
- if (error) {
- if (error->error_code != BadWindow) {
- free(error);
- return false;
- }
- priv->is_pixmap = true;
- xcb_unregister_for_special_event(c, priv->special_event);
- priv->special_event = NULL;
- }
- }
- dri3_flush_present_events(priv);
- return true;
-}