走査でスレッドのモーダル状態も見る

このコミットが含まれているのは:
routersys committed 2026-09-13 17:52:31 +09:00
1 親 856c7267c8
コミット 335daba4c8
3ファイル変更
+56 -1

検索条件に一致するファイルはありません

+48
ファイルの表示
@@ -1,3 +1,4 @@
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Threading;
@@ -333,6 +334,49 @@ public sealed class ExportWindowWatcherTests
Assert.Equal(ExportPhase.Idle, after);
}
[Fact]
public void TheScanTreatsAModalDialogWithoutAnOwnerAsPreparing()
{
var (during, after) = Watch(() =>
{
var dialog = CreateWindow("Dialog");
ExportPhase? during = null;
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
during = ExportWindowWatcher.Scan();
dialog.Close();
}), DispatcherPriority.ContextIdle);
dialog.ShowDialog();
Pump();
return (during, ExportWindowWatcher.Scan());
});
Assert.Equal(ExportPhase.Preparing, during);
Assert.Equal(ExportPhase.Idle, after);
}
[Fact]
public void TheScanTreatsADisabledVisibleWindowAsPreparing()
{
var (disabled, enabled) = Watch(() =>
{
var window = CreateWindow("Owner");
window.Show();
Pump();
var handle = new WindowInteropHelper(window).Handle;
EnableWindow(handle, false);
var disabled = ExportWindowWatcher.Scan();
EnableWindow(handle, true);
var enabled = ExportWindowWatcher.Scan();
window.Close();
Pump();
return (disabled, enabled);
});
Assert.Equal(ExportPhase.Preparing, disabled);
Assert.Equal(ExportPhase.Idle, enabled);
}
[Fact]
public void ThePhaseIsResolvedOnTheWatchingThread()
{
@@ -377,4 +421,8 @@ public sealed class ExportWindowWatcherTests
Assert.Equal(ExportPhase.Exporting, phase);
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool EnableWindow(nint window, [MarshalAs(UnmanagedType.Bool)] bool enable);
}
+2 -1
ファイルの表示
@@ -1,5 +1,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows.Threading;
using YukkuriMovieMaker.Commons;
@@ -91,7 +92,7 @@ internal static unsafe partial class ExportWindowWatcher
if (detector is null)
return null;
scanned = ExportPhase.Idle;
scanned = ComponentDispatcher.IsThreadModal ? ExportPhase.Preparing : ExportPhase.Idle;
EnumThreadWindows(threadId, &OnWindowEnumerated, 0);
return scanned;
}
+6
ファイルの表示
@@ -281,6 +281,12 @@
"find": " if (!IsWindowEnabled(window))\r\n scanned = ExportPhase.Preparing;",
"replace": ""
},
{
"name": "走査でスレッドのモーダル状態を見ない",
"file": "ProxyForge/Export/ExportWindowWatcher.cs",
"find": "scanned = ComponentDispatcher.IsThreadModal ? ExportPhase.Preparing : ExportPhase.Idle;",
"replace": "scanned = ExportPhase.Idle;"
},
{
"name": "走査で隠れたウィンドウも数える",
"file": "ProxyForge/Export/ExportWindowWatcher.cs",