From 719757ca22776c3ec3379baa658d7c856ef5f6e0 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 30 Oct 2004 16:16:32 +0000 Subject: [PATCH] Improved X extension detection in configure and added handling of dpms.h headers that don't have function prototypes. --- configure.in | 80 ++++++++++++++++++++------- lib/platform/CXWindowsScreenSaver.cpp | 16 ++++++ 2 files changed, 75 insertions(+), 21 deletions(-) diff --git a/configure.in b/configure.in index 884b3481..791acd83 100644 --- a/configure.in +++ b/configure.in @@ -97,37 +97,75 @@ if test x"$acx_host_winapi" = xXWINDOWS; then AC_PATH_XTRA save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$X_CFLAGS $CPPFLAGS" + XEXT_LDADD= + AC_CHECK_LIB(Xtst, XTestQueryExtension, - [X_LIBS="$X_LIBS -lXtst"], + [XEXT_LDADD="$XEXT_LDADD -lXtst"], AC_MSG_ERROR(You must have the XTest library to build synergy), [$X_LIBS -lXext -lX11 $X_EXTRA_LIBS]) - AC_CHECK_HEADERS([X11/extensions/XTest.h],, + AC_CHECK_HEADERS([X11/extensions/XTest.h], + , AC_MSG_ERROR(You must have the XTest headers to compile synergy)) - AC_CHECK_HEADERS([X11/extensions/Xinerama.h], - [acx_xinerama_lib_ok=yes], - [acx_xinerama_lib_ok=no], - [#include ]) - if test x"$acx_xinerama_lib_ok" = xyes; then - AC_CHECK_LIB(Xinerama, - XineramaQueryExtension, - [X_LIBS="$X_LIBS -lXinerama"], - [AC_DEFINE(HAVE_X11_EXTENSIONS_XINERAMA_H, 0)], - [$X_LIBS -lXext -lX11 $X_EXTRA_LIBS]) + + acx_have_xinerama=yes + AC_CHECK_LIB(Xinerama, + XineramaQueryExtension, + [acx_have_xinerama=yes], + [acx_have_xinerama=no], + [$X_LIBS -lXext -lX11 $X_EXTRA_LIBS]) + if test x"$acx_have_xinerama" = xyes; then + AC_CHECK_HEADERS([X11/extensions/Xinerama.h], + [acx_have_xinerama=yes], + [acx_have_xinerama=no], + [#include ]) fi - AC_CHECK_HEADERS([X11/extensions/dpms.h], - [acx_dpms_lib_ok=yes], - [acx_dpms_lib_ok=no], - [#include ]) - if test x"$acx_dpms_lib_ok" = xyes; then - AC_CHECK_LIB(Xext, + if test x"$acx_have_xinerama" = xyes; then + XEXT_LDADD="$XEXT_LDADD -lXinerama" + fi + + X_DPMS_LDADD= + acx_have_dpms=no + AC_CHECK_LIB(Xext, + DPMSQueryExtension, + [acx_have_dpms=yes], + [acx_have_dpms=no], + [$X_LIBS -lX11 $X_EXTRA_LIBS]) + if test x"$acx_have_dpms" != xyes; then + AC_CHECK_LIB(Xdpms, DPMSQueryExtension, - [true], - [AC_DEFINE(HAVE_X11_EXTENSIONS_DPMS_H, 0)], + [acx_have_dpms=yes; XDPMS_LDADD=-lXdpms], + [acx_have_dpms=no], [$X_LIBS -lX11 $X_EXTRA_LIBS]) fi + if test x"$acx_have_dpms" = xyes; then + AC_CHECK_HEADERS([X11/extensions/dpms.h], + [acx_have_dpms_h=yes], + [acx_have_dpms_h=no], + [#include ]) + if test x"$acx_have_dpms_h" = xyes; then + XEXT_LDADD="$XEXT_LDADD $XDPMS_LDADD" + AC_MSG_CHECKING(for prototypes in X11/extensions/dpms.h) + acx_have_dpms_protos=no + AC_TRY_COMPILE([ + #include + extern "C" { + #include + } + ],[ + int s = DPMSModeOn; + DPMSQueryExtension(0, 0, 0); + ], + [acx_have_dpms_protos=yes]) + AC_MSG_RESULT($acx_have_dpms_protos) + if test x"$acx_have_dpms_protos" = xyes; then + AC_DEFINE(HAVE_DPMS_PROTOTYPES,1,[Define if the header file declares function prototypes.]) + fi + fi + fi + CPPFLAGS="$save_CPPFLAGS" - ARCH_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS $ARCH_LIBS" + ARCH_LIBS="$X_LIBS $X_PRE_LIBS $XEXT_LDADD -lXext -lX11 $X_EXTRA_LIBS $ARCH_LIBS" ARCH_CFLAGS="$ARCH_CFLAGS $X_CFLAGS" fi diff --git a/lib/platform/CXWindowsScreenSaver.cpp b/lib/platform/CXWindowsScreenSaver.cpp index 222c9a31..6c8efbde 100644 --- a/lib/platform/CXWindowsScreenSaver.cpp +++ b/lib/platform/CXWindowsScreenSaver.cpp @@ -29,6 +29,22 @@ extern "C" { # include # include +# if !HAVE_DPMS_PROTOTYPES +# undef DPMSModeOn +# undef DPMSModeStandby +# undef DPMSModeSuspend +# undef DPMSModeOff +# define DPMSModeOn 0 +# define DPMSModeStandby 1 +# define DPMSModeSuspend 2 +# define DPMSModeOff 3 +extern Bool DPMSQueryExtension(Display *, int *, int *); +extern Bool DPMSCapable(Display *); +extern Status DPMSEnable(Display *); +extern Status DPMSDisable(Display *); +extern Status DPMSForceLevel(Display *, CARD16); +extern Status DPMSInfo(Display *, CARD16 *, BOOL *); +# endif } #endif