+ if ((gl = getenv("ECORE_X_NO_XLIB")))
+ {
+ /* we found the env var that says 'Yes, we are not ever gonna try
+ * OpenGL so it is safe to not use XLib at all' */
+
+ /* try to connect to the display server */
+ _ecore_xcb_conn = xcb_connect(name, NULL);
+ }
+ else
+ {
+ /* env var was not specified, so we will assume that the user
+ * may want opengl @ some point. connect this way for opengl to work */
+
+ /* want to dlopen here to avoid actual library linkage */
+ void *libxcb, *libxlib;
+ Display *(*_real_display)(const char *display);
+ xcb_connection_t *(*_real_connection)(Display *dpy);
+ void (*_real_queue)(Display *dpy, enum XEventQueueOwner owner);
+
+ libxlib = dlopen("libX11.so", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libxlib)
+ libxlib = dlopen("libX11.so.6", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libxlib)
+ libxlib = dlopen("libX11.so.6.3.0", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libxlib)
+ {
+ ERR("Could not dlsym to libX11");
+ /* unregister log domain */
+ eina_log_domain_unregister(_ecore_xcb_log_dom);
+ _ecore_xcb_log_dom = -1;
+ ecore_shutdown();
+ return --_ecore_xcb_init_count;
+ }
+
+ libxcb = dlopen("libX11-xcb.so", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libxcb)
+ libxcb = dlopen("libX11-xcb.so.1", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libxcb)
+ libxcb = dlopen("libX11-xcb.so.1.0.0", (RTLD_LAZY | RTLD_GLOBAL));
+ if (!libxcb)
+ {
+ ERR("Could not dlsym to libX11-xcb");
+ /* unregister log domain */
+ eina_log_domain_unregister(_ecore_xcb_log_dom);
+ _ecore_xcb_log_dom = -1;
+ ecore_shutdown();
+ return --_ecore_xcb_init_count;
+ }
+
+ _real_display = dlsym(libxlib, "XOpenDisplay");
+ if (_real_display) DBG("Have Real Display Symd");
+ _real_connection = dlsym(libxcb, "XGetXCBConnection");
+ if (_real_connection) DBG("Have Real Connection Symd");
+ _real_queue = dlsym(libxcb, "XSetEventQueueOwner");
+ if (_real_queue) DBG("Have Real Queue Symd");
+
+ if (_real_display)
+ {
+ _ecore_xcb_display = _real_display(name);
+ if (_real_connection)
+ _ecore_xcb_conn = _real_connection(_ecore_xcb_display);
+ if (_real_queue)
+ _real_queue(_ecore_xcb_display, XCBOwnsEventQueue);
+ }
+ }