From dd57de8e1977845a69cf048d51e582d0e69cd799 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 14 Apr 2023 11:55:29 +0200 Subject: [PATCH] [client,sdl] add function to context --- client/SDL/sdl_disp.cpp | 6 +++--- client/SDL/sdl_freerdp.cpp | 30 +++++++++++++----------------- client/SDL/sdl_freerdp.hpp | 6 +++--- client/SDL/sdl_kbd.cpp | 4 ++-- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/client/SDL/sdl_disp.cpp b/client/SDL/sdl_disp.cpp index 3061e460e..2c6dd414f 100644 --- a/client/SDL/sdl_disp.cpp +++ b/client/SDL/sdl_disp.cpp @@ -126,7 +126,7 @@ BOOL sdlDispContext::sendResize() BOOL sdlDispContext::set_window_resizable() { - update_resizeable(_sdl, TRUE); + _sdl->update_resizeable(TRUE); return TRUE; } @@ -389,7 +389,7 @@ BOOL sdlDispContext::init(DispClientContext* disp) disp->DisplayControlCaps = sdlDispContext::DisplayControlCaps; } - update_resizeable(_sdl, TRUE); + _sdl->update_resizeable(TRUE); return TRUE; } @@ -399,7 +399,7 @@ BOOL sdlDispContext::uninit(DispClientContext* disp) return FALSE; _disp = nullptr; - update_resizeable(_sdl, FALSE); + _sdl->update_resizeable(FALSE); return TRUE; } diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index e949fab18..4d1865ea7 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -906,8 +906,8 @@ static BOOL sdl_post_connect(freerdp* instance) context->update->SetKeyboardIndicators = sdlInput::keyboard_set_indicators; context->update->SetKeyboardImeStatus = sdlInput::keyboard_set_ime_status; - update_resizeable(sdl, FALSE); - update_fullscreen(sdl, context->settings->Fullscreen || context->settings->UseMultimon); + sdl->update_resizeable(FALSE); + sdl->update_fullscreen(context->settings->Fullscreen || context->settings->UseMultimon); return TRUE; } @@ -1278,39 +1278,35 @@ int main(int argc, char* argv[]) return rc; } -BOOL update_fullscreen(sdlContext* sdl, BOOL enter) +BOOL sdl_context::update_fullscreen(BOOL enter) { - WINPR_ASSERT(sdl); - - CriticalSectionLock lock(sdl->critical); - for (uint32_t x = 0; x < sdl->windowCount; x++) + CriticalSectionLock lock(critical); + for (uint32_t x = 0; x < windowCount; x++) { - sdl_window_t* window = &sdl->windows[x]; + sdl_window_t* window = &windows[x]; if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_FULLSCREEN, window->window, enter)) return FALSE; } - sdl->fullscreen = enter; + fullscreen = enter; return TRUE; } -BOOL update_resizeable(sdlContext* sdl, BOOL enable) +BOOL sdl_context::update_resizeable(BOOL enable) { - WINPR_ASSERT(sdl); + CriticalSectionLock lock(critical); - CriticalSectionLock lock(sdl->critical); - - const rdpSettings* settings = sdl->common.context.settings; + const rdpSettings* settings = common.context.settings; const BOOL dyn = freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate); const BOOL smart = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing); BOOL use = (dyn && enable) || smart; - for (uint32_t x = 0; x < sdl->windowCount; x++) + for (uint32_t x = 0; x < windowCount; x++) { - sdl_window_t* window = &sdl->windows[x]; + sdl_window_t* window = &windows[x]; if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_RESIZEABLE, window->window, use)) return FALSE; } - sdl->resizeable = use; + resizeable = use; return TRUE; } diff --git a/client/SDL/sdl_freerdp.hpp b/client/SDL/sdl_freerdp.hpp index 633dfdf25..52258fc4e 100644 --- a/client/SDL/sdl_freerdp.hpp +++ b/client/SDL/sdl_freerdp.hpp @@ -68,7 +68,7 @@ struct sdl_context Uint32 sdl_pixel_format; wLog* log; -}; -BOOL update_resizeable(sdlContext* sdl, BOOL enable); -BOOL update_fullscreen(sdlContext* sdl, BOOL enter); + BOOL update_resizeable(BOOL enable); + BOOL update_fullscreen(BOOL enter); +}; diff --git a/client/SDL/sdl_kbd.cpp b/client/SDL/sdl_kbd.cpp index 6964dd83d..a80de457a 100644 --- a/client/SDL/sdl_kbd.cpp +++ b/client/SDL/sdl_kbd.cpp @@ -435,13 +435,13 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev) case SDL_SCANCODE_RETURN: if (ev->type == SDL_KEYDOWN) { - update_fullscreen(_sdl, !_sdl->fullscreen); + _sdl->update_fullscreen(!_sdl->fullscreen); } return TRUE; case SDL_SCANCODE_R: if (ev->type == SDL_KEYDOWN) { - update_resizeable(_sdl, !_sdl->resizeable); + _sdl->update_resizeable(!_sdl->resizeable); } return TRUE; case SDL_SCANCODE_G: