emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c7f2b6a 3/5: Detect XCB and save a connection handl


From: Ken Raeburn
Subject: [Emacs-diffs] master c7f2b6a 3/5: Detect XCB and save a connection handle
Date: Thu, 12 Nov 2015 09:03:52 +0000

branch: master
commit c7f2b6ad892c93b8b848d21835a4b093c424cae6
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>

    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.
---
 configure.ac    |   15 +++++++++++++++
 src/Makefile.in |    3 ++-
 src/xterm.c     |   25 +++++++++++++++++++++++++
 src/xterm.h     |    8 ++++++++
 4 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5b2d9c7..94ee9b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/src/Makefile.in b/src/Makefile.in
index f735759..d667c55 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -128,8 +128,9 @@ address@hidden@
 
 address@hidden@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@
 
address@hidden@
 address@hidden@
-LIBX_EXTRA=-lX11 $(XFT_LIBS)
+LIBX_EXTRA=-lX11 $(XCB_LIBS) $(XFT_LIBS)
 
 FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
 FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
diff --git a/src/xterm.c b/src/xterm.c
index 5756378..d1cf8e4 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -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;
diff --git a/src/xterm.h b/src/xterm.h
index f7d2803..192839b 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]