eframe: Don't restore window position on Windows

If the app last ran on two monitors and only one is now connected, then
the given position is invalid.
If this happens on Mac, the window is clamped into valid area.
If this happens on Windows, the window is hidden and impossible
to bring to get at. So we no longer restore window positions on Windows.
This commit is contained in:
Emil Ernerfeldt 2021-08-18 19:54:13 +02:00
parent 734ec9dc5a
commit 9bc732328f
2 changed files with 13 additions and 5 deletions

View file

@ -6,6 +6,7 @@ All notable changes to the `egui_glium` integration will be noted in this file.
## Unreleased ## Unreleased
* [Fix minimize on Windows](https://github.com/emilk/egui/issues/518) * [Fix minimize on Windows](https://github.com/emilk/egui/issues/518)
* Change `drag_and_drop_support` to `false` by default (Windows only). See <https://github.com/emilk/egui/issues/598>. * Change `drag_and_drop_support` to `false` by default (Windows only). See <https://github.com/emilk/egui/issues/598>.
* Don't restore window position on Windows, because the position would sometimes be invalid.
## 0.13.1 - 2021-06-24 ## 0.13.1 - 2021-06-24

View file

@ -111,8 +111,15 @@ fn create_display(
let display = glium::Display::new(window_builder, context_builder, event_loop).unwrap(); let display = glium::Display::new(window_builder, context_builder, event_loop).unwrap();
if let Some(window_settings) = &window_settings { if !cfg!(target_os = "windows") {
window_settings.restore_positions(&display); // If the app last ran on two monitors and only one is now connected, then
// the given position is invalid.
// If this happens on Mac, the window is clamped into valid area.
// If this happens on Windows, the window is hidden and impossible to bring to get at.
// So we don't restore window positions on Windows.
if let Some(window_settings) = &window_settings {
window_settings.restore_positions(&display);
}
} }
display display
@ -165,7 +172,7 @@ fn load_icon(icon_data: epi::IconData) -> Option<glutin::window::Icon> {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// Run an egui app /// Run an egui app
pub fn run(mut app: Box<dyn epi::App>, nativve_options: epi::NativeOptions) -> ! { pub fn run(mut app: Box<dyn epi::App>, native_options: epi::NativeOptions) -> ! {
#[allow(unused_mut)] #[allow(unused_mut)]
let mut storage = create_storage(app.name()); let mut storage = create_storage(app.name());
@ -174,8 +181,8 @@ pub fn run(mut app: Box<dyn epi::App>, nativve_options: epi::NativeOptions) -> !
let window_settings = deserialize_window_settings(&storage); let window_settings = deserialize_window_settings(&storage);
let event_loop = glutin::event_loop::EventLoop::with_user_event(); let event_loop = glutin::event_loop::EventLoop::with_user_event();
let icon = nativve_options.icon_data.clone().and_then(load_icon); let icon = native_options.icon_data.clone().and_then(load_icon);
let display = create_display(&*app, &nativve_options, window_settings, icon, &event_loop); let display = create_display(&*app, &native_options, window_settings, icon, &event_loop);
let repaint_signal = std::sync::Arc::new(GliumRepaintSignal(std::sync::Mutex::new( let repaint_signal = std::sync::Arc::new(GliumRepaintSignal(std::sync::Mutex::new(
event_loop.create_proxy(), event_loop.create_proxy(),