Skip to content

Commit

Permalink
[MouseHighlighter]Fix stray highlights stucking (#37309)
Browse files Browse the repository at this point in the history
* [MouseHighlighter]Fix stray highlights stucking

* Fix spellcheck

---------

Co-authored-by: Stefan Markovic <[email protected]>
  • Loading branch information
jaimecbernardo and stefansjfw authored Feb 18, 2025
1 parent 91b53cd commit 82e386f
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 82e386f

Please sign in to comment.