[client,sdl] update to SDL3
update client for SDL3. Not compatible with SDL2
This commit is contained in:
parent
8281186a6d
commit
4a2ebe263b
@ -59,9 +59,7 @@ if (WITH_DEBUG_SDL_KBD_EVENTS)
|
||||
add_definitions(-DWITH_DEBUG_SDL_KBD_EVENTS)
|
||||
endif()
|
||||
|
||||
find_package(SDL2 REQUIRED COMPONENTS)
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
include_directories(${SDL2_INCLUDE_DIRS})
|
||||
find_package(SDL3 REQUIRED COMPONENTS)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
@ -106,9 +104,9 @@ list(APPEND LIBS
|
||||
)
|
||||
|
||||
if (NOT WITH_SDL_LINK_SHARED)
|
||||
list(APPEND LIBS ${SDL2_STATIC_LIBRARIES})
|
||||
list(APPEND LIBS ${SDL3_STATIC_LIBRARIES})
|
||||
else()
|
||||
list(APPEND LIBS ${SDL2_LIBRARIES})
|
||||
list(APPEND LIBS ${SDL3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
AddTargetWithResourceFile(${PROJECT_NAME} "${WIN32_GUI_FLAG}" "${PROJECT_VERSION}" SRCS)
|
||||
|
@ -25,40 +25,25 @@ list(APPEND LIBS
|
||||
)
|
||||
|
||||
if (NOT WITH_SDL_LINK_SHARED)
|
||||
list(APPEND LIBS ${SDL2_STATIC_LIBRARIES})
|
||||
list(APPEND LIBS ${SDL3_STATIC_LIBRARIES})
|
||||
else()
|
||||
list(APPEND LIBS ${SDL2_LIBRARIES})
|
||||
list(APPEND LIBS ${SDL3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
macro(find_sdl_component name)
|
||||
find_package(${name})
|
||||
if (NOT ${name}_FOUND)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(${name} REQUIRED ${name})
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
list(APPEND LIBS ${${name}_LIBRARIES})
|
||||
link_directories(${${name}_LIBRARY_DIRS})
|
||||
include_directories(${${name}_INCLUDE_DIRS})
|
||||
else()
|
||||
list(APPEND LIBS ${${name}_STATIC_LIBRARIES})
|
||||
link_directories(${${name}_STATIC_LIBRARY_DIRS})
|
||||
include_directories(${${name}_STATIC_INCLUDE_DIRS})
|
||||
endif()
|
||||
else()
|
||||
find_package(${name} REQUIRED)
|
||||
if (WITH_SDL_LINK_SHARED)
|
||||
list(APPEND LIBS ${name}::${name})
|
||||
else()
|
||||
list(APPEND LIBS ${name}::${name}-static)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
find_sdl_component(SDL2_ttf)
|
||||
find_sdl_component(SDL3_ttf)
|
||||
|
||||
option(WITH_SDL_IMAGE_DIALOGS "Build with SDL_image support (recommended)" OFF)
|
||||
if (WITH_SDL_IMAGE_DIALOGS)
|
||||
find_sdl_component(SDL2_image)
|
||||
find_sdl_component(SDL3_image)
|
||||
add_definitions(-DWITH_SDL_IMAGE_DIALOGS)
|
||||
endif()
|
||||
|
||||
|
@ -86,4 +86,10 @@ add_library(sdl3_client_res OBJECT
|
||||
${SRCS}
|
||||
${FACTORY_SRCS}
|
||||
)
|
||||
if (NOT WITH_SDL_LINK_SHARED)
|
||||
target_link_libraries(sdl3_client_res ${SDL3_STATIC_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(sdl3_client_res ${SDL3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set_property(TARGET sdl3_client_res PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
@ -27,7 +27,7 @@ namespace fs = std::experimental::filesystem;
|
||||
#error Could not find system header "<filesystem>" or "<experimental/filesystem>"
|
||||
#endif
|
||||
|
||||
SDL_RWops* SDLResourceManager::get(const std::string& type, const std::string& id)
|
||||
SDL_IOStream* SDLResourceManager::get(const std::string& type, const std::string& id)
|
||||
{
|
||||
std::string uuid = type + "/" + id;
|
||||
|
||||
@ -37,7 +37,7 @@ SDL_RWops* SDLResourceManager::get(const std::string& type, const std::string& i
|
||||
return nullptr;
|
||||
|
||||
const auto& v = val->second;
|
||||
return SDL_RWFromConstMem(v.data(), v.size());
|
||||
return SDL_IOFromConstMem(v.data(), v.size());
|
||||
#else
|
||||
fs::path path(SDL_RESOURCE_ROOT);
|
||||
path /= type;
|
||||
@ -49,7 +49,7 @@ SDL_RWops* SDLResourceManager::get(const std::string& type, const std::string& i
|
||||
<< fs::absolute(path) << std::endl;
|
||||
std::cerr << "file not found, application will fail" << std::endl;
|
||||
}
|
||||
return SDL_RWFromFile(path.u8string().c_str(), "rb");
|
||||
return SDL_IOFromFile(path.u8string().c_str(), "rb");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -20,14 +20,14 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
class SDLResourceManager
|
||||
{
|
||||
friend class SDLResourceFile;
|
||||
|
||||
public:
|
||||
static SDL_RWops* get(const std::string& type, const std::string& id);
|
||||
static SDL_IOStream* get(const std::string& type, const std::string& id);
|
||||
|
||||
static const std::string typeFonts();
|
||||
static const std::string typeImages();
|
||||
|
@ -27,7 +27,8 @@ static const SDL_Color buttonhighlightcolor = { 0xcd, 0xca, 0x35, 0x60 };
|
||||
static const SDL_Color buttonmouseovercolor = { 0x66, 0xff, 0x66, 0x60 };
|
||||
static const SDL_Color buttonfontcolor = { 0xd1, 0xcf, 0xcd, 0xff };
|
||||
|
||||
SdlButton::SdlButton(SDL_Renderer* renderer, const std::string& label, int id, const SDL_Rect& rect)
|
||||
SdlButton::SdlButton(SDL_Renderer* renderer, const std::string& label, int id,
|
||||
const SDL_FRect& rect)
|
||||
: SdlWidget(renderer, rect, false), _name(label), _id(id)
|
||||
{
|
||||
assert(renderer);
|
||||
|
@ -7,7 +7,7 @@
|
||||
class SdlButton : public SdlWidget
|
||||
{
|
||||
public:
|
||||
SdlButton(SDL_Renderer* renderer, const std::string& label, int id, const SDL_Rect& rect);
|
||||
SdlButton(SDL_Renderer* renderer, const std::string& label, int id, const SDL_FRect& rect);
|
||||
SdlButton(SdlButton&& other) noexcept;
|
||||
~SdlButton() override = default;
|
||||
|
||||
|
@ -20,7 +20,8 @@ bool SdlButtonList::populate(SDL_Renderer* renderer, const std::vector<std::stri
|
||||
for (size_t x = 0; x < ids.size(); x++)
|
||||
{
|
||||
const size_t curOffsetX = offsetX + x * (static_cast<size_t>(width) + hpadding);
|
||||
const SDL_Rect rect = { static_cast<int>(curOffsetX), offsetY, width, height };
|
||||
const SDL_FRect rect = { static_cast<float>(curOffsetX), static_cast<float>(offsetY),
|
||||
static_cast<float>(width), static_cast<float>(height) };
|
||||
_list.emplace_back(renderer, labels[x], ids[x], rect);
|
||||
}
|
||||
return true;
|
||||
|
@ -212,14 +212,14 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_USEREVENT_RETRY_DIALOG:
|
||||
case SDL_EVENT_USER_RETRY_DIALOG:
|
||||
return update();
|
||||
case SDL_QUIT:
|
||||
case SDL_EVENT_QUIT:
|
||||
resetTimer();
|
||||
destroyWindow();
|
||||
return false;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
if (visible())
|
||||
{
|
||||
auto& ev = reinterpret_cast<const SDL_KeyboardEvent&>(event);
|
||||
@ -230,7 +230,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
case SDLK_RETURN2:
|
||||
case SDLK_ESCAPE:
|
||||
case SDLK_KP_ENTER:
|
||||
if (event.type == SDL_KEYUP)
|
||||
if (event.type == SDL_EVENT_KEY_UP)
|
||||
{
|
||||
freerdp_abort_event(_context);
|
||||
sdl_push_quit();
|
||||
@ -246,7 +246,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
return windowID == ev.windowID;
|
||||
}
|
||||
return false;
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
if (visible())
|
||||
{
|
||||
auto& ev = reinterpret_cast<const SDL_MouseMotionEvent&>(event);
|
||||
@ -256,8 +256,8 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
return windowID == ev.windowID;
|
||||
}
|
||||
return false;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
if (visible())
|
||||
{
|
||||
auto& ev = reinterpret_cast<const SDL_MouseButtonEvent&>(event);
|
||||
@ -266,7 +266,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
auto button = _buttons.get_selected(event.button);
|
||||
if (button)
|
||||
{
|
||||
if (event.type == SDL_MOUSEBUTTONUP)
|
||||
if (event.type == SDL_EVENT_MOUSE_BUTTON_UP)
|
||||
{
|
||||
freerdp_abort_event(_context);
|
||||
sdl_push_quit();
|
||||
@ -276,7 +276,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
return windowID == ev.windowID;
|
||||
}
|
||||
return false;
|
||||
case SDL_MOUSEWHEEL:
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
if (visible())
|
||||
{
|
||||
auto& ev = reinterpret_cast<const SDL_MouseWheelEvent&>(event);
|
||||
@ -284,25 +284,22 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
return windowID == ev.windowID;
|
||||
}
|
||||
return false;
|
||||
case SDL_FINGERUP:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_EVENT_FINGER_UP:
|
||||
case SDL_EVENT_FINGER_DOWN:
|
||||
if (visible())
|
||||
{
|
||||
auto& ev = reinterpret_cast<const SDL_TouchFingerEvent&>(event);
|
||||
update(_renderer);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
return windowID == ev.windowID;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
case SDL_WINDOWEVENT:
|
||||
default:
|
||||
if ((event.type >= SDL_EVENT_WINDOW_FIRST) && (event.type <= SDL_EVENT_WINDOW_LAST))
|
||||
{
|
||||
auto& ev = reinterpret_cast<const SDL_WindowEvent&>(event);
|
||||
switch (ev.event)
|
||||
switch (ev.type)
|
||||
{
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||
if (windowID == ev.windowID)
|
||||
{
|
||||
freerdp_abort_event(_context);
|
||||
@ -317,7 +314,6 @@ bool SDLConnectionDialog::handle(const SDL_Event& event)
|
||||
|
||||
return windowID == ev.windowID;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -330,9 +326,9 @@ bool SDLConnectionDialog::createWindow()
|
||||
const size_t widget_width = 600;
|
||||
const size_t total_height = 300;
|
||||
|
||||
_window = SDL_CreateWindow(
|
||||
_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, widget_width,
|
||||
total_height, SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_FOCUS);
|
||||
_window = SDL_CreateWindow(_title.c_str(), widget_width, total_height,
|
||||
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_MOUSE_FOCUS |
|
||||
SDL_WINDOW_INPUT_FOCUS);
|
||||
if (_window == nullptr)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateWindow");
|
||||
@ -340,7 +336,7 @@ bool SDLConnectionDialog::createWindow()
|
||||
}
|
||||
setModal();
|
||||
|
||||
_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED);
|
||||
_renderer = SDL_CreateRenderer(_window, nullptr, SDL_RENDERER_PRESENTVSYNC);
|
||||
if (_renderer == nullptr)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateRenderer");
|
||||
@ -385,7 +381,8 @@ bool SDLConnectionDialog::createWindow()
|
||||
}
|
||||
|
||||
int height = (total_height - 3ul * vpadding) / 2ul;
|
||||
SDL_Rect iconRect{ hpadding, vpadding, widget_width / 4ul - 2ul * hpadding, height };
|
||||
SDL_FRect iconRect{ hpadding, vpadding, widget_width / 4ul - 2ul * hpadding,
|
||||
static_cast<float>(height) };
|
||||
widget_cfg_t icon{ textcolor,
|
||||
res_bgcolor,
|
||||
{ _renderer, iconRect,
|
||||
@ -401,10 +398,10 @@ bool SDLConnectionDialog::createWindow()
|
||||
"FreeRDP_Icon.svg") } };
|
||||
_list.emplace_back(std::move(logo));
|
||||
|
||||
SDL_Rect rect = { widget_width / 4ul, vpadding, widget_width * 3ul / 4ul,
|
||||
SDL_FRect rect = { widget_width / 4ul, vpadding, widget_width * 3ul / 4ul,
|
||||
total_height - 3ul * vpadding - widget_height };
|
||||
#else
|
||||
SDL_Rect rect = { hpadding, vpadding, widget_width - 2ul * hpadding,
|
||||
SDL_FRect rect = { hpadding, vpadding, widget_width - 2ul * hpadding,
|
||||
total_height - 2ul * vpadding };
|
||||
#endif
|
||||
|
||||
@ -446,7 +443,7 @@ bool SDLConnectionDialog::show(MsgType type, const char* fmt, va_list ap)
|
||||
bool SDLConnectionDialog::show(MsgType type)
|
||||
{
|
||||
_type = type;
|
||||
return sdl_push_user_event(SDL_USEREVENT_RETRY_DIALOG);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_RETRY_DIALOG);
|
||||
}
|
||||
|
||||
std::string SDLConnectionDialog::print(const char* fmt, va_list ap)
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <freerdp/log.h>
|
||||
#include <freerdp/utils/smartcardlogon.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "../sdl_freerdp.hpp"
|
||||
#include "sdl_dialogs.hpp"
|
||||
@ -76,10 +76,10 @@ static int sdl_show_dialog(rdpContext* context, const char* title, const char* m
|
||||
{
|
||||
SDL_Event event = { 0 };
|
||||
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_SHOW_DIALOG, title, message, flags))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_SHOW_DIALOG, title, message, flags))
|
||||
return 0;
|
||||
|
||||
if (!sdl_wait_for_result(context, SDL_USEREVENT_SHOW_RESULT, &event))
|
||||
if (!sdl_wait_for_result(context, SDL_EVENT_USER_SHOW_RESULT, &event))
|
||||
return 0;
|
||||
|
||||
return event.user.code;
|
||||
@ -131,10 +131,10 @@ BOOL sdl_authenticate_ex(freerdp* instance, char** username, char** password, ch
|
||||
d = *domain;
|
||||
p = *password;
|
||||
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_AUTH_DIALOG, title, u, d, p, reason))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_AUTH_DIALOG, title, u, d, p, reason))
|
||||
goto fail;
|
||||
|
||||
if (!sdl_wait_for_result(instance->context, SDL_USEREVENT_AUTH_RESULT, &event))
|
||||
if (!sdl_wait_for_result(instance->context, SDL_EVENT_USER_AUTH_RESULT, &event))
|
||||
goto fail;
|
||||
else
|
||||
{
|
||||
@ -194,10 +194,10 @@ BOOL sdl_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_list, DWOR
|
||||
const char* title = "Select a logon smartcard certificate";
|
||||
if (gateway)
|
||||
title = "Select a gateway logon smartcard certificate";
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_SCARD_DIALOG, title, list.data(), count))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_SCARD_DIALOG, title, list.data(), count))
|
||||
goto fail;
|
||||
|
||||
if (!sdl_wait_for_result(instance->context, SDL_USEREVENT_SCARD_RESULT, &event))
|
||||
if (!sdl_wait_for_result(instance->context, SDL_EVENT_USER_SCARD_RESULT, &event))
|
||||
goto fail;
|
||||
|
||||
res = (event.user.code >= 0) ? TRUE : FALSE;
|
||||
@ -318,11 +318,11 @@ static DWORD sdl_show_ceritifcate_dialog(rdpContext* context, const char* title,
|
||||
const char* message)
|
||||
{
|
||||
SDLConnectionDialogHider hider(context);
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_CERT_DIALOG, title, message))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_CERT_DIALOG, title, message))
|
||||
return 0;
|
||||
|
||||
SDL_Event event = { 0 };
|
||||
if (!sdl_wait_for_result(context, SDL_USEREVENT_CERT_RESULT, &event))
|
||||
if (!sdl_wait_for_result(context, SDL_EVENT_USER_CERT_RESULT, &event))
|
||||
return 0;
|
||||
return static_cast<DWORD>(event.user.code);
|
||||
}
|
||||
@ -502,7 +502,7 @@ BOOL sdl_cert_dialog_show(const char* title, const char* message)
|
||||
}
|
||||
}
|
||||
|
||||
return sdl_push_user_event(SDL_USEREVENT_CERT_RESULT, value);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_CERT_RESULT, value);
|
||||
}
|
||||
|
||||
BOOL sdl_message_dialog_show(const char* title, const char* message, Sint32 flags)
|
||||
@ -540,7 +540,7 @@ BOOL sdl_message_dialog_show(const char* title, const char* message, Sint32 flag
|
||||
}
|
||||
}
|
||||
|
||||
return sdl_push_user_event(SDL_USEREVENT_SHOW_RESULT, value);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_SHOW_RESULT, value);
|
||||
}
|
||||
|
||||
BOOL sdl_auth_dialog_show(const SDL_UserAuthArg* args)
|
||||
@ -606,7 +606,7 @@ BOOL sdl_auth_dialog_show(const SDL_UserAuthArg* args)
|
||||
pwd = _strdup(result[2].c_str());
|
||||
}
|
||||
}
|
||||
return sdl_push_user_event(SDL_USEREVENT_AUTH_RESULT, user, domain, pwd, rc);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_AUTH_RESULT, user, domain, pwd, rc);
|
||||
}
|
||||
|
||||
BOOL sdl_scard_dialog_show(const char* title, Sint32 count, const char** list)
|
||||
@ -617,5 +617,5 @@ BOOL sdl_scard_dialog_show(const char* title, Sint32 count, const char** list)
|
||||
vlist.emplace_back(list[x]);
|
||||
SdlSelectList slist(title, vlist);
|
||||
Sint32 value = slist.run();
|
||||
return sdl_push_user_event(SDL_USEREVENT_SCARD_RESULT, value);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_SCARD_RESULT, value);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#include "sdl_widget.hpp"
|
||||
#include "sdl_button.hpp"
|
||||
@ -44,12 +44,13 @@ SdlInputWidget::SdlInputWidget(SDL_Renderer* renderer, const std::string& label,
|
||||
size_t width, size_t height)
|
||||
: _flags(flags), _text(initial), _text_label(label),
|
||||
_label(renderer,
|
||||
{ 0, static_cast<int>(offset * (height + vpadding)), static_cast<int>(width),
|
||||
static_cast<int>(height) },
|
||||
{ 0, static_cast<float>(offset * (height + vpadding)), static_cast<float>(width),
|
||||
static_cast<float>(height) },
|
||||
false),
|
||||
_input(renderer,
|
||||
{ static_cast<int>(width + hpadding), static_cast<int>(offset * (height + vpadding)),
|
||||
static_cast<int>(width), static_cast<int>(height) },
|
||||
{ static_cast<float>(width + hpadding),
|
||||
static_cast<float>(offset * (height + vpadding)), static_cast<float>(width),
|
||||
static_cast<float>(height) },
|
||||
true),
|
||||
_highlight(false), _mouseover(false)
|
||||
{
|
||||
@ -146,7 +147,7 @@ bool SdlInputWidget::append_str(SDL_Renderer* renderer, const std::string& str)
|
||||
return update_input(renderer);
|
||||
}
|
||||
|
||||
const SDL_Rect& SdlInputWidget::input_rect() const
|
||||
const SDL_FRect& SdlInputWidget::input_rect() const
|
||||
{
|
||||
return _input.rect();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "sdl_widget.hpp"
|
||||
|
||||
class SdlInputWidget
|
||||
@ -51,7 +51,7 @@ class SdlInputWidget
|
||||
bool remove_str(SDL_Renderer* renderer, size_t count);
|
||||
bool append_str(SDL_Renderer* renderer, const std::string& text);
|
||||
|
||||
[[nodiscard]] const SDL_Rect& input_rect() const;
|
||||
[[nodiscard]] const SDL_FRect& input_rect() const;
|
||||
[[nodiscard]] std::string value() const;
|
||||
|
||||
[[nodiscard]] bool readonly() const;
|
||||
|
@ -22,9 +22,9 @@ SdlInputWidgetList::SdlInputWidgetList(const std::string& title,
|
||||
const size_t total_width = widget_width + widget_width;
|
||||
const size_t input_height = labels.size() * (widget_heigth + vpadding) + vpadding;
|
||||
const size_t total_height = input_height + widget_heigth;
|
||||
_window = SDL_CreateWindow(
|
||||
title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, total_width, total_height,
|
||||
SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_FOCUS);
|
||||
_window = SDL_CreateWindow(title.c_str(), total_width, total_height,
|
||||
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_MOUSE_FOCUS |
|
||||
SDL_WINDOW_INPUT_FOCUS);
|
||||
if (_window == nullptr)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateWindow");
|
||||
@ -32,7 +32,7 @@ SdlInputWidgetList::SdlInputWidgetList(const std::string& title,
|
||||
else
|
||||
{
|
||||
|
||||
_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED);
|
||||
_renderer = SDL_CreateRenderer(_window, nullptr, SDL_RENDERER_PRESENTVSYNC);
|
||||
if (_renderer == nullptr)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateRenderer");
|
||||
@ -160,7 +160,7 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
|
||||
SDL_WaitEvent(&event);
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_KEYUP:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
{
|
||||
auto it = std::remove(pressed.begin(), pressed.end(), event.key.keysym.sym);
|
||||
pressed.erase(it, pressed.end());
|
||||
@ -209,10 +209,10 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
pressed.push_back(event.key.keysym.sym);
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
{
|
||||
auto cur = get(CurrentActiveTextInput);
|
||||
if (cur)
|
||||
@ -222,7 +222,7 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
{
|
||||
auto TextInputIndex = get_index(event.button);
|
||||
for (auto& cur : _list)
|
||||
@ -240,7 +240,7 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
|
||||
_buttons.set_mouseover(event.button.x, event.button.y);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
{
|
||||
auto val = get_index(event.button);
|
||||
if (valid(val))
|
||||
@ -257,7 +257,7 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
case SDL_EVENT_QUIT:
|
||||
res = INPUT_BUTTON_CANCEL;
|
||||
running = false;
|
||||
break;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "sdl_input.hpp"
|
||||
#include "sdl_buttons.hpp"
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#include "sdl_select.hpp"
|
||||
#include "sdl_widget.hpp"
|
||||
@ -36,7 +36,7 @@ static const SDL_Color labelhighlightcolor = { 0xcd, 0xca, 0x35, 0x60 };
|
||||
static const SDL_Color labelfontcolor = { 0xd1, 0xcf, 0xcd, 0xff };
|
||||
|
||||
SdlSelectWidget::SdlSelectWidget(SDL_Renderer* renderer, const std::string& label,
|
||||
const SDL_Rect& rect)
|
||||
const SDL_FRect& rect)
|
||||
: SdlWidget(renderer, rect, true), _text(label), _mouseover(false), _highlight(false)
|
||||
{
|
||||
update_text(renderer);
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "sdl_widget.hpp"
|
||||
|
||||
class SdlSelectWidget : public SdlWidget
|
||||
{
|
||||
public:
|
||||
SdlSelectWidget(SDL_Renderer* renderer, const std::string& label, const SDL_Rect& rect);
|
||||
SdlSelectWidget(SDL_Renderer* renderer, const std::string& label, const SDL_FRect& rect);
|
||||
SdlSelectWidget(SdlSelectWidget&& other) noexcept;
|
||||
~SdlSelectWidget() override = default;
|
||||
|
||||
|
@ -9,9 +9,8 @@ SdlSelectList::SdlSelectList(const std::string& title, const std::vector<std::st
|
||||
const size_t widget_width = 600;
|
||||
|
||||
const size_t total_height = labels.size() * (widget_height + vpadding) + vpadding;
|
||||
_window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
widget_width, total_height + widget_height,
|
||||
SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_MOUSE_FOCUS |
|
||||
_window = SDL_CreateWindow(title.c_str(), widget_width, total_height + widget_height,
|
||||
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_MOUSE_FOCUS |
|
||||
SDL_WINDOW_INPUT_FOCUS);
|
||||
if (_window == nullptr)
|
||||
{
|
||||
@ -19,14 +18,14 @@ SdlSelectList::SdlSelectList(const std::string& title, const std::vector<std::st
|
||||
}
|
||||
else
|
||||
{
|
||||
_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED);
|
||||
_renderer = SDL_CreateRenderer(_window, nullptr, SDL_RENDERER_PRESENTVSYNC);
|
||||
if (_renderer == nullptr)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateRenderer");
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Rect rect = { 0, 0, widget_width, widget_height };
|
||||
SDL_FRect rect = { 0, 0, widget_width, widget_height };
|
||||
for (auto& label : labels)
|
||||
{
|
||||
_list.emplace_back(_renderer, label, rect);
|
||||
@ -76,7 +75,7 @@ int SdlSelectList::run()
|
||||
SDL_WaitEvent(&event);
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
@ -108,7 +107,7 @@ int SdlSelectList::run()
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
{
|
||||
ssize_t TextInputIndex = get_index(event.button);
|
||||
reset_mouseover();
|
||||
@ -122,7 +121,7 @@ int SdlSelectList::run()
|
||||
_buttons.set_mouseover(event.button.x, event.button.y);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
{
|
||||
auto button = _buttons.get_selected(event.button);
|
||||
if (button)
|
||||
@ -139,7 +138,7 @@ int SdlSelectList::run()
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
case SDL_EVENT_QUIT:
|
||||
res = INPUT_BUTTON_CANCEL;
|
||||
running = false;
|
||||
break;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "sdl_select.hpp"
|
||||
#include "sdl_button.hpp"
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#include "sdl_widget.hpp"
|
||||
#include "../sdl_utils.hpp"
|
||||
@ -32,7 +32,7 @@
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#if defined(WITH_SDL_IMAGE_DIALOGS)
|
||||
#include <SDL_image.h>
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
#endif
|
||||
|
||||
#define TAG CLIENT_TAG("SDL.widget")
|
||||
@ -41,7 +41,7 @@ static const SDL_Color backgroundcolor = { 0x38, 0x36, 0x35, 0xff };
|
||||
|
||||
static const Uint32 hpadding = 10;
|
||||
|
||||
SdlWidget::SdlWidget(SDL_Renderer* renderer, const SDL_Rect& rect, bool input)
|
||||
SdlWidget::SdlWidget(SDL_Renderer* renderer, const SDL_FRect& rect, bool input)
|
||||
: _rect(rect), _input(input)
|
||||
{
|
||||
assert(renderer);
|
||||
@ -52,20 +52,20 @@ SdlWidget::SdlWidget(SDL_Renderer* renderer, const SDL_Rect& rect, bool input)
|
||||
widget_log_error(-1, "SDLResourceManager::get");
|
||||
else
|
||||
{
|
||||
_font = TTF_OpenFontRW(ops, 1, 64);
|
||||
_font = TTF_OpenFontIO(ops, 1, 64);
|
||||
if (!_font)
|
||||
widget_log_error(-1, "TTF_OpenFontRW");
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_SDL_IMAGE_DIALOGS)
|
||||
SdlWidget::SdlWidget(SDL_Renderer* renderer, const SDL_Rect& rect, SDL_RWops* ops) : _rect(rect)
|
||||
SdlWidget::SdlWidget(SDL_Renderer* renderer, const SDL_FRect& rect, SDL_IOStream* ops) : _rect(rect)
|
||||
{
|
||||
if (ops)
|
||||
{
|
||||
_image = IMG_LoadTexture_RW(renderer, ops, 1);
|
||||
_image = IMG_LoadTexture_IO(renderer, ops, 1);
|
||||
if (!_image)
|
||||
widget_log_error(-1, "IMG_LoadTextureTyped_RW");
|
||||
widget_log_error(-1, "IMG_LoadTexture_IO");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -79,7 +79,7 @@ SdlWidget::SdlWidget(SdlWidget&& other) noexcept
|
||||
}
|
||||
|
||||
SDL_Texture* SdlWidget::render_text(SDL_Renderer* renderer, const std::string& text,
|
||||
SDL_Color fgcolor, SDL_Rect& src, SDL_Rect& dst)
|
||||
SDL_Color fgcolor, SDL_FRect& src, SDL_FRect& dst)
|
||||
{
|
||||
auto surface = TTF_RenderUTF8_Blended(_font, text.c_str(), fgcolor);
|
||||
if (!surface)
|
||||
@ -89,15 +89,19 @@ SDL_Texture* SdlWidget::render_text(SDL_Renderer* renderer, const std::string& t
|
||||
}
|
||||
|
||||
auto texture = SDL_CreateTextureFromSurface(renderer, surface);
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_DestroySurface(surface);
|
||||
if (!texture)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateTextureFromSurface");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TTF_SizeUTF8(_font, text.c_str(), &src.w, &src.h);
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
TTF_SizeUTF8(_font, text.c_str(), &w, &h);
|
||||
|
||||
src.w = w;
|
||||
src.h = h;
|
||||
/* Do some magic:
|
||||
* - Add padding before and after text
|
||||
* - if text is too long only show the last elements
|
||||
@ -106,21 +110,21 @@ SDL_Texture* SdlWidget::render_text(SDL_Renderer* renderer, const std::string& t
|
||||
dst = _rect;
|
||||
dst.x += hpadding;
|
||||
dst.w -= 2 * hpadding;
|
||||
const float scale = static_cast<float>(dst.h) / static_cast<float>(src.h);
|
||||
const float sws = static_cast<float>(src.w) * scale;
|
||||
const float dws = static_cast<float>(dst.w) / scale;
|
||||
if (static_cast<float>(dst.w) > sws)
|
||||
dst.w = static_cast<int>(sws);
|
||||
if (static_cast<float>(src.w) > dws)
|
||||
const float scale = dst.h / src.h;
|
||||
const float sws = (src.w) * scale;
|
||||
const float dws = (dst.w) / scale;
|
||||
if (dst.w > sws)
|
||||
dst.w = sws;
|
||||
if (src.w > dws)
|
||||
{
|
||||
src.x = src.w - static_cast<int>(dws);
|
||||
src.w = static_cast<int>(dws);
|
||||
src.x = src.w - dws;
|
||||
src.w = dws;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
SDL_Texture* SdlWidget::render_text_wrapped(SDL_Renderer* renderer, const std::string& text,
|
||||
SDL_Color fgcolor, SDL_Rect& src, SDL_Rect& dst)
|
||||
SDL_Color fgcolor, SDL_FRect& src, SDL_FRect& dst)
|
||||
{
|
||||
Sint32 w = 0;
|
||||
Sint32 h = 0;
|
||||
@ -136,7 +140,7 @@ SDL_Texture* SdlWidget::render_text_wrapped(SDL_Renderer* renderer, const std::s
|
||||
src.h = surface->h;
|
||||
|
||||
auto texture = SDL_CreateTextureFromSurface(renderer, surface);
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_DestroySurface(surface);
|
||||
if (!texture)
|
||||
{
|
||||
widget_log_error(-1, "SDL_CreateTextureFromSurface");
|
||||
@ -175,7 +179,7 @@ bool SdlWidget::error_ex(Uint32 res, const char* what, const char* file, size_t
|
||||
return sdl_log_error_ex(res, log, what, file, line, fkt);
|
||||
}
|
||||
|
||||
static bool draw_rect(SDL_Renderer* renderer, const SDL_Rect* rect, SDL_Color color)
|
||||
static bool draw_rect(SDL_Renderer* renderer, const SDL_FRect* rect, SDL_Color color)
|
||||
{
|
||||
const int drc = SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
|
||||
if (widget_log_error(drc, "SDL_SetRenderDrawColor"))
|
||||
@ -228,7 +232,7 @@ bool SdlWidget::set_wrap(bool wrap, size_t width)
|
||||
return _wrap;
|
||||
}
|
||||
|
||||
const SDL_Rect& SdlWidget::rect() const
|
||||
const SDL_FRect& SdlWidget::rect() const
|
||||
{
|
||||
return _rect;
|
||||
}
|
||||
@ -239,15 +243,19 @@ bool SdlWidget::update_text(SDL_Renderer* renderer, const std::string& text, SDL
|
||||
if (text.empty())
|
||||
return true;
|
||||
|
||||
SDL_Rect src{};
|
||||
SDL_Rect dst{};
|
||||
SDL_FRect src{};
|
||||
SDL_FRect dst{};
|
||||
|
||||
SDL_Texture* texture = nullptr;
|
||||
if (_image)
|
||||
{
|
||||
texture = _image;
|
||||
dst = _rect;
|
||||
auto rc = SDL_QueryTexture(_image, nullptr, nullptr, &src.w, &src.h);
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
auto rc = SDL_QueryTexture(_image, nullptr, nullptr, &w, &h);
|
||||
src.w = w;
|
||||
src.h = h;
|
||||
if (rc < 0)
|
||||
widget_log_error(rc, "SDL_QueryTexture");
|
||||
}
|
||||
@ -258,7 +266,7 @@ bool SdlWidget::update_text(SDL_Renderer* renderer, const std::string& text, SDL
|
||||
if (!texture)
|
||||
return false;
|
||||
|
||||
const int rc = SDL_RenderCopy(renderer, texture, &src, &dst);
|
||||
const int rc = SDL_RenderTexture(renderer, texture, &src, &dst);
|
||||
if (!_image)
|
||||
SDL_DestroyTexture(texture);
|
||||
if (rc < 0)
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include <string>
|
||||
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <BaseTsd.h>
|
||||
@ -48,8 +48,8 @@ typedef SSIZE_T ssize_t;
|
||||
class SdlWidget
|
||||
{
|
||||
public:
|
||||
SdlWidget(SDL_Renderer* renderer, const SDL_Rect& rect, bool input);
|
||||
SdlWidget(SDL_Renderer* renderer, const SDL_Rect& rect, SDL_RWops* ops);
|
||||
SdlWidget(SDL_Renderer* renderer, const SDL_FRect& rect, bool input);
|
||||
SdlWidget(SDL_Renderer* renderer, const SDL_FRect& rect, SDL_IOStream* ops);
|
||||
SdlWidget(SdlWidget&& other) noexcept;
|
||||
virtual ~SdlWidget();
|
||||
|
||||
@ -61,7 +61,7 @@ class SdlWidget
|
||||
|
||||
bool wrap() const;
|
||||
bool set_wrap(bool wrap = true, size_t width = 0);
|
||||
const SDL_Rect& rect() const;
|
||||
const SDL_FRect& rect() const;
|
||||
|
||||
public:
|
||||
#define widget_log_error(res, what) SdlWidget::error_ex(res, what, __FILE__, __LINE__, __func__)
|
||||
@ -72,14 +72,14 @@ class SdlWidget
|
||||
SdlWidget(const SdlWidget& other) = delete;
|
||||
|
||||
SDL_Texture* render_text(SDL_Renderer* renderer, const std::string& text, SDL_Color fgcolor,
|
||||
SDL_Rect& src, SDL_Rect& dst);
|
||||
SDL_FRect& src, SDL_FRect& dst);
|
||||
SDL_Texture* render_text_wrapped(SDL_Renderer* renderer, const std::string& text,
|
||||
SDL_Color fgcolor, SDL_Rect& src, SDL_Rect& dst);
|
||||
SDL_Color fgcolor, SDL_FRect& src, SDL_FRect& dst);
|
||||
|
||||
private:
|
||||
TTF_Font* _font = nullptr;
|
||||
SDL_Texture* _image = nullptr;
|
||||
SDL_Rect _rect;
|
||||
SDL_FRect _rect;
|
||||
bool _input = false;
|
||||
bool _wrap = false;
|
||||
size_t _text_width = 0;
|
||||
|
@ -3,9 +3,9 @@
|
||||
PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||
<!ENTITY syntax SYSTEM "freerdp-argument.1.xml">
|
||||
<!ENTITY config SYSTEM "sdl-freerdp-config.1.xml">
|
||||
<!ENTITY envvar SYSTEM "sdl-freerdp-envvar.1.xml">
|
||||
<!ENTITY examples SYSTEM "sdl-freerdp-examples.1.xml">
|
||||
<!ENTITY config SYSTEM "sdl3-freerdp-config.1.xml">
|
||||
<!ENTITY envvar SYSTEM "sdl3-freerdp-envvar.1.xml">
|
||||
<!ENTITY examples SYSTEM "sdl3-freerdp-examples.1.xml">
|
||||
]
|
||||
>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "sdl_disp.hpp"
|
||||
#include "sdl_kbd.hpp"
|
||||
@ -310,29 +310,25 @@ BOOL sdlDispContext::addTimer()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||
BOOL sdlDispContext::handle_display_event(const SDL_DisplayEvent* ev)
|
||||
{
|
||||
WINPR_ASSERT(ev);
|
||||
|
||||
switch (ev->event)
|
||||
switch (ev->type)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||
case SDL_DISPLAYEVENT_CONNECTED:
|
||||
SDL_Log("A new display with id %d was connected", ev->display);
|
||||
case SDL_EVENT_DISPLAY_ADDED:
|
||||
SDL_Log("A new display with id %d was connected", ev->displayID);
|
||||
return TRUE;
|
||||
case SDL_DISPLAYEVENT_DISCONNECTED:
|
||||
SDL_Log("The display with id %d was disconnected", ev->display);
|
||||
case SDL_EVENT_DISPLAY_REMOVED:
|
||||
SDL_Log("The display with id %d was disconnected", ev->displayID);
|
||||
return TRUE;
|
||||
#endif
|
||||
case SDL_DISPLAYEVENT_ORIENTATION:
|
||||
SDL_Log("The orientation of display with id %d was changed", ev->display);
|
||||
case SDL_EVENT_DISPLAY_ORIENTATION:
|
||||
SDL_Log("The orientation of display with id %d was changed", ev->displayID);
|
||||
return TRUE;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOL sdlDispContext::handle_window_event(const SDL_WindowEvent* ev)
|
||||
{
|
||||
@ -346,37 +342,37 @@ BOOL sdlDispContext::handle_window_event(const SDL_WindowEvent* ev)
|
||||
if (it != _sdl->windows.end())
|
||||
it->second.setBordered(bordered);
|
||||
|
||||
switch (ev->event)
|
||||
switch (ev->type)
|
||||
{
|
||||
case SDL_WINDOWEVENT_HIDDEN:
|
||||
case SDL_WINDOWEVENT_MINIMIZED:
|
||||
case SDL_EVENT_WINDOW_HIDDEN:
|
||||
case SDL_EVENT_WINDOW_MINIMIZED:
|
||||
gdi_send_suppress_output(_sdl->context()->gdi, TRUE);
|
||||
|
||||
return TRUE;
|
||||
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
case SDL_WINDOWEVENT_SHOWN:
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
case SDL_EVENT_WINDOW_EXPOSED:
|
||||
case SDL_EVENT_WINDOW_SHOWN:
|
||||
case SDL_EVENT_WINDOW_MAXIMIZED:
|
||||
case SDL_EVENT_WINDOW_RESTORED:
|
||||
gdi_send_suppress_output(_sdl->context()->gdi, FALSE);
|
||||
return TRUE;
|
||||
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
_targetWidth = ev->data1;
|
||||
_targetHeight = ev->data2;
|
||||
return addTimer();
|
||||
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
WINPR_ASSERT(_sdl);
|
||||
_sdl->input.keyboard_grab(ev->windowID, SDL_FALSE);
|
||||
return TRUE;
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
WINPR_ASSERT(_sdl);
|
||||
_sdl->input.keyboard_grab(ev->windowID, SDL_TRUE);
|
||||
return _sdl->input.keyboard_focus_in();
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||
case SDL_EVENT_WINDOW_TAKE_FOCUS:
|
||||
return _sdl->input.keyboard_focus_in();
|
||||
|
||||
default:
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "sdl_types.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
class sdlDispContext
|
||||
{
|
||||
@ -36,9 +36,7 @@ class sdlDispContext
|
||||
BOOL init(DispClientContext* disp);
|
||||
BOOL uninit(DispClientContext* disp);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||
BOOL handle_display_event(const SDL_DisplayEvent* ev);
|
||||
#endif
|
||||
|
||||
BOOL handle_window_event(const SDL_WindowEvent* ev);
|
||||
|
||||
|
@ -45,9 +45,9 @@
|
||||
#include <winpr/synch.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_hints.h>
|
||||
#include <SDL_video.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_hints.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
|
||||
#include "sdl_channels.hpp"
|
||||
#include "sdl_freerdp.hpp"
|
||||
@ -465,7 +465,7 @@ static BOOL sdl_end_paint(rdpContext* context)
|
||||
WINPR_ASSERT(sdl);
|
||||
|
||||
std::lock_guard<CriticalSection> lock(sdl->critical);
|
||||
const BOOL rc = sdl_push_user_event(SDL_USEREVENT_UPDATE, context);
|
||||
const BOOL rc = sdl_push_user_event(SDL_EVENT_USER_UPDATE, context);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -489,19 +489,19 @@ static BOOL sdl_create_primary(SdlContext* sdl)
|
||||
WINPR_ASSERT(gdi);
|
||||
|
||||
sdl_destroy_primary(sdl);
|
||||
sdl->primary = SDLSurfacePtr(
|
||||
SDL_CreateRGBSurfaceWithFormatFrom(gdi->primary_buffer, static_cast<int>(gdi->width),
|
||||
sdl->primary =
|
||||
SDLSurfacePtr(SDL_CreateSurfaceFrom(gdi->primary_buffer, static_cast<int>(gdi->width),
|
||||
static_cast<int>(gdi->height),
|
||||
static_cast<int>(FreeRDPGetBitsPerPixel(gdi->dstFormat)),
|
||||
static_cast<int>(gdi->stride), sdl->sdl_pixel_format),
|
||||
SDL_FreeSurface);
|
||||
sdl->primary_format = SDLPixelFormatPtr(SDL_AllocFormat(sdl->sdl_pixel_format), SDL_FreeFormat);
|
||||
SDL_DestroySurface);
|
||||
sdl->primary_format =
|
||||
SDLPixelFormatPtr(SDL_CreatePixelFormat(sdl->sdl_pixel_format), SDL_DestroyPixelFormat);
|
||||
|
||||
if (!sdl->primary || !sdl->primary_format)
|
||||
return FALSE;
|
||||
|
||||
SDL_SetSurfaceBlendMode(sdl->primary.get(), SDL_BLENDMODE_NONE);
|
||||
SDL_FillRect(sdl->primary.get(), nullptr,
|
||||
SDL_FillSurfaceRect(sdl->primary.get(), nullptr,
|
||||
SDL_MapRGBA(sdl->primary_format.get(), 0, 0, 0, 0xff));
|
||||
|
||||
return TRUE;
|
||||
@ -706,15 +706,13 @@ static BOOL sdl_create_windows(SdlContext* sdl)
|
||||
h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
||||
}
|
||||
|
||||
Uint32 flags = SDL_WINDOW_SHOWN;
|
||||
Uint32 flags = 0;
|
||||
Uint32 startupX = SDL_WINDOWPOS_CENTERED_DISPLAY(x);
|
||||
Uint32 startupY = SDL_WINDOWPOS_CENTERED_DISPLAY(x);
|
||||
|
||||
if (monitor->attributes.desktopScaleFactor > 100)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 1)
|
||||
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
#endif
|
||||
flags |= SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
}
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) &&
|
||||
@ -761,7 +759,7 @@ static BOOL sdl_wait_create_windows(SdlContext* sdl)
|
||||
{
|
||||
std::lock_guard<CriticalSection> lock(sdl->critical);
|
||||
sdl->windows_created.clear();
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_CREATE_WINDOWS, sdl))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_CREATE_WINDOWS, sdl))
|
||||
return FALSE;
|
||||
|
||||
HANDLE handles[] = { sdl->initialized.handle(), freerdp_abort_event(sdl->context()) };
|
||||
@ -805,12 +803,8 @@ static int sdl_run(SdlContext* sdl)
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
TTF_Init();
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||
SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, "0");
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 8)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
||||
#endif
|
||||
|
||||
freerdp_add_signal_cleanup_handler(sdl->context(), sdl_term_handler);
|
||||
|
||||
@ -821,11 +815,11 @@ static int sdl_run(SdlContext* sdl)
|
||||
SDL_Event windowEvent = { 0 };
|
||||
while (!shall_abort(sdl) && SDL_WaitEventTimeout(nullptr, 1000))
|
||||
{
|
||||
/* Only poll standard SDL events and SDL_USEREVENTS meant to create dialogs.
|
||||
/* 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_FIRSTEVENT,
|
||||
SDL_USEREVENT_RETRY_DIALOG);
|
||||
const int prc = SDL_PeepEvents(&windowEvent, 1, SDL_GETEVENT, SDL_EVENT_FIRST,
|
||||
SDL_EVENT_USER_RETRY_DIALOG);
|
||||
if (prc < 0)
|
||||
{
|
||||
if (sdl_log_error(prc, sdl->log, "SDL_PeepEvents"))
|
||||
@ -852,147 +846,105 @@ static int sdl_run(SdlContext* sdl)
|
||||
|
||||
switch (windowEvent.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
case SDL_EVENT_QUIT:
|
||||
freerdp_abort_connect_context(sdl->context());
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
{
|
||||
const SDL_KeyboardEvent* ev = &windowEvent.key;
|
||||
sdl->input.keyboard_handle_event(ev);
|
||||
}
|
||||
break;
|
||||
case SDL_KEYMAPCHANGED:
|
||||
case SDL_EVENT_KEYMAP_CHANGED:
|
||||
{
|
||||
}
|
||||
break; // TODO: Switch keyboard layout
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
{
|
||||
const SDL_MouseMotionEvent* ev = &windowEvent.motion;
|
||||
sdl_handle_mouse_motion(sdl, ev);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
{
|
||||
const SDL_MouseButtonEvent* ev = &windowEvent.button;
|
||||
sdl_handle_mouse_button(sdl, ev);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
{
|
||||
const SDL_MouseWheelEvent* ev = &windowEvent.wheel;
|
||||
sdl_handle_mouse_wheel(sdl, ev);
|
||||
}
|
||||
break;
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_EVENT_FINGER_DOWN:
|
||||
{
|
||||
const SDL_TouchFingerEvent* ev = &windowEvent.tfinger;
|
||||
sdl_handle_touch_down(sdl, ev);
|
||||
}
|
||||
break;
|
||||
case SDL_FINGERUP:
|
||||
case SDL_EVENT_FINGER_UP:
|
||||
{
|
||||
const SDL_TouchFingerEvent* ev = &windowEvent.tfinger;
|
||||
sdl_handle_touch_up(sdl, ev);
|
||||
}
|
||||
break;
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_EVENT_FINGER_MOTION:
|
||||
{
|
||||
const SDL_TouchFingerEvent* ev = &windowEvent.tfinger;
|
||||
sdl_handle_touch_motion(sdl, ev);
|
||||
}
|
||||
break;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||
case SDL_DISPLAYEVENT:
|
||||
{
|
||||
const SDL_DisplayEvent* ev = &windowEvent.display;
|
||||
sdl->disp.handle_display_event(ev);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
const SDL_WindowEvent* ev = &windowEvent.window;
|
||||
sdl->disp.handle_window_event(ev);
|
||||
|
||||
switch (ev->event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
auto window = sdl->windows.find(ev->windowID);
|
||||
if (window != sdl->windows.end())
|
||||
{
|
||||
window->second.fill();
|
||||
window->second.updateSurface();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
{
|
||||
auto window = sdl->windows.find(ev->windowID);
|
||||
if (window != sdl->windows.end())
|
||||
{
|
||||
auto r = window->second.rect();
|
||||
auto id = window->second.id();
|
||||
WLog_DBG(SDL_TAG, "%lu: %dx%d-%dx%d", id, r.x, r.y, r.w, r.h);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_RENDER_TARGETS_RESET:
|
||||
case SDL_EVENT_RENDER_TARGETS_RESET:
|
||||
sdl_redraw(sdl);
|
||||
break;
|
||||
case SDL_RENDER_DEVICE_RESET:
|
||||
case SDL_EVENT_RENDER_DEVICE_RESET:
|
||||
sdl_redraw(sdl);
|
||||
break;
|
||||
case SDL_APP_WILLENTERFOREGROUND:
|
||||
case SDL_EVENT_WILL_ENTER_FOREGROUND:
|
||||
sdl_redraw(sdl);
|
||||
break;
|
||||
case SDL_USEREVENT_CERT_DIALOG:
|
||||
case SDL_EVENT_USER_CERT_DIALOG:
|
||||
{
|
||||
auto title = static_cast<const char*>(windowEvent.user.data1);
|
||||
auto msg = static_cast<const char*>(windowEvent.user.data2);
|
||||
sdl_cert_dialog_show(title, msg);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_SHOW_DIALOG:
|
||||
case SDL_EVENT_USER_SHOW_DIALOG:
|
||||
{
|
||||
auto title = static_cast<const char*>(windowEvent.user.data1);
|
||||
auto msg = static_cast<const char*>(windowEvent.user.data2);
|
||||
sdl_message_dialog_show(title, msg, windowEvent.user.code);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_SCARD_DIALOG:
|
||||
case SDL_EVENT_USER_SCARD_DIALOG:
|
||||
{
|
||||
auto title = static_cast<const char*>(windowEvent.user.data1);
|
||||
auto msg = static_cast<const char**>(windowEvent.user.data2);
|
||||
sdl_scard_dialog_show(title, windowEvent.user.code, msg);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_AUTH_DIALOG:
|
||||
case SDL_EVENT_USER_AUTH_DIALOG:
|
||||
sdl_auth_dialog_show(
|
||||
reinterpret_cast<const SDL_UserAuthArg*>(windowEvent.padding));
|
||||
break;
|
||||
case SDL_USEREVENT_UPDATE:
|
||||
case SDL_EVENT_USER_UPDATE:
|
||||
{
|
||||
auto context = static_cast<rdpContext*>(windowEvent.user.data1);
|
||||
sdl_end_paint_process(context);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_CREATE_WINDOWS:
|
||||
case SDL_EVENT_USER_CREATE_WINDOWS:
|
||||
{
|
||||
auto ctx = static_cast<SdlContext*>(windowEvent.user.data1);
|
||||
sdl_create_windows(ctx);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_WINDOW_RESIZEABLE:
|
||||
case SDL_EVENT_USER_WINDOW_RESIZEABLE:
|
||||
{
|
||||
auto window = static_cast<SdlWindow*>(windowEvent.user.data1);
|
||||
const SDL_bool use = windowEvent.user.code != 0 ? SDL_TRUE : SDL_FALSE;
|
||||
@ -1000,7 +952,7 @@ static int sdl_run(SdlContext* sdl)
|
||||
window->resizeable(use);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_WINDOW_FULLSCREEN:
|
||||
case SDL_EVENT_USER_WINDOW_FULLSCREEN:
|
||||
{
|
||||
auto window = static_cast<SdlWindow*>(windowEvent.user.data1);
|
||||
const SDL_bool enter = windowEvent.user.code != 0 ? SDL_TRUE : SDL_FALSE;
|
||||
@ -1008,17 +960,17 @@ static int sdl_run(SdlContext* sdl)
|
||||
window->fullscreen(enter);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_POINTER_NULL:
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
case SDL_EVENT_USER_POINTER_NULL:
|
||||
SDL_HideCursor();
|
||||
break;
|
||||
case SDL_USEREVENT_POINTER_DEFAULT:
|
||||
case SDL_EVENT_USER_POINTER_DEFAULT:
|
||||
{
|
||||
SDL_Cursor* def = SDL_GetDefaultCursor();
|
||||
SDL_SetCursor(def);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_ShowCursor();
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_POINTER_POSITION:
|
||||
case SDL_EVENT_USER_POINTER_POSITION:
|
||||
{
|
||||
const auto x =
|
||||
static_cast<INT32>(reinterpret_cast<uintptr_t>(windowEvent.user.data1));
|
||||
@ -1037,11 +989,51 @@ static int sdl_run(SdlContext* sdl)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_POINTER_SET:
|
||||
case SDL_EVENT_USER_POINTER_SET:
|
||||
sdl_Pointer_Set_Process(&windowEvent.user);
|
||||
break;
|
||||
case SDL_USEREVENT_QUIT:
|
||||
case SDL_EVENT_USER_QUIT:
|
||||
default:
|
||||
if ((windowEvent.type >= SDL_EVENT_DISPLAY_FIRST) &&
|
||||
(windowEvent.type <= SDL_EVENT_DISPLAY_LAST))
|
||||
{
|
||||
const SDL_DisplayEvent* ev = &windowEvent.display;
|
||||
sdl->disp.handle_display_event(ev);
|
||||
}
|
||||
else if ((windowEvent.type >= SDL_EVENT_WINDOW_FIRST) &&
|
||||
(windowEvent.type <= SDL_EVENT_WINDOW_LAST))
|
||||
{
|
||||
const SDL_WindowEvent* ev = &windowEvent.window;
|
||||
sdl->disp.handle_window_event(ev);
|
||||
|
||||
switch (ev->type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
{
|
||||
auto window = sdl->windows.find(ev->windowID);
|
||||
if (window != sdl->windows.end())
|
||||
{
|
||||
window->second.fill();
|
||||
window->second.updateSurface();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_MOVED:
|
||||
{
|
||||
auto window = sdl->windows.find(ev->windowID);
|
||||
if (window != sdl->windows.end())
|
||||
{
|
||||
auto r = window->second.rect();
|
||||
auto id = window->second.id();
|
||||
WLog_DBG(SDL_TAG, "%lu: %dx%d-%dx%d", id, r.x, r.y, r.w, r.h);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1311,10 +1303,8 @@ terminate:
|
||||
}
|
||||
free(error_msg);
|
||||
sdl->exit_code = exit_code;
|
||||
sdl_push_user_event(SDL_USEREVENT_QUIT);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||
SDL_TLSCleanup();
|
||||
#endif
|
||||
sdl_push_user_event(SDL_EVENT_USER_QUIT);
|
||||
SDL_CleanupTLS();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1635,7 +1625,7 @@ int main(int argc, char* argv[])
|
||||
return rc;
|
||||
}
|
||||
|
||||
SDL_LogSetOutputFunction(winpr_LogOutputFunction, sdl);
|
||||
SDL_SetLogOutputFunction(winpr_LogOutputFunction, sdl);
|
||||
auto level = WLog_GetLogLevel(sdl->log);
|
||||
SDL_LogSetAllPriority(wloglevel2dl(level));
|
||||
|
||||
@ -1663,7 +1653,7 @@ BOOL SdlContext::update_fullscreen(BOOL enter)
|
||||
std::lock_guard<CriticalSection> lock(critical);
|
||||
for (const auto& window : windows)
|
||||
{
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_FULLSCREEN, &window.second, enter))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_WINDOW_FULLSCREEN, &window.second, enter))
|
||||
return FALSE;
|
||||
}
|
||||
fullscreen = enter;
|
||||
@ -1681,7 +1671,7 @@ BOOL SdlContext::update_resizeable(BOOL enable)
|
||||
|
||||
for (const auto& window : windows)
|
||||
{
|
||||
if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_RESIZEABLE, &window.second, use))
|
||||
if (!sdl_push_user_event(SDL_EVENT_USER_WINDOW_RESIZEABLE, &window.second, use))
|
||||
return FALSE;
|
||||
}
|
||||
resizeable = use;
|
||||
@ -1691,7 +1681,7 @@ BOOL SdlContext::update_resizeable(BOOL enable)
|
||||
|
||||
SdlContext::SdlContext(rdpContext* context)
|
||||
: _context(context), log(WLog_Get(SDL_TAG)), update_complete(true), disp(this), input(this),
|
||||
primary(nullptr, SDL_FreeSurface), primary_format(nullptr, SDL_FreeFormat)
|
||||
primary(nullptr, SDL_DestroySurface), primary_format(nullptr, SDL_DestroyPixelFormat)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <freerdp/client/cliprdr.h>
|
||||
#include <freerdp/client/rdpgfx.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
|
||||
#include "sdl_types.hpp"
|
||||
#include "sdl_disp.hpp"
|
||||
@ -39,8 +39,8 @@
|
||||
#include "sdl_window.hpp"
|
||||
#include "dialogs/sdl_connection_dialog.hpp"
|
||||
|
||||
using SDLSurfacePtr = std::unique_ptr<SDL_Surface, decltype(&SDL_FreeSurface)>;
|
||||
using SDLPixelFormatPtr = std::unique_ptr<SDL_PixelFormat, decltype(&SDL_FreeFormat)>;
|
||||
using SDLSurfacePtr = std::unique_ptr<SDL_Surface, decltype(&SDL_DestroySurface)>;
|
||||
using SDLPixelFormatPtr = std::unique_ptr<SDL_PixelFormat, decltype(&SDL_DestroyPixelFormat)>;
|
||||
|
||||
class SdlContext
|
||||
{
|
||||
@ -75,7 +75,7 @@ class SdlContext
|
||||
SDLSurfacePtr primary;
|
||||
SDLPixelFormatPtr primary_format;
|
||||
|
||||
Uint32 sdl_pixel_format = 0;
|
||||
SDL_PixelFormatEnum sdl_pixel_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
|
||||
std::unique_ptr<SDLConnectionDialog> connection_dialog;
|
||||
|
||||
|
@ -297,14 +297,12 @@ static UINT32 sdl_get_kbd_flags(void)
|
||||
UINT32 flags = 0;
|
||||
|
||||
SDL_Keymod mod = SDL_GetModState();
|
||||
if ((mod & KMOD_NUM) != 0)
|
||||
if ((mod & SDL_KMOD_NUM) != 0)
|
||||
flags |= KBD_SYNC_NUM_LOCK;
|
||||
if ((mod & KMOD_CAPS) != 0)
|
||||
if ((mod & SDL_KMOD_CAPS) != 0)
|
||||
flags |= KBD_SYNC_CAPS_LOCK;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
if ((mod & KMOD_SCROLL) != 0)
|
||||
if ((mod & SDL_KMOD_SCROLL) != 0)
|
||||
flags |= KBD_SYNC_SCROLL_LOCK;
|
||||
#endif
|
||||
|
||||
// TODO: KBD_SYNC_KANA_LOCK
|
||||
|
||||
@ -347,16 +345,14 @@ BOOL sdlInput::keyboard_set_indicators(rdpContext* context, UINT16 led_flags)
|
||||
{
|
||||
WINPR_UNUSED(context);
|
||||
|
||||
int state = KMOD_NONE;
|
||||
int state = SDL_KMOD_NONE;
|
||||
|
||||
if ((led_flags & KBD_SYNC_NUM_LOCK) != 0)
|
||||
state |= KMOD_NUM;
|
||||
state |= SDL_KMOD_NUM;
|
||||
if ((led_flags & KBD_SYNC_CAPS_LOCK) != 0)
|
||||
state |= KMOD_CAPS;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
state |= SDL_KMOD_CAPS;
|
||||
if ((led_flags & KBD_SYNC_SCROLL_LOCK) != 0)
|
||||
state |= KMOD_SCROLL;
|
||||
#endif
|
||||
state |= SDL_KMOD_SCROLL;
|
||||
|
||||
// TODO: KBD_SYNC_KANA_LOCK
|
||||
|
||||
@ -382,26 +378,16 @@ BOOL sdlInput::keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32
|
||||
uint32_t sdlInput::prefToMask()
|
||||
{
|
||||
const std::map<std::string, uint32_t> mapping = {
|
||||
{ "KMOD_LSHIFT", KMOD_LSHIFT },
|
||||
{ "KMOD_RSHIFT", KMOD_RSHIFT },
|
||||
{ "KMOD_LCTRL", KMOD_LCTRL },
|
||||
{ "KMOD_RCTRL", KMOD_RCTRL },
|
||||
{ "KMOD_LALT", KMOD_LALT },
|
||||
{ "KMOD_RALT", KMOD_RALT },
|
||||
{ "KMOD_LGUI", KMOD_LGUI },
|
||||
{ "KMOD_RGUI", KMOD_RGUI },
|
||||
{ "KMOD_NUM", KMOD_NUM },
|
||||
{ "KMOD_CAPS", KMOD_CAPS },
|
||||
{ "KMOD_MODE", KMOD_MODE },
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
{ "KMOD_SCROLL", KMOD_SCROLL },
|
||||
#endif
|
||||
{ "KMOD_CTRL", KMOD_CTRL },
|
||||
{ "KMOD_SHIFT", KMOD_SHIFT },
|
||||
{ "KMOD_ALT", KMOD_ALT },
|
||||
{ "KMOD_GUI", KMOD_GUI }
|
||||
{ "KMOD_LSHIFT", SDL_KMOD_LSHIFT }, { "KMOD_RSHIFT", SDL_KMOD_RSHIFT },
|
||||
{ "KMOD_LCTRL", SDL_KMOD_LCTRL }, { "KMOD_RCTRL", SDL_KMOD_RCTRL },
|
||||
{ "KMOD_LALT", SDL_KMOD_LALT }, { "KMOD_RALT", SDL_KMOD_RALT },
|
||||
{ "KMOD_LGUI", SDL_KMOD_LGUI }, { "KMOD_RGUI", SDL_KMOD_RGUI },
|
||||
{ "KMOD_NUM", SDL_KMOD_NUM }, { "KMOD_CAPS", SDL_KMOD_CAPS },
|
||||
{ "KMOD_MODE", SDL_KMOD_MODE }, { "KMOD_SCROLL", SDL_KMOD_SCROLL },
|
||||
{ "KMOD_CTRL", SDL_KMOD_CTRL }, { "KMOD_SHIFT", SDL_KMOD_SHIFT },
|
||||
{ "KMOD_ALT", SDL_KMOD_ALT }, { "KMOD_GUI", SDL_KMOD_GUI }
|
||||
};
|
||||
uint32_t mod = KMOD_NONE;
|
||||
uint32_t mod = SDL_KMOD_NONE;
|
||||
for (const auto& val : SdlPref::instance()->get_array("SDL_KeyModMask", { "KMOD_RSHIFT" }))
|
||||
{
|
||||
auto it = mapping.find(val);
|
||||
@ -562,7 +548,7 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev)
|
||||
|
||||
if ((mods & mask) == mask)
|
||||
{
|
||||
if (ev->type == SDL_KEYDOWN)
|
||||
if (ev->type == SDL_EVENT_KEY_DOWN)
|
||||
{
|
||||
if (ev->keysym.scancode == valFullscreen)
|
||||
{
|
||||
@ -589,8 +575,8 @@ 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, scancode);
|
||||
return freerdp_input_send_keyboard_event_ex(
|
||||
_sdl->context()->input, ev->type == SDL_EVENT_KEY_DOWN, ev->repeat, scancode);
|
||||
}
|
||||
|
||||
BOOL sdlInput::keyboard_grab(Uint32 windowID, SDL_bool enable)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <winpr/wtypes.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "sdl_types.hpp"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/crt.h>
|
||||
@ -58,21 +58,24 @@ typedef struct
|
||||
int sdl_list_monitors(SdlContext* sdl)
|
||||
{
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
const int nmonitors = SDL_GetNumVideoDisplays();
|
||||
|
||||
int nmonitors = 0;
|
||||
auto ids = SDL_GetDisplays(&nmonitors);
|
||||
|
||||
printf("listing %d monitors:\n", nmonitors);
|
||||
for (int i = 0; i < nmonitors; i++)
|
||||
{
|
||||
SDL_Rect rect = {};
|
||||
const int brc = SDL_GetDisplayBounds(i, &rect);
|
||||
const char* name = SDL_GetDisplayName(i);
|
||||
auto id = ids[i];
|
||||
const int brc = SDL_GetDisplayBounds(id, &rect);
|
||||
const char* name = SDL_GetDisplayName(id);
|
||||
|
||||
if (brc != 0)
|
||||
continue;
|
||||
printf(" %s [%d] [%s] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", i, name, rect.w, rect.h,
|
||||
printf(" %s [%d] [%s] %dx%d\t+%d+%d\n", (i == 0) ? "*" : " ", id, name, rect.w, rect.h,
|
||||
rect.x, rect.y);
|
||||
}
|
||||
|
||||
SDL_free(ids);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
@ -156,7 +159,6 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||
static UINT32 sdl_orientaion_to_rdp(SDL_DisplayOrientation orientation)
|
||||
{
|
||||
switch (orientation)
|
||||
@ -172,7 +174,6 @@ static UINT32 sdl_orientaion_to_rdp(SDL_DisplayOrientation orientation)
|
||||
return ORIENTATION_PORTRAIT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOL sdl_apply_display_properties(SdlContext* sdl)
|
||||
{
|
||||
@ -193,24 +194,18 @@ static BOOL sdl_apply_display_properties(SdlContext* sdl)
|
||||
freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, x));
|
||||
WINPR_ASSERT(id);
|
||||
|
||||
float ddpi = 1.0f;
|
||||
float hdpi = 1.0f;
|
||||
float vdpi = 1.0f;
|
||||
float dpi = SDL_GetDisplayContentScale(*id);
|
||||
float hdpi = dpi;
|
||||
float vdpi = dpi;
|
||||
SDL_Rect rect = {};
|
||||
|
||||
if (SDL_GetDisplayBounds(*id, &rect) < 0)
|
||||
return FALSE;
|
||||
|
||||
if (SDL_GetDisplayDPI(*id, &ddpi, &hdpi, &vdpi) < 0)
|
||||
return FALSE;
|
||||
|
||||
WINPR_ASSERT(rect.w > 0);
|
||||
WINPR_ASSERT(rect.h > 0);
|
||||
WINPR_ASSERT(ddpi > 0);
|
||||
WINPR_ASSERT(hdpi > 0);
|
||||
WINPR_ASSERT(vdpi > 0);
|
||||
|
||||
bool highDpi = hdpi > 100;
|
||||
bool highDpi = dpi > 100;
|
||||
|
||||
if (highDpi)
|
||||
{
|
||||
@ -218,25 +213,29 @@ static BOOL sdl_apply_display_properties(SdlContext* sdl)
|
||||
// window. Work around this by checking the supported resolutions (and keep maximum)
|
||||
// Also scale the DPI
|
||||
const SDL_Rect scaleRect = rect;
|
||||
for (int i = 0; i < SDL_GetNumDisplayModes(*id); i++)
|
||||
int count = 0;
|
||||
auto modes = SDL_GetFullscreenDisplayModes(x, &count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
SDL_DisplayMode mode = {};
|
||||
SDL_GetDisplayMode(x, i, &mode);
|
||||
auto mode = modes[i];
|
||||
if (!mode)
|
||||
break;
|
||||
|
||||
if (mode.w > rect.w)
|
||||
if (mode->w > rect.w)
|
||||
{
|
||||
rect.w = mode.w;
|
||||
rect.h = mode.h;
|
||||
rect.w = mode->w;
|
||||
rect.h = mode->h;
|
||||
}
|
||||
else if (mode.w == rect.w)
|
||||
else if (mode->w == rect.w)
|
||||
{
|
||||
if (mode.h > rect.h)
|
||||
if (mode->h > rect.h)
|
||||
{
|
||||
rect.w = mode.w;
|
||||
rect.h = mode.h;
|
||||
rect.w = mode->w;
|
||||
rect.h = mode->h;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_free(modes);
|
||||
|
||||
const float dw = 1.0f * rect.w / scaleRect.w;
|
||||
const float dh = 1.0f * rect.h / scaleRect.h;
|
||||
@ -244,19 +243,15 @@ static BOOL sdl_apply_display_properties(SdlContext* sdl)
|
||||
vdpi /= dh;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||
const SDL_DisplayOrientation orientation = SDL_GetDisplayOrientation(*id);
|
||||
const SDL_DisplayOrientation orientation = SDL_GetCurrentDisplayOrientation(*id);
|
||||
const UINT32 rdp_orientation = sdl_orientaion_to_rdp(orientation);
|
||||
#else
|
||||
const UINT32 rdp_orientation = ORIENTATION_LANDSCAPE;
|
||||
#endif
|
||||
|
||||
auto monitor = static_cast<rdpMonitor*>(
|
||||
freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, x));
|
||||
WINPR_ASSERT(monitor);
|
||||
|
||||
/* windows uses 96 dpi as 'default' and the scale factors are in percent. */
|
||||
const auto factor = ddpi / 96.0f * 100.0f;
|
||||
const auto factor = dpi / 96.0f * 100.0f;
|
||||
monitor->orig_screen = x;
|
||||
monitor->x = rect.x;
|
||||
monitor->y = rect.y;
|
||||
@ -323,15 +318,25 @@ BOOL sdl_detect_monitors(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight)
|
||||
rdpSettings* settings = sdl->context()->settings;
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
const int numDisplays = SDL_GetNumVideoDisplays();
|
||||
int numDisplays = 0;
|
||||
auto ids = SDL_GetDisplays(&numDisplays);
|
||||
|
||||
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, nullptr, numDisplays))
|
||||
{
|
||||
SDL_free(ids);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (size_t x = 0; x < numDisplays; x++)
|
||||
{
|
||||
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_MonitorIds, x, &x))
|
||||
auto id = ids[x];
|
||||
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_MonitorIds, x, &id))
|
||||
{
|
||||
SDL_free(ids);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
SDL_free(ids);
|
||||
|
||||
if (!sdl_apply_display_properties(sdl))
|
||||
return FALSE;
|
||||
|
@ -72,8 +72,8 @@ static BOOL sdl_Pointer_New(rdpContext* context, rdpPointer* pointer)
|
||||
static void sdl_Pointer_Clear(sdlPointer* ptr)
|
||||
{
|
||||
WINPR_ASSERT(ptr);
|
||||
SDL_FreeCursor(ptr->cursor);
|
||||
SDL_FreeSurface(ptr->image);
|
||||
SDL_DestroyCursor(ptr->cursor);
|
||||
SDL_DestroySurface(ptr->image);
|
||||
ptr->cursor = nullptr;
|
||||
ptr->image = nullptr;
|
||||
}
|
||||
@ -95,14 +95,14 @@ static BOOL sdl_Pointer_SetDefault(rdpContext* context)
|
||||
{
|
||||
WINPR_UNUSED(context);
|
||||
|
||||
return sdl_push_user_event(SDL_USEREVENT_POINTER_DEFAULT);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_POINTER_DEFAULT);
|
||||
}
|
||||
|
||||
static BOOL sdl_Pointer_Set(rdpContext* context, rdpPointer* pointer)
|
||||
{
|
||||
auto sdl = get_context(context);
|
||||
|
||||
return sdl_push_user_event(SDL_USEREVENT_POINTER_SET, pointer, sdl);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_POINTER_SET, pointer, sdl);
|
||||
}
|
||||
|
||||
BOOL sdl_Pointer_Set_Process(SDL_UserEvent* uptr)
|
||||
@ -145,9 +145,7 @@ BOOL sdl_Pointer_Set_Process(SDL_UserEvent* uptr)
|
||||
|
||||
sdl_Pointer_Clear(ptr);
|
||||
|
||||
const DWORD bpp = FreeRDPGetBitsPerPixel(gdi->dstFormat);
|
||||
ptr->image =
|
||||
SDL_CreateRGBSurfaceWithFormat(0, sw, sh, static_cast<int>(bpp), sdl->sdl_pixel_format);
|
||||
ptr->image = SDL_CreateSurface(sw, sh, sdl->sdl_pixel_format);
|
||||
if (!ptr->image)
|
||||
return FALSE;
|
||||
|
||||
@ -167,7 +165,7 @@ BOOL sdl_Pointer_Set_Process(SDL_UserEvent* uptr)
|
||||
return FALSE;
|
||||
|
||||
SDL_SetCursor(ptr->cursor);
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
SDL_ShowCursor();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -175,7 +173,7 @@ static BOOL sdl_Pointer_SetNull(rdpContext* context)
|
||||
{
|
||||
WINPR_UNUSED(context);
|
||||
|
||||
return sdl_push_user_event(SDL_USEREVENT_POINTER_NULL);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_POINTER_NULL);
|
||||
}
|
||||
|
||||
static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
|
||||
@ -183,7 +181,7 @@ static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
|
||||
auto sdl = get_context(context);
|
||||
WINPR_ASSERT(sdl);
|
||||
|
||||
return sdl_push_user_event(SDL_USEREVENT_POINTER_POSITION, x, y);
|
||||
return sdl_push_user_event(SDL_EVENT_USER_POINTER_POSITION, x, y);
|
||||
}
|
||||
|
||||
BOOL sdl_register_pointer(rdpGraphics* graphics)
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <freerdp/graphics.h>
|
||||
|
||||
BOOL sdl_register_pointer(rdpGraphics* graphics);
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#define TAG CLIENT_TAG("SDL.touch")
|
||||
|
||||
@ -104,11 +104,7 @@ static BOOL sdl_get_touch_scaled(SdlContext* sdl, const SDL_TouchFingerEvent* ev
|
||||
WINPR_ASSERT(px);
|
||||
WINPR_ASSERT(py);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 12)
|
||||
SDL_Window* window = SDL_GetWindowFromID(ev->windowID);
|
||||
#else
|
||||
SDL_Window* window = SDL_GetMouseFocus();
|
||||
#endif
|
||||
|
||||
if (!window)
|
||||
return FALSE;
|
||||
@ -168,7 +164,7 @@ BOOL sdl_handle_touch_up(SdlContext* sdl, const SDL_TouchFingerEvent* ev)
|
||||
if (!sdl_get_touch_scaled(sdl, ev, &x, &y, TRUE))
|
||||
return FALSE;
|
||||
return freerdp_client_handle_touch(sdl->common(), FREERDP_TOUCH_UP | FREERDP_TOUCH_HAS_PRESSURE,
|
||||
static_cast<INT32>(ev->fingerId),
|
||||
static_cast<INT32>(ev->fingerID),
|
||||
sdl_scale_pressure(ev->pressure), x, y);
|
||||
}
|
||||
|
||||
@ -183,7 +179,7 @@ BOOL sdl_handle_touch_down(SdlContext* sdl, const SDL_TouchFingerEvent* ev)
|
||||
return FALSE;
|
||||
return freerdp_client_handle_touch(
|
||||
sdl->common(), FREERDP_TOUCH_DOWN | FREERDP_TOUCH_HAS_PRESSURE,
|
||||
static_cast<INT32>(ev->fingerId), sdl_scale_pressure(ev->pressure), x, y);
|
||||
static_cast<INT32>(ev->fingerID), sdl_scale_pressure(ev->pressure), x, y);
|
||||
}
|
||||
|
||||
BOOL sdl_handle_touch_motion(SdlContext* sdl, const SDL_TouchFingerEvent* ev)
|
||||
@ -197,7 +193,7 @@ BOOL sdl_handle_touch_motion(SdlContext* sdl, const SDL_TouchFingerEvent* ev)
|
||||
return FALSE;
|
||||
return freerdp_client_handle_touch(
|
||||
sdl->common(), FREERDP_TOUCH_MOTION | FREERDP_TOUCH_HAS_PRESSURE,
|
||||
static_cast<INT32>(ev->fingerId), sdl_scale_pressure(ev->pressure), x, y);
|
||||
static_cast<INT32>(ev->fingerID), sdl_scale_pressure(ev->pressure), x, y);
|
||||
}
|
||||
|
||||
BOOL sdl_handle_mouse_motion(SdlContext* sdl, const SDL_MouseMotionEvent* ev)
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "sdl_types.hpp"
|
||||
|
||||
BOOL sdl_scale_coordinates(SdlContext* sdl, Uint32 windowId, INT32* px, INT32* py,
|
||||
|
@ -22,106 +22,156 @@
|
||||
|
||||
#include "sdl_freerdp.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <freerdp/version.h>
|
||||
|
||||
const char* sdl_event_type_str(Uint32 type)
|
||||
{
|
||||
#define STR(x) #x
|
||||
#define EV_CASE_STR(x) \
|
||||
case x: \
|
||||
return STR(x)
|
||||
|
||||
const char* sdl_event_type_str(Uint32 type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
EV_CASE_STR(SDL_FIRSTEVENT);
|
||||
EV_CASE_STR(SDL_QUIT);
|
||||
EV_CASE_STR(SDL_APP_TERMINATING);
|
||||
EV_CASE_STR(SDL_APP_LOWMEMORY);
|
||||
EV_CASE_STR(SDL_APP_WILLENTERBACKGROUND);
|
||||
EV_CASE_STR(SDL_APP_DIDENTERBACKGROUND);
|
||||
EV_CASE_STR(SDL_APP_WILLENTERFOREGROUND);
|
||||
EV_CASE_STR(SDL_APP_DIDENTERFOREGROUND);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 10)
|
||||
EV_CASE_STR(SDL_DISPLAYEVENT);
|
||||
#endif
|
||||
EV_CASE_STR(SDL_WINDOWEVENT);
|
||||
EV_CASE_STR(SDL_SYSWMEVENT);
|
||||
EV_CASE_STR(SDL_KEYDOWN);
|
||||
EV_CASE_STR(SDL_KEYUP);
|
||||
EV_CASE_STR(SDL_TEXTEDITING);
|
||||
EV_CASE_STR(SDL_TEXTINPUT);
|
||||
EV_CASE_STR(SDL_KEYMAPCHANGED);
|
||||
EV_CASE_STR(SDL_MOUSEMOTION);
|
||||
EV_CASE_STR(SDL_MOUSEBUTTONDOWN);
|
||||
EV_CASE_STR(SDL_MOUSEBUTTONUP);
|
||||
EV_CASE_STR(SDL_MOUSEWHEEL);
|
||||
EV_CASE_STR(SDL_JOYAXISMOTION);
|
||||
EV_CASE_STR(SDL_JOYBALLMOTION);
|
||||
EV_CASE_STR(SDL_JOYHATMOTION);
|
||||
EV_CASE_STR(SDL_JOYBUTTONDOWN);
|
||||
EV_CASE_STR(SDL_JOYBUTTONUP);
|
||||
EV_CASE_STR(SDL_JOYDEVICEADDED);
|
||||
EV_CASE_STR(SDL_JOYDEVICEREMOVED);
|
||||
EV_CASE_STR(SDL_CONTROLLERAXISMOTION);
|
||||
EV_CASE_STR(SDL_CONTROLLERBUTTONDOWN);
|
||||
EV_CASE_STR(SDL_CONTROLLERBUTTONUP);
|
||||
EV_CASE_STR(SDL_CONTROLLERDEVICEADDED);
|
||||
EV_CASE_STR(SDL_CONTROLLERDEVICEREMOVED);
|
||||
EV_CASE_STR(SDL_CONTROLLERDEVICEREMAPPED);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||
EV_CASE_STR(SDL_LOCALECHANGED);
|
||||
EV_CASE_STR(SDL_CONTROLLERTOUCHPADDOWN);
|
||||
EV_CASE_STR(SDL_CONTROLLERTOUCHPADMOTION);
|
||||
EV_CASE_STR(SDL_CONTROLLERTOUCHPADUP);
|
||||
EV_CASE_STR(SDL_CONTROLLERSENSORUPDATE);
|
||||
#endif
|
||||
EV_CASE_STR(SDL_FINGERDOWN);
|
||||
EV_CASE_STR(SDL_FINGERUP);
|
||||
EV_CASE_STR(SDL_FINGERMOTION);
|
||||
EV_CASE_STR(SDL_DOLLARGESTURE);
|
||||
EV_CASE_STR(SDL_DOLLARRECORD);
|
||||
EV_CASE_STR(SDL_MULTIGESTURE);
|
||||
EV_CASE_STR(SDL_CLIPBOARDUPDATE);
|
||||
EV_CASE_STR(SDL_DROPFILE);
|
||||
EV_CASE_STR(SDL_DROPTEXT);
|
||||
EV_CASE_STR(SDL_DROPBEGIN);
|
||||
EV_CASE_STR(SDL_DROPCOMPLETE);
|
||||
EV_CASE_STR(SDL_AUDIODEVICEADDED);
|
||||
EV_CASE_STR(SDL_AUDIODEVICEREMOVED);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||
EV_CASE_STR(SDL_SENSORUPDATE);
|
||||
#endif
|
||||
EV_CASE_STR(SDL_RENDER_TARGETS_RESET);
|
||||
EV_CASE_STR(SDL_RENDER_DEVICE_RESET);
|
||||
EV_CASE_STR(SDL_USEREVENT);
|
||||
EV_CASE_STR(SDL_EVENT_FIRST);
|
||||
EV_CASE_STR(SDL_EVENT_QUIT);
|
||||
EV_CASE_STR(SDL_EVENT_TERMINATING);
|
||||
EV_CASE_STR(SDL_EVENT_LOW_MEMORY);
|
||||
EV_CASE_STR(SDL_EVENT_WILL_ENTER_BACKGROUND);
|
||||
EV_CASE_STR(SDL_EVENT_DID_ENTER_BACKGROUND);
|
||||
EV_CASE_STR(SDL_EVENT_WILL_ENTER_FOREGROUND);
|
||||
EV_CASE_STR(SDL_EVENT_DID_ENTER_FOREGROUND);
|
||||
EV_CASE_STR(SDL_EVENT_LOCALE_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_SYSTEM_THEME_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_DISPLAY_ORIENTATION);
|
||||
EV_CASE_STR(SDL_EVENT_DISPLAY_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_DISPLAY_REMOVED);
|
||||
EV_CASE_STR(SDL_EVENT_DISPLAY_MOVED);
|
||||
EV_CASE_STR(SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_DISPLAY_HDR_STATE_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_SHOWN);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_HIDDEN);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_EXPOSED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_MOVED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_RESIZED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_MINIMIZED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_MAXIMIZED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_RESTORED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_MOUSE_ENTER);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_MOUSE_LEAVE);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_FOCUS_GAINED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_FOCUS_LOST);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_CLOSE_REQUESTED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_TAKE_FOCUS);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_HIT_TEST);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_ICCPROF_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_DISPLAY_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_OCCLUDED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_ENTER_FULLSCREEN);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_LEAVE_FULLSCREEN);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_DESTROYED);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_PEN_ENTER);
|
||||
EV_CASE_STR(SDL_EVENT_WINDOW_PEN_LEAVE);
|
||||
|
||||
EV_CASE_STR(SDL_USEREVENT_CERT_DIALOG);
|
||||
EV_CASE_STR(SDL_USEREVENT_CERT_RESULT);
|
||||
EV_CASE_STR(SDL_USEREVENT_SHOW_DIALOG);
|
||||
EV_CASE_STR(SDL_USEREVENT_SHOW_RESULT);
|
||||
EV_CASE_STR(SDL_USEREVENT_AUTH_DIALOG);
|
||||
EV_CASE_STR(SDL_USEREVENT_AUTH_RESULT);
|
||||
EV_CASE_STR(SDL_USEREVENT_SCARD_DIALOG);
|
||||
EV_CASE_STR(SDL_USEREVENT_RETRY_DIALOG);
|
||||
EV_CASE_STR(SDL_USEREVENT_SCARD_RESULT);
|
||||
EV_CASE_STR(SDL_USEREVENT_UPDATE);
|
||||
EV_CASE_STR(SDL_USEREVENT_CREATE_WINDOWS);
|
||||
EV_CASE_STR(SDL_USEREVENT_WINDOW_RESIZEABLE);
|
||||
EV_CASE_STR(SDL_USEREVENT_WINDOW_FULLSCREEN);
|
||||
EV_CASE_STR(SDL_USEREVENT_POINTER_NULL);
|
||||
EV_CASE_STR(SDL_USEREVENT_POINTER_DEFAULT);
|
||||
EV_CASE_STR(SDL_USEREVENT_POINTER_POSITION);
|
||||
EV_CASE_STR(SDL_USEREVENT_POINTER_SET);
|
||||
EV_CASE_STR(SDL_USEREVENT_QUIT);
|
||||
EV_CASE_STR(SDL_EVENT_KEY_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_KEY_UP);
|
||||
EV_CASE_STR(SDL_EVENT_TEXT_EDITING);
|
||||
EV_CASE_STR(SDL_EVENT_TEXT_INPUT);
|
||||
EV_CASE_STR(SDL_EVENT_KEYMAP_CHANGED);
|
||||
EV_CASE_STR(SDL_EVENT_KEYBOARD_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_KEYBOARD_REMOVED);
|
||||
|
||||
EV_CASE_STR(SDL_LASTEVENT);
|
||||
EV_CASE_STR(SDL_EVENT_MOUSE_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_MOUSE_BUTTON_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_MOUSE_BUTTON_UP);
|
||||
EV_CASE_STR(SDL_EVENT_MOUSE_WHEEL);
|
||||
EV_CASE_STR(SDL_EVENT_MOUSE_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_MOUSE_REMOVED);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_AXIS_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_BALL_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_HAT_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_BUTTON_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_BUTTON_UP);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_REMOVED);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_BATTERY_UPDATED);
|
||||
EV_CASE_STR(SDL_EVENT_JOYSTICK_UPDATE_COMPLETE);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_AXIS_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_BUTTON_UP);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_REMOVED);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_REMAPPED);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_TOUCHPAD_UP);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_SENSOR_UPDATE);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_UPDATE_COMPLETE);
|
||||
EV_CASE_STR(SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_FINGER_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_FINGER_UP);
|
||||
EV_CASE_STR(SDL_EVENT_FINGER_MOTION);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_CLIPBOARD_UPDATE);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_DROP_FILE);
|
||||
EV_CASE_STR(SDL_EVENT_DROP_TEXT);
|
||||
EV_CASE_STR(SDL_EVENT_DROP_BEGIN);
|
||||
EV_CASE_STR(SDL_EVENT_DROP_COMPLETE);
|
||||
EV_CASE_STR(SDL_EVENT_DROP_POSITION);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_AUDIO_DEVICE_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_AUDIO_DEVICE_REMOVED);
|
||||
EV_CASE_STR(SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_SENSOR_UPDATE);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_PEN_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_PEN_UP);
|
||||
EV_CASE_STR(SDL_EVENT_PEN_MOTION);
|
||||
EV_CASE_STR(SDL_EVENT_PEN_BUTTON_DOWN);
|
||||
EV_CASE_STR(SDL_EVENT_PEN_BUTTON_UP);
|
||||
EV_CASE_STR(SDL_EVENT_CAMERA_DEVICE_ADDED);
|
||||
EV_CASE_STR(SDL_EVENT_CAMERA_DEVICE_REMOVED);
|
||||
EV_CASE_STR(SDL_EVENT_CAMERA_DEVICE_APPROVED);
|
||||
EV_CASE_STR(SDL_EVENT_CAMERA_DEVICE_DENIED);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_RENDER_TARGETS_RESET);
|
||||
EV_CASE_STR(SDL_EVENT_RENDER_DEVICE_RESET);
|
||||
EV_CASE_STR(SDL_EVENT_POLL_SENTINEL);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_USER);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_USER_CERT_DIALOG);
|
||||
EV_CASE_STR(SDL_EVENT_USER_CERT_RESULT);
|
||||
EV_CASE_STR(SDL_EVENT_USER_SHOW_DIALOG);
|
||||
EV_CASE_STR(SDL_EVENT_USER_SHOW_RESULT);
|
||||
EV_CASE_STR(SDL_EVENT_USER_AUTH_DIALOG);
|
||||
EV_CASE_STR(SDL_EVENT_USER_AUTH_RESULT);
|
||||
EV_CASE_STR(SDL_EVENT_USER_SCARD_DIALOG);
|
||||
EV_CASE_STR(SDL_EVENT_USER_RETRY_DIALOG);
|
||||
EV_CASE_STR(SDL_EVENT_USER_SCARD_RESULT);
|
||||
EV_CASE_STR(SDL_EVENT_USER_UPDATE);
|
||||
EV_CASE_STR(SDL_EVENT_USER_CREATE_WINDOWS);
|
||||
EV_CASE_STR(SDL_EVENT_USER_WINDOW_RESIZEABLE);
|
||||
EV_CASE_STR(SDL_EVENT_USER_WINDOW_FULLSCREEN);
|
||||
EV_CASE_STR(SDL_EVENT_USER_POINTER_NULL);
|
||||
EV_CASE_STR(SDL_EVENT_USER_POINTER_DEFAULT);
|
||||
EV_CASE_STR(SDL_EVENT_USER_POINTER_POSITION);
|
||||
EV_CASE_STR(SDL_EVENT_USER_POINTER_SET);
|
||||
EV_CASE_STR(SDL_EVENT_USER_QUIT);
|
||||
|
||||
EV_CASE_STR(SDL_EVENT_LAST);
|
||||
default:
|
||||
return "SDL_UNKNOWNEVENT";
|
||||
}
|
||||
#undef EV_CASE_STR
|
||||
#undef STR
|
||||
}
|
||||
|
||||
const char* sdl_error_string(Uint32 res)
|
||||
@ -156,7 +206,7 @@ BOOL sdl_push_user_event(Uint32 type, ...)
|
||||
event->type = type;
|
||||
switch (type)
|
||||
{
|
||||
case SDL_USEREVENT_AUTH_RESULT:
|
||||
case SDL_EVENT_USER_AUTH_RESULT:
|
||||
{
|
||||
auto arg = reinterpret_cast<SDL_UserAuthArg*>(ev.padding);
|
||||
arg->user = va_arg(ap, char*);
|
||||
@ -165,7 +215,7 @@ BOOL sdl_push_user_event(Uint32 type, ...)
|
||||
arg->result = va_arg(ap, Sint32);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_AUTH_DIALOG:
|
||||
case SDL_EVENT_USER_AUTH_DIALOG:
|
||||
{
|
||||
auto arg = reinterpret_cast<SDL_UserAuthArg*>(ev.padding);
|
||||
|
||||
@ -176,52 +226,52 @@ BOOL sdl_push_user_event(Uint32 type, ...)
|
||||
arg->result = va_arg(ap, Sint32);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_SCARD_DIALOG:
|
||||
case SDL_EVENT_USER_SCARD_DIALOG:
|
||||
{
|
||||
event->data1 = va_arg(ap, char*);
|
||||
event->data2 = va_arg(ap, char**);
|
||||
event->code = va_arg(ap, Sint32);
|
||||
}
|
||||
break;
|
||||
case SDL_USEREVENT_RETRY_DIALOG:
|
||||
case SDL_EVENT_USER_RETRY_DIALOG:
|
||||
break;
|
||||
case SDL_USEREVENT_SCARD_RESULT:
|
||||
case SDL_USEREVENT_SHOW_RESULT:
|
||||
case SDL_USEREVENT_CERT_RESULT:
|
||||
case SDL_EVENT_USER_SCARD_RESULT:
|
||||
case SDL_EVENT_USER_SHOW_RESULT:
|
||||
case SDL_EVENT_USER_CERT_RESULT:
|
||||
event->code = va_arg(ap, Sint32);
|
||||
break;
|
||||
|
||||
case SDL_USEREVENT_SHOW_DIALOG:
|
||||
case SDL_EVENT_USER_SHOW_DIALOG:
|
||||
event->data1 = va_arg(ap, char*);
|
||||
event->data2 = va_arg(ap, char*);
|
||||
event->code = va_arg(ap, Sint32);
|
||||
break;
|
||||
case SDL_USEREVENT_CERT_DIALOG:
|
||||
case SDL_EVENT_USER_CERT_DIALOG:
|
||||
event->data1 = va_arg(ap, char*);
|
||||
event->data2 = va_arg(ap, char*);
|
||||
break;
|
||||
case SDL_USEREVENT_UPDATE:
|
||||
case SDL_EVENT_USER_UPDATE:
|
||||
event->data1 = va_arg(ap, void*);
|
||||
break;
|
||||
case SDL_USEREVENT_POINTER_POSITION:
|
||||
case SDL_EVENT_USER_POINTER_POSITION:
|
||||
event->data1 = reinterpret_cast<void*>(static_cast<uintptr_t>(va_arg(ap, UINT32)));
|
||||
event->data2 = reinterpret_cast<void*>(static_cast<uintptr_t>(va_arg(ap, UINT32)));
|
||||
break;
|
||||
case SDL_USEREVENT_POINTER_SET:
|
||||
case SDL_EVENT_USER_POINTER_SET:
|
||||
event->data1 = va_arg(ap, void*);
|
||||
event->data2 = va_arg(ap, void*);
|
||||
break;
|
||||
case SDL_USEREVENT_CREATE_WINDOWS:
|
||||
case SDL_EVENT_USER_CREATE_WINDOWS:
|
||||
event->data1 = reinterpret_cast<void*>(va_arg(ap, void*));
|
||||
break;
|
||||
case SDL_USEREVENT_WINDOW_FULLSCREEN:
|
||||
case SDL_USEREVENT_WINDOW_RESIZEABLE:
|
||||
case SDL_EVENT_USER_WINDOW_FULLSCREEN:
|
||||
case SDL_EVENT_USER_WINDOW_RESIZEABLE:
|
||||
event->data1 = va_arg(ap, void*);
|
||||
event->code = va_arg(ap, int);
|
||||
break;
|
||||
case SDL_USEREVENT_QUIT:
|
||||
case SDL_USEREVENT_POINTER_NULL:
|
||||
case SDL_USEREVENT_POINTER_DEFAULT:
|
||||
case SDL_EVENT_USER_QUIT:
|
||||
case SDL_EVENT_USER_POINTER_NULL:
|
||||
case SDL_EVENT_USER_POINTER_DEFAULT:
|
||||
break;
|
||||
default:
|
||||
va_end(ap);
|
||||
@ -284,58 +334,15 @@ HANDLE WinPREvent::handle() const
|
||||
bool sdl_push_quit()
|
||||
{
|
||||
SDL_Event ev = { 0 };
|
||||
ev.type = SDL_QUIT;
|
||||
ev.type = SDL_EVENT_QUIT;
|
||||
SDL_PushEvent(&ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string sdl_window_event_str(Uint8 ev)
|
||||
std::string sdl_window_event_str(Uint32 ev)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case SDL_WINDOWEVENT_NONE:
|
||||
return "SDL_WINDOWEVENT_NONE";
|
||||
case SDL_WINDOWEVENT_SHOWN:
|
||||
return "SDL_WINDOWEVENT_SHOWN";
|
||||
case SDL_WINDOWEVENT_HIDDEN:
|
||||
return "SDL_WINDOWEVENT_HIDDEN";
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
return "SDL_WINDOWEVENT_EXPOSED";
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
return "SDL_WINDOWEVENT_MOVED";
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
return "SDL_WINDOWEVENT_RESIZED";
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
return "SDL_WINDOWEVENT_SIZE_CHANGED";
|
||||
case SDL_WINDOWEVENT_MINIMIZED:
|
||||
return "SDL_WINDOWEVENT_MINIMIZED";
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
return "SDL_WINDOWEVENT_MAXIMIZED";
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
return "SDL_WINDOWEVENT_RESTORED";
|
||||
case SDL_WINDOWEVENT_ENTER:
|
||||
return "SDL_WINDOWEVENT_ENTER";
|
||||
case SDL_WINDOWEVENT_LEAVE:
|
||||
return "SDL_WINDOWEVENT_LEAVE";
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
return "SDL_WINDOWEVENT_FOCUS_GAINED";
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
return "SDL_WINDOWEVENT_FOCUS_LOST";
|
||||
case SDL_WINDOWEVENT_CLOSE:
|
||||
return "SDL_WINDOWEVENT_CLOSE";
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
return "SDL_WINDOWEVENT_TAKE_FOCUS";
|
||||
case SDL_WINDOWEVENT_HIT_TEST:
|
||||
return "SDL_WINDOWEVENT_HIT_TEST";
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 18)
|
||||
case SDL_WINDOWEVENT_ICCPROF_CHANGED:
|
||||
return "SDL_WINDOWEVENT_ICCPROF_CHANGED";
|
||||
case SDL_WINDOWEVENT_DISPLAY_CHANGED:
|
||||
return "SDL_WINDOWEVENT_DISPLAY_CHANGED";
|
||||
#endif
|
||||
default:
|
||||
return "SDL_WINDOWEVENT_UNKNOWN";
|
||||
}
|
||||
if ((ev >= SDL_EVENT_WINDOW_FIRST) && (ev <= SDL_EVENT_WINDOW_LAST))
|
||||
return sdl_event_type_str(ev);
|
||||
|
||||
return "SDL_EVENT_WINDOW_UNKNOWN";
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/wlog.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -57,25 +57,25 @@ class WinPREvent
|
||||
|
||||
enum
|
||||
{
|
||||
SDL_USEREVENT_UPDATE = SDL_USEREVENT + 1,
|
||||
SDL_USEREVENT_CREATE_WINDOWS,
|
||||
SDL_USEREVENT_WINDOW_RESIZEABLE,
|
||||
SDL_USEREVENT_WINDOW_FULLSCREEN,
|
||||
SDL_USEREVENT_POINTER_NULL,
|
||||
SDL_USEREVENT_POINTER_DEFAULT,
|
||||
SDL_USEREVENT_POINTER_POSITION,
|
||||
SDL_USEREVENT_POINTER_SET,
|
||||
SDL_USEREVENT_QUIT,
|
||||
SDL_USEREVENT_CERT_DIALOG,
|
||||
SDL_USEREVENT_SHOW_DIALOG,
|
||||
SDL_USEREVENT_AUTH_DIALOG,
|
||||
SDL_USEREVENT_SCARD_DIALOG,
|
||||
SDL_USEREVENT_RETRY_DIALOG,
|
||||
SDL_EVENT_USER_UPDATE = SDL_EVENT_USER + 1,
|
||||
SDL_EVENT_USER_CREATE_WINDOWS,
|
||||
SDL_EVENT_USER_WINDOW_RESIZEABLE,
|
||||
SDL_EVENT_USER_WINDOW_FULLSCREEN,
|
||||
SDL_EVENT_USER_POINTER_NULL,
|
||||
SDL_EVENT_USER_POINTER_DEFAULT,
|
||||
SDL_EVENT_USER_POINTER_POSITION,
|
||||
SDL_EVENT_USER_POINTER_SET,
|
||||
SDL_EVENT_USER_QUIT,
|
||||
SDL_EVENT_USER_CERT_DIALOG,
|
||||
SDL_EVENT_USER_SHOW_DIALOG,
|
||||
SDL_EVENT_USER_AUTH_DIALOG,
|
||||
SDL_EVENT_USER_SCARD_DIALOG,
|
||||
SDL_EVENT_USER_RETRY_DIALOG,
|
||||
|
||||
SDL_USEREVENT_CERT_RESULT,
|
||||
SDL_USEREVENT_SHOW_RESULT,
|
||||
SDL_USEREVENT_AUTH_RESULT,
|
||||
SDL_USEREVENT_SCARD_RESULT
|
||||
SDL_EVENT_USER_CERT_RESULT,
|
||||
SDL_EVENT_USER_SHOW_RESULT,
|
||||
SDL_EVENT_USER_AUTH_RESULT,
|
||||
SDL_EVENT_USER_SCARD_RESULT
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@ -93,7 +93,7 @@ BOOL sdl_push_user_event(Uint32 type, ...);
|
||||
|
||||
bool sdl_push_quit();
|
||||
|
||||
std::string sdl_window_event_str(Uint8 ev);
|
||||
std::string sdl_window_event_str(Uint32 ev);
|
||||
const char* sdl_event_type_str(Uint32 type);
|
||||
const char* sdl_error_string(Uint32 res);
|
||||
|
||||
|
@ -22,9 +22,17 @@
|
||||
|
||||
SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, Sint32 width,
|
||||
Sint32 height, Uint32 flags)
|
||||
: _window(SDL_CreateWindow(title.c_str(), startupX, startupY, width, height, flags)),
|
||||
_offset_x(0), _offset_y(0)
|
||||
: _offset_x(0), _offset_y(0)
|
||||
{
|
||||
auto props = SDL_CreateProperties();
|
||||
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str());
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, startupX);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, startupY);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, width);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, height);
|
||||
// SDL_SetProperty(props, SDL_PROP_WINDOW_CREATE_FL);
|
||||
_window = SDL_CreateWindowWithProperties(props);
|
||||
SDL_DestroyProperties(props);
|
||||
}
|
||||
|
||||
SdlWindow::SdlWindow(SdlWindow&& other)
|
||||
@ -49,7 +57,7 @@ int SdlWindow::displayIndex() const
|
||||
{
|
||||
if (!_window)
|
||||
return 0;
|
||||
return SDL_GetWindowDisplayIndex(_window);
|
||||
return SDL_GetDisplayForWindow(_window);
|
||||
}
|
||||
|
||||
SDL_Rect SdlWindow::rect() const
|
||||
@ -92,24 +100,15 @@ bool SdlWindow::grabKeyboard(bool enable)
|
||||
{
|
||||
if (!_window)
|
||||
return false;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||
SDL_SetWindowKeyboardGrab(_window, enable ? SDL_TRUE : SDL_FALSE);
|
||||
return true;
|
||||
#else
|
||||
SDL_LogError(SDL_LOG_CATEGORY_INPUT, "Keyboard grabbing not supported by SDL2 < 2.0.16");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SdlWindow::grabMouse(bool enable)
|
||||
{
|
||||
if (!_window)
|
||||
return false;
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||
SDL_SetWindowMouseGrab(_window, enable ? SDL_TRUE : SDL_FALSE);
|
||||
#else
|
||||
SDL_SetWindowGrab(_window, enable ? SDL_TRUE : SDL_FALSE);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -137,19 +136,17 @@ void SdlWindow::fullscreen(bool enter)
|
||||
{
|
||||
if (!(curFlags & SDL_WINDOW_BORDERLESS))
|
||||
{
|
||||
auto idx = SDL_GetWindowDisplayIndex(_window);
|
||||
SDL_DisplayMode mode = {};
|
||||
SDL_GetCurrentDisplayMode(idx, &mode);
|
||||
auto idx = SDL_GetDisplayForWindow(_window);
|
||||
auto mode = SDL_GetCurrentDisplayMode(idx);
|
||||
|
||||
SDL_RestoreWindow(_window); // Maximize so we can see the caption and
|
||||
// bits
|
||||
SDL_SetWindowBordered(_window, SDL_FALSE);
|
||||
SDL_SetWindowPosition(_window, 0, 0);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||
SDL_SetWindowAlwaysOnTop(_window, SDL_TRUE);
|
||||
#endif
|
||||
SDL_RaiseWindow(_window);
|
||||
SDL_SetWindowSize(_window, mode.w, mode.h);
|
||||
if (mode)
|
||||
SDL_SetWindowSize(_window, mode->w, mode->h);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -158,9 +155,7 @@ void SdlWindow::fullscreen(bool enter)
|
||||
{
|
||||
|
||||
SDL_SetWindowBordered(_window, SDL_TRUE);
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||
SDL_SetWindowAlwaysOnTop(_window, SDL_FALSE);
|
||||
#endif
|
||||
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
|
||||
@ -176,7 +171,7 @@ bool SdlWindow::fill(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
SDL_Rect rect = { 0, 0, surface->w, surface->h };
|
||||
auto color = SDL_MapRGBA(surface->format, r, g, b, a);
|
||||
|
||||
SDL_FillRect(surface, &rect, color);
|
||||
SDL_FillSurfaceRect(surface, &rect, color);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -185,11 +180,11 @@ bool SdlWindow::blit(SDL_Surface* surface, const SDL_Rect& srcRect, SDL_Rect& ds
|
||||
auto screen = SDL_GetWindowSurface(_window);
|
||||
if (!screen || !surface)
|
||||
return false;
|
||||
if (!SDL_SetClipRect(surface, &srcRect))
|
||||
if (!SDL_SetSurfaceClipRect(surface, &srcRect))
|
||||
return true;
|
||||
if (!SDL_SetClipRect(screen, &dstRect))
|
||||
if (!SDL_SetSurfaceClipRect(screen, &dstRect))
|
||||
return true;
|
||||
auto rc = SDL_BlitScaled(surface, &srcRect, screen, &dstRect);
|
||||
auto rc = SDL_BlitSurfaceScaled(surface, &srcRect, screen, &dstRect, SDL_SCALEMODE_BEST);
|
||||
if (rc != 0)
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "SDL_BlitScaled: %s [%d]", sdl_error_string(rc), rc);
|
||||
|
@ -20,7 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
class SdlWindow
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user