mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Web: Fix incorrect scale when moving to screen with new DPI (#5631)
* Closes https://github.com/emilk/egui/issues/5246 Tested on * [x] Chromium * [x] Firefox * [x] Safari On Chromium and Firefox we get one annoying frame with the wrong size, which can mess up the layout of egui apps, but this PR is still a huge improvement, and I don't want to spend more time on this right now.
This commit is contained in:
@@ -59,7 +59,7 @@ impl AppRunner {
|
||||
|
||||
egui_ctx.options_mut(|o| {
|
||||
// On web by default egui follows the zoom factor of the browser,
|
||||
// and lets the browser handle the zoom shortscuts.
|
||||
// and lets the browser handle the zoom shortcuts.
|
||||
// A user can still zoom egui separately by calling [`egui::Context::set_zoom_factor`].
|
||||
o.zoom_with_keyboard = false;
|
||||
o.zoom_factor = 1.0;
|
||||
@@ -216,6 +216,18 @@ impl AppRunner {
|
||||
let canvas_size = super::canvas_size_in_points(self.canvas(), self.egui_ctx());
|
||||
let mut raw_input = self.input.new_frame(canvas_size);
|
||||
|
||||
if super::DEBUG_RESIZE {
|
||||
log::info!(
|
||||
"egui running at canvas size: {}x{}, DPR: {}, zoom_factor: {}. egui size: {}x{} points",
|
||||
self.canvas().width(),
|
||||
self.canvas().height(),
|
||||
super::native_pixels_per_point(),
|
||||
self.egui_ctx.zoom_factor(),
|
||||
canvas_size.x,
|
||||
canvas_size.y,
|
||||
);
|
||||
}
|
||||
|
||||
self.app.raw_input_hook(&self.egui_ctx, &mut raw_input);
|
||||
|
||||
let full_output = self.egui_ctx.run(raw_input, |egui_ctx| {
|
||||
|
||||
Reference in New Issue
Block a user