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/rtwindow.cc +++ rtgui/rtwindow.cc @@ -40,7 +40,7 @@ Glib::RefPtr cssRT; extern unsigned char initialGdkScale; -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) static gboolean osx_should_quit_cb (GtkosxApplication *app, gpointer data) { @@ -258,7 +258,7 @@ RTWindow::RTWindow () } #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && !defined(NO_COCOA) { osxApp = (GtkosxApplication *)g_object_new (GTKOSX_TYPE_APPLICATION, NULL); RTWindow *rtWin = this; @@ -448,7 +448,7 @@ RTWindow::~RTWindow() } 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/rtwindow.h +++ rtgui/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