[client,sdl] tidy up code

This commit is contained in:
akallabeth 2024-02-13 09:52:47 +01:00 committed by akallabeth
parent 05175d70f0
commit 8492738b0d
29 changed files with 134 additions and 206 deletions

View File

@ -25,8 +25,8 @@
#include <QWebEngineUrlRequestJob>
#include <string>
#include <stdlib.h>
#include <stdarg.h>
#include <cstdlib>
#include <cstdarg>
#include <winpr/string.h>
#include <winpr/assert.h>
#include <freerdp/log.h>
@ -39,7 +39,7 @@
class SchemeHandler : public QWebEngineUrlSchemeHandler
{
public:
SchemeHandler(QObject* parent = nullptr) : QWebEngineUrlSchemeHandler(parent)
explicit SchemeHandler(QObject* parent = nullptr) : QWebEngineUrlSchemeHandler(parent)
{
}
@ -52,7 +52,7 @@ class SchemeHandler : public QWebEngineUrlSchemeHandler
{
QStringList pair = param.split('=');
if (pair.size() != 2 || pair[0] != "code")
if (pair.size() != 2 || pair[0] != QLatin1String("code"))
continue;
auto qc = pair[1];
@ -63,20 +63,20 @@ class SchemeHandler : public QWebEngineUrlSchemeHandler
qApp->exit(rc);
}
const std::string code() const
[[nodiscard]] std::string code() const
{
return m_code;
}
private:
std::string m_code;
std::string m_code{};
};
bool webview_impl_run(const std::string& title, const std::string& url, std::string& code)
{
int argc = 1;
QString vendor(FREERDP_VENDOR_STRING);
QString product(FREERDP_PRODUCT_STRING);
const auto vendor = QString::fromUtf8(FREERDP_VENDOR_STRING);
const auto product = QString::fromUtf8(FREERDP_PRODUCT_STRING);
QWebEngineUrlScheme::registerScheme(QWebEngineUrlScheme("ms-appx-web"));
std::string wtitle = title;

View File

@ -19,7 +19,7 @@
#include <string>
#include <sstream>
#include <stdlib.h>
#include <cstdlib>
#include <winpr/string.h>
#include <freerdp/log.h>

View File

@ -102,7 +102,7 @@ static int write_cpp_trailer(std::ostream& out)
return 0;
}
static int write_hpp_header(const fs::path prg, const fs::path& file, const std::string& name,
static int write_hpp_header(const fs::path& prg, const fs::path& file, const std::string& name,
const std::string& fname)
{
std::ofstream out(file, std::ios::out);

View File

@ -18,7 +18,7 @@
* limitations under the License.
*/
#include <assert.h>
#include <cassert>
#include "sdl_button.hpp"
@ -40,10 +40,6 @@ SdlButton::SdlButton(SdlButton&& other) noexcept
{
}
SdlButton::~SdlButton()
{
}
bool SdlButton::highlight(SDL_Renderer* renderer)
{
assert(renderer);

View File

@ -9,13 +9,13 @@ class SdlButton : public SdlWidget
public:
SdlButton(SDL_Renderer* renderer, const std::string& label, int id, const SDL_Rect& rect);
SdlButton(SdlButton&& other) noexcept;
virtual ~SdlButton() override;
~SdlButton() override = default;
bool highlight(SDL_Renderer* renderer);
bool mouseover(SDL_Renderer* renderer);
bool update(SDL_Renderer* renderer);
int id() const;
[[nodiscard]] int id() const;
private:
SdlButton(const SdlButton& other) = delete;

View File

@ -1,14 +1,10 @@
#include <assert.h>
#include <cassert>
#include <algorithm>
#include "sdl_buttons.hpp"
static const Uint32 hpadding = 10;
SdlButtonList::SdlButtonList()
{
}
bool SdlButtonList::populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY,
Sint32 width, Sint32 height)
@ -25,15 +21,11 @@ bool SdlButtonList::populate(SDL_Renderer* renderer, const std::vector<std::stri
{
const size_t curOffsetX = offsetX + x * (static_cast<size_t>(width) + hpadding);
const SDL_Rect rect = { static_cast<int>(curOffsetX), offsetY, width, height };
_list.push_back({ renderer, labels[x], ids[x], rect });
_list.emplace_back(renderer, labels[x], ids[x], rect);
}
return true;
}
SdlButtonList::~SdlButtonList()
{
}
SdlButton* SdlButtonList::get_selected(const SDL_MouseButtonEvent& button)
{
const Sint32 x = button.x;

View File

@ -1,15 +1,15 @@
#pragma once
#include <vector>
#include <stdint.h>
#include <cstdint>
#include "sdl_button.hpp"
class SdlButtonList
{
public:
SdlButtonList();
virtual ~SdlButtonList();
SdlButtonList() = default;
virtual ~SdlButtonList() = default;
bool populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY, Sint32 width,

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <assert.h>
#include <cassert>
#include <thread>
#include "sdl_connection_dialog.hpp"
@ -377,8 +377,8 @@ bool SDLConnectionDialog::createWindow()
break;
}
int height = (total_height - 3 * vpadding) / 2;
SDL_Rect iconRect{ hpadding, vpadding, widget_width / 4 - 2 * hpadding, height };
int height = (total_height - 3ul * vpadding) / 2ul;
SDL_Rect iconRect{ hpadding, vpadding, widget_width / 4ul - 2ul * hpadding, height };
widget_cfg_t icon{ textcolor,
res_bgcolor,
{ _renderer, iconRect,
@ -394,11 +394,11 @@ bool SDLConnectionDialog::createWindow()
"FreeRDP_Icon.svg") } };
_list.emplace_back(std::move(logo));
SDL_Rect rect = { widget_width / 4, vpadding, widget_width * 3 / 4,
total_height - 3 * vpadding - widget_height };
SDL_Rect rect = { widget_width / 4ul, vpadding, widget_width * 3ul / 4ul,
total_height - 3ul * vpadding - widget_height };
#else
SDL_Rect rect = { hpadding, vpadding, widget_width - 2 * hpadding,
total_height - 2 * vpadding };
SDL_Rect rect = { hpadding, vpadding, widget_width - 2ul * hpadding,
total_height - 2ul * vpadding };
#endif
widget_cfg_t w{ textcolor, backgroundcolor, { _renderer, rect, false } };

View File

@ -34,7 +34,7 @@
class SDLConnectionDialog
{
public:
SDLConnectionDialog(rdpContext* context);
explicit SDLConnectionDialog(rdpContext* context);
SDLConnectionDialog(const SDLConnectionDialog& other) = delete;
SDLConnectionDialog(const SDLConnectionDialog&& other) = delete;
virtual ~SDLConnectionDialog();
@ -112,10 +112,10 @@ class SDLConnectionDialog
class SDLConnectionDialogHider
{
public:
SDLConnectionDialogHider(freerdp* instance);
SDLConnectionDialogHider(rdpContext* context);
explicit SDLConnectionDialogHider(freerdp* instance);
explicit SDLConnectionDialogHider(rdpContext* context);
SDLConnectionDialogHider(SDLConnectionDialog* dialog);
explicit SDLConnectionDialogHider(SDLConnectionDialog* dialog);
~SDLConnectionDialogHider();

View File

@ -19,7 +19,7 @@
#include <vector>
#include <string>
#include <assert.h>
#include <cassert>
#include <freerdp/log.h>
#include <freerdp/utils/smartcardlogon.h>
@ -138,7 +138,7 @@ BOOL sdl_authenticate_ex(freerdp* instance, char** username, char** password, ch
goto fail;
else
{
SDL_UserAuthArg* arg = reinterpret_cast<SDL_UserAuthArg*>(event.padding);
auto arg = reinterpret_cast<SDL_UserAuthArg*>(event.padding);
res = arg->result > 0 ? TRUE : FALSE;
@ -181,7 +181,7 @@ BOOL sdl_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_list, DWOR
container_name, reader, cert->userHint, cert->domainHint, cert->subject,
cert->issuer, cert->upn);
strlist.push_back(msg);
strlist.emplace_back(msg);
free(msg);
free(reader);
free(container_name);
@ -607,8 +607,9 @@ BOOL sdl_auth_dialog_show(const SDL_UserAuthArg* args)
BOOL sdl_scard_dialog_show(const char* title, Sint32 count, const char** list)
{
std::vector<std::string> vlist;
vlist.reserve(count);
for (Sint32 x = 0; x < count; x++)
vlist.push_back(list[x]);
vlist.emplace_back(list[x]);
SdlSelectList slist(title, vlist);
Sint32 value = slist.run();
return sdl_push_user_event(SDL_USEREVENT_SCARD_RESULT, value);

View File

@ -19,8 +19,8 @@
#include "sdl_input.hpp"
#include <assert.h>
#include <stdbool.h>
#include <cassert>
#include <string>
#include <SDL.h>
@ -168,8 +168,8 @@ bool SdlInputWidget::update_input(SDL_Renderer* renderer, SDL_Color fgcolor)
{
if (_flags & SDL_INPUT_MASK)
{
for (size_t x = 0; x < text.length(); x++)
text[x] = '*';
for (char& x : text)
x = '*';
}
}

View File

@ -51,10 +51,10 @@ class SdlInputWidget
bool remove_str(SDL_Renderer* renderer, size_t count);
bool append_str(SDL_Renderer* renderer, const std::string& text);
const SDL_Rect& input_rect() const;
std::string value() const;
[[nodiscard]] const SDL_Rect& input_rect() const;
[[nodiscard]] std::string value() const;
bool readonly() const;
[[nodiscard]] bool readonly() const;
protected:
bool update_input(SDL_Renderer* renderer, SDL_Color fgclor);

View File

@ -1,4 +1,4 @@
#include <assert.h>
#include <cassert>
#include <algorithm>
#include "sdl_input_widgets.hpp"
@ -40,8 +40,8 @@ SdlInputWidgetList::SdlInputWidgetList(const std::string& title,
else
{
for (size_t x = 0; x < labels.size(); x++)
_list.push_back(
{ _renderer, labels[x], initial[x], flags[x], x, widget_width, widget_heigth });
_list.emplace_back(_renderer, labels[x], initial[x], flags[x], x, widget_width,
widget_heigth);
_buttons.populate(_renderer, buttonlabels, buttonids, total_width,
static_cast<Sint32>(input_height), static_cast<Sint32>(widget_width),
@ -54,7 +54,7 @@ SdlInputWidgetList::SdlInputWidgetList(const std::string& title,
ssize_t SdlInputWidgetList::next(ssize_t current)
{
size_t iteration = 0;
size_t val = static_cast<size_t>(current);
auto val = static_cast<size_t>(current);
do
{

View File

@ -33,7 +33,7 @@ class SdlInputWidgetList
private:
ssize_t next(ssize_t current);
bool valid(ssize_t current) const;
[[nodiscard]] bool valid(ssize_t current) const;
SdlInputWidget* get(ssize_t index);
private:

View File

@ -17,8 +17,7 @@
* limitations under the License.
*/
#include <assert.h>
#include <stdbool.h>
#include <cassert>
#include <string>
@ -49,10 +48,6 @@ SdlSelectWidget::SdlSelectWidget(SdlSelectWidget&& other) noexcept
{
}
SdlSelectWidget::~SdlSelectWidget()
{
}
bool SdlSelectWidget::set_mouseover(SDL_Renderer* renderer, bool mouseOver)
{
_mouseover = mouseOver;

View File

@ -30,7 +30,7 @@ class SdlSelectWidget : public SdlWidget
public:
SdlSelectWidget(SDL_Renderer* renderer, const std::string& label, const SDL_Rect& rect);
SdlSelectWidget(SdlSelectWidget&& other) noexcept;
virtual ~SdlSelectWidget() override;
~SdlSelectWidget() override = default;
bool set_mouseover(SDL_Renderer* renderer, bool mouseOver);
bool set_highlight(SDL_Renderer* renderer, bool highlight);

View File

@ -29,7 +29,7 @@ SdlSelectList::SdlSelectList(const std::string& title, const std::vector<std::st
SDL_Rect rect = { 0, 0, widget_width, widget_height };
for (auto& label : labels)
{
_list.push_back({ _renderer, label, rect });
_list.emplace_back(_renderer, label, rect);
rect.y += widget_height + vpadding;
}

View File

@ -17,10 +17,10 @@
* limitations under the License.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <SDL.h>
#include <SDL_ttf.h>

View File

@ -21,8 +21,6 @@
#include <string>
#include <stdbool.h>
#include <vector>
#include <SDL.h>
#include <SDL_ttf.h>

View File

@ -30,7 +30,7 @@ class sdlDispContext
{
public:
sdlDispContext(SdlContext* sdl);
explicit sdlDispContext(SdlContext* sdl);
~sdlDispContext();
BOOL init(DispClientContext* disp);

View File

@ -23,9 +23,9 @@
#include <freerdp/config.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
@ -315,7 +315,7 @@ class SdlEventUpdateTriggerGuard
SdlContext* _sdl;
public:
SdlEventUpdateTriggerGuard(SdlContext* sdl) : _sdl(sdl)
explicit SdlEventUpdateTriggerGuard(SdlContext* sdl) : _sdl(sdl)
{
}
~SdlEventUpdateTriggerGuard()
@ -324,57 +324,49 @@ class SdlEventUpdateTriggerGuard
}
};
static BOOL sdl_draw_to_window_rect(SdlContext* sdl, SDL_Surface* screen, SDL_Surface* surface,
static bool sdl_draw_to_window_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface,
SDL_Point offset, const SDL_Rect& srcRect)
{
SDL_Rect dstRect = { offset.x + srcRect.x, offset.y + srcRect.y, srcRect.w, srcRect.h };
SDL_SetClipRect(surface, &srcRect);
SDL_SetClipRect(screen, &dstRect);
SDL_BlitSurface(surface, &srcRect, screen, &dstRect);
return TRUE;
return window.blit(surface, srcRect, dstRect);
}
static BOOL sdl_draw_to_window_rect(SdlContext* sdl, SDL_Surface* screen, SDL_Surface* surface,
static bool sdl_draw_to_window_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface,
SDL_Point offset, const std::vector<SDL_Rect>& rects = {})
{
if (rects.empty())
{
return sdl_draw_to_window_rect(sdl, screen, surface, offset,
return sdl_draw_to_window_rect(sdl, window, surface, offset,
{ 0, 0, surface->w, surface->h });
}
for (auto& srcRect : rects)
{
if (!sdl_draw_to_window_rect(sdl, screen, surface, offset, srcRect))
return FALSE;
if (!sdl_draw_to_window_rect(sdl, window, surface, offset, srcRect))
return false;
}
return TRUE;
return true;
}
static BOOL sdl_draw_to_window_scaled_rect(SdlContext* sdl, Sint32 windowId, SDL_Surface* screen,
SDL_Surface* surface, const SDL_Rect& srcRect)
static bool sdl_draw_to_window_scaled_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface,
const SDL_Rect& srcRect)
{
SDL_Rect dstRect = srcRect;
sdl_scale_coordinates(sdl, windowId, &dstRect.x, &dstRect.y, FALSE, TRUE);
sdl_scale_coordinates(sdl, windowId, &dstRect.w, &dstRect.h, FALSE, TRUE);
SDL_SetClipRect(surface, &srcRect);
SDL_SetClipRect(screen, &dstRect);
SDL_BlitScaled(surface, &srcRect, screen, &dstRect);
return TRUE;
sdl_scale_coordinates(sdl, window.id(), &dstRect.x, &dstRect.y, FALSE, TRUE);
sdl_scale_coordinates(sdl, window.id(), &dstRect.w, &dstRect.h, FALSE, TRUE);
return window.blit(surface, srcRect, dstRect);
}
static BOOL sdl_draw_to_window_scaled_rect(SdlContext* sdl, Sint32 windowId, SDL_Surface* screen,
SDL_Surface* surface,
static BOOL sdl_draw_to_window_scaled_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface,
const std::vector<SDL_Rect>& rects = {})
{
if (rects.empty())
{
return sdl_draw_to_window_scaled_rect(sdl, windowId, screen, surface,
return sdl_draw_to_window_scaled_rect(sdl, window, surface,
{ 0, 0, surface->w, surface->h });
}
for (auto& srcRect : rects)
for (const auto& srcRect : rects)
{
if (!sdl_draw_to_window_scaled_rect(sdl, windowId, screen, surface, srcRect))
if (!sdl_draw_to_window_scaled_rect(sdl, window, surface, srcRect))
return FALSE;
}
return TRUE;
@ -388,45 +380,39 @@ static BOOL sdl_draw_to_window(SdlContext* sdl, SdlWindow& window,
auto context = sdl->context();
auto gdi = context->gdi;
SDL_Surface* screen = SDL_GetWindowSurface(window.window());
int w = 0;
int h = 0;
SDL_GetWindowSize(window.window(), &w, &h);
auto size = window.rect();
if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))
{
if (gdi->width < w)
if (gdi->width < size.w)
{
window.setOffsetX((w - gdi->width) / 2);
window.setOffsetX((size.w - gdi->width) / 2);
}
if (gdi->height < h)
if (gdi->height < size.h)
{
window.setOffsetY((h - gdi->height) / 2);
window.setOffsetY((size.h - gdi->height) / 2);
}
auto surface = sdl->primary.get();
if (!sdl_draw_to_window_rect(sdl, screen, surface, { window.offsetX(), window.offsetY() },
if (!sdl_draw_to_window_rect(sdl, window, surface, { window.offsetX(), window.offsetY() },
rects))
return FALSE;
}
else
{
auto id = SDL_GetWindowID(window.window());
if (!sdl_draw_to_window_scaled_rect(sdl, id, screen, sdl->primary.get(), rects))
if (!sdl_draw_to_window_scaled_rect(sdl, window, sdl->primary.get(), rects))
return FALSE;
}
SDL_UpdateWindowSurface(window.window());
window.updateSurface();
return TRUE;
}
static BOOL sdl_draw_to_window(SdlContext* sdl, std::vector<SdlWindow>& windows,
static BOOL sdl_draw_to_window(SdlContext* sdl, std::map<Uint32, SdlWindow>& windows,
const std::vector<SDL_Rect>& rects = {})
{
for (auto& window : windows)
{
if (!sdl_draw_to_window(sdl, window, rects))
if (!sdl_draw_to_window(sdl, window.second, rects))
return FALSE;
}
@ -601,7 +587,7 @@ static BOOL sdl_pre_connect(freerdp* instance)
std::lock_guard<CriticalSection> lock(sdl->critical);
if (!freerdp_settings_get_bool(settings, FreeRDP_UseCommonStdioCallbacks))
sdl->connection_dialog.reset(new SDLConnectionDialog(instance->context));
sdl->connection_dialog = std::make_unique<SDLConnectionDialog>(instance->context);
if (sdl->connection_dialog)
{
sdl->connection_dialog->setTitle("Connecting to '%s'",
@ -754,14 +740,12 @@ static BOOL sdl_create_windows(SdlContext* sdl)
if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
{
int win_x = 0;
int win_y = 0;
SDL_GetWindowPosition(window.window(), &win_x, &win_y);
window.setOffsetX(0 - win_x);
window.setOffsetY(0 - win_y);
auto r = window.rect();
window.setOffsetX(0 - r.x);
window.setOffsetY(0 - r.y);
}
sdl->windows.emplace_back(std::move(window));
sdl->windows.insert({ window.id(), std::move(window) });
}
rc = TRUE;
@ -817,7 +801,7 @@ static int sdl_run(SdlContext* sdl)
return -1;
}
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
#if SDL_VERSION_ATLEAST(2, 0, 16)
SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, "0");
@ -935,19 +919,21 @@ static int sdl_run(SdlContext* sdl)
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED:
{
auto window = SDL_GetWindowFromID(ev->windowID);
if (window)
auto window = sdl->windows.find(ev->windowID);
if (window != sdl->windows.end())
{
auto surface = SDL_GetWindowSurface(window);
if (surface)
{
SDL_Rect rect = { 0, 0, surface->w, surface->h };
auto color = SDL_MapRGBA(surface->format, 0, 0, 0, 0xff);
SDL_FillRect(surface, &rect, color);
}
sdl_draw_to_window(sdl, sdl->windows);
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();
}
}
break;
@ -1005,53 +991,18 @@ static int sdl_run(SdlContext* sdl)
break;
case SDL_USEREVENT_WINDOW_RESIZEABLE:
{
auto window = static_cast<SDL_Window*>(windowEvent.user.data1);
auto window = static_cast<SdlWindow*>(windowEvent.user.data1);
const SDL_bool use = windowEvent.user.code != 0 ? SDL_TRUE : SDL_FALSE;
SDL_SetWindowResizable(window, use);
if (window)
window->resizeable(use);
}
break;
case SDL_USEREVENT_WINDOW_FULLSCREEN:
{
auto window = static_cast<SDL_Window*>(windowEvent.user.data1);
auto window = static_cast<SdlWindow*>(windowEvent.user.data1);
const SDL_bool enter = windowEvent.user.code != 0 ? SDL_TRUE : SDL_FALSE;
Uint32 curFlags = SDL_GetWindowFlags(window);
if (enter)
{
if (!(curFlags & SDL_WINDOW_BORDERLESS))
{
auto idx = SDL_GetWindowDisplayIndex(window);
SDL_DisplayMode mode = {};
SDL_GetCurrentDisplayMode(idx, &mode);
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);
}
}
else
{
if (curFlags & SDL_WINDOW_BORDERLESS)
{
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
}
}
if (window)
window->fullscreen(enter);
}
break;
case SDL_USEREVENT_POINTER_NULL:
@ -1066,9 +1017,9 @@ static int sdl_run(SdlContext* sdl)
break;
case SDL_USEREVENT_POINTER_POSITION:
{
const INT32 x =
const auto x =
static_cast<INT32>(reinterpret_cast<uintptr_t>(windowEvent.user.data1));
const INT32 y =
const auto y =
static_cast<INT32>(reinterpret_cast<uintptr_t>(windowEvent.user.data2));
SDL_Window* window = SDL_GetMouseFocus();
@ -1709,7 +1660,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.window(), enter))
if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_FULLSCREEN, &window.second, enter))
return FALSE;
}
fullscreen = enter;
@ -1727,7 +1678,7 @@ BOOL SdlContext::update_resizeable(BOOL enable)
for (const auto& window : windows)
{
if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_RESIZEABLE, window.window(), use))
if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_RESIZEABLE, &window.second, use))
return FALSE;
}
resizeable = use;

View File

@ -45,7 +45,7 @@ using SDLPixelFormatPtr = std::unique_ptr<SDL_PixelFormat, decltype(&SDL_FreeFor
class SdlContext
{
public:
SdlContext(rdpContext* context);
explicit SdlContext(rdpContext* context);
private:
rdpContext* _context;
@ -83,6 +83,6 @@ class SdlContext
BOOL update_resizeable(BOOL enable);
BOOL update_fullscreen(BOOL enter);
rdpContext* context() const;
rdpClientContext* common() const;
[[nodiscard]] rdpContext* context() const;
[[nodiscard]] rdpClientContext* common() const;
};

View File

@ -579,7 +579,3 @@ sdlInput::sdlInput(SdlContext* sdl) : _sdl(sdl), _lastWindowID(UINT32_MAX)
{
WINPR_ASSERT(_sdl);
}
sdlInput::~sdlInput()
{
}

View File

@ -30,8 +30,8 @@
class sdlInput
{
public:
sdlInput(SdlContext* sdl);
~sdlInput();
explicit sdlInput(SdlContext* sdl);
~sdlInput() = default;
BOOL keyboard_sync_state();
BOOL keyboard_focus_in();

View File

@ -21,9 +21,9 @@
#include <freerdp/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <SDL.h>
@ -229,8 +229,8 @@ static BOOL sdl_apply_display_properties(SdlContext* sdl)
}
}
const float dw = rect.w / scaleRect.w;
const float dh = rect.h / scaleRect.h;
const float dw = 1.0f * rect.w / scaleRect.w;
const float dh = 1.0f * rect.h / scaleRect.h;
hdpi /= dw;
vdpi /= dh;
}

View File

@ -50,7 +50,7 @@ static BOOL sdl_Pointer_New(rdpContext* context, rdpPointer* pointer)
rdpGdi* gdi = context->gdi;
WINPR_ASSERT(gdi);
ptr->size = pointer->width * pointer->height * 4ULL;
ptr->size = 4ull * pointer->width * pointer->height;
ptr->data = winpr_aligned_malloc(ptr->size, 16);
if (!ptr->data)

View File

@ -28,7 +28,7 @@ namespace fs = std::experimental::filesystem;
#error Could not find system header "<filesystem>" or "<experimental/filesystem>"
#endif
#include <assert.h>
#include <cassert>
#include "sdl_utils.hpp"
#include "sdl_freerdp.hpp"
@ -173,7 +173,7 @@ BOOL sdl_push_user_event(Uint32 type, ...)
{
case SDL_USEREVENT_AUTH_RESULT:
{
SDL_UserAuthArg* arg = reinterpret_cast<SDL_UserAuthArg*>(ev.padding);
auto arg = reinterpret_cast<SDL_UserAuthArg*>(ev.padding);
arg->user = va_arg(ap, char*);
arg->domain = va_arg(ap, char*);
arg->password = va_arg(ap, char*);
@ -182,7 +182,7 @@ BOOL sdl_push_user_event(Uint32 type, ...)
break;
case SDL_USEREVENT_AUTH_DIALOG:
{
SDL_UserAuthArg* arg = reinterpret_cast<SDL_UserAuthArg*>(ev.padding);
auto arg = reinterpret_cast<SDL_UserAuthArg*>(ev.padding);
arg->title = va_arg(ap, char*);
arg->user = va_arg(ap, char*);

View File

@ -22,7 +22,6 @@
#include <winpr/synch.h>
#include <winpr/wlog.h>
#include <stdbool.h>
#include <SDL.h>
#include <string>
#include <vector>
@ -43,14 +42,14 @@ class CriticalSection
class WinPREvent
{
public:
WinPREvent(bool initial = false);
explicit WinPREvent(bool initial = false);
~WinPREvent();
void set();
void clear();
bool isSet() const;
[[nodiscard]] bool isSet() const;
HANDLE handle() const;
[[nodiscard]] HANDLE handle() const;
private:
HANDLE _handle;

View File

@ -30,13 +30,13 @@ class SdlWindow
SdlWindow(SdlWindow&& other);
~SdlWindow();
SDL_Window* window() const;
[[nodiscard]] SDL_Window* window() const;
Sint32 offsetX() const;
[[nodiscard]] Sint32 offsetX() const;
void setOffsetX(Sint32 x);
void setOffsetY(Sint32 y);
Sint32 offsetY() const;
[[nodiscard]] Sint32 offsetY() const;
private:
SDL_Window* _window;