Skip to content

Add ViewportInfo::occluded and visible#7948

Merged
emilk merged 5 commits intomainfrom
emilk/report-occluded
Mar 2, 2026
Merged

Add ViewportInfo::occluded and visible#7948
emilk merged 5 commits intomainfrom
emilk/report-occluded

Conversation

@emilk
Copy link
Owner

@emilk emilk commented Mar 2, 2026

Once we support calling App::logic when an app is occluded or minimized, it is useful to know that it is, in fact, occluded or minimized.

@emilk emilk added feature New feature or request egui labels Mar 2, 2026
@emilk emilk self-assigned this Mar 2, 2026
@emilk emilk added the eframe Relates to epi and eframe label Mar 2, 2026
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Preview available at https://egui-pr-preview.github.io/pr/7948-emilkreport-occluded
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds viewport occlusion state to egui’s ViewportInfo and wires native backends to populate it, enabling backends/apps to distinguish “hidden for rendering” from “should still run background logic” (per the linked issues).

Changes:

  • Add ViewportInfo::occluded: Option<bool> and a ViewportInfo::visible() helper.
  • Populate occluded from winit WindowEvent::Occluded in both wgpu and glow native integrations.
  • Add a small native test app (tests/test_background_logic) to exercise background logic vs ui behavior and print viewport visibility flags.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/egui/src/data/input.rs Extends ViewportInfo with occluded and adds visible() + debug UI display.
crates/eframe/src/native/wgpu_integration.rs Updates per-viewport info on winit occlusion events (wgpu backend).
crates/eframe/src/native/glow_integration.rs Updates per-viewport info on winit occlusion events (glow backend).
tests/test_background_logic/src/main.rs New test app that periodically repaints and logs minimized/focused/occluded/visible.
tests/test_background_logic/Cargo.toml Adds the new test crate to the workspace.
Cargo.lock Lockfile update to include the new test crate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

emilk and others added 3 commits March 2, 2026 17:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! It doesn't log minimized when I minimize on macOS but I guess thats an unrelated issue?

@emilk
Copy link
Owner Author

emilk commented Mar 2, 2026

Indeed - making sure that ui and logic are called at the right times will come later

@emilk emilk merged commit 2be6e22 into main Mar 2, 2026
46 checks passed
@emilk emilk deleted the emilk/report-occluded branch March 2, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eframe Relates to epi and eframe egui feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants