Merge branch 'develop' into fix-gha-smells

This commit is contained in:
Tig
2024-06-20 17:50:01 -07:00
committed by GitHub
5 changed files with 16 additions and 11 deletions

View File

@@ -1037,6 +1037,7 @@ namespace Terminal.Gui {
toplevel.LayoutSubviews ();
toplevel.PositionToplevels ();
toplevel.WillPresent ();
EnsuresTopOnFront ();
if (refreshDriver) {
MdiTop?.OnChildLoaded (toplevel);
toplevel.OnLoaded ();

View File

@@ -394,6 +394,10 @@ namespace Terminal.Gui {
}
}
}
if (SuperView is Toplevel && Application.Current?.Focused != SuperView) {
Application.EnsuresTopOnFront ();
}
}
OnCanFocusChanged ();
SetNeedsDisplay ();

View File

@@ -104,7 +104,7 @@ namespace Terminal.Gui {
public override void OnCanFocusChanged ()
{
if (MostFocused == null && CanFocus && Visible) {
if (HasFocus && MostFocused == null && CanFocus && Visible) {
EnsureFocus ();
}

View File

@@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="CsvHelper" Version="32.0.3" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
</ItemGroup>
<ItemGroup>

View File

@@ -771,28 +771,28 @@ namespace Terminal.Gui.ApplicationTests {
Assert.True (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.False (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
Assert.True (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
Assert.True (win.CanFocus);
Assert.True (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.False (win2.HasFocus);
Assert.Equal ("win", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
win2.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Pressed });
Assert.True (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
win2.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Released });
Assert.Null (Toplevel.dragPosition);
}
@@ -816,35 +816,35 @@ namespace Terminal.Gui.ApplicationTests {
Assert.True (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.False (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
win.CanFocus = false;
Assert.False (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
Assert.True (win2.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
top.ProcessKey (new KeyEvent (Key.CtrlMask | Key.Tab, new KeyModifiers ()));
Assert.False (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
win.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Pressed });
Assert.False (win.CanFocus);
Assert.False (win.HasFocus);
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [top.Subviews.Count - 1]).Title);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
win2.MouseEvent (new MouseEvent () { Flags = MouseFlags.Button1Released });
Assert.Null (Toplevel.dragPosition);
}