diff --git a/client/SDL/SDL3/dialogs/CMakeLists.txt b/client/SDL/SDL3/dialogs/CMakeLists.txt index 078c47249..f3638e28c 100644 --- a/client/SDL/SDL3/dialogs/CMakeLists.txt +++ b/client/SDL/SDL3/dialogs/CMakeLists.txt @@ -68,6 +68,7 @@ add_subdirectory(res) add_library(sdl3-dialogs STATIC ${SRCS}) +set_property(TARGET sdl3-dialogs PROPERTY FOLDER "Client/SDL") target_link_libraries(sdl3-dialogs PRIVATE ${LIBS}) if(BUILD_TESTING) diff --git a/client/SDL/SDL3/dialogs/res/CMakeLists.txt b/client/SDL/SDL3/dialogs/res/CMakeLists.txt index 37dc3668c..370ee1eac 100644 --- a/client/SDL/SDL3/dialogs/res/CMakeLists.txt +++ b/client/SDL/SDL3/dialogs/res/CMakeLists.txt @@ -18,6 +18,8 @@ set(SRCS sdl3_resource_manager.cpp sdl3_resource_manager.hpp) add_library(sdl3_client_res STATIC ${SRCS}) +set_property(TARGET sdl3_client_res PROPERTY FOLDER "Client/SDL") + if(NOT WITH_SDL_LINK_SHARED) target_link_libraries(sdl3_client_res ${SDL3_STATIC_LIBRARIES}) else() diff --git a/client/SDL/SDL3/sdl_freerdp.cpp b/client/SDL/SDL3/sdl_freerdp.cpp index a39b58412..26658b28f 100644 --- a/client/SDL/SDL3/sdl_freerdp.cpp +++ b/client/SDL/SDL3/sdl_freerdp.cpp @@ -278,7 +278,7 @@ static int error_info_to_error(freerdp* instance, DWORD* pcode, char** msg, size winpr_asprintf(msg, len, "Terminate with %s due to ERROR_INFO %s [0x%08" PRIx32 "]: %s", sdl_map_error_to_code_tag(code), name, code, str); - WLog_DBG(SDL_TAG, "%s", *msg); + SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "%s", *msg); if (pcode) *pcode = code; return exit_code; @@ -293,17 +293,6 @@ static BOOL sdl_begin_paint(rdpContext* context) WINPR_ASSERT(sdl); - HANDLE handles[] = { sdl->update_complete.handle(), freerdp_abort_event(context) }; - const DWORD status = WaitForMultipleObjects(ARRAYSIZE(handles), handles, FALSE, INFINITE); - switch (status) - { - case WAIT_OBJECT_0: - break; - default: - return FALSE; - } - sdl->update_complete.clear(); - gdi = context->gdi; WINPR_ASSERT(gdi); WINPR_ASSERT(gdi->primary); @@ -316,25 +305,6 @@ static BOOL sdl_begin_paint(rdpContext* context) return TRUE; } -class SdlEventUpdateTriggerGuard -{ - private: - SdlContext* _sdl; - - public: - explicit SdlEventUpdateTriggerGuard(SdlContext* sdl) : _sdl(sdl) - { - } - ~SdlEventUpdateTriggerGuard() - { - _sdl->update_complete.set(); - } - SdlEventUpdateTriggerGuard(const SdlEventUpdateTriggerGuard&) = delete; - SdlEventUpdateTriggerGuard(SdlEventUpdateTriggerGuard&&) = delete; - SdlEventUpdateTriggerGuard& operator=(const SdlEventUpdateTriggerGuard&) = delete; - SdlEventUpdateTriggerGuard& operator=(SdlEventUpdateTriggerGuard&&) = delete; -}; - static bool sdl_draw_to_window_rect([[maybe_unused]] SdlContext* sdl, SdlWindow& window, SDL_Surface* surface, SDL_Point offset, const SDL_Rect& srcRect) { @@ -432,16 +402,16 @@ static BOOL sdl_draw_to_window(SdlContext* sdl, std::map& win return TRUE; } -static BOOL sdl_end_paint_process(rdpContext* context) +/* This function is called when the library completed composing a new + * frame. Read out the changed areas and blit them to your output device. + * The image buffer will have the format specified by gdi_init + */ +static BOOL sdl_end_paint(rdpContext* context) { - rdpGdi* gdi = nullptr; auto sdl = get_context(context); + WINPR_ASSERT(sdl); - WINPR_ASSERT(context); - - SdlEventUpdateTriggerGuard guard(sdl); - - gdi = context->gdi; + auto gdi = context->gdi; WINPR_ASSERT(gdi); WINPR_ASSERT(gdi->primary); WINPR_ASSERT(gdi->primary->hdc); @@ -463,22 +433,8 @@ static BOOL sdl_end_paint_process(rdpContext* context) rects.push_back({ rgn.x, rgn.y, rgn.w, rgn.h }); } - return sdl_draw_to_window(sdl, sdl->windows, rects); -} - -/* This function is called when the library completed composing a new - * frame. Read out the changed areas and blit them to your output device. - * The image buffer will have the format specified by gdi_init - */ -static BOOL sdl_end_paint(rdpContext* context) -{ - auto sdl = get_context(context); - WINPR_ASSERT(sdl); - - std::lock_guard lock(sdl->critical); - const BOOL rc = sdl_push_user_event(SDL_EVENT_USER_UPDATE, context); - - return rc; + sdl->_queue.push(rects); + return sdl_push_user_event(SDL_EVENT_USER_UPDATE); } static void sdl_destroy_primary(SdlContext* sdl) @@ -965,8 +921,12 @@ static int sdl_run(SdlContext* sdl) break; case SDL_EVENT_USER_UPDATE: { - auto context = static_cast(windowEvent.user.data1); - sdl_end_paint_process(context); + while (!sdl->_queue.empty()) + { + auto rectangles = sdl->_queue.front(); + sdl_draw_to_window(sdl, sdl->windows, rectangles); + sdl->_queue.pop(); + } } break; case SDL_EVENT_USER_CREATE_WINDOWS: @@ -1748,7 +1708,6 @@ int main(int argc, char* argv[]) bool SdlContext::update_fullscreen(bool enter) { - std::lock_guard lock(critical); for (const auto& window : windows) { if (!sdl_push_user_event(SDL_EVENT_USER_WINDOW_FULLSCREEN, &window.second, enter)) @@ -1760,14 +1719,11 @@ bool SdlContext::update_fullscreen(bool enter) bool SdlContext::update_minimize() { - std::lock_guard lock(critical); return sdl_push_user_event(SDL_EVENT_USER_WINDOW_MINIMIZE); } bool SdlContext::update_resizeable(bool enable) { - std::lock_guard lock(critical); - const auto settings = context()->settings; const bool dyn = freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate); const bool smart = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing); @@ -1784,8 +1740,8 @@ bool SdlContext::update_resizeable(bool enable) } SdlContext::SdlContext(rdpContext* context) - : _context(context), log(WLog_Get(SDL_TAG)), update_complete(true), disp(this), input(this), - clip(this), primary(nullptr, SDL_DestroySurface), rdp_thread_running(false) + : _context(context), log(WLog_Get(SDL_TAG)), disp(this), input(this), clip(this), + primary(nullptr, SDL_DestroySurface), rdp_thread_running(false) { WINPR_ASSERT(context); } diff --git a/client/SDL/SDL3/sdl_freerdp.hpp b/client/SDL/SDL3/sdl_freerdp.hpp index 5afd71fd1..5bec3b157 100644 --- a/client/SDL/SDL3/sdl_freerdp.hpp +++ b/client/SDL/SDL3/sdl_freerdp.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -85,7 +86,6 @@ class SdlContext std::thread thread; WinPREvent initialize; WinPREvent initialized; - WinPREvent update_complete; WinPREvent windows_created; int exit_code = -1; @@ -100,4 +100,6 @@ class SdlContext std::unique_ptr connection_dialog; std::atomic rdp_thread_running; + + std::queue> _queue; }; diff --git a/client/SDL/common/CMakeLists.txt b/client/SDL/common/CMakeLists.txt index b750db711..e579ecf75 100644 --- a/client/SDL/common/CMakeLists.txt +++ b/client/SDL/common/CMakeLists.txt @@ -23,6 +23,7 @@ add_library( sdl-common-prefs STATIC sdl_prefs.hpp sdl_prefs.cpp scoped_guard.hpp sdl_common_utils.hpp sdl_common_utils.cpp ) target_link_libraries(sdl-common-prefs winpr freerdp) +set_property(TARGET sdl-common-prefs PROPERTY FOLDER "Client/Common") if(BUILD_TESTING_INTERNAL OR BUILD_TESTING) add_subdirectory(test) diff --git a/client/SDL/common/aad/CMakeLists.txt b/client/SDL/common/aad/CMakeLists.txt index 85d9dbcf6..1811a692e 100644 --- a/client/SDL/common/aad/CMakeLists.txt +++ b/client/SDL/common/aad/CMakeLists.txt @@ -54,6 +54,8 @@ cleaning_configure_file(sdl_config.hpp.in sdl_config.hpp @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_library(sdl-common-aad-view STATIC ${SRCS}) +set_property(TARGET sdl-common-aad-view PROPERTY FOLDER "Client/Common") + target_include_directories(sdl-common-aad-view PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(sdl-common-aad-view PRIVATE ${LIBS}) target_compile_definitions(sdl-common-aad-view PUBLIC ${DEFINITIONS}) diff --git a/client/SDL/common/res/CMakeLists.txt b/client/SDL/common/res/CMakeLists.txt index a67289402..0be4804bf 100644 --- a/client/SDL/common/res/CMakeLists.txt +++ b/client/SDL/common/res/CMakeLists.txt @@ -105,3 +105,4 @@ endif() add_library(sdl-common-client-res STATIC ${RES_FILES} ${SRCS} ${FACTORY_HDR} ${FACTORY_SRCS}) set_property(TARGET sdl-common-client-res PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET sdl-common-client-res PROPERTY FOLDER "Client/Common") diff --git a/client/X11/cli/CMakeLists.txt b/client/X11/cli/CMakeLists.txt index 38e3eb8fe..2aaa2055a 100644 --- a/client/X11/cli/CMakeLists.txt +++ b/client/X11/cli/CMakeLists.txt @@ -19,6 +19,7 @@ set(SRCS xfreerdp.c) addtargetwithresourcefile(${MODULE_NAME} TRUE "${PROJECT_VERSION}" SRCS) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "..") +set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Client/X11") list(APPEND LIBS xfreerdp-client)