Skip to content

Commit 9d9c81a

Browse files
Yu Lengclaude
andcommitted
Fix PowerOCR white flash on overlay startup and close
Use WinUIEx TransparentTintBackdrop for a truly transparent window background, and toggle RootGrid visibility so content is hidden until the screenshot is loaded and re-hidden before the window closes. Co-Authored-By: Claude Opus 4 <[email protected]>
1 parent f1bea04 commit 9d9c81a

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/modules/PowerOCR/PowerOCR/OCROverlay.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
Title="TextExtractor">
66

7-
<Grid x:Name="RootGrid">
7+
<Grid x:Name="RootGrid" Visibility="Collapsed">
88
<Viewbox>
99
<Image x:Name="BackgroundImage" Stretch="UniformToFill" />
1010
</Viewbox>

src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public OCROverlay(RectInt32 screenRectParam, double rasterizationScaleParam)
122122

123123
InitializeComponent();
124124

125+
// Transparent window background to prevent white flash during load and close
126+
this.SystemBackdrop = new WinUIEx.TransparentTintBackdrop();
127+
125128
userSettings = new UserSettings(new ThrottledActionInvoker());
126129

127130
// Configure transparent overlay window
@@ -191,6 +194,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
191194
_capturedScreenshotBytes = null;
192195
}
193196

197+
RootGrid.Visibility = Visibility.Visible;
194198
DarkOverlayPath.Opacity = ActiveOpacity;
195199
TopButtonsStackPanel.Visibility = Visibility.Visible;
196200

@@ -208,6 +212,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
208212

209213
private void Window_Closed(object sender, WindowEventArgs args)
210214
{
215+
RootGrid.Visibility = Visibility.Collapsed;
211216
BackgroundImage.Source = null;
212217
App.UntrackOverlay(this);
213218
}

src/modules/PowerOCR/PowerOCR/PowerOCR.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<PackageReference Include="Microsoft.WindowsAppSDK" />
3232
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
3333
<PackageReference Include="System.Drawing.Common" />
34+
<PackageReference Include="WinUIEx" />
3435
</ItemGroup>
3536

3637
<ItemGroup>

0 commit comments

Comments
 (0)