summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Jon McCann <mccann@jhu.edu>2007-03-26 14:39:44 -0400
committerWilliam Jon McCann <mccann@jhu.edu>2007-03-26 14:39:44 -0400
commita2b51f00af2143a90138c6ce1df1e7e9b4ec8afa (patch)
tree66857662444b160d1435037fe233638227e0ef5f
parent4c365a8e28adafd6619ada97d4239e9e6df429ab (diff)
use xlib directly instead of via gdk
-rw-r--r--configure.ac5
-rw-r--r--tools/linux/ck-get-x11-server-pid.c39
2 files changed, 35 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index 5e85b36..cc96ee6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,7 @@ AM_GLIB_GNU_GETTEXT
DBUS_REQUIRED_VERSION=0.30
GLIB_REQUIRED_VERSION=2.7.0
-GDK_REQUIRED_VERSION=2.8.0
+X11_REQUIRED_VERSION=1.0.0
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(paths.h)
@@ -51,7 +51,8 @@ PKG_CHECK_MODULES(LIBDBUS,
dbus-1 >= $DBUS_REQUIRED_VERSION
)
PKG_CHECK_MODULES(TOOLS,
- gdk-2.0 >= $GDK_REQUIRED_VERSION
+ x11 >= $X11_REQUIRED_VERSION
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
)
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
diff --git a/tools/linux/ck-get-x11-server-pid.c b/tools/linux/ck-get-x11-server-pid.c
index 4e5d6c5..cd48cd1 100644
--- a/tools/linux/ck-get-x11-server-pid.c
+++ b/tools/linux/ck-get-x11-server-pid.c
@@ -29,15 +29,17 @@
#include <sys/types.h>
#include <sys/socket.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+#include <glib.h>
static void
print_peer_pid (int fd)
{
#ifdef SO_PEERCRED
struct ucred cr;
- int cr_len = sizeof (cr);
+ socklen_t cr_len;
+
+ cr_len = sizeof (cr);
if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) == 0 && cr_len == sizeof (cr)) {
/* paranoia check for peer running as root */
@@ -53,18 +55,41 @@ print_peer_pid (int fd)
#endif
}
+static Display *
+display_init (int *argc, char ***argv)
+{
+ const char *display_name;
+ Display *xdisplay;
+
+ display_name = g_getenv ("DISPLAY");
+
+ if (display_name == NULL) {
+ g_warning ("DISPLAY is not set");
+ exit (1);
+ }
+
+ xdisplay = XOpenDisplay (display_name);
+ if (xdisplay == NULL) {
+ g_warning ("cannot open display: %s", display_name ? display_name : "");
+ exit (1);
+ }
+
+ return xdisplay;
+}
+
int
main (int argc,
char **argv)
{
- int fd;
- int ret;
+ int fd;
+ int ret;
+ Display *xdisplay;
ret = 1;
- gdk_init (&argc, &argv);
+ xdisplay = display_init (&argc, &argv);
- fd = ConnectionNumber (GDK_DISPLAY());
+ fd = ConnectionNumber (xdisplay);
if (fd > 0) {
ret = 0;