Skip to content

Commit

Permalink
Fix a bug on Windows where minimizing adjusts all of the egui window …
Browse files Browse the repository at this point in the history
…positions. (emilk#522)

- Closes emilk#518
- This bug is caused by an issue in winit where minimized windows will
  be given 0 width and height on Windows.
- See: rust-windowing/winit#208
- See also: hasenbanck/egui_winit_platform#19
  • Loading branch information
parasyte authored Jun 28, 2021
1 parent ccecad8 commit 3a14f5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions egui_glium/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to the `egui_glium` integration will be noted in this file.

## Unreleased

### Fixed 🐛
* [Fix minimize on Windows](https://github.com/emilk/egui/issues/518)


## 0.13.1 - 2021-06-24

Expand Down
17 changes: 13 additions & 4 deletions egui_glium/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,19 @@ impl EguiGlium {
.unwrap_or_else(|| self.egui_ctx.pixels_per_point());

self.input_state.raw.time = Some(self.start_time.elapsed().as_nanos() as f64 * 1e-9);
self.input_state.raw.screen_rect = Some(Rect::from_min_size(
Default::default(),
screen_size_in_pixels(display) / pixels_per_point,
));

// On Windows, a minimized window will have 0 width and height.
// See: https://github.com/rust-windowing/winit/issues/208
// This solves an issue where egui window positions would be changed when minimizing on Windows.
let screen_size = screen_size_in_pixels(display);
self.input_state.raw.screen_rect = if screen_size.x > 0.0 && screen_size.y > 0.0 {
Some(Rect::from_min_size(
Default::default(),
screen_size / pixels_per_point,
))
} else {
None
};

self.egui_ctx.begin_frame(self.input_state.raw.take());
}
Expand Down

0 comments on commit 3a14f5e

Please sign in to comment.