From 699fc70941ffad62ec9477ad64263c958cfc96c4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 20 Sep 2024 09:05:40 +0200 Subject: [PATCH] [client,sdl] update to current sdl3-api --- .../SDL/SDL3/dialogs/sdl_connection_dialog.cpp | 4 ++-- client/SDL/SDL3/sdl_disp.cpp | 12 +++++------- client/SDL/SDL3/sdl_freerdp.cpp | 4 ++-- client/SDL/SDL3/sdl_kbd.cpp | 6 +++--- client/SDL/SDL3/sdl_kbd.hpp | 4 ++-- client/SDL/SDL3/sdl_window.cpp | 16 ++++++++-------- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp index b099890c6..45b800f13 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp @@ -35,7 +35,7 @@ static const Uint32 hpadding = 5; SDLConnectionDialog::SDLConnectionDialog(rdpContext* context) : _context(context) { - SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO); + SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO); hide(); } @@ -149,7 +149,7 @@ bool SDLConnectionDialog::setModal() auto parent = sdl->windows.begin()->second.window(); SDL_SetWindowParent(_window, parent); - SDL_SetWindowModal(_window, SDL_TRUE); + SDL_SetWindowModal(_window, true); SDL_RaiseWindow(_window); } return true; diff --git a/client/SDL/SDL3/sdl_disp.cpp b/client/SDL/SDL3/sdl_disp.cpp index eac2d9d1d..99b13cf98 100644 --- a/client/SDL/SDL3/sdl_disp.cpp +++ b/client/SDL/SDL3/sdl_disp.cpp @@ -298,7 +298,7 @@ UINT sdlDispContext::sendLayout(const rdpMonitor* monitors, size_t nmonitors) BOOL sdlDispContext::addTimer() { - if (SDL_WasInit(SDL_INIT_TIMER) == 0) + if (SDL_WasInit(SDL_INIT_EVENTS) == 0) return FALSE; SDL_RemoveTimer(_timer); @@ -334,9 +334,7 @@ BOOL sdlDispContext::handle_window_event(const SDL_WindowEvent* ev) { WINPR_ASSERT(ev); - auto bordered = freerdp_settings_get_bool(_sdl->context()->settings, FreeRDP_Decorations) - ? SDL_TRUE - : SDL_FALSE; + auto bordered = freerdp_settings_get_bool(_sdl->context()->settings, FreeRDP_Decorations); auto it = _sdl->windows.find(ev->windowID); if (it != _sdl->windows.end()) @@ -365,11 +363,11 @@ BOOL sdlDispContext::handle_window_event(const SDL_WindowEvent* ev) case SDL_EVENT_WINDOW_MOUSE_LEAVE: WINPR_ASSERT(_sdl); - _sdl->input.keyboard_grab(ev->windowID, SDL_FALSE); + _sdl->input.keyboard_grab(ev->windowID, false); return TRUE; case SDL_EVENT_WINDOW_MOUSE_ENTER: WINPR_ASSERT(_sdl); - _sdl->input.keyboard_grab(ev->windowID, SDL_TRUE); + _sdl->input.keyboard_grab(ev->windowID, true); return _sdl->input.keyboard_focus_in(); case SDL_EVENT_WINDOW_FOCUS_GAINED: return _sdl->input.keyboard_focus_in(); @@ -443,7 +441,7 @@ BOOL sdlDispContext::uninit(DispClientContext* disp) sdlDispContext::sdlDispContext(SdlContext* sdl) : _sdl(sdl) { - SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO); + SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO); WINPR_ASSERT(_sdl); WINPR_ASSERT(_sdl->context()->settings); diff --git a/client/SDL/SDL3/sdl_freerdp.cpp b/client/SDL/SDL3/sdl_freerdp.cpp index 6145bfd15..76611518c 100644 --- a/client/SDL/SDL3/sdl_freerdp.cpp +++ b/client/SDL/SDL3/sdl_freerdp.cpp @@ -963,7 +963,7 @@ static int sdl_run(SdlContext* sdl) case SDL_EVENT_USER_WINDOW_RESIZEABLE: { auto window = static_cast(windowEvent.user.data1); - const SDL_bool use = windowEvent.user.code != 0 ? SDL_TRUE : SDL_FALSE; + const bool use = windowEvent.user.code != 0; if (window) window->resizeable(use); } @@ -971,7 +971,7 @@ static int sdl_run(SdlContext* sdl) case SDL_EVENT_USER_WINDOW_FULLSCREEN: { auto window = static_cast(windowEvent.user.data1); - const SDL_bool enter = windowEvent.user.code != 0 ? SDL_TRUE : SDL_FALSE; + const bool enter = windowEvent.user.code != 0; if (window) window->fullscreen(enter); } diff --git a/client/SDL/SDL3/sdl_kbd.cpp b/client/SDL/SDL3/sdl_kbd.cpp index 5fd40081d..c2f7c52f7 100644 --- a/client/SDL/SDL3/sdl_kbd.cpp +++ b/client/SDL/SDL3/sdl_kbd.cpp @@ -549,7 +549,7 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev) if (ev->scancode == _hotkeyGrab) { _sdl->grab_kbd_enabled = !_sdl->grab_kbd_enabled; - keyboard_grab(ev->windowID, _sdl->grab_kbd ? SDL_FALSE : SDL_TRUE); + keyboard_grab(ev->windowID, _sdl->grab_kbd); return TRUE; } if (ev->scancode == _hotkeyDisconnect) @@ -570,7 +570,7 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev) _sdl->context()->input, ev->type == SDL_EVENT_KEY_DOWN, ev->repeat, scancode); } -BOOL sdlInput::keyboard_grab(Uint32 windowID, SDL_bool enable) +BOOL sdlInput::keyboard_grab(Uint32 windowID, bool enable) { auto it = _sdl->windows.find(windowID); if (it == _sdl->windows.end()) @@ -594,7 +594,7 @@ BOOL sdlInput::mouse_focus(Uint32 windowID) return TRUE; } -BOOL sdlInput::mouse_grab(Uint32 windowID, SDL_bool enable) +BOOL sdlInput::mouse_grab(Uint32 windowID, bool enable) { auto it = _sdl->windows.find(windowID); if (it == _sdl->windows.end()) diff --git a/client/SDL/SDL3/sdl_kbd.hpp b/client/SDL/SDL3/sdl_kbd.hpp index 626f337df..2e7a60909 100644 --- a/client/SDL/SDL3/sdl_kbd.hpp +++ b/client/SDL/SDL3/sdl_kbd.hpp @@ -46,9 +46,9 @@ class sdlInput BOOL keyboard_handle_event(const SDL_KeyboardEvent* ev); - BOOL keyboard_grab(Uint32 windowID, SDL_bool enable); + BOOL keyboard_grab(Uint32 windowID, bool enable); BOOL mouse_focus(Uint32 windowID); - BOOL mouse_grab(Uint32 windowID, SDL_bool enable); + BOOL mouse_grab(Uint32 windowID, bool enable); static BOOL keyboard_set_indicators(rdpContext* context, UINT16 led_flags); static BOOL keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeState, diff --git a/client/SDL/SDL3/sdl_window.cpp b/client/SDL/SDL3/sdl_window.cpp index 41c2a1fc2..65c95a36e 100644 --- a/client/SDL/SDL3/sdl_window.cpp +++ b/client/SDL/SDL3/sdl_window.cpp @@ -99,7 +99,7 @@ bool SdlWindow::grabKeyboard(bool enable) { if (!_window) return false; - SDL_SetWindowKeyboardGrab(_window, enable ? SDL_TRUE : SDL_FALSE); + SDL_SetWindowKeyboardGrab(_window, enable); return true; } @@ -107,14 +107,14 @@ bool SdlWindow::grabMouse(bool enable) { if (!_window) return false; - SDL_SetWindowMouseGrab(_window, enable ? SDL_TRUE : SDL_FALSE); + SDL_SetWindowMouseGrab(_window, enable); return true; } void SdlWindow::setBordered(bool bordered) { if (_window) - SDL_SetWindowBordered(_window, bordered ? SDL_TRUE : SDL_FALSE); + SDL_SetWindowBordered(_window, bordered); } void SdlWindow::raise() @@ -124,7 +124,7 @@ void SdlWindow::raise() void SdlWindow::resizeable(bool use) { - SDL_SetWindowResizable(_window, use ? SDL_TRUE : SDL_FALSE); + SDL_SetWindowResizable(_window, use); } void SdlWindow::fullscreen(bool enter) @@ -140,9 +140,9 @@ void SdlWindow::fullscreen(bool enter) SDL_RestoreWindow(_window); // Maximize so we can see the caption and // bits - SDL_SetWindowBordered(_window, SDL_FALSE); + SDL_SetWindowBordered(_window, false); SDL_SetWindowPosition(_window, 0, 0); - SDL_SetWindowAlwaysOnTop(_window, SDL_TRUE); + SDL_SetWindowAlwaysOnTop(_window, true); SDL_RaiseWindow(_window); if (mode) SDL_SetWindowSize(_window, mode->w, mode->h); @@ -153,8 +153,8 @@ void SdlWindow::fullscreen(bool enter) if (curFlags & SDL_WINDOW_BORDERLESS) { - SDL_SetWindowBordered(_window, SDL_TRUE); - SDL_SetWindowAlwaysOnTop(_window, SDL_FALSE); + SDL_SetWindowBordered(_window, true); + SDL_SetWindowAlwaysOnTop(_window, false); SDL_RaiseWindow(_window); SDL_MinimizeWindow(_window); // Maximize so we can see the caption and bits SDL_MaximizeWindow(_window); // Maximize so we can see the caption and bits