# degenview-eframe
> **This is a fork.** It is [`eframe`](https://github.com/emilk/egui/tree/main/crates/eframe) 0.37.0
> from the [egui](https://github.com/emilk/egui) project (Emil Ernerfeldt and contributors) with two
> small window fixes, published for [DegenView](https://github.com/degenview/degenview). It is not
> affiliated with or endorsed by the egui project. If you do not need the fixes, use
> [`eframe`](https://crates.io/crates/eframe).
## What it changes
### 1. On Wayland, a viewport the app hid is not presented
On Wayland, a viewport the app hid is no longer painted or presented.
Wayland cannot hide a toplevel window. Upstream eframe presents every viewport on every pass, which
maps a viewport the app asked to hide, and winit then gates that window's redraws on frame callbacks
that compositors withhold from a window nobody sees (minimized, or on another virtual desktop). A
hidden root viewport that drives other viewports then stalls until the user makes it visible again:
dialogs that should close stay open, new windows do not open. This is
[degenview/degenview#622](https://github.com/degenview/degenview/issues/622).
With this fork, `Viewport::hidden` records that the app asked for the viewport to be hidden (through
`NativeOptions::viewport` or the viewport builder, and then through every
`ViewportCommand::Visible`). On Wayland such a viewport still runs its ui pass, so `App::update` and
the viewports it creates keep working, but it is not tessellated, painted or presented. Its surface
never gets a buffer and stays unmapped. Its texture deltas wait for the next painted viewport, as
they already do for a minimized one. Other platforms and visible viewports behave as in upstream.
This change is one commit, "Do not present a viewport the app hid on Wayland", in
`src/native/wgpu_integration.rs` and `src/native/glow_integration.rs` (same shape in both
renderers). It is first on top of the 0.36.2 import and again on top of the 0.37.0 import.
Apart from the two changes here, `src/` is byte-identical to upstream.
egui 0.37 added a pass that runs only `App::logic` when a redraw is overdue. It creates and closes
no viewports, so it does not replace this fix.
### 2. Every viewport is shown after its first painted frame, and an app-hidden one never
Upstream builds only the root window hidden and shows it after its first frame. A window opened
later is shown by the OS before it has a frame, so it is painted white until the first present. And
the root is shown after its first frame even when the app built it hidden, which flashes a window on
Windows (a 78×102 one at the corner of the screen, for the pass until the app hides it again).
Here each viewport has `reveal_after_paint`. Its window is created hidden and shown right after the
first frame it painted, so the first thing anyone sees is that frame. A viewport the app built
hidden is never shown. A `ViewportCommand::Visible` from the app takes the decision over, even one
sent in the pass being painted, so the reveal never undoes an app's `Visible(false)`. A window that
asks for maximized, fullscreen or a monitor is created as described: X11 window managers ignore
those for a hidden window, and macOS enters fullscreen on its own path (`is_held_until_painted`).
The change is in `src/native/` (both renderers) and in `EpiIntegration::post_rendering`, which takes
`show` and restores the saved window state around the first show only when it shows.
## Base
| Upstream | `eframe` 0.37.0, `crates/eframe` of <https://github.com/emilk/egui> (commit `3c6eb8261c3293ad9c7ea1ed58487e038860ebef`, from the crate's `.cargo_vcs_info.json`) |
| Imported from | <https://static.crates.io/crates/eframe/eframe-0.37.0.crate> |
| sha256 of that file | `9c5642501a65ca657d05f00c643a5c14ff2346cb3818032bfe23d58e1f8e5f84` |
| Version here | `0.37.x`: the eframe release it is based on, and a patch number for our changes (`0.37.1` is the second fix) |
Each upstream release is imported in a commit of its own, unmodified (`src/`, `data/`, `Cargo.toml`);
`git diff` from that commit shows every change. Besides the source fix, the package metadata in `Cargo.toml` is ours (name,
description, repository, keywords, `include`), `Cargo.toml.orig`, `.cargo_vcs_info.json` and
`Cargo.lock` of the tarball are not kept (the first two describe upstream's workspace, the lock file
is not used by dependents), and the license texts are added (the crates.io tarball does not ship
them).
## Use
The library is still called `eframe`, so `use eframe::...` keeps working:
```toml
[dependencies]
eframe = { package = "degenview-eframe", version = "=0.37.1", features = ["persistence"] }
```
Features are those of eframe 0.37.0. Pin the version exactly: this crate follows DegenView's needs,
not upstream's release schedule.
## Retirement
The crate goes away once egui ships an equivalent fix; DegenView then depends on `eframe` again. It
will not be updated for new egui releases unless DegenView still needs it. Other changes belong in
egui, not here.
## License
`MIT OR Apache-2.0`, as upstream. See [LICENSE-MIT](LICENSE-MIT) and
[LICENSE-APACHE](LICENSE-APACHE), copied from <https://github.com/emilk/egui>. The code is
copyrighted by Emil Ernerfeldt and the egui contributors; the fix is contributed under the same
terms.