Skip to main content

Module main_wake

Module main_wake 

Source
Expand description

The main window’s frames owed, for whoever runs the event loop.

Experimental: may change in any release (docs/stability.md).

egui paints a window in its RedrawRequested, and on Wayland that event comes only with the compositor’s frame callback, which a compositor withholds from a window it does not show: GNOME’s, for a main window covered by the application’s other windows. eframe then runs the application’s logic only (App::logic), no pass of the main window, until the system shows it again.

The main window’s pass is not only its own picture: it lets go of a closed window (the backend drops the system windows its last pass no longer declares) and it draws the detached panels’ windows (egui’s immediate viewports, painted inside it). With the main window covered, a closed Settings window stayed on screen frozen, and a detached panel froze while it was the one shown, until a click or Alt+Tab brought the main window forward.

MainWake keeps what is owed: a repaint asked of the main window (egui’s repaint request, for it), or a redraw of a window that ran no pass of its own (an immediate viewport: its pass is the main window’s); a pass of the main window pays it. Owed longer than GRACE, the loop paints the main window itself (MainWake::due), as a RedrawRequested the system did not send. Safe where the present does not wait for the compositor (egui-pop’s present mode on Wayland, windows::present_mode); a FIFO present to a hidden Wayland surface can block, so a loop presenting that way does not paint (MainWake::set_enabled).

The window key W is the loop’s window id (winit’s WindowId); the crate’s native runner and a host running its own loop use it alike, and the test kit runs it with viewport ids.

Structs§

MainWake
The main window’s frame owed, and since when.
PassCounter
The passes begun in a context, counted by a begin-pass hook: the main window’s, and every window’s (a redraw that began none drew an immediate viewport, whose pass is the main window’s).

Constants§

GRACE
How long a frame of the main window may be owed before the loop paints it: well over a frame at 30 Hz, so a window the system shows always gets its own redraw first; short enough that a closed window goes without a wait anyone notices.

Functions§

paint_safe
Whether the loop may paint a window the system does not show with this present mode: not with a FIFO present (eframe’s default), which on Wayland waits for the compositor’s frame callback that a hidden window does not get; with one that does not wait (egui-pop’s choice on Wayland, windows::present_mode), or off Wayland, where nothing withholds a window’s redraw.