Fix display glitches when switching between monitors with different DPI settings #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users experience display glitches in the PDF viewer when switching between monitors with different resolutions or DPI settings (e.g., switching between a laptop's high-DPI display at 2880x1800 and an external monitor). The glitches persist until QuickLook is restarted, significantly impacting the user experience for those working with multiple displays.
Root Cause
The WebView2 control used to render PDFs was not properly responding to DPI changes when Windows notifies applications of display setting changes. Without explicit handling, the WebView2 rendering becomes corrupted when DPI scaling factors change.
Solution
This PR implements DPI-aware rendering by:
WebpagePanelnow listens for theWindow.DpiChangedevent when loadedInvalidateVisual()andUpdateLayout()Dispose()method to prevent memory leaksThe implementation uses asynchronous dispatching at render priority to ensure smooth UI updates without blocking the main thread.
Changes
OnLoaded,OnUnloaded, andOnDpiChangedevent handlers toWebpagePanelUpdateRasterizationScalemethod to refresh WebView2 renderingDisposemethod to properly clean up all event subscriptionsDrawingColoraliasTesting
The solution builds successfully with no errors. Manual testing is recommended on Windows with multiple monitors at different DPI settings to verify the fix resolves the reported glitches without requiring an application restart.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.