mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
This changes the monitor selection used when restoring a persisted window position. Currently, `egui-winit` picks a monitor by checking whether the saved window position fits inside a loose monitor range. This can choose the wrong monitor when a saved window rectangle slightly overlaps another monitor. My failure case was on Windows with two monitors: - primary monitor on the right - secondary monitor on the left - window maximized on the primary monitor - persisted outer position was slightly negative, e.g. `x = -8`, because of the invisible window border That position matched both monitor ranges, so the restored maximized window could open on the secondary monitor instead of the primary one. This PR picks the monitor with the largest overlap with the saved window rectangle instead. Related note: probably the best solution would be to save the normal window position when maximized, so that when unmaximizing, the window would get restored to the previous state. It's mentioned in this comment https://github.com/emilk/egui/issues/3494#issuecomment-1986985211. I tried doing that in [fix-windows-maximized-restore-placement](https://github.com/YelovSK/egui/tree/fix-windows-maximized-restore-placement), and it works, but it requires adding windows-sys as a dependency to call a relevant winapi, so that's probably not the right solution. Winit doesn't seem to provide an API that would return this information. * [x] I have followed the instructions in the PR template --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>