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

prevent flickering when selecting files in staged/unstaged FileStatusList #7267

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 21 additions & 21 deletions GitUI/CommandsDialogs/FormCommit.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions GitUI/CommandsDialogs/FormCommit.cs
Expand Up @@ -1638,13 +1638,13 @@ private void StagedFileContext_Opening(object sender, System.ComponentModel.Canc
stagedOpenDifftoolToolStripMenuItem9.Enabled = !isNewSelected;
}

private void Unstaged_Enter(object sender, EventArgs e)
private void Unstaged_Enter(object sender, EnterEventArgs e)
{
if (_currentFilesList != Unstaged)
{
_currentFilesList = Unstaged;
_skipUpdate = false;
if (Unstaged.AllItems.Count() != 0 && Unstaged.SelectedIndex == -1)
if (!e.ByMouse && Unstaged.AllItems.Count() != 0 && Unstaged.SelectedIndex == -1)
{
Unstaged.SelectedIndex = 0;
}
Expand Down Expand Up @@ -1874,13 +1874,13 @@ private void Staged_DataSourceChanged(object sender, EventArgs e)
commitStagedCount.Text = stagedCount + "/" + totalFilesCount;
}

private void Staged_Enter(object sender, EventArgs e)
private void Staged_Enter(object sender, EnterEventArgs e)
{
if (_currentFilesList != Staged)
{
_currentFilesList = Staged;
_skipUpdate = false;
if (Staged.AllItems.Count() != 0 && Staged.SelectedIndex == -1)
if (!e.ByMouse && Staged.AllItems.Count() != 0 && Staged.SelectedIndex == -1)
{
Staged.SelectedIndex = 0;
}
Expand Down
1 change: 1 addition & 0 deletions GitUI/GitUI.csproj
Expand Up @@ -462,6 +462,7 @@
<Compile Include="Strings.cs" />
<Compile Include="TaskbarProgress.cs" />
<Compile Include="UserControls\GitItemStatusWithParent.cs" />
<Compile Include="UserControls\EnterEventArgs.cs" />
<Compile Include="UserControls\NativeTreeViewDoubleClickDecorator.cs" />
<Compile Include="UserControls\NativeTreeViewExplorerNavigationDecorator.cs" />
<Compile Include="UserControls\RevisionGrid\CellStyle.cs" />
Expand Down
14 changes: 14 additions & 0 deletions GitUI/UserControls/EnterEventArgs.cs
@@ -0,0 +1,14 @@
using System;

namespace GitUI
{
public class EnterEventArgs : EventArgs
{
public bool ByMouse { get; }

public EnterEventArgs(bool byMouse)
{
ByMouse = byMouse;
}
}
}
22 changes: 22 additions & 0 deletions GitUI/UserControls/FileStatusList.cs
Expand Up @@ -36,6 +36,7 @@ public sealed partial class FileStatusList : GitModuleControl
private int _nextIndexToSelect = -1;
private bool _groupByRevision;
private bool _enableSelectedIndexChangeEvent = true;
private bool _mouseEntered;
private ToolStripItem _openSubmoduleMenuItem;
private Rectangle _dragBoxFromMouseDown;
private IReadOnlyList<(GitRevision revision, IReadOnlyList<GitItemStatus> statuses)> _itemsWithParent = Array.Empty<(GitRevision, IReadOnlyList<GitItemStatus>)>();
Expand All @@ -44,11 +45,14 @@ public sealed partial class FileStatusList : GitModuleControl

private bool _updatingColumnWidth;

public delegate void EnterEventHandler(object sender, EnterEventArgs e);

public event EventHandler SelectedIndexChanged;
public event EventHandler DataSourceChanged;

public new event EventHandler DoubleClick;
public new event KeyEventHandler KeyDown;
public new event EnterEventHandler Enter;

public FileStatusList()
{
Expand Down Expand Up @@ -77,6 +81,8 @@ public FileStatusList()
_fullPathResolver = new FullPathResolver(() => Module.WorkingDir);
_revisionTester = new GitRevisionTester(_fullPathResolver);

base.Enter += FileStatusList_Enter;

return;

ImageList CreateImageList()
Expand Down Expand Up @@ -780,6 +786,16 @@ protected override void DisposeCustomResources()
_diffListSortSubscription?.Dispose();
}

protected override void WndProc(ref Message m)
{
if (m.Msg == NativeConstants.WM_MOUSEACTIVATE)
{
_mouseEntered = !Focused;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this from simply true to !Focused as if you'd click on a list a second time this would get set to true and would remain so as Enter would not fire and this would not get reset to False.
Found this after some more manual testing.

}

base.WndProc(ref m);
}

// Private methods

private void CreateOpenSubmoduleMenuItem()
Expand Down Expand Up @@ -1335,6 +1351,12 @@ private void FileStatusListView_Scroll(object sender, ScrollEventArgs e)
UpdateColumnWidth();
}

private void FileStatusList_Enter(object sender, EventArgs e)
{
Enter?.Invoke(this, new EnterEventArgs(_mouseEntered));
_mouseEntered = false;
}

#region Filtering

private string _toolTipText = "";
Expand Down