diff --git a/cmake/compile_definitions/common.cmake b/cmake/compile_definitions/common.cmake index 47f32acf20b..94f1ac598cc 100644 --- a/cmake/compile_definitions/common.cmake +++ b/cmake/compile_definitions/common.cmake @@ -49,6 +49,8 @@ set(SUNSHINE_TARGET_FILES "${CMAKE_SOURCE_DIR}/src/entry_handler.h" "${CMAKE_SOURCE_DIR}/src/file_handler.cpp" "${CMAKE_SOURCE_DIR}/src/file_handler.h" + "${CMAKE_SOURCE_DIR}/src/globals.cpp" + "${CMAKE_SOURCE_DIR}/src/globals.h" "${CMAKE_SOURCE_DIR}/src/logging.cpp" "${CMAKE_SOURCE_DIR}/src/logging.h" "${CMAKE_SOURCE_DIR}/src/main.cpp" diff --git a/src/entry_handler.h b/src/entry_handler.h index ba7dff9ba49..99d071e9185 100644 --- a/src/entry_handler.h +++ b/src/entry_handler.h @@ -12,9 +12,6 @@ #include "thread_pool.h" #include "thread_safe.h" -extern thread_pool_util::ThreadPool task_pool; -extern bool display_cursor; - // functions void launch_ui(); diff --git a/src/globals.cpp b/src/globals.cpp new file mode 100644 index 00000000000..e753b4c0cf2 --- /dev/null +++ b/src/globals.cpp @@ -0,0 +1,9 @@ +/** + * @file globals.cpp + * @brief Implementation for globally accessible variables and functions. + */ +#include "globals.h" + +safe::mail_t mail::man; +thread_pool_util::ThreadPool task_pool; +bool display_cursor = true; diff --git a/src/globals.h b/src/globals.h new file mode 100644 index 00000000000..3078e19dad5 --- /dev/null +++ b/src/globals.h @@ -0,0 +1,12 @@ +/** + * @file globals.h + * @brief Header for globally accessible variables and functions. + */ +#pragma once + +#include "entry_handler.h" +#include "thread_pool.h" + +extern safe::mail_t mail::man; +extern thread_pool_util::ThreadPool task_pool; +extern bool display_cursor; diff --git a/src/input.cpp b/src/input.cpp index c48b86842da..f47a2f20a67 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -18,6 +18,7 @@ extern "C" { #include "config.h" #include "entry_handler.h" +#include "globals.h" #include "input.h" #include "logging.h" #include "platform/common.h" diff --git a/src/main.cpp b/src/main.cpp index 62524998727..66dda6cf105 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,7 @@ // local includes #include "confighttp.h" #include "entry_handler.h" +#include "globals.h" #include "httpcommon.h" #include "logging.h" #include "main.h" @@ -38,15 +39,9 @@ extern "C" { #include } -safe::mail_t mail::man; - using namespace std::literals; namespace bl = boost::log; -thread_pool_util::ThreadPool task_pool; - -bool display_cursor = true; - struct NoDelete { void operator()(void *) {} diff --git a/src/platform/linux/x11grab.cpp b/src/platform/linux/x11grab.cpp index aff3df3183e..86625a58d70 100644 --- a/src/platform/linux/x11grab.cpp +++ b/src/platform/linux/x11grab.cpp @@ -18,6 +18,7 @@ #include "src/config.h" #include "src/entry_handler.h" +#include "src/globals.h" #include "src/logging.h" #include "src/task_pool.h" #include "src/thread_pool.h" diff --git a/src/platform/windows/input.cpp b/src/platform/windows/input.cpp index b9484a4fafc..75199164f58 100644 --- a/src/platform/windows/input.cpp +++ b/src/platform/windows/input.cpp @@ -13,6 +13,7 @@ #include "misc.h" #include "src/config.h" #include "src/entry_handler.h" +#include "src/globals.h" #include "src/logging.h" #include "src/platform/common.h" #include "src/task_pool.h" diff --git a/src/stream.cpp b/src/stream.cpp index 0cabc750e76..513ca3f7923 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -19,6 +19,7 @@ extern "C" { #include "config.h" #include "entry_handler.h" +#include "globals.h" #include "input.h" #include "logging.h" #include "network.h" diff --git a/src/video.cpp b/src/video.cpp index 07b2eaa39cb..3f0d920ddb0 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -20,6 +20,7 @@ extern "C" { #include "cbs.h" #include "config.h" #include "entry_handler.h" +#include "globals.h" #include "input.h" #include "logging.h" #include "nvenc/nvenc_base.h"