diff --git a/CMakeLists.txt b/CMakeLists.txt index 287f6ac22..374bb88c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,10 @@ list(APPEND CMAKE_PREFIX_PATH ${CMAKE_ADDITIONAL_DEPS_PATH}) ############################################################################ include(CMakeDependentOption) option(PROJECT_FOLDERS "Put source files into subfolders in project file" ON) -option(USE_SDL_MAINLOOP "Use SDL to create windows etc." OFF) -CMAKE_DEPENDENT_OPTION(USE_X11 "Use X11 to create windows etc." ON - "UNIX AND NOT APPLE AND NOT USE_SDL_MAINLOOP" OFF) -CMAKE_DEPENDENT_OPTION(USE_GTK "Use GTK for the developer mode" ON "USE_X11" OFF) -CMAKE_DEPENDENT_OPTION(USE_COCOA "Use Apple Cocoa for the developer mode and the windows." ON "APPLE" OFF) +CMAKE_DEPENDENT_OPTION(USE_COCOA "Use Apple Cocoa widgets." ON "APPLE" OFF) +CMAKE_DEPENDENT_OPTION(USE_WIN32_WINDOWS "Use Microsoft Desktop App User Interface widgets." ON "WIN32" OFF) +CMAKE_DEPENDENT_OPTION(USE_GTK "Use GTK+ widgets." ON "NOT USE_COCOA AND NOT USE_WIN32_WINDOWS" OFF) +CMAKE_DEPENDENT_OPTION(USE_SDL_MAINLOOP "Use SDL to create windows etc. No editor." ON "NOT USE_COCOA AND NOT USE_WIN32_WINDOWS AND NOT USE_GTK" OFF) option(WITH_AUTOMATIC_UPDATE "Automatic updates are downloaded from the project website." OFF) set_property(GLOBAL PROPERTY USE_FOLDERS ${PROJECT_FOLDERS}) @@ -263,7 +262,7 @@ add_definitions(${GLEW_DEFINITIONS}) set(CMAKE_REQUIRED_INCLUDES "${GLEW_INCLUDE_DIRS}") CHECK_CXX_SOURCE_COMPILES("#include \nvoid GLAPIENTRY OpenGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void* userParam) {}\nint main() { GLDEBUGPROCARB proc = &OpenGLDebugProc; }" GLDEBUGPROCARB_USERPARAM_IS_CONST) -if(USE_X11) +if(USE_GTK AND UNIX) FINDLIB(X11_LIBRARIES X11) FINDLIB(XRANDR_LIBRARIES Xrandr) endif() @@ -904,7 +903,7 @@ elseif(USE_SDL_MAINLOOP) src/platform/C4AppSDL.cpp src/platform/C4WindowSDL.cpp ) -elseif(WIN32) +elseif(USE_WIN32_WINDOWS) list(APPEND OC_GUI_SOURCES src/editor/C4ConsoleWin32.cpp src/platform/C4WindowWin32.cpp diff --git a/config.h.cmake b/config.h.cmake index 97bb5686c..5c76f7b8f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -89,19 +89,6 @@ /* MP3 music */ #cmakedefine USE_MP3 1 -/* Define to 1 if SDL is used for the main loop */ -#cmakedefine USE_SDL_MAINLOOP 1 - -/* Define to 1 if the X Window System is used */ -#cmakedefine USE_X11 1 -#cmakedefine USE_GTK 1 - -/* Use Apple Cocoa for the UI */ -#cmakedefine USE_COCOA 1 - -/* Enable automatic update system */ -#cmakedefine WITH_AUTOMATIC_UPDATE 1 - /* Define to 1 if the userParam parameter to GLDEBUGPROCARB is const, as the spec requires. */ #cmakedefine GLDEBUGPROCARB_USERPARAM_IS_CONST 1 @@ -115,24 +102,25 @@ /* Define to 1 if you have support for precompiled headers */ #cmakedefine HAVE_PRECOMPILED_HEADERS 1 +#ifndef USE_CONSOLE +/* The widgets for the windows and the editor GUI */ +#cmakedefine USE_SDL_MAINLOOP 1 +#cmakedefine USE_WIN32_WINDOWS 1 +#cmakedefine USE_COCOA 1 +#cmakedefine USE_GTK 1 + +/* Enable automatic update system */ +#cmakedefine WITH_AUTOMATIC_UPDATE 1 + /* Select an audio provider */ +#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER} +#else +#define AUDIO_TK AUDIO_TK_NONE +#endif + #define AUDIO_TK_NONE 0 #define AUDIO_TK_OPENAL 1 #define AUDIO_TK_SDL_MIXER 3 -#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER} /* Include OpenAL extensions (alext.h) for sound modifiers */ #cmakedefine HAVE_ALEXT 1 - -#ifdef USE_CONSOLE -/* FIXME: Sort this out in CMake instead of here */ -#undef USE_COCOA -#undef USE_SDL_MAINLOOP -#undef USE_X11 -#undef USE_GTK 1 -#undef WITH_AUTOMATIC_UPDATE - -#undef AUDIO_TK -#define AUDIO_TK AUDIO_TK_NONE - -#endif diff --git a/src/game/C4Game.cpp b/src/game/C4Game.cpp index 027051701..c64559be4 100644 --- a/src/game/C4Game.cpp +++ b/src/game/C4Game.cpp @@ -1873,7 +1873,7 @@ bool C4Game::SaveGameTitle(C4Group &hGroup) bool C4Game::DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog, bool fPlrCtrlOnly, int32_t iStrength) { -#ifdef USE_X11 +#ifdef USE_GTK static std::map PressedKeys; // Keyrepeats are send as down, down, ..., down, up, where all downs are not distinguishable from the first. if (eEventType == KEYEV_Down) diff --git a/src/graphics/C4DrawGL.h b/src/graphics/C4DrawGL.h index 9d5ab9cf3..97499c4b3 100644 --- a/src/graphics/C4DrawGL.h +++ b/src/graphics/C4DrawGL.h @@ -132,7 +132,7 @@ protected: HWND hWindow; // used if pWindow==NULL HDC hDC; // device context handle static bool InitGlew(HINSTANCE hInst); -#elif defined(USE_X11) +#elif defined(USE_GTK) /*GLXContext*/void * ctx; #endif diff --git a/src/graphics/C4DrawGLCtx.cpp b/src/graphics/C4DrawGLCtx.cpp index 81839e480..4e089ca2e 100644 --- a/src/graphics/C4DrawGLCtx.cpp +++ b/src/graphics/C4DrawGLCtx.cpp @@ -439,7 +439,7 @@ bool CStdGLCtx::PageFlip() return true; } -#elif defined(USE_X11) +#elif defined(USE_GTK) #include #include #include @@ -654,6 +654,6 @@ bool CStdGLCtx::PageFlip() return true; } -#endif //USE_X11/USE_SDL_MAINLOOP +#endif //USE_GTK/USE_SDL_MAINLOOP #endif // USE_CONSOLE diff --git a/src/gui/C4KeyboardInput.cpp b/src/gui/C4KeyboardInput.cpp index 7e100e774..7cc5e9537 100644 --- a/src/gui/C4KeyboardInput.cpp +++ b/src/gui/C4KeyboardInput.cpp @@ -22,11 +22,13 @@ #include #include -#ifdef USE_X11 -#include +#ifdef USE_GTK #include +#ifdef GDK_WINDOWING_X11 +#include #include #endif +#endif #include @@ -100,7 +102,7 @@ struct C4KeyCodeMapEntry const char *szShortName; }; -#if defined(USE_WIN32_WINDOWS) || defined(USE_X11) +#if defined(USE_WIN32_WINDOWS) || defined(USE_GTK) const C4KeyCodeMapEntry KeyCodeMap[] = { {K_ESCAPE, "Escape", "Esc"}, {K_1, "1", NULL}, @@ -329,7 +331,7 @@ C4KeyCode C4KeyCodeEx::String2KeyCode(const StdStrBuf &sName) } } -#if defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(USE_X11) +#if defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(USE_GTK) // query map const C4KeyCodeMapEntry *pCheck = KeyCodeMap; while (pCheck->szName) { @@ -448,7 +450,7 @@ StdStrBuf C4KeyCodeEx::KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool if (wCode == pCheck->wCode) return StdStrBuf((pCheck->szShortName && fShort) ? pCheck->szShortName : pCheck->szName); else ++pCheck; // not found: Compose as direct code return FormatString("\\x%x", static_cast(wCode)); -#elif defined(USE_X11) +#elif defined(USE_GTK) Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); KeySym keysym = (KeySym)XkbKeycodeToKeysym(dpy,wCode+8,0,0); char* name = NULL; diff --git a/src/platform/C4App.h b/src/platform/C4App.h index 318f3506e..7fc8b0012 100644 --- a/src/platform/C4App.h +++ b/src/platform/C4App.h @@ -27,7 +27,7 @@ #include #endif -#if defined(USE_X11) +#if defined(USE_GTK) // from X.h: //#define ShiftMask (1<<0) //#define ControlMask (1<<2) @@ -148,7 +148,7 @@ public: pthread_t MainThread; #endif -#if defined(USE_X11) +#if defined(USE_GTK) protected: class C4X11AppImpl * Priv; diff --git a/src/platform/C4AppGTK.cpp b/src/platform/C4AppGTK.cpp index e94b40892..7daafbd85 100644 --- a/src/platform/C4AppGTK.cpp +++ b/src/platform/C4AppGTK.cpp @@ -28,7 +28,7 @@ #include #include -#ifdef USE_X11 +#ifdef GDK_WINDOWING_X11 #include #include #include diff --git a/src/platform/C4Window.h b/src/platform/C4Window.h index 23e141c60..0c787b7b8 100644 --- a/src/platform/C4Window.h +++ b/src/platform/C4Window.h @@ -21,7 +21,7 @@ #include -#if defined(USE_WIN32_WINDOWS) || defined(USE_X11) || defined(USE_CONSOLE) +#if defined(USE_WIN32_WINDOWS) || defined(USE_GTK) || defined(USE_CONSOLE) #define K_ESCAPE 1 #define K_1 2 #define K_2 3 @@ -274,10 +274,8 @@ extern C4KeyCode K_X; extern C4KeyCode K_A; #endif -#ifdef USE_X11 -// Forward declarations because xlib.h is evil -typedef union _XEvent XEvent; -typedef struct _XDisplay Display; +#ifdef USE_GTK +// Forward declaration because xlib.h is evil typedef struct __GLXFBConfigRec *GLXFBConfig; #endif @@ -334,14 +332,12 @@ public: HWND hWindow; HWND hRenderWindow; virtual bool Win32DialogMessageHandling(MSG * msg) { return false; }; -#elif defined(WITH_GLIB) +#elif defined(USE_GTK) public: /*GtkWidget*/void * window; // Set by Init to the widget which is used as a // render target, which can be the whole window. /*GtkWidget*/void * render_widget; -#endif -#ifdef USE_X11 protected: bool FindFBConfig(int samples, GLXFBConfig *info); diff --git a/src/platform/C4WindowGTK.cpp b/src/platform/C4WindowGTK.cpp index 14561bdbc..08aa25d06 100644 --- a/src/platform/C4WindowGTK.cpp +++ b/src/platform/C4WindowGTK.cpp @@ -39,7 +39,7 @@ #include #include -#ifdef USE_X11 +#ifdef GDK_WINDOWING_X11 #include #include #include diff --git a/src/platform/PlatformAbstraction.cpp b/src/platform/PlatformAbstraction.cpp index 48ca969ba..56a8688de 100644 --- a/src/platform/PlatformAbstraction.cpp +++ b/src/platform/PlatformAbstraction.cpp @@ -60,7 +60,7 @@ bool EraseItemSafe(const char *szFilename) return false; } -#if !defined(USE_X11) +#if !defined(USE_GTK) bool OpenURL(char const*) {return 0;} #endif diff --git a/src/platform/PlatformAbstraction.h b/src/platform/PlatformAbstraction.h index 3785d6985..692734213 100644 --- a/src/platform/PlatformAbstraction.h +++ b/src/platform/PlatformAbstraction.h @@ -48,10 +48,6 @@ #endif #endif -#if defined(_WIN32) && !defined(USE_CONSOLE) && !defined(USE_SDL_MAINLOOP) && !defined(USE_X11) && !defined(USE_COCOA) -#define USE_WIN32_WINDOWS -#endif - #ifdef _MSC_VER #define DEPRECATED __declspec(deprecated) #elif defined(__GNUC__)