Detect XCB and save a connection handle

* configure.ac: If using X11, check for XCB libraries and header.
* src/Makefile.in (XCB_LIBS): Define.
(LIBX_EXTRA): Include it.

* src/xterm.h [USE_XCB]: Include X11/Xlib-xcb.h.
(struct x_display_info) [USE_XCB]: Add an XCB connection handle field.
* src/xterm.c (x_term_init) [USE_XCB]: Initialize the new field.
This commit is contained in:
Ken Raeburn 2015-11-07 03:06:32 -05:00
parent e1c27dbd25
commit c7f2b6ad89
4 changed files with 50 additions and 1 deletions

View file

@ -3115,6 +3115,21 @@ if test "${HAVE_X11}" = "yes"; then
fi
fi
if test "${HAVE_X11}" = "yes"; then
AC_CHECK_HEADER(X11/Xlib-xcb.h,
AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
if test "${HAVE_XCB}" = "yes"; then
AC_CHECK_LIB(X11-xcb, XGetXCBConnection, HAVE_X11_XCB=yes)
if test "${HAVE_X11_XCB}" = "yes"; then
AC_DEFINE(USE_XCB, 1,
[Define to 1 if you have the XCB library and X11-XCB library for mixed
X11/XCB programming.])
XCB_LIBS="-lX11-xcb -lxcb"
AC_SUBST(XCB_LIBS)
fi
fi
fi
### Use -lXpm if available, unless '--with-xpm=no'.
### mingw32 doesn't use -lXpm, since it loads the library dynamically.
### In the Cygwin-w32 build, we need to use /usr/include/noX/X11/xpm.h

View file

@ -128,8 +128,9 @@ LIB_PTHREAD=@LIB_PTHREAD@
LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@
XCB_LIBS=@XCB_LIBS@
XFT_LIBS=@XFT_LIBS@
LIBX_EXTRA=-lX11 $(XFT_LIBS)
LIBX_EXTRA=-lX11 $(XCB_LIBS) $(XFT_LIBS)
FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
FONTCONFIG_LIBS = @FONTCONFIG_LIBS@

View file

@ -11773,6 +11773,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
struct terminal *terminal;
struct x_display_info *dpyinfo;
XrmDatabase xrdb;
#ifdef USE_XCB
xcb_connection_t *xcb_conn;
#endif
block_input ();
@ -11911,6 +11914,25 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
return 0;
}
#ifdef USE_XCB
xcb_conn = XGetXCBConnection (dpy);
if (xcb_conn == 0)
{
#ifdef USE_GTK
xg_display_close (dpy);
#else
#ifdef USE_X_TOOLKIT
XtCloseDisplay (dpy);
#else
XCloseDisplay (dpy);
#endif
#endif /* ! USE_GTK */
unblock_input ();
return 0;
}
#endif
/* We have definitely succeeded. Record the new connection. */
dpyinfo = xzalloc (sizeof *dpyinfo);
@ -11961,6 +11983,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
dpyinfo->name_list_element = Fcons (display_name, Qnil);
dpyinfo->display = dpy;
dpyinfo->connection = ConnectionNumber (dpyinfo->display);
#ifdef USE_XCB
dpyinfo->xcb_connection = xcb_conn;
#endif
/* http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg00194.html */
dpyinfo->smallest_font_height = 1;

View file

@ -87,6 +87,10 @@ typedef GtkWidget *xt_or_gtk_widget;
#include <X11/Xlocale.h>
#endif
#ifdef USE_XCB
#include <X11/Xlib-xcb.h>
#endif
#include "dispextern.h"
#include "termhooks.h"
@ -458,6 +462,10 @@ struct x_display_info
#ifdef USE_CAIRO
XExtCodes *ext_codes;
#endif
#ifdef USE_XCB
xcb_connection_t *xcb_connection;
#endif
};
#ifdef HAVE_X_I18N