diff -u -p -r1.300 configure.in
--- configure.in	2 Oct 2006 07:35:01 -0000	1.300
+++ configure.in	17 Oct 2006 13:36:00 -0000
@@ -271,7 +271,7 @@ EXTRA_GNOME_LIBS="$EXTRA_GNOME_LIBS $EXT
 AC_SUBST(EXTRA_GNOME_CFLAGS)
 AC_SUBST(EXTRA_GNOME_LIBS)
 
-PKG_CHECK_MODULES(GTK, gtk+-x11-2.0 $MM gthread-2.0)
+PKG_CHECK_MODULES(GTK, gtk+-2.0 $MM gthread-2.0)
 AC_SUBST(GTK_CFLAGS)
 GTK_LIBS="$GTK_LIBS $EXTRA_BACKEND_LIBS"
 AC_SUBST(GTK_LIBS)
@@ -593,8 +593,11 @@ if test $have_randr = yes -a $have_xvidm
 	AC_DEFINE(HAVE_XVIDMODE,, [Define this if you have the XVidMode and XRandR extension installed])
 fi
 
-dnl Explicitely link against libX11 to avoid problems with crappy linkers
-X_LIBS="$X_LIBRARIES -lX11"
+X_LIBS=""
+if test x$(pkg-config --variable=target gtk+-2.0) = xx11; then
+	dnl Explicitely link against libX11 to avoid problems with crappy linkers
+	X_LIBS="$X_LIBRARIES -lX11"
+fi
 AC_SUBST(X_LIBS)
 
 dnl Multimedia keys
diff -u -p -r1.9 totem-screenshot.c
--- src/totem-screenshot.c	14 Apr 2005 22:03:22 -0000	1.9
+++ src/totem-screenshot.c	17 Oct 2006 13:36:39 -0000
@@ -240,7 +240,7 @@ totem_screenshot_temp_file (TotemScreens
 
 		dir = g_strdup_printf ("totem-screenshot-%d", getpid ());
 		fulldir = g_build_filename (g_get_tmp_dir (), dir, NULL);
-		if (mkdir (fulldir, 0700) < 0) {
+		if (g_mkdir (fulldir, 0700) < 0) {
 			g_free (fulldir);
 			g_free (dir);
 			return;
diff -u -p -r1.59 totem-video-thumbnailer.c
--- src/totem-video-thumbnailer.c	2 Oct 2006 22:47:27 -0000	1.59
+++ src/totem-video-thumbnailer.c	17 Oct 2006 13:36:39 -0000
@@ -366,7 +366,9 @@ int main (int argc, char *argv[])
 		return -1;
 	}
 
+#ifdef G_OS_UNIX
 	nice (20);
+#endif
 
 	g_thread_init (NULL);
 #ifndef THUMB_DEBUG
diff -u -p -r1.524 totem.c
--- src/totem.c	26 Sep 2006 22:23:10 -0000	1.524
+++ src/totem.c	17 Oct 2006 13:36:40 -0000
@@ -40,12 +40,14 @@
 
 #include <string.h>
 
+#ifdef GDK_WINDOWING_X11
 /* X11 headers */
 #include <gdk/gdkx.h>
 #include <X11/Xlib.h>
 #ifdef HAVE_XFREE
 #include <X11/XF86keysym.h>
 #endif
+#endif
 
 #include "bacon-video-widget.h"
 #include "bacon-video-widget-properties.h"
@@ -3195,12 +3197,14 @@ main (int argc, char **argv)
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
+#ifdef GDK_WINDOWING_X11
 	if (XInitThreads () == 0)
 	{
 		gtk_init (&argc, &argv);
 		g_set_application_name (_("Totem Movie Player"));
 		totem_action_error_and_exit (_("Could not initialize the thread-safe libraries."), _("Verify your system installation. Totem will now exit."), NULL);
 	}
+#endif
 
 	g_thread_init (NULL);
 
diff -u -p -r1.8 bvw-test.c
--- src/backend/bvw-test.c	22 May 2006 16:27:47 -0000	1.8
+++ src/backend/bvw-test.c	17 Oct 2006 14:42:04 -0000
@@ -2,7 +2,9 @@
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 #include "bacon-video-widget.h"
+#ifdef GDK_WINDOWING_X11
 #include <X11/Xlib.h>
+#endif
 
 GtkWidget *win;
 GtkWidget *xine;
@@ -35,9 +37,11 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+#ifdef GDK_WINDOWING_X11
 	XInitThreads();
-	gtk_init (&argc, &argv);
+#endif
 	g_thread_init (NULL);
+	gtk_init (&argc, &argv);
 	bacon_video_widget_init_backend (NULL, NULL);
 	gdk_threads_init ();
 
diff -u -p -r1.31 video-utils.c
--- src/backend/video-utils.c	17 May 2006 14:49:22 -0000	1.31
+++ src/backend/video-utils.c	17 Oct 2006 14:44:21 -0000
@@ -7,8 +7,6 @@
 #include <libintl.h>
 
 #include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-#include <X11/Xlib.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
