Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 5e93aa5

Browse files
committed
AvalonEdit: don't unnecessarily update the mouse cursor.
1 parent 4f1262e commit 5e93aa5

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,14 +966,14 @@ protected override void OnPreviewKeyUp(KeyEventArgs e)
966966
protected override void OnKeyDown(KeyEventArgs e)
967967
{
968968
base.OnKeyDown(e);
969-
TextView.InvalidateCursor();
969+
TextView.InvalidateCursorIfMouseWithinTextView();
970970
}
971971

972972
/// <inheritdoc/>
973973
protected override void OnKeyUp(KeyEventArgs e)
974974
{
975975
base.OnKeyUp(e);
976-
TextView.InvalidateCursor();
976+
TextView.InvalidateCursorIfMouseWithinTextView();
977977
}
978978
#endregion
979979

src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ protected override Size ArrangeOverride(Size finalSize)
11651165
}
11661166
}
11671167
}
1168-
InvalidateCursor();
1168+
InvalidateCursorIfMouseWithinTextView();
11691169

11701170
return finalSize;
11711171
}
@@ -1636,6 +1636,15 @@ public static void InvalidateCursor()
16361636
}
16371637
}
16381638

1639+
internal void InvalidateCursorIfMouseWithinTextView()
1640+
{
1641+
// Don't unnecessarily call Mouse.UpdateCursor() if the mouse is outside the text view.
1642+
// Unnecessary updates may cause the mouse pointer to flicker
1643+
// (e.g. if it is over a window border, it blinks between Resize and Normal)
1644+
if (this.IsMouseOver)
1645+
InvalidateCursor();
1646+
}
1647+
16391648
/// <inheritdoc/>
16401649
protected override void OnQueryCursor(QueryCursorEventArgs e)
16411650
{

0 commit comments

Comments
 (0)