Ejemplo n.º 1
0
static struct wsi_x11_connection *
wsi_x11_connection_create(const VkAllocationCallbacks *alloc,
                          xcb_connection_t *conn)
{
   xcb_query_extension_cookie_t dri3_cookie, pres_cookie;
   xcb_query_extension_reply_t *dri3_reply, *pres_reply;

   struct wsi_x11_connection *wsi_conn =
      vk_alloc(alloc, sizeof(*wsi_conn), 8,
                VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
   if (!wsi_conn)
      return NULL;

   dri3_cookie = xcb_query_extension(conn, 4, "DRI3");
   pres_cookie = xcb_query_extension(conn, 7, "PRESENT");

   dri3_reply = xcb_query_extension_reply(conn, dri3_cookie, NULL);
   pres_reply = xcb_query_extension_reply(conn, pres_cookie, NULL);
   if (dri3_reply == NULL || pres_reply == NULL) {
      free(dri3_reply);
      free(pres_reply);
      vk_free(alloc, wsi_conn);
      return NULL;
   }

   wsi_conn->has_dri3 = dri3_reply->present != 0;
   wsi_conn->has_present = pres_reply->present != 0;

   free(dri3_reply);
   free(pres_reply);

   return wsi_conn;
}
Ejemplo n.º 2
0
ExcCode screen_shm_init() {
	xcb_query_extension_cookie_t extension_cookie =
			xcb_query_extension(display,
			strlen(MIT_SHM_EXTENSION_NAME), MIT_SHM_EXTENSION_NAME);
	xcb_query_extension_reply_t *extension_reply =
			xcb_query_extension_reply(display, extension_cookie, NULL);
	if (extension_reply == NULL)
		PANIC(ERR_X_EXTENSION, MIT_SHM_EXTENSION_NAME);
	free(extension_reply);
	xcb_shm_query_version_cookie_t version_cookie =
			xcb_shm_query_version(display);
	xcb_shm_query_version_reply_t *version_reply =
			xcb_shm_query_version_reply(display, version_cookie, NULL);
	if (version_reply == NULL)
		PANIC(ERR_X_EXTENSION, MIT_SHM_EXTENSION_NAME);
	free(version_reply);
	
	size_t max_size = screen->width_in_pixels * screen->height_in_pixels *
			sizeof (unsigned);
	shmid = shmget(IPC_PRIVATE, max_size, IPC_CREAT | 0777);
	if (shmid < 0)
		PANIC(ERR_SHM_ALLOC);		
	shmaddr = shmat(shmid, 0, 0);
	if (shmaddr == (uint8_t *) -1)
		PANIC(ERR_SHM_ATTACH);
					
	shmseg = xcb_generate_id(display);
	xcb_void_cookie_t attach_cookie = xcb_shm_attach_checked(display,
			shmseg, shmid, 0);
	if (xcb_request_check(display, attach_cookie) != NULL)
		PANIC(ERR_SHM_ATTACH);
	return 0;
}
Ejemplo n.º 3
0
/* Do not free the returned xcb_query_extension_reply_t - on return, it's aliased
 * from the cache. */
const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
{
    lazyreply *data;
    if(c->has_error)
        return 0;

    pthread_mutex_lock(&c->ext.lock);
    data = get_lazyreply(c, ext);
    if(data && data->tag == LAZY_COOKIE)
    {
        data->tag = LAZY_FORCED;
        data->value.reply = xcb_query_extension_reply(c, data->value.cookie, 0);
    }
    pthread_mutex_unlock(&c->ext.lock);

    return data ? data->value.reply : 0;
}
Ejemplo n.º 4
0
ExcCode screen_cursor_init() {
	xcb_query_extension_cookie_t extension_cookie =
			xcb_query_extension(display,
			strlen(XFIXES_EXTENSION_NAME), XFIXES_EXTENSION_NAME);
	xcb_query_extension_reply_t *extension_reply =
			xcb_query_extension_reply(display, extension_cookie, NULL);
	if (extension_reply == NULL)
		PANIC(ERR_X_EXTENSION, XFIXES_EXTENSION_NAME);
	free(extension_reply);
	xcb_xfixes_query_version_cookie_t version_cookie =
			xcb_xfixes_query_version(display,
			XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION);
	xcb_xfixes_query_version_reply_t *version_reply =
			xcb_xfixes_query_version_reply(display, version_cookie, NULL);
	if (version_reply == NULL)
		PANIC(ERR_X_EXTENSION, XFIXES_EXTENSION_NAME);
	free(version_reply);
	return 0;
}