summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2009-07-27 21:15:31 -0400
committerEamon Walsh <ewalsh@tycho.nsa.gov>2009-07-27 21:15:31 -0400
commitc0e09be4086e76866e9ff22bfc02e5e96bd80a44 (patch)
tree0be8a4354b8ba8f5fb8d6e2bd74ee72f46699599
parentdabd471bffe1f772c3cf4770dffbce240761917d (diff)
Add support for an Xlib display pointer.
-rw-r--r--configure.ac9
-rw-r--r--src/Makefile.am4
-rw-r--r--src/app.h6
-rw-r--r--src/conn.c26
-rw-r--r--src/propmon.c2
-rw-r--r--src/selmgr.c2
-rw-r--r--src/selmon.c2
7 files changed, 34 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 04ec8d1..d8fe79d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,14 +11,21 @@ AC_PROG_CC
AC_HEADER_STDC
CFLAGS="-g3 -O0 -Wall"
-AC_SUBST(CFLAGS)
+AC_SUBST([CFLAGS])
# Checks for pkg-config packages
PKG_CHECK_MODULES(XCB, xcb)
PKG_CHECK_MODULES(XFIXES, xcb-xfixes)
PKG_CHECK_MODULES(XSELINUX, xcb-xselinux)
+PKG_CHECK_MODULES(X11, x11)
+PKG_CHECK_MODULES(X11XCB, x11-xcb)
PKG_CHECK_MODULES(GTK, gtk+-2.0)
+SEDPYMGR_LIBS="$GTK_LIBS $X11XCB_LIBS $X11LIBS $XFIXES_LIBS $XSELINUX_LIBS -lselinux"
+AC_SUBST([SEDPYMGR_LIBS])
+SEDPYMGR_CFLAGS="$GTK_CFLAGS"
+AC_SUBST([SEDPYMGR_CFLAGS])
+
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 3009a4f..eca067a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@ pkgpythondir = $(pythondir)/xcb
bin_PROGRAMS = sedpymgr
sedpymgr_SOURCES = main.c selmon.c selmgr.c propmon.c atom.c conn.c util.c
-sedpymgr_CFLAGS = $(GTK_CFLAGS)
-sedpymgr_LDADD = $(GTK_LIBS) $(XFIXES_LIBS) $(XSELINUX_LIBS) -lselinux
+sedpymgr_CFLAGS = $(SEDPYMGR_CFLAGS)
+sedpymgr_LDADD = $(SEDPYMGR_LIBS)
noinst_HEADERS = app.h
diff --git a/src/app.h b/src/app.h
index 1a1c61c..27a50f3 100644
--- a/src/app.h
+++ b/src/app.h
@@ -7,6 +7,8 @@
#include <xcb/xproto.h>
#include <xcb/xfixes.h>
#include <xcb/xselinux.h>
+#include <X11/Xlib.h>
+#include <X11/Xlib-xcb.h>
#include <gtk/gtk.h>
enum {
@@ -81,8 +83,8 @@ void
selection_register(xcb_connection_t *conn, xcb_window_t window);
/* conn.c */
-xcb_connection_t *
-make_connection(const gchar *display);
+void
+make_connection(const gchar *name, xcb_connection_t **conn, Display **dpy);
int
fetch_property_data(xcb_connection_t *conn,
diff --git a/src/conn.c b/src/conn.c
index 7176f61..673fda5 100644
--- a/src/conn.c
+++ b/src/conn.c
@@ -52,18 +52,26 @@ check_xselinux(xcb_connection_t *conn)
free(version);
}
-xcb_connection_t *
-make_connection(const gchar *display)
+void
+make_connection(const gchar *name, xcb_connection_t **conn, Display **dpy)
{
- xcb_connection_t *conn = xcb_connect(display, NULL);
- if (xcb_connection_has_error(conn))
+ Display *td;
+ xcb_connection_t *tc;
+
+ td = XOpenDisplay(name);
+ if (!td)
APP_ERR(NULL, "could not connect to X display\n");
- xcb_prefetch_extension_data(conn, &xcb_xfixes_id);
- xcb_prefetch_extension_data(conn, &xcb_selinux_id);
- check_xfixes(conn);
- check_xselinux(conn);
- return conn;
+ tc = XGetXCBConnection(td);
+ xcb_prefetch_extension_data(tc, &xcb_xfixes_id);
+ xcb_prefetch_extension_data(tc, &xcb_selinux_id);
+ check_xfixes(tc);
+ check_xselinux(tc);
+
+ if (conn)
+ *conn = tc;
+ if (dpy)
+ *dpy = td;
}
int
diff --git a/src/propmon.c b/src/propmon.c
index 96182db..85f6cee 100644
--- a/src/propmon.c
+++ b/src/propmon.c
@@ -16,7 +16,7 @@ setup_x(const gchar *display)
xcb_screen_iterator_t iter;
uint32_t mask, list;
- conn = make_connection(display);
+ make_connection(display, &conn, NULL);
setup = xcb_get_setup(conn);
iter = xcb_setup_roots_iterator(setup);
diff --git a/src/selmgr.c b/src/selmgr.c
index 5908f5c..7ac4a95 100644
--- a/src/selmgr.c
+++ b/src/selmgr.c
@@ -52,7 +52,7 @@ setup_x(const gchar *display)
xcb_screen_iterator_t iter;
xcb_window_t root;
- conn = make_connection(display);
+ make_connection(display, &conn, NULL);
xfixes_type = xcb_get_extension_data(conn, &xcb_xfixes_id)->first_event;
setup = xcb_get_setup(conn);
diff --git a/src/selmon.c b/src/selmon.c
index 9f4b1b5..92c864d 100644
--- a/src/selmon.c
+++ b/src/selmon.c
@@ -41,7 +41,7 @@ setup_x(const gchar *display)
xcb_screen_iterator_t iter;
xcb_window_t root;
- conn = make_connection(display);
+ make_connection(display, &conn, NULL);
xfixes_type = xcb_get_extension_data(conn, &xcb_xfixes_id)->first_event;
setup = xcb_get_setup(conn);