[warnings] fix float-conversion

This commit is contained in:
akallabeth 2024-10-30 20:25:45 +01:00
parent dcf5a8e28c
commit b6e051f16c
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
8 changed files with 21 additions and 20 deletions

View File

@ -31,13 +31,13 @@ bool SdlButtonList::populate(SDL_Renderer* renderer, const std::vector<std::stri
SdlButton* SdlButtonList::get_selected(const SDL_MouseButtonEvent& button)
{
const Sint32 x = button.x;
const Sint32 y = button.y;
const auto x = button.x;
const auto y = button.y;
return get_selected(x, y);
}
SdlButton* SdlButtonList::get_selected(Sint32 x, Sint32 y)
SdlButton* SdlButtonList::get_selected(float x, float y)
{
for (auto& btn : _list)
{
@ -75,7 +75,7 @@ bool SdlButtonList::set_highlight(size_t index)
return true;
}
bool SdlButtonList::set_mouseover(Sint32 x, Sint32 y)
bool SdlButtonList::set_mouseover(float x, float y)
{
_mouseover = get_selected(x, y);
return _mouseover != nullptr;

View File

@ -22,11 +22,11 @@ class SdlButtonList
bool update(SDL_Renderer* renderer);
SdlButton* get_selected(const SDL_MouseButtonEvent& button);
SdlButton* get_selected(Sint32 x, Sint32 y);
SdlButton* get_selected(float x, float y);
bool set_highlight_next(bool reset = false);
bool set_highlight(size_t index);
bool set_mouseover(Sint32 x, Sint32 y);
bool set_mouseover(float x, float y);
void clear();

View File

@ -385,7 +385,7 @@ bool SDLConnectionDialog::createWindow()
SDL3ResourceManager::get(SDLResourceManager::typeImages(), res_name) } };
_list.emplace_back(std::move(icon));
iconRect.y += height;
iconRect.y += static_cast<float>(height);
widget_cfg_t logo{ textcolor,
backgroundcolor,

View File

@ -109,8 +109,8 @@ bool SdlInputWidgetList::update(SDL_Renderer* renderer)
ssize_t SdlInputWidgetList::get_index(const SDL_MouseButtonEvent& button)
{
const Sint32 x = button.x;
const Sint32 y = button.y;
const auto x = button.x;
const auto y = button.y;
for (size_t i = 0; i < _list.size(); i++)
{
auto& cur = _list[i];

View File

@ -157,8 +157,8 @@ int SdlSelectList::run()
ssize_t SdlSelectList::get_index(const SDL_MouseButtonEvent& button)
{
const Sint32 x = button.x;
const Sint32 y = button.y;
const auto x = button.x;
const auto y = button.y;
for (size_t i = 0; i < _list.size(); i++)
{
auto& cur = _list[i];

View File

@ -120,8 +120,8 @@ SDL_Texture* SdlWidget::render_text(SDL_Renderer* renderer, const std::string& t
return nullptr;
}
src.w = w;
src.h = h;
src.w = static_cast<float>(w);
src.h = static_cast<float>(h);
/* Do some magic:
* - Add padding before and after text
* - if text is too long only show the last elements

View File

@ -1007,7 +1007,8 @@ static int sdl_run(SdlContext* sdl)
INT32 sx = x;
INT32 sy = y;
if (sdl_scale_coordinates(sdl, id, &sx, &sy, FALSE, FALSE))
SDL_WarpMouseInWindow(window, sx, sy);
SDL_WarpMouseInWindow(window, static_cast<float>(sx),
static_cast<float>(sy));
}
}
break;

View File

@ -201,8 +201,8 @@ BOOL sdl_handle_mouse_motion(SdlContext* sdl, const SDL_MouseMotionEvent* ev)
sdl->input.mouse_focus(ev->windowID);
const BOOL relative = freerdp_client_use_relative_mouse_events(sdl->common());
INT32 x = relative ? ev->xrel : ev->x;
INT32 y = relative ? ev->yrel : ev->y;
auto x = static_cast<INT32>(relative ? ev->xrel : ev->x);
auto y = static_cast<INT32>(relative ? ev->yrel : ev->y);
sdl_scale_coordinates(sdl, ev->windowID, &x, &y, TRUE, TRUE);
return freerdp_client_send_button_event(sdl->common(), relative, PTR_FLAGS_MOVE, x, y);
}
@ -213,8 +213,8 @@ BOOL sdl_handle_mouse_wheel(SdlContext* sdl, const SDL_MouseWheelEvent* ev)
WINPR_ASSERT(ev);
const BOOL flipped = (ev->direction == SDL_MOUSEWHEEL_FLIPPED);
const INT32 x = ev->x * (flipped ? -1 : 1) * 0x78;
const INT32 y = ev->y * (flipped ? -1 : 1) * 0x78;
const auto x = static_cast<INT32>(ev->x * (flipped ? -1 : 1) * 0x78);
const auto y = static_cast<INT32>(ev->y * (flipped ? -1 : 1) * 0x78);
UINT16 flags = 0;
if (y != 0)
@ -267,8 +267,8 @@ BOOL sdl_handle_mouse_button(SdlContext* sdl, const SDL_MouseButtonEvent* ev)
}
const BOOL relative = freerdp_client_use_relative_mouse_events(sdl->common());
INT32 x = relative ? 0 : ev->x;
INT32 y = relative ? 0 : ev->y;
auto x = static_cast<INT32>(relative ? 0 : ev->x);
auto y = static_cast<INT32>(relative ? 0 : ev->y);
sdl_scale_coordinates(sdl, ev->windowID, &x, &y, TRUE, TRUE);
if ((flags & (~PTR_FLAGS_DOWN)) != 0)
return freerdp_client_send_button_event(sdl->common(), relative, flags, x, y);