diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/SDL/dialogs/sdl_connection_dialog.hpp | 14 | ||||
-rw-r--r-- | client/SDL/sdl_disp.cpp | 5 | ||||
-rw-r--r-- | client/SDL/sdl_kbd.cpp | 65 | ||||
-rw-r--r-- | client/SDL/sdl_kbd.hpp | 13 | ||||
-rw-r--r-- | client/Wayland/wlf_cliprdr.c | 13 | ||||
-rw-r--r-- | client/common/cmdline.c | 2 |
6 files changed, 99 insertions, 13 deletions
diff --git a/client/SDL/dialogs/sdl_connection_dialog.hpp b/client/SDL/dialogs/sdl_connection_dialog.hpp index f21f538..57e5596 100644 --- a/client/SDL/dialogs/sdl_connection_dialog.hpp +++ b/client/SDL/dialogs/sdl_connection_dialog.hpp @@ -89,15 +89,15 @@ class SDLConnectionDialog private: struct widget_cfg_t { - SDL_Color fgcolor; - SDL_Color bgcolor; + SDL_Color fgcolor = {}; + SDL_Color bgcolor = {}; SdlWidget widget; }; private: - rdpContext* _context; - SDL_Window* _window; - SDL_Renderer* _renderer; + rdpContext* _context = nullptr; + SDL_Window* _window = nullptr; + SDL_Renderer* _renderer = nullptr; mutable std::mutex _mux; std::string _title; std::string _msg; @@ -124,6 +124,6 @@ class SDLConnectionDialogHider SDLConnectionDialog* get(rdpContext* context); private: - SDLConnectionDialog* _dialog; - bool _visible; + SDLConnectionDialog* _dialog = nullptr; + bool _visible = false; }; diff --git a/client/SDL/sdl_disp.cpp b/client/SDL/sdl_disp.cpp index ffd13c8..34863ba 100644 --- a/client/SDL/sdl_disp.cpp +++ b/client/SDL/sdl_disp.cpp @@ -142,6 +142,8 @@ static BOOL sdl_disp_check_context(void* context, SdlContext** ppsdl, sdlDispCon return FALSE; auto sdl = get_context(context); + if (!sdl) + return FALSE; if (!sdl->context()->settings) return FALSE; @@ -200,6 +202,9 @@ Uint32 sdlDispContext::OnTimer(Uint32 interval, void* param) return 0; SdlContext* sdl = ctx->_sdl; + if (!sdl) + return 0; + sdlDispContext* sdlDisp = nullptr; rdpSettings* settings = nullptr; diff --git a/client/SDL/sdl_kbd.cpp b/client/SDL/sdl_kbd.cpp index 984614e..c6e668d 100644 --- a/client/SDL/sdl_kbd.cpp +++ b/client/SDL/sdl_kbd.cpp @@ -488,6 +488,66 @@ uint32_t sdlInput::prefKeyValue(const std::string& key, uint32_t fallback) return val; } +std::list<std::string> sdlInput::tokenize(const std::string& data, const std::string& delimiter) +{ + size_t lastpos = 0; + size_t pos = 0; + std::list<std::string> list; + while ((pos = data.find(delimiter, lastpos)) != std::string::npos) + { + auto token = data.substr(lastpos, pos); + lastpos = pos + 1; + list.push_back(token); + } + auto token = data.substr(lastpos); + list.push_back(token); + return list; +} + +bool sdlInput::extract(const std::string& token, uint32_t& key, uint32_t& value) +{ + int rc = sscanf(token.c_str(), "%" PRIu32 "=%" PRIu32, &key, &value); + if (rc != 2) + rc = sscanf(token.c_str(), "%" PRIx32 "=%" PRIx32 "", &key, &value); + if (rc != 2) + rc = sscanf(token.c_str(), "%" PRIu32 "=%" PRIx32, &key, &value); + if (rc != 2) + rc = sscanf(token.c_str(), "%" PRIx32 "=%" PRIu32, &key, &value); + return (rc == 2); +} + +uint32_t sdlInput::remapScancode(uint32_t scancode) +{ + if (!_remapInitialized.exchange(true)) + remapInitialize(); + auto it = _remapList.find(scancode); + if (it != _remapList.end()) + return it->second; + return scancode; +} + +void sdlInput::remapInitialize() +{ + WINPR_ASSERT(_sdl); + + auto context = _sdl->context(); + WINPR_ASSERT(context); + auto KeyboardRemappingList = + freerdp_settings_get_string(context->settings, FreeRDP_KeyboardRemappingList); + if (!KeyboardRemappingList) + return; + + auto list = tokenize(KeyboardRemappingList); + for (auto& token : list) + { + uint32_t key = 0; + uint32_t value = 0; + if (!extract(token, key, value)) + continue; + _remapList.emplace(key, value); + } +} + BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev) { WINPR_ASSERT(ev); @@ -526,8 +586,10 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev) } } } + + auto scancode = remapScancode(rdp_scancode); return freerdp_input_send_keyboard_event_ex(_sdl->context()->input, ev->type == SDL_KEYDOWN, - ev->repeat, rdp_scancode); + ev->repeat, scancode); } BOOL sdlInput::keyboard_grab(Uint32 windowID, SDL_bool enable) @@ -564,5 +626,4 @@ BOOL sdlInput::mouse_grab(Uint32 windowID, SDL_bool enable) sdlInput::sdlInput(SdlContext* sdl) : _sdl(sdl), _lastWindowID(UINT32_MAX) { - WINPR_ASSERT(_sdl); } diff --git a/client/SDL/sdl_kbd.hpp b/client/SDL/sdl_kbd.hpp index 2a6c7fa..c75da4d 100644 --- a/client/SDL/sdl_kbd.hpp +++ b/client/SDL/sdl_kbd.hpp @@ -20,6 +20,9 @@ #pragma once #include <string> +#include <map> +#include <list> +#include <atomic> #include <winpr/wtypes.h> #include <freerdp/freerdp.h> @@ -51,6 +54,16 @@ class sdlInput static uint32_t prefKeyValue(const std::string& key, uint32_t fallback = SDL_SCANCODE_UNKNOWN); private: + static std::list<std::string> tokenize(const std::string& data, + const std::string& delimiter = ","); + static bool extract(const std::string& token, uint32_t& key, uint32_t& value); + + uint32_t remapScancode(uint32_t scancode); + void remapInitialize(); + + private: SdlContext* _sdl; Uint32 _lastWindowID; + std::map<uint32_t, uint32_t> _remapList; + std::atomic<bool> _remapInitialized = false; }; diff --git a/client/Wayland/wlf_cliprdr.c b/client/Wayland/wlf_cliprdr.c index f0c3318..112ffd1 100644 --- a/client/Wayland/wlf_cliprdr.c +++ b/client/Wayland/wlf_cliprdr.c @@ -70,6 +70,13 @@ typedef struct char* responseMime; } wlf_request; +typedef struct +{ + const FILE* responseFile; + UINT32 responseFormat; + const char* responseMime; +} wlf_const_request; + struct wlf_clipboard { wlfContext* wfc; @@ -311,7 +318,7 @@ static BOOL wlf_cliprdr_add_client_format(wfClipboard* clipboard, const char* mi * * @return 0 on success, otherwise a Win32 error code */ -static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, const wlf_request* rq) +static UINT wlf_cliprdr_send_data_request(wfClipboard* clipboard, const wlf_const_request* rq) { WINPR_ASSERT(rq); @@ -522,7 +529,7 @@ static void wlf_cliprdr_transfer_data(UwacSeat* seat, void* context, const char* EnterCriticalSection(&clipboard->lock); - wlf_request request = { 0 }; + wlf_const_request request = { 0 }; if (wlf_mime_is_html(mime)) { request.responseMime = mime_html; @@ -720,7 +727,7 @@ wlf_cliprdr_server_format_data_request(CliprdrClientContext* context, const CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest) { UINT rc = CHANNEL_RC_OK; - BYTE* data = NULL; + char* data = NULL; size_t size = 0; const char* mime = NULL; UINT32 formatId = 0; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 01d5b37..8d24af7 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -5321,7 +5321,7 @@ static void argv_free(int* pargc, char** pargv[]) free(argv); } -static BOOL argv_append(int* pargc, char** pargv[], const char* what) +static BOOL argv_append(int* pargc, char** pargv[], char* what) { WINPR_ASSERT(pargc); WINPR_ASSERT(pargv); |