]> code.delx.au - gnu-emacs/commitdiff
Detect XCB and save a connection handle
authorKen Raeburn <raeburn@raeburn.org>
Sat, 7 Nov 2015 08:06:32 +0000 (03:06 -0500)
committerKen Raeburn <raeburn@raeburn.org>
Thu, 12 Nov 2015 08:58:09 +0000 (03:58 -0500)
* 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.

configure.ac
src/Makefile.in
src/xterm.c
src/xterm.h

index 5b2d9c7c59f975183bb139719ececb4e14a13de3..94ee9b7aa2b9e25f73ba7e826d56f893f34449fd 100644 (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
index f73575938d3d0ae82a0902c2b7f759497714fa63..d667c55ee33ddee1800f034870e0e071b749556d 100644 (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@
index 5756378bd3af91c874523f17717575d1e173bafa..d1cf8e4d0c1cc337946e0ff55a400d0d4e02bd1f 100644 (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;
index f7d2803ff299694b39cdfad24e49351d5a6126e0..192839b059ef42a8920530677fba7b6bed8254ba 100644 (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