mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Analyzers][CPP]Changes to fix warning 26493 on src/modules/ (L to M) (#23486)
starting with letter L to Letter M
This commit is contained in:
parent
0c5b528c54
commit
b13f74c089
@ -161,7 +161,7 @@ bool SuperSonar<D>::Initialize(HINSTANCE hinst)
|
|||||||
wc.hInstance = hinst;
|
wc.hInstance = hinst;
|
||||||
wc.hIcon = LoadIcon(hinst, IDI_APPLICATION);
|
wc.hIcon = LoadIcon(hinst, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
|
wc.hbrBackground = static_cast<HBRUSH>(GetStockObject(NULL_BRUSH));
|
||||||
wc.lpszClassName = className;
|
wc.lpszClassName = className;
|
||||||
|
|
||||||
if (!RegisterClassW(&wc))
|
if (!RegisterClassW(&wc))
|
||||||
@ -196,14 +196,14 @@ LRESULT SuperSonar<D>::s_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
SuperSonar* self;
|
SuperSonar* self;
|
||||||
if (message == WM_NCCREATE)
|
if (message == WM_NCCREATE)
|
||||||
{
|
{
|
||||||
auto info = (LPCREATESTRUCT)lParam;
|
auto info = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
||||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)info->lpCreateParams);
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(info->lpCreateParams));
|
||||||
self = (SuperSonar*)info->lpCreateParams;
|
self = static_cast<SuperSonar*>(info->lpCreateParams);
|
||||||
self->m_hwnd = hwnd;
|
self->m_hwnd = hwnd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self = (SuperSonar*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
self = reinterpret_cast<SuperSonar*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
|
||||||
}
|
}
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
@ -230,7 +230,7 @@ LRESULT SuperSonar<D>::BaseWndProc(UINT message, WPARAM wParam, LPARAM lParam) n
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_INPUT:
|
case WM_INPUT:
|
||||||
OnSonarInput(wParam, (HRAWINPUT)lParam);
|
OnSonarInput(wParam, reinterpret_cast<HRAWINPUT>(lParam));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
@ -272,7 +272,7 @@ void SuperSonar<D>::OnSonarInput(WPARAM flags, HRAWINPUT hInput)
|
|||||||
RAWINPUT input;
|
RAWINPUT input;
|
||||||
UINT size = sizeof(input);
|
UINT size = sizeof(input);
|
||||||
auto result = GetRawInputData(hInput, RID_INPUT, &input, &size, sizeof(RAWINPUTHEADER));
|
auto result = GetRawInputData(hInput, RID_INPUT, &input, &size, sizeof(RAWINPUTHEADER));
|
||||||
if ((int)result < sizeof(RAWINPUTHEADER))
|
if (result < sizeof(RAWINPUTHEADER))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ void SuperSonar<D>::DetectShake()
|
|||||||
{
|
{
|
||||||
currentX += movement.diff.x;
|
currentX += movement.diff.x;
|
||||||
currentY += movement.diff.y;
|
currentY += movement.diff.y;
|
||||||
distanceTravelled += sqrt((double)movement.diff.x * movement.diff.x + (double)movement.diff.y * movement.diff.y); // Pythagorean theorem
|
distanceTravelled += sqrt(static_cast<double>(movement.diff.x) * movement.diff.x + static_cast<double>(movement.diff.y) * movement.diff.y); // Pythagorean theorem
|
||||||
minX = min(currentX, minX);
|
minX = min(currentX, minX);
|
||||||
maxX = max(currentX, maxX);
|
maxX = max(currentX, maxX);
|
||||||
minY = min(currentY, minY);
|
minY = min(currentY, minY);
|
||||||
@ -410,8 +410,8 @@ void SuperSonar<D>::DetectShake()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Size of the rectangle the pointer moved in.
|
// Size of the rectangle the pointer moved in.
|
||||||
double rectangleWidth = (double)maxX - minX;
|
double rectangleWidth = static_cast<double>(maxX) - minX;
|
||||||
double rectangleHeight = (double)maxY - minY;
|
double rectangleHeight = static_cast<double>(maxY) - minY;
|
||||||
|
|
||||||
double diagonal = sqrt(rectangleWidth * rectangleWidth + rectangleHeight * rectangleHeight);
|
double diagonal = sqrt(rectangleWidth * rectangleWidth + rectangleHeight * rectangleHeight);
|
||||||
if (diagonal > 0 && distanceTravelled / diagonal > ShakeFactor)
|
if (diagonal > 0 && distanceTravelled / diagonal > ShakeFactor)
|
||||||
@ -592,7 +592,7 @@ bool SuperSonar<D>::IsForegroundAppExcluded()
|
|||||||
if (HWND foregroundApp{ GetForegroundWindow() })
|
if (HWND foregroundApp{ GetForegroundWindow() })
|
||||||
{
|
{
|
||||||
auto processPath = get_process_path(foregroundApp);
|
auto processPath = get_process_path(foregroundApp);
|
||||||
CharUpperBuffW(processPath.data(), (DWORD)processPath.length());
|
CharUpperBuffW(processPath.data(), static_cast<DWORD>(processPath.length()));
|
||||||
return find_app_name_in_path(processPath, m_excludedApps);
|
return find_app_name_in_path(processPath, m_excludedApps);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -613,7 +613,7 @@ struct CompositionSpotlight : SuperSonar<CompositionSpotlight>
|
|||||||
|
|
||||||
void AfterMoveSonar()
|
void AfterMoveSonar()
|
||||||
{
|
{
|
||||||
m_spotlight.Offset({ (float)m_sonarPos.x, (float)m_sonarPos.y, 0.0f });
|
m_spotlight.Offset({ static_cast<float>(m_sonarPos.x), static_cast<float>(m_sonarPos.y), 0.0f });
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT WndProc(UINT message, WPARAM wParam, LPARAM lParam) noexcept
|
LRESULT WndProc(UINT message, WPARAM wParam, LPARAM lParam) noexcept
|
||||||
@ -924,10 +924,10 @@ struct GdiSpotlight : GdiSonar<GdiSpotlight>
|
|||||||
auto spotlight = CreateRoundRectRgn(
|
auto spotlight = CreateRoundRectRgn(
|
||||||
this->m_sonarPos.x - radius, this->m_sonarPos.y - radius, this->m_sonarPos.x + radius, this->m_sonarPos.y + radius, radius * 2, radius * 2);
|
this->m_sonarPos.x - radius, this->m_sonarPos.y - radius, this->m_sonarPos.x + radius, this->m_sonarPos.y + radius, radius * 2, radius * 2);
|
||||||
|
|
||||||
FillRgn(ps.hdc, spotlight, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
FillRgn(ps.hdc, spotlight, static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)));
|
||||||
Sleep(1000 / 60);
|
Sleep(1000 / 60);
|
||||||
ExtSelectClipRgn(ps.hdc, spotlight, RGN_DIFF);
|
ExtSelectClipRgn(ps.hdc, spotlight, RGN_DIFF);
|
||||||
FillRect(ps.hdc, &ps.rcPaint, (HBRUSH)GetStockObject(BLACK_BRUSH));
|
FillRect(ps.hdc, &ps.rcPaint, static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
|
||||||
DeleteObject(spotlight);
|
DeleteObject(spotlight);
|
||||||
|
|
||||||
EndPaint(this->m_hwnd, &ps);
|
EndPaint(this->m_hwnd, &ps);
|
||||||
@ -959,7 +959,7 @@ struct GdiCrosshairs : GdiSonar<GdiCrosshairs>
|
|||||||
auto radius = CurrentSonarRadius();
|
auto radius = CurrentSonarRadius();
|
||||||
RECT rc;
|
RECT rc;
|
||||||
|
|
||||||
HBRUSH white = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
HBRUSH white = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
rc.left = m_sonarPos.x - radius;
|
rc.left = m_sonarPos.x - radius;
|
||||||
rc.top = ps.rcPaint.top;
|
rc.top = ps.rcPaint.top;
|
||||||
@ -973,7 +973,7 @@ struct GdiCrosshairs : GdiSonar<GdiCrosshairs>
|
|||||||
rc.bottom = m_sonarPos.y + radius;
|
rc.bottom = m_sonarPos.y + radius;
|
||||||
FillRect(ps.hdc, &rc, white);
|
FillRect(ps.hdc, &rc, white);
|
||||||
|
|
||||||
HBRUSH black = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
HBRUSH black = static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
|
||||||
|
|
||||||
// Top left
|
// Top left
|
||||||
rc.left = ps.rcPaint.left;
|
rc.left = ps.rcPaint.left;
|
||||||
|
@ -185,11 +185,16 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
{
|
{
|
||||||
// Parse Activation Method
|
// Parse Activation Method
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ACTIVATION_METHOD);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ACTIVATION_METHOD);
|
||||||
UINT value = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
if (value < (int)FindMyMouseActivationMethod::EnumElements)
|
if (value < static_cast<int>(FindMyMouseActivationMethod::EnumElements) && value >= 0)
|
||||||
{
|
{
|
||||||
findMyMouseSettings.activationMethod = (FindMyMouseActivationMethod)value;
|
findMyMouseSettings.activationMethod = static_cast<FindMyMouseActivationMethod>(value);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -198,7 +203,7 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_DO_NOT_ACTIVATE_ON_GAME_MODE);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_DO_NOT_ACTIVATE_ON_GAME_MODE);
|
||||||
findMyMouseSettings.doNotActivateOnGameMode = (bool)jsonPropertiesObject.GetNamedBoolean(JSON_KEY_VALUE);
|
findMyMouseSettings.doNotActivateOnGameMode = jsonPropertiesObject.GetNamedBoolean(JSON_KEY_VALUE);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -246,7 +251,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
{
|
{
|
||||||
// Parse Overlay Opacity
|
// Parse Overlay Opacity
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_OVERLAY_OPACITY);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_OVERLAY_OPACITY);
|
||||||
findMyMouseSettings.overlayOpacity = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
findMyMouseSettings.overlayOpacity = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -256,7 +269,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
{
|
{
|
||||||
// Parse Spotlight Radius
|
// Parse Spotlight Radius
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SPOTLIGHT_RADIUS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SPOTLIGHT_RADIUS);
|
||||||
findMyMouseSettings.spotlightRadius = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
findMyMouseSettings.spotlightRadius = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -266,7 +287,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
{
|
{
|
||||||
// Parse Animation Duration
|
// Parse Animation Duration
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ANIMATION_DURATION_MS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ANIMATION_DURATION_MS);
|
||||||
findMyMouseSettings.animationDurationMs = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
findMyMouseSettings.animationDurationMs = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -276,7 +305,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
{
|
{
|
||||||
// Parse Spotlight Initial Zoom
|
// Parse Spotlight Initial Zoom
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SPOTLIGHT_INITIAL_ZOOM);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SPOTLIGHT_INITIAL_ZOOM);
|
||||||
findMyMouseSettings.spotlightInitialZoom = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
findMyMouseSettings.spotlightInitialZoom = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -289,7 +326,7 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
std::wstring apps = jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE).c_str();
|
std::wstring apps = jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE).c_str();
|
||||||
std::vector<std::wstring> excludedApps;
|
std::vector<std::wstring> excludedApps;
|
||||||
auto excludedUppercase = apps;
|
auto excludedUppercase = apps;
|
||||||
CharUpperBuffW(excludedUppercase.data(), (DWORD)excludedUppercase.length());
|
CharUpperBuffW(excludedUppercase.data(), static_cast<DWORD>(excludedUppercase.length()));
|
||||||
std::wstring_view view(excludedUppercase);
|
std::wstring_view view(excludedUppercase);
|
||||||
view = left_trim<wchar_t>(trim<wchar_t>(view));
|
view = left_trim<wchar_t>(trim<wchar_t>(view));
|
||||||
|
|
||||||
@ -311,7 +348,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|||||||
{
|
{
|
||||||
// Parse Shaking Minimum Distance
|
// Parse Shaking Minimum Distance
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SHAKING_MINIMUM_DISTANCE);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_SHAKING_MINIMUM_DISTANCE);
|
||||||
findMyMouseSettings.shakeMinimumDistance = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
findMyMouseSettings.shakeMinimumDistance = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ void Highlighter::AddDrawingPoint(MouseButton button)
|
|||||||
auto circleGeometry = m_compositor.CreateEllipseGeometry();
|
auto circleGeometry = m_compositor.CreateEllipseGeometry();
|
||||||
circleGeometry.Radius({ m_radius, m_radius });
|
circleGeometry.Radius({ m_radius, m_radius });
|
||||||
auto circleShape = m_compositor.CreateSpriteShape(circleGeometry);
|
auto circleShape = m_compositor.CreateSpriteShape(circleGeometry);
|
||||||
circleShape.Offset({ (float)pt.x, (float)pt.y });
|
circleShape.Offset({ static_cast<float>(pt.x), static_cast<float>(pt.y )});
|
||||||
if (button == MouseButton::Left)
|
if (button == MouseButton::Left)
|
||||||
{
|
{
|
||||||
circleShape.FillBrush(m_compositor.CreateColorBrush(m_leftClickColor));
|
circleShape.FillBrush(m_compositor.CreateColorBrush(m_leftClickColor));
|
||||||
@ -166,12 +166,12 @@ void Highlighter::UpdateDrawingPointPosition(MouseButton button)
|
|||||||
|
|
||||||
if (button == MouseButton::Left)
|
if (button == MouseButton::Left)
|
||||||
{
|
{
|
||||||
m_leftPointer.Offset({ (float)pt.x, (float)pt.y });
|
m_leftPointer.Offset({ static_cast<float>(pt.x), static_cast<float>(pt.y )});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//right
|
//right
|
||||||
m_rightPointer.Offset({ (float)pt.x, (float)pt.y });
|
m_rightPointer.Offset({ static_cast<float>(pt.x), static_cast<float>(pt.y )});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Highlighter::StartDrawingPointFading(MouseButton button)
|
void Highlighter::StartDrawingPointFading(MouseButton button)
|
||||||
@ -217,7 +217,7 @@ LRESULT CALLBACK Highlighter::MouseHookProc(int nCode, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
if (nCode >= 0)
|
if (nCode >= 0)
|
||||||
{
|
{
|
||||||
MSLLHOOKSTRUCT* hookData = (MSLLHOOKSTRUCT*)lParam;
|
MSLLHOOKSTRUCT* hookData = reinterpret_cast<MSLLHOOKSTRUCT*>(lParam);
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
@ -293,7 +293,7 @@ void Highlighter::SwitchActivationMode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Highlighter::ApplySettings(MouseHighlighterSettings settings) {
|
void Highlighter::ApplySettings(MouseHighlighterSettings settings) {
|
||||||
m_radius = (float)settings.radius;
|
m_radius = static_cast<float>(settings.radius);
|
||||||
m_fadeDelay_ms = settings.fadeDelayMs;
|
m_fadeDelay_ms = settings.fadeDelayMs;
|
||||||
m_fadeDuration_ms = settings.fadeDurationMs;
|
m_fadeDuration_ms = settings.fadeDurationMs;
|
||||||
m_leftClickColor = settings.leftButtonColor;
|
m_leftClickColor = settings.leftButtonColor;
|
||||||
@ -349,7 +349,7 @@ bool Highlighter::MyRegisterClass(HINSTANCE hInstance)
|
|||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
|
wc.hbrBackground = static_cast<HBRUSH>(GetStockObject(NULL_BRUSH));
|
||||||
wc.lpszClassName = m_className;
|
wc.lpszClassName = m_className;
|
||||||
|
|
||||||
if (!RegisterClassW(&wc))
|
if (!RegisterClassW(&wc))
|
||||||
|
@ -215,7 +215,15 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Opacity
|
// Parse Opacity
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_OPACITY);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_OPACITY);
|
||||||
opacity = (uint8_t)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
opacity = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -234,7 +242,7 @@ public:
|
|||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_LEFT_BUTTON_CLICK_COLOR);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_LEFT_BUTTON_CLICK_COLOR);
|
||||||
auto leftColor = (std::wstring)jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE);
|
auto leftColor = (std::wstring)jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE);
|
||||||
uint8_t r, g, b;
|
uint8_t r, g, b;
|
||||||
if (!checkValidRGB(leftColor,&r,&g,&b))
|
if (!checkValidRGB(leftColor, &r, &g, &b))
|
||||||
{
|
{
|
||||||
Logger::error("Left click color RGB value is invalid. Will use default value");
|
Logger::error("Left click color RGB value is invalid. Will use default value");
|
||||||
}
|
}
|
||||||
@ -270,7 +278,15 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Radius
|
// Parse Radius
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_RADIUS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_RADIUS);
|
||||||
highlightSettings.radius = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
highlightSettings.radius = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -280,7 +296,15 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Fade Delay
|
// Parse Fade Delay
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_FADE_DELAY_MS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_FADE_DELAY_MS);
|
||||||
highlightSettings.fadeDelayMs = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
highlightSettings.fadeDelayMs = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -290,7 +314,15 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Fade Duration
|
// Parse Fade Duration
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_FADE_DURATION_MS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_HIGHLIGHT_FADE_DURATION_MS);
|
||||||
highlightSettings.fadeDurationMs = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
highlightSettings.fadeDurationMs = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -212,25 +212,25 @@ void InclusiveCrosshairs::UpdateCrosshairsPosition()
|
|||||||
float halfPixelAdjustment = m_crosshairs_thickness % 2 == 1 ? 0.5f : 0.0f;
|
float halfPixelAdjustment = m_crosshairs_thickness % 2 == 1 ? 0.5f : 0.0f;
|
||||||
|
|
||||||
// Position crosshairs components around the mouse pointer.
|
// Position crosshairs components around the mouse pointer.
|
||||||
m_left_crosshairs_border.Offset({ (float)ptCursor.x - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2, (float)ptCursor.y + halfPixelAdjustment, .0f });
|
m_left_crosshairs_border.Offset({ ptCursor.x - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2, ptCursor.y + halfPixelAdjustment, .0f });
|
||||||
m_left_crosshairs_border.Size({ (float)ptCursor.x - (float)ptMonitorUpperLeft.x - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2, (float)m_crosshairs_thickness + m_crosshairs_border_size * 2 });
|
m_left_crosshairs_border.Size({ ptCursor.x - ptMonitorUpperLeft.x - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2, m_crosshairs_thickness + m_crosshairs_border_size * 2.f });
|
||||||
m_left_crosshairs.Offset({ (float)ptCursor.x - m_crosshairs_radius + halfPixelAdjustment * 2, (float)ptCursor.y + halfPixelAdjustment, .0f });
|
m_left_crosshairs.Offset({ ptCursor.x - m_crosshairs_radius + halfPixelAdjustment * 2.f, ptCursor.y + halfPixelAdjustment, .0f });
|
||||||
m_left_crosshairs.Size({ (float)ptCursor.x - (float)ptMonitorUpperLeft.x - m_crosshairs_radius + halfPixelAdjustment * 2, (float)m_crosshairs_thickness });
|
m_left_crosshairs.Size({ ptCursor.x - ptMonitorUpperLeft.x - m_crosshairs_radius + halfPixelAdjustment * 2, static_cast<float>(m_crosshairs_thickness) });
|
||||||
|
|
||||||
m_right_crosshairs_border.Offset({ (float)ptCursor.x + m_crosshairs_radius - m_crosshairs_border_size, (float)ptCursor.y + halfPixelAdjustment, .0f });
|
m_right_crosshairs_border.Offset({static_cast<float>(ptCursor.x) + m_crosshairs_radius - m_crosshairs_border_size, ptCursor.y + halfPixelAdjustment, .0f });
|
||||||
m_right_crosshairs_border.Size({ (float)ptMonitorBottomRight.x - (float)ptCursor.x - m_crosshairs_radius + m_crosshairs_border_size, (float)m_crosshairs_thickness + m_crosshairs_border_size * 2 });
|
m_right_crosshairs_border.Size({ static_cast<float>(ptMonitorBottomRight.x) - ptCursor.x - m_crosshairs_radius + m_crosshairs_border_size, m_crosshairs_thickness + m_crosshairs_border_size * 2.f });
|
||||||
m_right_crosshairs.Offset({ (float)ptCursor.x + m_crosshairs_radius, (float)ptCursor.y + halfPixelAdjustment, .0f });
|
m_right_crosshairs.Offset({ static_cast<float>(ptCursor.x) + m_crosshairs_radius, ptCursor.y + halfPixelAdjustment, .0f });
|
||||||
m_right_crosshairs.Size({ (float)ptMonitorBottomRight.x - (float)ptCursor.x - m_crosshairs_radius, (float)m_crosshairs_thickness });
|
m_right_crosshairs.Size({ static_cast<float>(ptMonitorBottomRight.x) - ptCursor.x - m_crosshairs_radius, static_cast<float>(m_crosshairs_thickness) });
|
||||||
|
|
||||||
m_top_crosshairs_border.Offset({ (float)ptCursor.x + halfPixelAdjustment, (float)ptCursor.y - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2, .0f });
|
m_top_crosshairs_border.Offset({ ptCursor.x + halfPixelAdjustment, ptCursor.y - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2, .0f });
|
||||||
m_top_crosshairs_border.Size({ (float)m_crosshairs_thickness + m_crosshairs_border_size * 2, (float)ptCursor.y - (float)ptMonitorUpperLeft.y - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2 });
|
m_top_crosshairs_border.Size({ m_crosshairs_thickness + m_crosshairs_border_size * 2.f, ptCursor.y - ptMonitorUpperLeft.y - m_crosshairs_radius + m_crosshairs_border_size + halfPixelAdjustment * 2 });
|
||||||
m_top_crosshairs.Offset({ (float)ptCursor.x + halfPixelAdjustment, (float)ptCursor.y - m_crosshairs_radius + halfPixelAdjustment * 2, .0f });
|
m_top_crosshairs.Offset({ ptCursor.x + halfPixelAdjustment, ptCursor.y - m_crosshairs_radius + halfPixelAdjustment * 2, .0f });
|
||||||
m_top_crosshairs.Size({ (float)m_crosshairs_thickness, (float)ptCursor.y - (float)ptMonitorUpperLeft.y - m_crosshairs_radius + halfPixelAdjustment * 2 });
|
m_top_crosshairs.Size({ static_cast<float>(m_crosshairs_thickness), ptCursor.y - ptMonitorUpperLeft.y - m_crosshairs_radius + halfPixelAdjustment * 2 });
|
||||||
|
|
||||||
m_bottom_crosshairs_border.Offset({ (float)ptCursor.x + halfPixelAdjustment, (float)ptCursor.y + m_crosshairs_radius - m_crosshairs_border_size, .0f });
|
m_bottom_crosshairs_border.Offset({ ptCursor.x + halfPixelAdjustment, static_cast<float>(ptCursor.y) + m_crosshairs_radius - m_crosshairs_border_size, .0f });
|
||||||
m_bottom_crosshairs_border.Size({ (float)m_crosshairs_thickness + m_crosshairs_border_size * 2, (float)ptMonitorBottomRight.y - (float)ptCursor.y - m_crosshairs_radius + m_crosshairs_border_size });
|
m_bottom_crosshairs_border.Size({ m_crosshairs_thickness + m_crosshairs_border_size * 2.f, static_cast<float>(ptMonitorBottomRight.y) - ptCursor.y - m_crosshairs_radius + m_crosshairs_border_size });
|
||||||
m_bottom_crosshairs.Offset({ (float)ptCursor.x + halfPixelAdjustment, (float)ptCursor.y + m_crosshairs_radius, .0f });
|
m_bottom_crosshairs.Offset({ ptCursor.x + halfPixelAdjustment, static_cast<float>(ptCursor.y) + m_crosshairs_radius, .0f });
|
||||||
m_bottom_crosshairs.Size({ (float)m_crosshairs_thickness, (float)ptMonitorBottomRight.y - (float)ptCursor.y - m_crosshairs_radius });
|
m_bottom_crosshairs.Size({ static_cast<float>(m_crosshairs_thickness), static_cast<float>(ptMonitorBottomRight.y) - ptCursor.y - m_crosshairs_radius });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ LRESULT CALLBACK InclusiveCrosshairs::MouseHookProc(int nCode, WPARAM wParam, LP
|
|||||||
{
|
{
|
||||||
if (nCode >= 0)
|
if (nCode >= 0)
|
||||||
{
|
{
|
||||||
MSLLHOOKSTRUCT* hookData = (MSLLHOOKSTRUCT*)lParam;
|
MSLLHOOKSTRUCT* hookData = reinterpret_cast<MSLLHOOKSTRUCT*>(lParam);
|
||||||
if (wParam == WM_MOUSEMOVE) {
|
if (wParam == WM_MOUSEMOVE) {
|
||||||
instance->UpdateCrosshairsPosition();
|
instance->UpdateCrosshairsPosition();
|
||||||
}
|
}
|
||||||
@ -362,7 +362,7 @@ bool InclusiveCrosshairs::MyRegisterClass(HINSTANCE hInstance)
|
|||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
|
wc.hbrBackground = static_cast<HBRUSH>(GetStockObject(NULL_BRUSH));
|
||||||
wc.lpszClassName = m_className;
|
wc.lpszClassName = m_className;
|
||||||
|
|
||||||
if (!RegisterClassW(&wc))
|
if (!RegisterClassW(&wc))
|
||||||
|
@ -222,7 +222,15 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Opacity
|
// Parse Opacity
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_OPACITY);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_OPACITY);
|
||||||
inclusiveCrosshairsSettings.crosshairsOpacity = (uint8_t)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<uint8_t>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
inclusiveCrosshairsSettings.crosshairsOpacity = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -251,7 +259,16 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Radius
|
// Parse Radius
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_RADIUS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_RADIUS);
|
||||||
inclusiveCrosshairsSettings.crosshairsRadius = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
inclusiveCrosshairsSettings.crosshairsRadius = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -261,7 +278,16 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse Thickness
|
// Parse Thickness
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_THICKNESS);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_THICKNESS);
|
||||||
inclusiveCrosshairsSettings.crosshairsThickness = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
inclusiveCrosshairsSettings.crosshairsThickness = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -290,7 +316,15 @@ public:
|
|||||||
{
|
{
|
||||||
// Parse border size
|
// Parse border size
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_BORDER_SIZE);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_BORDER_SIZE);
|
||||||
inclusiveCrosshairsSettings.crosshairsBorderSize = (UINT)jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE);
|
int value = static_cast <int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
||||||
|
if (value >= 0)
|
||||||
|
{
|
||||||
|
inclusiveCrosshairsSettings.crosshairsBorderSize = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -349,7 +349,7 @@ public:
|
|||||||
DWORD windowPid;
|
DWORD windowPid;
|
||||||
GetWindowThreadProcessId(nextWindow, &windowPid);
|
GetWindowThreadProcessId(nextWindow, &windowPid);
|
||||||
|
|
||||||
if (windowPid == (DWORD)closePid)
|
if (windowPid == static_cast<DWORD>(closePid))
|
||||||
::PostMessage(nextWindow, WM_CLOSE, 0, 0);
|
::PostMessage(nextWindow, WM_CLOSE, 0, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -401,7 +401,7 @@ void Microsoft_Launcher::parse_hotkey(PowerToysSettings::PowerToyValues& setting
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES);
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES);
|
||||||
m_use_centralized_keyboard_hook = (bool)jsonPropertiesObject.GetNamedBoolean(JSON_KEY_USE_CENTRALIZED_KEYBOARD_HOOK);
|
m_use_centralized_keyboard_hook =jsonPropertiesObject.GetNamedBoolean(JSON_KEY_USE_CENTRALIZED_KEYBOARD_HOOK);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user