Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MouseHighlighter]Fix stray highlights stucking #37309

Merged
merged 3 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/modules/MouseUtils/MouseHighlighter/MouseHighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ void Highlighter::ClearDrawingPoint(MouseButton _button)
{
winrt::Windows::UI::Composition::CompositionSpriteShape circleShape{ nullptr };

if (nullptr == m_alwaysPointer)
{
// Guard against alwaysPointer not being initialized.
return;
}

// always
circleShape = m_alwaysPointer;

Expand Down Expand Up @@ -265,6 +271,11 @@ LRESULT CALLBACK Highlighter::MouseHookProc(int nCode, WPARAM wParam, LPARAM lPa
// Clear AlwaysPointer only when it's enabled and RightPointer is not active
instance->ClearDrawingPoint(MouseButton::None);
}
if (instance->m_leftButtonPressed)
{
// There might be a stray point from the user releasing the mouse button on an elevated window, which wasn't caught by us.
instance->StartDrawingPointFading(MouseButton::Left);
}
instance->AddDrawingPoint(MouseButton::Left);
instance->m_leftButtonPressed = true;
// start a timer for the scenario, when the user clicks a pinned window which has no focus.
Expand All @@ -284,6 +295,11 @@ LRESULT CALLBACK Highlighter::MouseHookProc(int nCode, WPARAM wParam, LPARAM lPa
// Clear AlwaysPointer only when it's enabled and LeftPointer is not active
instance->ClearDrawingPoint(MouseButton::None);
}
if (instance->m_rightButtonPressed)
{
// There might be a stray point from the user releasing the mouse button on an elevated window, which wasn't caught by us.
instance->StartDrawingPointFading(MouseButton::Right);
}
instance->AddDrawingPoint(MouseButton::Right);
instance->m_rightButtonPressed = true;
// same as for the left button, start a timer for reposition ourselves to topmost position
Expand Down
Loading