From c92524c85e1492dc21e27a20a20dd4ac40c86e7d Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 22 Apr 2024 06:25:45 +0800 Subject: [PATCH] Allow non-Cocoa code in sources --- CMakeLists.txt | 4 ++++ rtgui/rtwindow.cc | 6 +++--- rtgui/rtwindow.h | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git CMakeLists.txt CMakeLists.txt index eecffe531..0934622b6 100644 --- CMakeLists.txt +++ CMakeLists.txt @@ -83,6 +83,10 @@ if(APPLE) option(MACOS_NATIVE "Use macOS Cocoa backend" ON) endif() +if(APPLE AND NOT MACOS_NATIVE) + add_definitions(-DNO_COCOA) +endif() + # For macOS only, OSX_DEV_BUILD option allows using relative paths instead of absolute # paths. Consequently, for development builds, application can be launching without # being bundled. However, file access can be restricted for some folder. diff --git rtgui/rtwindow.cc rtgui/rtwindow.cc index 2165162b3..d2a481b9c 100755 --- rtgui/windows/rtwindow.cc +++ rtgui/windows/rtwindow.cc @@ -36,7 +36,7 @@ Glib::RefPtr cssForced; Glib::RefPtr cssRT; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) static gboolean osx_should_quit_cb(GtkosxApplication *app, gpointer data) { @@ -154,7 +154,7 @@ , iFullscreen_exit (nullptr) , epanel (nullptr) , fpanel (nullptr) -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) , osxApp (nullptr) #endif { @@ -257,7 +257,7 @@ } #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) { osxApp = static_cast( g_object_new(GTKOSX_TYPE_APPLICATION, nullptr) @@ -468,7 +468,7 @@ } } } -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) gtkosx_application_ready(osxApp); #endif } @@ -480,7 +480,7 @@ } pldBridge = nullptr; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) g_object_unref (osxApp); #endif diff --git rtgui/rtwindow.h rtgui/rtwindow.h index 4c3aa75ea..22470fd00 100755 --- rtgui/windows/rtwindow.h +++ rtgui/windows/rtwindow.h @@ -22,7 +22,7 @@ #include #include -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) #include #endif @@ -72,7 +72,7 @@ private: void showErrors (); Glib::ustring versionStr; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) GtkosxApplication *osxApp; #endif