From f74a7247cd2ebc64c9192dc85777cb04c9c6d2e3 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 2 Jun 2025 18:03:51 +0200 Subject: [PATCH] [client,sdl] fix clang-tidy warnings --- .../SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp | 2 +- .../SDL3/dialogs/sdl_connection_dialog.hpp | 8 +-- .../dialogs/sdl_connection_dialog_wrapper.cpp | 8 +-- .../dialogs/sdl_connection_dialog_wrapper.hpp | 26 +++---- .../dialogs/sdl_input_widget_pair_list.hpp | 2 +- client/SDL/SDL3/dialogs/sdl_select_list.hpp | 2 +- .../SDL3/dialogs/sdl_selectable_widget.hpp | 2 +- client/SDL/SDL3/dialogs/sdl_widget.hpp | 2 +- client/SDL/SDL3/dialogs/sdl_widget_list.hpp | 7 +- client/SDL/SDL3/sdl_freerdp.cpp | 72 +++++++------------ client/SDL/SDL3/sdl_utils.hpp | 2 +- client/SDL/SDL3/sdl_window.hpp | 1 - 12 files changed, 54 insertions(+), 80 deletions(-) diff --git a/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp b/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp index 005ca4b0b..1262133f2 100644 --- a/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp +++ b/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp @@ -42,5 +42,5 @@ class SdlBlendModeGuard private: SDL_BlendMode _restore_mode = SDL_BLENDMODE_INVALID; SDL_BlendMode _current_mode = SDL_BLENDMODE_INVALID; - std::shared_ptr _renderer{}; + std::shared_ptr _renderer; }; diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp index 779490bb6..6021af251 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp @@ -26,10 +26,10 @@ #include -#include "sdl_widget_list.hpp" -#include "sdl_widget.hpp" #include "sdl_buttons.hpp" #include "sdl_connection_dialog_wrapper.hpp" +#include "sdl_widget.hpp" +#include "sdl_widget_list.hpp" class SDLConnectionDialog : public SdlWidgetList { @@ -37,7 +37,7 @@ class SDLConnectionDialog : public SdlWidgetList explicit SDLConnectionDialog(rdpContext* context); SDLConnectionDialog(const SDLConnectionDialog& other) = delete; SDLConnectionDialog(const SDLConnectionDialog&& other) = delete; - virtual ~SDLConnectionDialog() override; + ~SDLConnectionDialog() override; SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete; SDLConnectionDialog& operator=(SDLConnectionDialog&& other) = delete; @@ -91,5 +91,5 @@ class SDLConnectionDialog : public SdlWidgetList SdlConnectionDialogWrapper::MsgType _type_active = SdlConnectionDialogWrapper::MSG_NONE; SDL_TimerID _timer = 0; bool _running = false; - std::vector _list{}; + std::vector _list; }; diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp index 988e5208b..647e34b2b 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp @@ -20,9 +20,9 @@ #include -#include "sdl_connection_dialog_wrapper.hpp" -#include "sdl_connection_dialog.hpp" #include "../sdl_utils.hpp" +#include "sdl_connection_dialog.hpp" +#include "sdl_connection_dialog_wrapper.hpp" SdlConnectionDialogWrapper::SdlConnectionDialogWrapper() = default; @@ -93,7 +93,7 @@ void SdlConnectionDialogWrapper::setTitle(const char* fmt, ...) void SdlConnectionDialogWrapper::setTitle(const std::string& title) { - push({ title }); + push(EventArg{ title }); } void SdlConnectionDialogWrapper::showInfo(const char* fmt, ...) @@ -143,7 +143,7 @@ void SdlConnectionDialogWrapper::show(SdlConnectionDialogWrapper::MsgType type, void SdlConnectionDialogWrapper::show(bool visible) { - push({ visible }); + push(EventArg{ visible }); } void SdlConnectionDialogWrapper::handleShow() diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp index c35f71aa0..231006dba 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp @@ -87,27 +87,27 @@ class SdlConnectionDialogWrapper class EventArg { public: - EventArg(bool visible); - EventArg(const std::string& title); + explicit EventArg(bool visible); + explicit EventArg(const std::string& title); EventArg(SdlConnectionDialogWrapper::MsgType type, const std::string& msg, bool visible); - bool hasTitle() const; - const std::string& title() const; + [[nodiscard]] bool hasTitle() const; + [[nodiscard]] const std::string& title() const; - bool hasMessage() const; - const std::string& message() const; + [[nodiscard]] bool hasMessage() const; + [[nodiscard]] const std::string& message() const; - bool hasType() const; - SdlConnectionDialogWrapper::MsgType type() const; + [[nodiscard]] bool hasType() const; + [[nodiscard]] SdlConnectionDialogWrapper::MsgType type() const; - bool hasVisibility() const; - bool visible() const; + [[nodiscard]] bool hasVisibility() const; + [[nodiscard]] bool visible() const; - std::string str() const; + [[nodiscard]] std::string str() const; private: - std::string _title{}; - std::string _message{}; + std::string _title; + std::string _message; SdlConnectionDialogWrapper::MsgType _type = MSG_NONE; bool _visible = false; uint32_t _mask = 0; diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp b/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp index f2e79ebce..28b597d5e 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp @@ -36,7 +36,7 @@ class SdlInputWidgetPairList : public SdlWidgetList SdlInputWidgetPairList(const SdlInputWidgetPairList& other) = delete; SdlInputWidgetPairList(SdlInputWidgetPairList&& other) = delete; - virtual ~SdlInputWidgetPairList() override; + ~SdlInputWidgetPairList() override; SdlInputWidgetPairList& operator=(const SdlInputWidgetPairList& other) = delete; SdlInputWidgetPairList& operator=(SdlInputWidgetPairList&& other) = delete; diff --git a/client/SDL/SDL3/dialogs/sdl_select_list.hpp b/client/SDL/SDL3/dialogs/sdl_select_list.hpp index b199669fa..d611fd029 100644 --- a/client/SDL/SDL3/dialogs/sdl_select_list.hpp +++ b/client/SDL/SDL3/dialogs/sdl_select_list.hpp @@ -16,7 +16,7 @@ class SdlSelectList : public SdlWidgetList SdlSelectList(const std::string& title, const std::vector& labels); SdlSelectList(const SdlSelectList& other) = delete; SdlSelectList(SdlSelectList&& other) = delete; - virtual ~SdlSelectList() override; + ~SdlSelectList() override; SdlSelectList& operator=(const SdlSelectList& other) = delete; SdlSelectList& operator=(SdlSelectList&& other) = delete; diff --git a/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp b/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp index 56cf65a42..53e6ed8a8 100644 --- a/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp @@ -31,7 +31,7 @@ class SdlSelectableWidget : public SdlWidget #endif SdlSelectableWidget(SdlSelectableWidget&& other) noexcept; SdlSelectableWidget(const SdlSelectableWidget& other) = delete; - virtual ~SdlSelectableWidget() override; + ~SdlSelectableWidget() override; SdlSelectableWidget& operator=(const SdlSelectableWidget& other) = delete; SdlSelectableWidget& operator=(SdlSelectableWidget&& other) = delete; diff --git a/client/SDL/SDL3/dialogs/sdl_widget.hpp b/client/SDL/SDL3/dialogs/sdl_widget.hpp index 117aac0b9..38305d44f 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_widget.hpp @@ -74,7 +74,7 @@ class SdlWidget const char* fkt); protected: - std::shared_ptr _renderer{}; + std::shared_ptr _renderer; SDL_Color _backgroundcolor = { 0x56, 0x56, 0x56, 0xff }; SDL_Color _fontcolor = { 0xd1, 0xcf, 0xcd, 0xff }; mutable std::string _text; diff --git a/client/SDL/SDL3/dialogs/sdl_widget_list.hpp b/client/SDL/SDL3/dialogs/sdl_widget_list.hpp index 0a6a6f5e9..768f331c7 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget_list.hpp +++ b/client/SDL/SDL3/dialogs/sdl_widget_list.hpp @@ -20,16 +20,15 @@ class SdlWidgetList virtual bool reset(const std::string& title, size_t width, size_t height); - virtual bool visible() const; + [[nodiscard]] virtual bool visible() const; protected: bool update(); virtual bool clearWindow(); virtual bool updateInternal() = 0; - protected: - std::shared_ptr _window{}; - std::shared_ptr _renderer{}; + std::shared_ptr _window; + std::shared_ptr _renderer; SdlButtonList _buttons; SDL_Color _backgroundcolor{ 0x38, 0x36, 0x35, 0xff }; }; diff --git a/client/SDL/SDL3/sdl_freerdp.cpp b/client/SDL/SDL3/sdl_freerdp.cpp index 80ebaf8ef..4c702d0a6 100644 --- a/client/SDL/SDL3/sdl_freerdp.cpp +++ b/client/SDL/SDL3/sdl_freerdp.cpp @@ -17,9 +17,9 @@ * limitations under the License. */ +#include #include #include -#include #include @@ -27,44 +27,44 @@ #include #include -#include #include +#include #include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #if !defined(__MINGW32__) #include #endif #include -#include #include +#include +#include "dialogs/sdl_connection_dialog_hider.hpp" +#include "dialogs/sdl_dialogs.hpp" +#include "scoped_guard.hpp" #include "sdl_channels.hpp" -#include "sdl_freerdp.hpp" -#include "sdl_utils.hpp" #include "sdl_disp.hpp" -#include "sdl_monitor.hpp" +#include "sdl_freerdp.hpp" #include "sdl_kbd.hpp" -#include "sdl_touch.hpp" +#include "sdl_monitor.hpp" #include "sdl_pointer.hpp" #include "sdl_prefs.hpp" -#include "dialogs/sdl_dialogs.hpp" -#include "dialogs/sdl_connection_dialog_hider.hpp" -#include "scoped_guard.hpp" +#include "sdl_touch.hpp" +#include "sdl_utils.hpp" #include @@ -314,31 +314,6 @@ static bool sdl_draw_to_window_rect(SdlContext* sdl, SdlWindow& window, SDL_Surf return true; } -static bool sdl_draw_to_window_scaled_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface, - const SDL_Rect& srcRect) -{ - SDL_Rect dstRect = srcRect; - sdl_scale_coordinates(sdl, window.id(), &dstRect.x, &dstRect.y, FALSE, TRUE); - sdl_scale_coordinates(sdl, window.id(), &dstRect.w, &dstRect.h, FALSE, TRUE); - return window.blit(surface, srcRect, dstRect); -} - -static BOOL sdl_draw_to_window_scaled_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface, - const std::vector& rects = {}) -{ - if (rects.empty()) - { - return sdl_draw_to_window_scaled_rect(sdl, window, surface, - { 0, 0, surface->w, surface->h }); - } - for (const auto& srcRect : rects) - { - if (!sdl_draw_to_window_scaled_rect(sdl, window, surface, srcRect)) - return FALSE; - } - return TRUE; -} - static BOOL sdl_draw_to_window(SdlContext* sdl, SdlWindow& window, const std::vector& rects = {}) { @@ -636,7 +611,8 @@ static BOOL sdl_create_windows(SdlContext* sdl) UINT32 windowCount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); - Sint32 originX = 0, originY = 0; + Sint32 originX = 0; + Sint32 originY = 0; for (UINT32 x = 0; x < windowCount; x++) { auto id = sdl->monitorId(x); @@ -781,8 +757,8 @@ static int sdl_run(SdlContext* sdl) SDL_Event windowEvent = {}; while (!shall_abort(sdl) && SDL_WaitEventTimeout(nullptr, 1000)) { - /* Only poll standard SDL events and SDL_EVENT_USERS meant to create dialogs. - * do not process the dialog return value events here. + /* Only poll standard SDL events and SDL_EVENT_USERS meant to create + * dialogs. do not process the dialog return value events here. */ const int prc = SDL_PeepEvents(&windowEvent, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_USER_RETRY_DIALOG); @@ -798,8 +774,8 @@ static int sdl_run(SdlContext* sdl) #endif { std::lock_guard lock(sdl->critical); - /* The session might have been disconnected while we were waiting for a new SDL - * event. In that case ignore the SDL event and terminate. */ + /* The session might have been disconnected while we were waiting for a + * new SDL event. In that case ignore the SDL event and terminate. */ if (freerdp_shall_disconnect_context(sdl->context())) continue; } diff --git a/client/SDL/SDL3/sdl_utils.hpp b/client/SDL/SDL3/sdl_utils.hpp index 240a41fc7..1157b1467 100644 --- a/client/SDL/SDL3/sdl_utils.hpp +++ b/client/SDL/SDL3/sdl_utils.hpp @@ -86,4 +86,4 @@ namespace sdl::utils UINT32 orientaion_to_rdp(SDL_DisplayOrientation orientation); std::string generate_uuid_v4(); -} +} // namespace sdl::utils diff --git a/client/SDL/SDL3/sdl_window.hpp b/client/SDL/SDL3/sdl_window.hpp index b7154f1b7..d53255f43 100644 --- a/client/SDL/SDL3/sdl_window.hpp +++ b/client/SDL/SDL3/sdl_window.hpp @@ -64,7 +64,6 @@ class SdlWindow private: static UINT32 orientaion_to_rdp(SDL_DisplayOrientation orientation); - private: SDL_Window* _window = nullptr; Sint32 _offset_x = 0; Sint32 _offset_y = 0;