Fix Windows clang-tidy errors

This commit is contained in:
Chris Thrasher 2023-01-13 17:10:42 -07:00
parent cab0e75503
commit f0119145c2
5 changed files with 35 additions and 33 deletions

View File

@ -107,8 +107,8 @@ int main()
nullptr, nullptr,
instance, instance,
nullptr); nullptr);
sf::RenderWindow SFMLView1(view1); sf::RenderWindow sfmlView1(view1);
sf::RenderWindow SFMLView2(view2); sf::RenderWindow sfmlView2(view2);
// Load some textures to display // Load some textures to display
sf::Texture texture1, texture2; sf::Texture texture1, texture2;
@ -138,26 +138,26 @@ int main()
float time = clock.getElapsedTime().asSeconds(); float time = clock.getElapsedTime().asSeconds();
// Clear views // Clear views
SFMLView1.clear(); sfmlView1.clear();
SFMLView2.clear(); sfmlView2.clear();
// Draw sprite 1 on view 1 // Draw sprite 1 on view 1
sprite1.setRotation(sf::degrees(time * 100)); sprite1.setRotation(sf::degrees(time * 100));
SFMLView1.draw(sprite1); sfmlView1.draw(sprite1);
// Draw sprite 2 on view 2 // Draw sprite 2 on view 2
sprite2.setPosition({std::cos(time) * 100.f, 0.f}); sprite2.setPosition({std::cos(time) * 100.f, 0.f});
SFMLView2.draw(sprite2); sfmlView2.draw(sprite2);
// Display each view on screen // Display each view on screen
SFMLView1.display(); sfmlView1.display();
SFMLView2.display(); sfmlView2.display();
} }
} }
// Close our SFML views before destroying the underlying window // Close our SFML views before destroying the underlying window
SFMLView1.close(); sfmlView1.close();
SFMLView2.close(); sfmlView2.close();
// Destroy the main window (all its child controls will be destroyed) // Destroy the main window (all its child controls will be destroyed)
DestroyWindow(window); DestroyWindow(window);

View File

@ -52,17 +52,17 @@ String ClipboardImpl::getString()
return text; return text;
} }
HANDLE clipboard_handle = GetClipboardData(CF_UNICODETEXT); HANDLE clipboardHandle = GetClipboardData(CF_UNICODETEXT);
if (!clipboard_handle) if (!clipboardHandle)
{ {
err() << "Failed to get Win32 handle for clipboard content." << std::endl; err() << "Failed to get Win32 handle for clipboard content." << std::endl;
CloseClipboard(); CloseClipboard();
return text; return text;
} }
text = String(static_cast<wchar_t*>(GlobalLock(clipboard_handle))); text = String(static_cast<wchar_t*>(GlobalLock(clipboardHandle)));
GlobalUnlock(clipboard_handle); GlobalUnlock(clipboardHandle);
CloseClipboard(); CloseClipboard();
return text; return text;
@ -85,14 +85,14 @@ void ClipboardImpl::setString(const String& text)
} }
// Create a Win32-compatible string // Create a Win32-compatible string
std::size_t string_size = (text.getSize() + 1) * sizeof(WCHAR); std::size_t stringSize = (text.getSize() + 1) * sizeof(WCHAR);
HANDLE string_handle = GlobalAlloc(GMEM_MOVEABLE, string_size); HANDLE stringHandle = GlobalAlloc(GMEM_MOVEABLE, stringSize);
if (string_handle) if (stringHandle)
{ {
memcpy(GlobalLock(string_handle), text.toWideString().data(), string_size); memcpy(GlobalLock(stringHandle), text.toWideString().data(), stringSize);
GlobalUnlock(string_handle); GlobalUnlock(stringHandle);
SetClipboardData(CF_UNICODETEXT, string_handle); SetClipboardData(CF_UNICODETEXT, stringHandle);
} }
CloseClipboard(); CloseClipboard();

View File

