From dbab277658d193d3fd1a18d4b0d43823349bf2d2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 21 Dec 2020 22:10:31 +0100 Subject: [PATCH] [egui_glium] Restore window position when starting app --- egui_glium/CHANGELOG.md | 8 ++++---- egui_glium/src/backend.rs | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/egui_glium/CHANGELOG.md b/egui_glium/CHANGELOG.md index 176d75b21..6d95c4829 100644 --- a/egui_glium/CHANGELOG.md +++ b/egui_glium/CHANGELOG.md @@ -13,14 +13,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed -* `egui_glium` will now save you app state to [a better directory](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir) +* `egui_glium` will now save you app state to [a better directory](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir). * `egui_glium::run`: the parameter `app` now has signature `Box` (you need to add `Box::new(app)` to your code). -* Window title is now passed via the `trait` function `egui::App::name()` +* Window title is now passed via the `trait` function `egui::App::name()`. ### Fixed 🐛 -* Serialize window size in logical points instead of physical pixels - +* Serialize window size in logical points instead of physical pixels. +* Window position is now restored on restart. ## 0.5.0 - 2020-12-13 diff --git a/egui_glium/src/backend.rs b/egui_glium/src/backend.rs index 773f5b4dd..ed864d81b 100644 --- a/egui_glium/src/backend.rs +++ b/egui_glium/src/backend.rs @@ -60,7 +60,13 @@ fn create_display( .with_stencil_buffer(0) .with_vsync(true); - 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 { + window_settings.restore_positions(&display); + } + + display } fn create_storage(app_name: &str) -> Option> {