Handle dpi awareness api feature flag

This commit is contained in:
meehl committed 2025-10-28 16:54:44 +01:00
1 parent 3ff483ad19
commit 3352152ef6
5 files changed
+27 -7

No files matched your search

+12 -5
View File
@@ -1,12 +1,19 @@
use crate::lua::ContextSocket;
use crate::{
dpi::{LogicalSize, PhysicalSize},
lua::ContextSocket,
};
use mlua::{Lua, Result as LuaResult};
// NOTE: needs to return physical size if this MR gets merged:
// https://github.com/PathOfBuildingCommunity/PathOfBuilding-PoE2/pull/1420
pub fn get_screen_size(l: &Lua, _: ()) -> LuaResult<(u32, u32)> {
let socket = l.app_data_ref::<&'static ContextSocket>().unwrap();
let size = socket.window().logical_size();
Ok((size.width, size.height))
let size = if *socket.is_dpi_aware() {
let PhysicalSize { width, height, .. } = socket.window().size;
(width, height)
} else {
let LogicalSize { width, height, .. } = socket.window().logical_size();
(width, height)
};
Ok(size)
}
pub fn get_screen_scale(l: &Lua, _: ()) -> LuaResult<f32> {