mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[Analyzers][CPP] Turn on rule 26497 (#23119)
* Turn on warning 26497 This function function-name could be marked constexpr if compile-time evaluation is desired. * C++20 has constexpr swap * as constexpr is not only for compile time, make all functions that can be constexpr constexpr * constexpr functions are implicity inline
This commit is contained in:
@@ -207,7 +207,7 @@ namespace MonitorUtils
|
||||
return { .id = str.substr(0, dividerPos), .instanceId = str.substr(dividerPos + 1) };
|
||||
}
|
||||
|
||||
inline bool not_digit(wchar_t ch)
|
||||
constexpr inline bool not_digit(wchar_t ch)
|
||||
{
|
||||
return '0' <= ch && ch <= '9';
|
||||
}
|
||||
|
||||
@@ -248,32 +248,6 @@ namespace FancyZonesUtils
|
||||
return closestIdx;
|
||||
}
|
||||
|
||||
RECT PrepareRectForCycling(RECT windowRect, RECT workAreaRect, DWORD vkCode) noexcept
|
||||
{
|
||||
LONG deltaX = 0, deltaY = 0;
|
||||
switch (vkCode)
|
||||
{
|
||||
case VK_UP:
|
||||
deltaY = workAreaRect.bottom - workAreaRect.top;
|
||||
break;
|
||||
case VK_DOWN:
|
||||
deltaY = workAreaRect.top - workAreaRect.bottom;
|
||||
break;
|
||||
case VK_LEFT:
|
||||
deltaX = workAreaRect.right - workAreaRect.left;
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
deltaX = workAreaRect.left - workAreaRect.right;
|
||||
}
|
||||
|
||||
windowRect.left += deltaX;
|
||||
windowRect.right += deltaX;
|
||||
windowRect.top += deltaY;
|
||||
windowRect.bottom += deltaY;
|
||||
|
||||
return windowRect;
|
||||
}
|
||||
|
||||
void SwallowKey(const WORD key) noexcept
|
||||
{
|
||||
INPUT inputKey[1] = {};
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace FancyZonesUtils
|
||||
}
|
||||
}
|
||||
|
||||
inline BYTE OpacitySettingToAlpha(int opacity)
|
||||
constexpr inline BYTE OpacitySettingToAlpha(int opacity)
|
||||
{
|
||||
return static_cast<BYTE>(opacity * 2.55);
|
||||
}
|
||||
@@ -168,6 +168,32 @@ namespace FancyZonesUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
constexpr RECT PrepareRectForCycling(RECT windowRect, RECT workAreaRect, DWORD vkCode) noexcept
|
||||
{
|
||||
LONG deltaX = 0, deltaY = 0;
|
||||
switch (vkCode)
|
||||
{
|
||||
case VK_UP:
|
||||
deltaY = workAreaRect.bottom - workAreaRect.top;
|
||||
break;
|
||||
case VK_DOWN:
|
||||
deltaY = workAreaRect.top - workAreaRect.bottom;
|
||||
break;
|
||||
case VK_LEFT:
|
||||
deltaX = workAreaRect.right - workAreaRect.left;
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
deltaX = workAreaRect.left - workAreaRect.right;
|
||||
}
|
||||
|
||||
windowRect.left += deltaX;
|
||||
windowRect.right += deltaX;
|
||||
windowRect.top += deltaY;
|
||||
windowRect.bottom += deltaY;
|
||||
|
||||
return windowRect;
|
||||
}
|
||||
|
||||
UINT GetDpiForMonitor(HMONITOR monitor) noexcept;
|
||||
void OrderMonitors(std::vector<std::pair<HMONITOR, RECT>>& monitorInfo);
|
||||
|
||||
@@ -175,7 +201,6 @@ namespace FancyZonesUtils
|
||||
std::optional<GUID> GuidFromString(const std::wstring& str) noexcept;
|
||||
std::optional<std::wstring> GuidToString(const GUID& guid) noexcept;
|
||||
|
||||
RECT PrepareRectForCycling(RECT windowRect, RECT workAreaRect, DWORD vkCode) noexcept;
|
||||
size_t ChooseNextZoneByPosition(DWORD vkCode, RECT windowRect, const std::vector<RECT>& zoneRects) noexcept;
|
||||
|
||||
void SwallowKey(const WORD key) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user