From 38390f9b88cad323254d9d3e405972bc5123b226 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Dec 2020 14:18:02 +1000 Subject: [PATCH 1/3] Undef X_DISPLAY_MISSING As of f815f9840d459ff43d10c760ba0543ed208a8510 several years ago nothing sets this #define anywhere anymore. --- res/config.h.in | 3 -- src/lib/platform/IXWindowsImpl.h | 60 ++++++++++----------- src/lib/platform/XWindowsClipboard.h | 6 +-- src/lib/platform/XWindowsEventQueueBuffer.h | 6 +-- src/lib/platform/XWindowsKeyState.cpp | 14 ++--- src/lib/platform/XWindowsKeyState.h | 18 +++---- src/lib/platform/XWindowsScreen.h | 6 +-- src/lib/platform/XWindowsScreenSaver.h | 6 +-- src/lib/platform/XWindowsUtil.h | 6 +-- 9 files changed, 45 insertions(+), 80 deletions(-) diff --git a/res/config.h.in b/res/config.h.in index 2bd3b3bf..b04930a1 100644 --- a/res/config.h.in +++ b/res/config.h.in @@ -160,8 +160,5 @@ /* Define to 1 if your declares `struct tm`. */ #cmakedefine TM_IN_SYS_TIME ${TM_IN_SYS_TIME} -/* Define to 1 if the X Window System is missing or not being used. */ -#cmakedefine X_DISPLAY_MISSING ${X_DISPLAY_MISSING} - /* Define to `unsigned int` if does not define. */ #cmakedefine size_t ${size_t} diff --git a/src/lib/platform/IXWindowsImpl.h b/src/lib/platform/IXWindowsImpl.h index ddcaf2f5..8a190a84 100644 --- a/src/lib/platform/IXWindowsImpl.h +++ b/src/lib/platform/IXWindowsImpl.h @@ -3,39 +3,35 @@ #include "config.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier +#include +#include +#define XK_MISCELLANY +#define XK_XKB_KEYS +#include +#if HAVE_X11_EXTENSIONS_DPMS_H + extern "C" { +# include + } +#endif +#if HAVE_X11_EXTENSIONS_XTEST_H +# include #else -# include -# include -# define XK_MISCELLANY -# define XK_XKB_KEYS -# include -# if HAVE_X11_EXTENSIONS_DPMS_H - extern "C" { -# include - } -# endif -# if HAVE_X11_EXTENSIONS_XTEST_H -# include -# else -# error The XTest extension is required to build barrier -# endif -# if HAVE_X11_EXTENSIONS_XINERAMA_H - // Xinerama.h may lack extern "C" for inclusion by C++ - extern "C" { -# include - } -# endif -# if HAVE_X11_EXTENSIONS_XRANDR_H -# include -# endif -# if HAVE_XKB_EXTENSION -# include -# endif -# ifdef HAVE_XI2 -# include -# endif +# error The XTest extension is required to build barrier +#endif +#if HAVE_X11_EXTENSIONS_XINERAMA_H + // Xinerama.h may lack extern "C" for inclusion by C++ + extern "C" { +# include + } +#endif +#if HAVE_X11_EXTENSIONS_XRANDR_H +# include +#endif +#if HAVE_XKB_EXTENSION +# include +#endif +#ifdef HAVE_XI2 +# include #endif class IXWindowsImpl { diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h index 091036e5..84d49455 100644 --- a/src/lib/platform/XWindowsClipboard.h +++ b/src/lib/platform/XWindowsClipboard.h @@ -25,11 +25,7 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class IXWindowsClipboardConverter; diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h index 13f6b160..ac4409f3 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.h +++ b/src/lib/platform/XWindowsEventQueueBuffer.h @@ -23,11 +23,7 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class IEventQueue; diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 9fb71cae..4e477b1f 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -24,18 +24,14 @@ #include #include -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -# include -# define XK_MISCELLANY -# define XK_XKB_KEYS -# include +#include +#include +#define XK_MISCELLANY +#define XK_XKB_KEYS +#include #if HAVE_XKB_EXTENSION # include #endif -#endif static const size_t ModifiersFromXDefaultSize = 32; diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index 6abd6142..d48a2af4 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -23,18 +23,14 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier +#include +#if HAVE_X11_EXTENSIONS_XTEST_H +# include #else -# include -# if HAVE_X11_EXTENSIONS_XTEST_H -# include -# else -# error The XTest extension is required to build barrier -# endif -# if HAVE_XKB_EXTENSION -# include -# endif +# error The XTest extension is required to build barrier +#endif +#if HAVE_XKB_EXTENSION +# include #endif class IEventQueue; diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h index 55738397..3cb4aa97 100644 --- a/src/lib/platform/XWindowsScreen.h +++ b/src/lib/platform/XWindowsScreen.h @@ -24,11 +24,7 @@ #include "common/stdvector.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class XWindowsClipboard; class XWindowsKeyState; diff --git a/src/lib/platform/XWindowsScreenSaver.h b/src/lib/platform/XWindowsScreenSaver.h index 1761db28..f17959d9 100644 --- a/src/lib/platform/XWindowsScreenSaver.h +++ b/src/lib/platform/XWindowsScreenSaver.h @@ -23,11 +23,7 @@ #include "common/stdmap.h" #include "XWindowsImpl.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include class Event; class EventQueueTimer; diff --git a/src/lib/platform/XWindowsUtil.h b/src/lib/platform/XWindowsUtil.h index f5b3ea80..39d397c2 100644 --- a/src/lib/platform/XWindowsUtil.h +++ b/src/lib/platform/XWindowsUtil.h @@ -22,11 +22,7 @@ #include "common/stdmap.h" #include "common/stdvector.h" -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include -#endif +#include #include From f3eb89121db00c959daf374c8712f15860276b52 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Dec 2020 14:29:33 +1000 Subject: [PATCH 2/3] Move the XTest check to cmake Where the ifdef was checked, the alternative was a compiler error. We can shortcut that process and just fail in cmake where the header is not found. --- CMakeLists.txt | 4 ++++ res/config.h.in | 3 --- src/lib/platform/IXWindowsImpl.h | 6 +----- src/lib/platform/XWindowsKeyState.h | 6 +----- src/lib/platform/XWindowsScreenSaver.cpp | 6 +----- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c57eeb9..2fb555a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,10 @@ if (UNIX) set (HAVE_DPMS_PROTOTYPES 1) endif() + if (NOT HAVE_X11_EXTENSIONS_XTEST_H) + message (FATAL_ERROR "Missing header: X11/extensions/XTest.h") + endif() + if (NOT HAVE_X11_XKBLIB_H) message (FATAL_ERROR "Missing header: " ${XKBlib}) endif() diff --git a/res/config.h.in b/res/config.h.in index b04930a1..eb1e34fb 100644 --- a/res/config.h.in +++ b/res/config.h.in @@ -115,9 +115,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_X11_EXTENSIONS_XKBSTR_H ${HAVE_X11_EXTENSIONS_XKBSTR_H} -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_X11_EXTENSIONS_XTEST_H ${HAVE_X11_EXTENSIONS_XTEST_H} - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_X11_XKBLIB_H ${HAVE_X11_XKBLIB_H} diff --git a/src/lib/platform/IXWindowsImpl.h b/src/lib/platform/IXWindowsImpl.h index 8a190a84..37c59b22 100644 --- a/src/lib/platform/IXWindowsImpl.h +++ b/src/lib/platform/IXWindowsImpl.h @@ -13,11 +13,7 @@ # include } #endif -#if HAVE_X11_EXTENSIONS_XTEST_H -# include -#else -# error The XTest extension is required to build barrier -#endif +#include #if HAVE_X11_EXTENSIONS_XINERAMA_H // Xinerama.h may lack extern "C" for inclusion by C++ extern "C" { diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index d48a2af4..cad1d533 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -24,11 +24,7 @@ #include "XWindowsImpl.h" #include -#if HAVE_X11_EXTENSIONS_XTEST_H -# include -#else -# error The XTest extension is required to build barrier -#endif +#include #if HAVE_XKB_EXTENSION # include #endif diff --git a/src/lib/platform/XWindowsScreenSaver.cpp b/src/lib/platform/XWindowsScreenSaver.cpp index 5c4ef913..a02fdfd5 100644 --- a/src/lib/platform/XWindowsScreenSaver.cpp +++ b/src/lib/platform/XWindowsScreenSaver.cpp @@ -26,11 +26,7 @@ #include "base/TMethodEventJob.h" #include -#if HAVE_X11_EXTENSIONS_XTEST_H -# include -#else -# error The XTest extension is required to build barrier -#endif +#include #if HAVE_X11_EXTENSIONS_DPMS_H extern "C" { # include From 1474f04f5360d39aa7b4b3df91fe1157ca2a50fe Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Dec 2020 14:31:08 +1000 Subject: [PATCH 3/3] Remove an unreachable preprocessor directive cmake sets HAVE_DPMS_PROTOTYPES unconditionally to 1 if we have the dpms headers. So code inside HAVE_X11_EXTENSIONS_DPMS_H never needs to check for it. And since there's only one place that cared for this, we can remove the define in cmake as well. --- CMakeLists.txt | 5 ----- res/config.h.in | 3 --- src/lib/platform/XWindowsScreenSaver.cpp | 16 ---------------- 3 files changed, 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fb555a9..5af4362f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,11 +195,6 @@ if (UNIX) check_include_files ("X11/extensions/XInput2.h" HAVE_XI2) check_include_files ("dns_sd.h" HAVE_DNSSD) - if (HAVE_X11_EXTENSIONS_DPMS_H) - # Assume that function prototypes declared, when include exists. - set (HAVE_DPMS_PROTOTYPES 1) - endif() - if (NOT HAVE_X11_EXTENSIONS_XTEST_H) message (FATAL_ERROR "Missing header: X11/extensions/XTest.h") endif() diff --git a/res/config.h.in b/res/config.h.in index eb1e34fb..a2216875 100644 --- a/res/config.h.in +++ b/res/config.h.in @@ -19,9 +19,6 @@ /* Define if your compiler has standard C++ library support. */ #cmakedefine HAVE_CXX_STDLIB ${HAVE_CXX_STDLIB} -/* Define if the header file declares function prototypes. */ -#cmakedefine HAVE_DPMS_PROTOTYPES ${HAVE_DPMS_PROTOTYPES} - /* Define if you have a working `getpwuid_r` function. */ #cmakedefine HAVE_GETPWUID_R ${HAVE_GETPWUID_R} diff --git a/src/lib/platform/XWindowsScreenSaver.cpp b/src/lib/platform/XWindowsScreenSaver.cpp index a02fdfd5..be1d7d43 100644 --- a/src/lib/platform/XWindowsScreenSaver.cpp +++ b/src/lib/platform/XWindowsScreenSaver.cpp @@ -31,22 +31,6 @@ 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