From e877b599c1d15d252558777b8a0f8f64c7bc9bf0 Mon Sep 17 00:00:00 2001 From: meehl <12648828+meehl@users.noreply.github.com> Date: Sun, 2 Nov 2025 15:42:53 +0100 Subject: [PATCH] Fix UI scaling factor not being applied at startup on X11 On wayland an event it dispatched right after window creation. This is not the case on X11 so we need to set it manually. --- CHANGELOG.md | 1 + src/api/window.rs | 3 ++- src/window.rs | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 846c68f..2d91573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - Fix missing window title during installation step +- Fix UI scaling factor not being applied at startup on X11 ## [0.2.6] - 2025-10-31 diff --git a/src/api/window.rs b/src/api/window.rs index 533b882..8fdd095 100644 --- a/src/api/window.rs +++ b/src/api/window.rs @@ -18,7 +18,8 @@ pub fn get_screen_size(l: &Lua, _: ()) -> LuaResult<(u32, u32)> { pub fn get_screen_scale(l: &Lua, _: ()) -> LuaResult { let ctx = l.app_data_ref::<&'static Context>().unwrap(); - Ok(ctx.window().scale_factor) + let scale_factor = ctx.window().scale_factor; + Ok(scale_factor) } pub fn set_window_title(l: &Lua, title: String) -> LuaResult<()> { diff --git a/src/window.rs b/src/window.rs index 470af38..a8a218c 100644 --- a/src/window.rs +++ b/src/window.rs @@ -28,6 +28,9 @@ impl WindowState { window.set_title(&title); } + let winit::dpi::PhysicalSize { width, height } = window.inner_size(); + self.size = PhysicalSize::new(width, height); + self.scale_factor = window.scale_factor() as f32; self.window = Some(window); }