Expand description
The native runner: eframe on an event loop egui-pop owns.
With the create-native feature (on by default), AppBuilder::run_native
and run_native_with do not call eframe::run_native: they build the
winit event loop, hand eframe to it through eframe::create_native, and
run it with a handler of their own, which sees every winit callback
before eframe does. eframe still creates and paints every window and
runs the application as before; what owning the loop adds:
-
The screens before the main window. The handler reads the monitors in
resumed, before eframe’s ownresumedcreates the main window, and tells them (window::set_screens, the way a host running its own loop tells them); eframe calls the window’swindow_builderhook inside it, so the place restored from the last run is repaired against real screens (window::repair_builder), not only bounded. They are read again when a window’s scale factor changes or a window moves (onto another monitor, maybe).screensgives them. -
Every window’s handles. eframe hands out the main window’s only. It paints a window synchronously in that window’s
RedrawRequested, so the handler notes which window is being painted, and aContext::on_begin_passhook pairs it with the pass’s viewport. The handles come from the window’s winit id (egui_pop_winit, where theunsafelives), checked first against the main window’s handles from eframe: they are used only once both agree (ids_verified). Each window’s handles are recorded where egui-pop keeps them per viewport (files::set_parent_window,frame::set_native_window) and forgotten when winit destroys the window.windowgives a viewport’s window by its id,windowsthe viewports whose window is known,window_handlethe raw handle alone. -
Paced paints. A window paints at most once per interval, a little under the fastest screen’s refresh period (read in
resumed, 60 Hz when no screen tells): aRedrawRequestedthat comes sooner is held and painted at its time. Vsync and Wayland’s frame callbacks pace a window already; this holds where the present does not wait (an X server without DRI3, Mesa’s software rendering), where an animating window would otherwise draw as fast as the CPU goes. -
Immediate viewports’ windows too (a detached panel’s window): painted inside their parent’s pass, their own window’s redraw runs no pass; the nested pass and that redraw are paired in the order seen.
A host that runs the event loop itself (feature host-loop, without
create-native) gets the same pairing by calling host’s hooks
from its own handler. On the web, and without either feature, eframe
runs as before and this module’s functions answer nothing.
Re-exports§
pub use raw_window_handle;
Modules§
- host
- What pairs each window with its viewport, for egui-pop’s own runner and for a host running the event loop itself.
Structs§
- Window
- The native window showing a viewport (
window): what takes a window throughHasWindowHandleandHasDisplayHandle(a file chooser’s parent, a Wayland subsurface, a Win32 subclass) is given it.
Functions§
- ids_
verified - Whether winit’s window ids were seen to be the native windows: the
main window’s id read as a handle, compared with the handle eframe
gives for it.
Noneuntil the main window is painted, or when egui-pop does not own the event loop;Some(false)on a system where they differ (macOS, or a winit that changed), where no window’s handles are recorded beyond the main window’s. - screens
- The screens, in points (each monitor’s physical rectangle over its
scale factor): those told to egui-pop (
window::screens), by this runner before the main window is created and again when they change, or by a host running the event loop itself (window::set_screens); empty until told. - window
- The native window showing
viewport, reached by its id: the main window ([ViewportId::ROOT]) as soon as eframe created it, on every system; another deferred viewport’s once it was painted for a redraw request, an immediate viewport’s (a detached panel’s window) once its window’s redraw came, and the window ids were verified (ids_verified). None for a viewport not open (or closed since), when called off the event loop’s thread, or when neither egui-pop nor the host (host, featurehost-loop) pairs the windows. - window_
handle - The raw handle of the window showing
viewport(window): the main window’s as eframe gives it, another window’s once it was painted for a redraw request (eframe paints a window still hidden at start outside of one) and the window ids were verified (ids_verified); none when neither egui-pop nor the host pairs the windows. - windowing
- The windowing system the event loop’s display is on: told when the
loop resumes (egui-pop’s runner, or a host’s
host::resumed);Windowing::Unknownbefore, or when nobody told. - windows
- The viewports whose native window is known (
window), the main window first.