diff --git a/client/SDL/sdl_disp.cpp b/client/SDL/sdl_disp.cpp index 2c6dd414f..a29fed50c 100644 --- a/client/SDL/sdl_disp.cpp +++ b/client/SDL/sdl_disp.cpp @@ -138,7 +138,7 @@ static BOOL sdl_disp_check_context(void* context, sdlContext** ppsdl, sdlDispCon if (!context) return FALSE; - sdl = (sdlContext*)context; + sdl = reinterpret_cast(context); if (!(sdl->disp)) return FALSE; diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index 385ff6d56..0bb40414f 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -439,8 +439,9 @@ static BOOL sdl_create_primary(sdlContext* sdl) sdl_destroy_primary(sdl); sdl->primary = SDL_CreateRGBSurfaceWithFormatFrom( - gdi->primary_buffer, (int)gdi->width, (int)gdi->height, - (int)FreeRDPGetBitsPerPixel(gdi->dstFormat), (int)gdi->stride, sdl->sdl_pixel_format); + gdi->primary_buffer, static_cast(gdi->width), static_cast(gdi->height), + static_cast(FreeRDPGetBitsPerPixel(gdi->dstFormat)), static_cast(gdi->stride), + sdl->sdl_pixel_format); sdl->primary_format = SDL_AllocFormat(sdl->sdl_pixel_format); if (!sdl->primary || !sdl->primary_format) @@ -500,16 +501,13 @@ static BOOL sdl_wait_for_init(sdlContext* sdl) * Set all configuration options to support and load channels here. */ static BOOL sdl_pre_connect(freerdp* instance) { - rdpSettings* settings; - sdlContext* sdl; - WINPR_ASSERT(instance); WINPR_ASSERT(instance->context); - sdl = (sdlContext*)instance->context; + auto sdl = reinterpret_cast(instance->context); sdl->highDpi = TRUE; // If High DPI is available, we want unscaled data, RDP can scale itself. - settings = instance->context->settings; + auto settings = instance->context->settings; WINPR_ASSERT(settings); /* Optional OS identifier sent to server */ @@ -646,7 +644,7 @@ static BOOL sdl_create_windows(sdlContext* sdl) window = &sdl->windows[x]; window->window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - (int)w, (int)h, flags); + static_cast(w), static_cast(h), flags); if (!window->window) goto fail; } @@ -836,8 +834,10 @@ static int sdl_run(sdlContext* sdl) break; case SDL_USEREVENT_POINTER_POSITION: { - const INT32 x = (INT32)(uintptr_t)windowEvent.user.data1; - const INT32 y = (INT32)(uintptr_t)windowEvent.user.data2; + const INT32 x = + static_cast(reinterpret_cast(windowEvent.user.data1)); + const INT32 y = + static_cast(reinterpret_cast(windowEvent.user.data2)); SDL_Window* window = SDL_GetMouseFocus(); if (window) @@ -877,15 +877,12 @@ fail: */ static BOOL sdl_post_connect(freerdp* instance) { - sdlContext* sdl; - rdpContext* context; - WINPR_ASSERT(instance); - context = instance->context; + auto context = instance->context; WINPR_ASSERT(context); - sdl = (sdlContext*)context; + auto sdl = reinterpret_cast(context); if (freerdp_settings_get_bool(context->settings, FreeRDP_AuthenticationOnly)) { @@ -940,15 +937,13 @@ static BOOL sdl_post_connect(freerdp* instance) */ static void sdl_post_disconnect(freerdp* instance) { - sdlContext* context; - if (!instance) return; if (!instance->context) return; - context = (sdlContext*)instance->context; + auto context = reinterpret_cast(instance->context); PubSub_UnsubscribeChannelConnected(instance->context->pubSub, sdl_OnChannelConnectedEventHandler); PubSub_UnsubscribeChannelDisconnected(instance->context->pubSub, @@ -960,15 +955,13 @@ static void sdl_post_disconnect(freerdp* instance) static void sdl_post_final_disconnect(freerdp* instance) { - sdlContext* context; - if (!instance) return; if (!instance->context) return; - context = (sdlContext*)instance->context; + auto context = reinterpret_cast(instance->context); delete (context->disp); context->disp = nullptr; @@ -982,7 +975,7 @@ static void sdl_post_final_disconnect(freerdp* instance) * after the connection ends. */ static DWORD WINAPI sdl_client_thread_proc(void* arg) { - sdlContext* sdl = (sdlContext*)arg; + auto sdl = reinterpret_cast(arg); DWORD nCount; DWORD status; int exit_code = SDL_EXIT_SUCCESS; diff --git a/client/SDL/sdl_pointer.cpp b/client/SDL/sdl_pointer.cpp index 688a248ad..2e82e9d10 100644 --- a/client/SDL/sdl_pointer.cpp +++ b/client/SDL/sdl_pointer.cpp @@ -80,7 +80,7 @@ static void sdl_Pointer_Clear(sdlPointer* ptr) static void sdl_Pointer_Free(rdpContext* context, rdpPointer* pointer) { - sdlPointer* ptr = (sdlPointer*)pointer; + auto ptr = reinterpret_cast(pointer); WINPR_UNUSED(context); if (ptr) @@ -100,7 +100,7 @@ static BOOL sdl_Pointer_SetDefault(rdpContext* context) static BOOL sdl_Pointer_Set(rdpContext* context, rdpPointer* pointer) { - sdlContext* sdl = (sdlContext*)context; + auto sdl = reinterpret_cast(context); return sdl_push_user_event(SDL_USEREVENT_POINTER_SET, pointer, sdl); } @@ -123,10 +123,10 @@ BOOL sdl_Pointer_Set_Process(SDL_UserEvent* uptr) rdpGdi* gdi = context->gdi; WINPR_ASSERT(gdi); - x = (INT32)pointer->xPos; - y = (INT32)pointer->yPos; - sw = w = (INT32)pointer->width; - sh = h = (INT32)pointer->height; + x = static_cast(pointer->xPos); + y = static_cast(pointer->yPos); + sw = w = static_cast(pointer->width); + sh = h = static_cast(pointer->height); SDL_Window* window = SDL_GetMouseFocus(); if (!window) @@ -141,16 +141,18 @@ 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, (int)bpp, sdl->sdl_pixel_format); + ptr->image = + SDL_CreateRGBSurfaceWithFormat(0, sw, sh, static_cast(bpp), sdl->sdl_pixel_format); if (!ptr->image) return FALSE; SDL_LockSurface(ptr->image); auto pixels = static_cast(ptr->image->pixels); auto data = static_cast(ptr->data); - const BOOL rc = - freerdp_image_scale(pixels, gdi->dstFormat, ptr->image->pitch, 0, 0, ptr->image->w, - ptr->image->h, data, gdi->dstFormat, 0, 0, 0, w, h); + const BOOL rc = freerdp_image_scale( + pixels, gdi->dstFormat, static_cast(ptr->image->pitch), 0, 0, + static_cast(ptr->image->w), static_cast(ptr->image->h), data, + gdi->dstFormat, 0, 0, 0, static_cast(w), static_cast(h)); SDL_UnlockSurface(ptr->image); if (!rc) return FALSE; @@ -181,19 +183,10 @@ static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) BOOL sdl_register_pointer(rdpGraphics* graphics) { - rdpPointer* pointer = nullptr; - - if (!(pointer = (rdpPointer*)calloc(1, sizeof(rdpPointer)))) - return FALSE; - - pointer->size = sizeof(sdlPointer); - pointer->New = sdl_Pointer_New; - pointer->Free = sdl_Pointer_Free; - pointer->Set = sdl_Pointer_Set; - pointer->SetNull = sdl_Pointer_SetNull; - pointer->SetDefault = sdl_Pointer_SetDefault; - pointer->SetPosition = sdl_Pointer_SetPosition; - graphics_register_pointer(graphics, pointer); - free(pointer); + const rdpPointer pointer = { sizeof(sdlPointer), sdl_Pointer_New, + sdl_Pointer_Free, sdl_Pointer_Set, + sdl_Pointer_SetNull, sdl_Pointer_SetDefault, + sdl_Pointer_SetPosition }; + graphics_register_pointer(graphics, &pointer); return TRUE; } diff --git a/client/SDL/sdl_touch.cpp b/client/SDL/sdl_touch.cpp index e3fd35da9..3ea34791e 100644 --- a/client/SDL/sdl_touch.cpp +++ b/client/SDL/sdl_touch.cpp @@ -65,8 +65,8 @@ BOOL sdl_scale_coordinates(sdlContext* sdl, Uint32 windowId, INT32* px, INT32* p } SDL_GetWindowSize(window->window, &w, &h); - sx = w / (double)gdi->width; - sy = h / (double)gdi->height; + sx = w / static_cast(gdi->width); + sy = h / static_cast(gdi->height); offset_x = window->offset_x; offset_y = window->offset_y; break; @@ -76,13 +76,13 @@ BOOL sdl_scale_coordinates(sdlContext* sdl, Uint32 windowId, INT32* px, INT32* p { if (!fromLocalToRDP) { - *px = (INT32)(*px * sx); - *py = (INT32)(*py * sy); + *px = static_cast(*px * sx); + *py = static_cast(*py * sy); } else { - *px = (INT32)(*px / sx); - *py = (INT32)(*py / sy); + *px = static_cast(*px / sx); + *py = static_cast(*py / sy); } } else if (applyOffset) @@ -119,8 +119,8 @@ static BOOL sdl_get_touch_scaled(sdlContext* sdl, const SDL_TouchFingerEvent* ev return FALSE; // TODO: Add the offset of the surface in the global coordinates - *px = (INT32)(ev->x * (float)surface->w); - *py = (INT32)(ev->y * (float)surface->h); + *px = static_cast(ev->x * static_cast(surface->w)); + *py = static_cast(ev->y * static_cast(surface->h)); return sdl_scale_coordinates(sdl, windowID, px, py, local, TRUE); } @@ -135,7 +135,7 @@ static BOOL send_mouse_wheel(sdlContext* sdl, UINT16 flags, INT32 avalue) while (avalue > 0) { - const UINT16 cval = (avalue > 0xFF) ? 0xFF : (UINT16)avalue; + const UINT16 cval = (avalue > 0xFF) ? 0xFF : static_cast(avalue); UINT16 cflags = flags | cval; /* Convert negative values to 9bit twos complement */ if (flags & PTR_FLAGS_WHEEL_NEGATIVE) @@ -155,7 +155,7 @@ static UINT32 sdl_scale_pressure(const float pressure) return 0; if (val > 0x400) return 0x400; - return (UINT32)val; + return static_cast(val); } BOOL sdl_handle_touch_up(sdlContext* sdl, const SDL_TouchFingerEvent* ev) @@ -167,7 +167,8 @@ 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, - (INT32)ev->fingerId, sdl_scale_pressure(ev->pressure), x, y); + static_cast(ev->fingerId), + sdl_scale_pressure(ev->pressure), x, y); } BOOL sdl_handle_touch_down(sdlContext* sdl, const SDL_TouchFingerEvent* ev) @@ -178,9 +179,9 @@ BOOL sdl_handle_touch_down(sdlContext* sdl, const SDL_TouchFingerEvent* ev) INT32 x, y; if (!sdl_get_touch_scaled(sdl, ev, &x, &y, TRUE)) return FALSE; - return freerdp_client_handle_touch(&sdl->common, - FREERDP_TOUCH_DOWN | FREERDP_TOUCH_HAS_PRESSURE, - (INT32)ev->fingerId, sdl_scale_pressure(ev->pressure), x, y); + return freerdp_client_handle_touch( + &sdl->common, FREERDP_TOUCH_DOWN | FREERDP_TOUCH_HAS_PRESSURE, + static_cast(ev->fingerId), sdl_scale_pressure(ev->pressure), x, y); } BOOL sdl_handle_touch_motion(sdlContext* sdl, const SDL_TouchFingerEvent* ev) @@ -191,9 +192,9 @@ BOOL sdl_handle_touch_motion(sdlContext* sdl, const SDL_TouchFingerEvent* ev) INT32 x, y; if (!sdl_get_touch_scaled(sdl, ev, &x, &y, TRUE)) return FALSE; - return freerdp_client_handle_touch(&sdl->common, - FREERDP_TOUCH_MOTION | FREERDP_TOUCH_HAS_PRESSURE, - (INT32)ev->fingerId, sdl_scale_pressure(ev->pressure), x, y); + return freerdp_client_handle_touch( + &sdl->common, FREERDP_TOUCH_MOTION | FREERDP_TOUCH_HAS_PRESSURE, + static_cast(ev->fingerId), sdl_scale_pressure(ev->pressure), x, y); } BOOL sdl_handle_mouse_motion(sdlContext* sdl, const SDL_MouseMotionEvent* ev) diff --git a/client/SDL/sdl_utils.cpp b/client/SDL/sdl_utils.cpp index 0eb1a32db..9ffd0d70b 100644 --- a/client/SDL/sdl_utils.cpp +++ b/client/SDL/sdl_utils.cpp @@ -136,7 +136,7 @@ BOOL sdl_log_error_ex(Uint32 res, wLog* log, const char* what, const char* file, BOOL sdl_push_user_event(Uint32 type, ...) { - SDL_Event ev = { 0 }; + SDL_Event ev = {}; SDL_UserEvent* event = &ev.user; va_list ap; @@ -148,15 +148,15 @@ BOOL sdl_push_user_event(Uint32 type, ...) event->data1 = va_arg(ap, void*); break; case SDL_USEREVENT_POINTER_POSITION: - event->data1 = (void*)(uintptr_t)va_arg(ap, UINT32); - event->data2 = (void*)(uintptr_t)va_arg(ap, UINT32); + event->data1 = reinterpret_cast(static_cast(va_arg(ap, UINT32))); + event->data2 = reinterpret_cast(static_cast(va_arg(ap, UINT32))); break; case SDL_USEREVENT_POINTER_SET: event->data1 = va_arg(ap, void*); event->data2 = va_arg(ap, void*); break; case SDL_USEREVENT_CREATE_WINDOWS: - event->data1 = (void*)va_arg(ap, void*); + event->data1 = reinterpret_cast(va_arg(ap, void*)); break; case SDL_USEREVENT_WINDOW_FULLSCREEN: case SDL_USEREVENT_WINDOW_RESIZEABLE: diff --git a/client/SDL/sdl_webview.cpp b/client/SDL/sdl_webview.cpp index 23f374f41..e77b77355 100644 --- a/client/SDL/sdl_webview.cpp +++ b/client/SDL/sdl_webview.cpp @@ -50,7 +50,7 @@ class SchemeHandler : public QWebEngineUrlSchemeHandler continue; QByteArray code = pair[1].toUtf8(); - *codeptr = (char*)calloc(1, code.size() + 1); + *codeptr = reinterpret_cast(calloc(1, code.size() + 1)); strcpy(*codeptr, code.constData()); break; }