@ -56,6 +56,7 @@ namespace
{ {
namespace guids namespace guids
{ {
// NOLINTBEGIN(readability-identifier-naming)
const GUID IID_IDirectInput8W = {0xbf798031, 0x483a, 0x4da2, {0xaa, 0x99, 0x5d, 0x64, 0xed, 0x36, 0x97, 0x00}}; const GUID IID_IDirectInput8W = {0xbf798031, 0x483a, 0x4da2, {0xaa, 0x99, 0x5d, 0x64, 0xed, 0x36, 0x97, 0x00}};
const GUID GUID_XAxis = {0xa36d02e0, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}; const GUID GUID_XAxis = {0xa36d02e0, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
@ -68,6 +69,7 @@ const GUID GUID_POV = {0xa36d02f2, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53
const GUID GUID_RxAxis = {0xa36d02f4, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}; const GUID GUID_RxAxis = {0xa36d02f4, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
const GUID GUID_RyAxis = {0xa36d02f5, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}; const GUID GUID_RyAxis = {0xa36d02f5, 0xc9f3, 0x11cf, {0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
// NOLINTEND(readability-identifier-naming)
} // namespace guids } // namespace guids
HMODULE dinput8dll = nullptr; HMODULE dinput8dll = nullptr;

View File

@ -133,22 +133,22 @@ bool VulkanImplWin32::isAvailable(bool requireGraphics)
wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensionProperties.data()); wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensionProperties.data());
// Check if the necessary extensions are available // Check if the necessary extensions are available
bool has_VK_KHR_surface = false; bool hasVkKhrSurface = false;
bool has_VK_KHR_platform_surface = false; bool hasVkKhrPlatformSurface = false;
for (const VkExtensionProperties& properties : extensionProperties) for (const VkExtensionProperties& properties : extensionProperties)
{ {
if (!std::strcmp(properties.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) if (!std::strcmp(properties.extensionName, VK_KHR_SURFACE_EXTENSION_NAME))
{ {
has_VK_KHR_surface = true; hasVkKhrSurface = true;
} }
else if (!std::strcmp(properties.extensionName, VK_KHR_WIN32_SURFACE_EXTENSION_NAME)) else if (!std::strcmp(properties.extensionName, VK_KHR_WIN32_SURFACE_EXTENSION_NAME))
{ {
has_VK_KHR_platform_surface = true; hasVkKhrPlatformSurface = true;
} }
} }
if (!has_VK_KHR_surface || !has_VK_KHR_platform_surface) if (!hasVkKhrSurface || !hasVkKhrPlatformSurface)
graphicsAvailable = false; graphicsAvailable = false;
} }
} }

View File

@ -61,7 +61,7 @@ unsigned int handleCount = 0; // All window handles
const wchar_t* className = L"SFML_Window"; const wchar_t* className = L"SFML_Window";
sf::priv::WindowImplWin32* fullscreenWindow = nullptr; sf::priv::WindowImplWin32* fullscreenWindow = nullptr;
const GUID GUID_DEVINTERFACE_HID = {0x4d1e55b2, 0xf16f, 0x11cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}}; const GUID guidDevinterfaceHid = {0x4d1e55b2, 0xf16f, 0x11cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}};
void setProcessDpiAware() void setProcessDpiAware()
{ {
@ -78,10 +78,10 @@ void setProcessDpiAware()
}; };
using SetProcessDpiAwarenessFuncType = HRESULT(WINAPI*)(ProcessDpiAwareness); using SetProcessDpiAwarenessFuncType = HRESULT(WINAPI*)(ProcessDpiAwareness);
auto SetProcessDpiAwarenessFunc = reinterpret_cast<SetProcessDpiAwarenessFuncType>( auto setProcessDpiAwarenessFunc = reinterpret_cast<SetProcessDpiAwarenessFuncType>(
reinterpret_cast<void*>(GetProcAddress(shCoreDll, "SetProcessDpiAwareness"))); reinterpret_cast<void*>(GetProcAddress(shCoreDll, "SetProcessDpiAwareness")));
if (SetProcessDpiAwarenessFunc) if (setProcessDpiAwarenessFunc)
{ {
// We only check for E_INVALIDARG because we would get // We only check for E_INVALIDARG because we would get
// E_ACCESSDENIED if the DPI was already set previously // E_ACCESSDENIED if the DPI was already set previously
@ -90,7 +90,7 @@ void setProcessDpiAware()
// enabled with SetProcessDpiAwarenessContext, because that // enabled with SetProcessDpiAwarenessContext, because that
// would scale the title bar and thus change window size // would scale the title bar and thus change window size
// by default when moving the window between monitors. // by default when moving the window between monitors.
if (SetProcessDpiAwarenessFunc(ProcessPerMonitorDpiAware) == E_INVALIDARG) if (setProcessDpiAwarenessFunc(ProcessPerMonitorDpiAware) == E_INVALIDARG)
{ {
sf::err() << "Failed to set process DPI awareness" << std::endl; sf::err() << "Failed to set process DPI awareness" << std::endl;
} }
@ -111,12 +111,12 @@ void setProcessDpiAware()
if (user32Dll) if (user32Dll)
{ {
using SetProcessDPIAwareFuncType = BOOL(WINAPI*)(); using SetProcessDPIAwareFuncType = BOOL(WINAPI*)();
auto SetProcessDPIAwareFunc = reinterpret_cast<SetProcessDPIAwareFuncType>( auto setProcessDPIAwareFunc = reinterpret_cast<SetProcessDPIAwareFuncType>(
reinterpret_cast<void*>(GetProcAddress(user32Dll, "SetProcessDPIAware"))); reinterpret_cast<void*>(GetProcAddress(user32Dll, "SetProcessDPIAware")));
if (SetProcessDPIAwareFunc) if (setProcessDPIAwareFunc)
{ {
if (!SetProcessDPIAwareFunc()) if (!setProcessDPIAwareFunc())
sf::err() << "Failed to set process DPI awareness" << std::endl; sf::err() << "Failed to set process DPI awareness" << std::endl;
} }
@ -209,7 +209,7 @@ m_cursorGrabbed(m_fullscreen)
// Register to receive device interface change notifications (used for joystick connection handling) // Register to receive device interface change notifications (used for joystick connection handling)
DEV_BROADCAST_DEVICEINTERFACE deviceInterface = DEV_BROADCAST_DEVICEINTERFACE deviceInterface =
{sizeof(DEV_BROADCAST_DEVICEINTERFACE), DBT_DEVTYP_DEVICEINTERFACE, 0, GUID_DEVINTERFACE_HID, {0}}; {sizeof(DEV_BROADCAST_DEVICEINTERFACE), DBT_DEVTYP_DEVICEINTERFACE, 0, guidDevinterfaceHid, {0}};
RegisterDeviceNotification(m_handle, &deviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE); RegisterDeviceNotification(m_handle, &deviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE);
// If we're the first window handle, we only need to poll for joysticks when WM_DEVICECHANGE message is received // If we're the first window handle, we only need to poll for joysticks when WM_DEVICECHANGE message is received