Skip to content

[WIP] Fix un-fullscreen functionality for PDF in Peek#45429

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-pdf-unfullscreen-issue
Draft

[WIP] Fix un-fullscreen functionality for PDF in Peek#45429
Copilot wants to merge 4 commits intomainfrom
copilot/fix-pdf-unfullscreen-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Fix PDF Fullscreen Toggle in Peek

Problem

When viewing a PDF in Peek and clicking the fullscreen button:

  • The PDF viewer goes fullscreen but Peek window doesn't adapt
  • The titlebar remains visible
  • There's no way to exit fullscreen (button doesn't toggle back)
  • User must press Escape to exit

Root Cause

WebView2's CoreWebView2 has ContainsFullScreenElement property and ContainsFullScreenElementChanged event that fires when PDFs go fullscreen, but Peek doesn't handle this event.

Solution

Implemented proper fullscreen handling by:

  1. Subscribing to CoreWebView2.ContainsFullScreenElementChanged event in BrowserControl
  2. Propagating fullscreen state changes through FilePreview to MainWindow
  3. Using AppWindow.SetPresenter() to toggle between FullScreen and Default modes

Implementation

  • Explore codebase and identify issue location
  • Add ContainsFullScreenElementChanged event handler in BrowserControl
  • Implement logic to toggle window fullscreen state when PDF viewer requests fullscreen
  • Hide/show titlebar appropriately during fullscreen (automatic via FullScreen presenter)
  • Create comprehensive testing documentation (TESTING_NOTES.md)
  • Create architecture documentation (ARCHITECTURE_NOTES.md)
  • Manual testing with PDF files (requires full build environment)

Files Changed

  1. BrowserControl.xaml.cs

    • Added FullScreenChangedHandler delegate and FullScreenChanged event
    • Subscribe to CoreWebView2.ContainsFullScreenElementChanged event
    • Properly unsubscribe in Dispose method
    • Added event handler that notifies listeners of fullscreen state changes
  2. FilePreview.xaml / FilePreview.xaml.cs

    • Added FullScreenChanged event to FilePreview
    • Wire up BrowserPreview_FullScreenChanged event handler in XAML
    • Propagate fullscreen changes from BrowserControl to MainWindow
  3. MainWindow.xaml / MainWindow.xaml.cs

    • Added FilePreviewer_FullScreenChanged event handler
    • Toggle between AppWindowPresenterKind.FullScreen and AppWindowPresenterKind.Default
    • Window now properly enters/exits fullscreen when PDF viewer requests it
  4. TESTING_NOTES.md (New)

    • Comprehensive manual testing guide with 5 test cases
    • Expected behavior comparison (before/after fix)
    • Technical implementation details
  5. ARCHITECTURE_NOTES.md (New)

    • Visual event flow diagram
    • Component responsibilities
    • Design decisions and rationale
    • Edge cases handled
    • Future enhancement ideas

Technical Details

Event Chain:

PDF Fullscreen Button Click
  ↓
WebView2 ContainsFullScreenElementChanged
  ↓
BrowserControl.FullScreenChanged
  ↓
FilePreview.FullScreenChanged
  ↓
MainWindow.FilePreviewer_FullScreenChanged
  ↓
AppWindow.SetPresenter(FullScreen/Default)

Key APIs:

  • CoreWebView2.ContainsFullScreenElementChanged - Detects PDF fullscreen state
  • AppWindow.SetPresenter(AppWindowPresenterKind) - Native WinUI 3 fullscreen API

Testing

See TESTING_NOTES.md for detailed manual testing instructions. Key scenarios:

  • Enter/exit fullscreen via PDF button (main fix)
  • Multiple toggle cycles
  • Navigation between files in fullscreen
  • Escape key behavior (closes Peek)
  • Non-PDF files (no regression)

Documentation

See ARCHITECTURE_NOTES.md for:

  • Event flow diagram
  • Component architecture
  • Design decisions
  • Edge cases
  • Future enhancements
Original prompt

This section details on the original issue you should resolve

<issue_title>[Peek] How do I un-fullscreen a PDF?</issue_title>
<issue_description>### Microsoft PowerToys version

0.73.0

Installation method

GitHub

Running as admin

Yes

Area(s) with issue?

Peek

Steps to reproduce

  1. Preview a PDF file with Peek
  2. Click the full screen button
  3. You can't un-fullscreen it now.

✔️ Expected Behavior

Clicking the full screen button should maximize the Peek window and Esc should revert it to the original size and show the toolbar.

❌ Actual Behavior

The only way to get the toolbar back is by pressing Esc and then manually maximizing the window.

Other Software

No response</issue_description>

<agent_instructions>Implement a proper fix for this issue. Do NOT create placeholder stub files. Create actual working code that addresses the issue described. Follow PowerToys coding guidelines and conventions.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 5, 2026 15:30
- Handle ContainsFullScreenElementChanged event in BrowserControl
- Propagate fullscreen state changes through FilePreview to MainWindow
- Toggle window presenter between FullScreen and Default modes
- Fixes issue where PDF fullscreen button didn't allow toggling back

Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Peek] How do I un-fullscreen a PDF?

2 participants