From 95efbbc03e40602abdb4a94bc178ef1c6cb3e6a2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 3 Apr 2022 10:20:49 +0200 Subject: [PATCH] Remember to update glow window size when DPI changes (#1441) --- eframe/CHANGELOG.md | 1 + egui_glow/CHANGELOG.md | 1 + egui_glow/examples/pure_glow.rs | 10 ++++++++-- egui_glow/src/epi_backend.rs | 10 ++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/eframe/CHANGELOG.md b/eframe/CHANGELOG.md index bf100752..6fcd90a7 100644 --- a/eframe/CHANGELOG.md +++ b/eframe/CHANGELOG.md @@ -19,6 +19,7 @@ NOTE: [`egui_web`](../egui_web/CHANGELOG.md), [`egui-winit`](../egui-winit/CHANG * Changed `App::update` to take `&mut Frame` instead of `&Frame`. * `Frame` is no longer `Clone` or `Sync`. * Add `glow` (OpenGL) context to `Frame` ([#1425](https://github.com/emilk/egui/pull/1425)). +* Fixed potential scale bug when DPI scaling changes (e.g. when dragging a window between different displays) ([#1441](https://github.com/emilk/egui/pull/1441)). ## 0.17.0 - 2022-02-22 diff --git a/egui_glow/CHANGELOG.md b/egui_glow/CHANGELOG.md index 60aa349e..f2ce04d4 100644 --- a/egui_glow/CHANGELOG.md +++ b/egui_glow/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to the `egui_glow` integration will be noted in this file. ## Unreleased * Improved logging on rendering failures. * Add new `NativeOptions`: `vsync`, `multisampling`, `depth_buffer`, `stencil_buffer`. +* Fixed potential scale bug when DPI scaling changes (e.g. when dragging a window between different displays) ([#1441](https://github.com/emilk/egui/pull/1441)). ## 0.17.0 - 2022-02-22 diff --git a/egui_glow/examples/pure_glow.rs b/egui_glow/examples/pure_glow.rs index 173654b8..5a2d280b 100644 --- a/egui_glow/examples/pure_glow.rs +++ b/egui_glow/examples/pure_glow.rs @@ -65,8 +65,14 @@ fn main() { *control_flow = glutin::event_loop::ControlFlow::Exit; } - if let glutin::event::WindowEvent::Resized(physical_size) = event { - gl_window.resize(physical_size); + if let glutin::event::WindowEvent::Resized(physical_size) = &event { + gl_window.resize(*physical_size); + } else if let glutin::event::WindowEvent::ScaleFactorChanged { + new_inner_size, + .. + } = &event + { + gl_window.resize(**new_inner_size); } egui_glow.on_event(&event); diff --git a/egui_glow/src/epi_backend.rs b/egui_glow/src/epi_backend.rs index fde2bb30..9c891ea3 100644 --- a/egui_glow/src/epi_backend.rs +++ b/egui_glow/src/epi_backend.rs @@ -136,8 +136,14 @@ pub fn run(app_name: &str, native_options: &epi::NativeOptions, app_creator: epi is_focused = new_focused; } - if let winit::event::WindowEvent::Resized(physical_size) = event { - gl_window.resize(physical_size); + if let winit::event::WindowEvent::Resized(physical_size) = &event { + gl_window.resize(*physical_size); + } else if let glutin::event::WindowEvent::ScaleFactorChanged { + new_inner_size, + .. + } = &event + { + gl_window.resize(**new_inner_size); } integration.on_event(app.as_mut(), &event);