pub(crate) fn follow_screen_corner(
ctx: &Context,
id: Id,
pivot: Align2,
) -> Option<Pos2>Expand description
Shift a movable window by however far the screen corner it belongs to moved when the screen changed shape.
egui applies a window’s opening position on the pass that first shows it and afterwards only clamps the remembered rectangle into the screen, so a window seeded into a corner keeps its old spot when the display rotates and the frame becomes a different shape. Shifting it by the corner’s movement keeps its distance from that corner — including a distance the user dragged it to — instead of leaving it stranded off its edge.
The window is anchored to the corner pivot names, so its pivot position
(the point of the window sitting on that corner) is what moves. The screen
the last call saw is remembered under id, so the shift is computed once
per change and the returned position is applied with
[egui::Window::current_pos] for that one pass; every other pass returns
None and the window keeps the position egui remembers for it.