Fix rendering of the Qt platform example with high-dpi

- Provide a C++ platform event for the scale factor change and send it
- Report the correct logical and physical sizes to Slint
This commit is contained in:
Simon Hausmann 2023-05-24 15:33:37 +02:00 committed by Simon Hausmann
parent 459f810bd8
commit dd61890e23
3 changed files with 34 additions and 12 deletions

View file

@ -139,7 +139,7 @@ pub unsafe extern "C" fn slint_windowrc_has_active_animations(
window_adapter.window().has_active_animations()
}
/// Dispatch a key pressed or release event
/// Dispatch resize event
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_dispatch_resize_event(
handle: *const WindowAdapterRcOpaque,
@ -152,6 +152,18 @@ pub unsafe extern "C" fn slint_windowrc_dispatch_resize_event(
});
}
/// Dispatch scale factor change event
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_dispatch_scale_factor_change_event(
handle: *const WindowAdapterRcOpaque,
scale_factor: f32,
) {
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter
.window()
.dispatch_event(i_slint_core::platform::WindowEvent::ScaleFactorChanged { scale_factor });
}
#[no_mangle]
pub extern "C" fn slint_platform_update_timers_and_animations() {
i_slint_core::platform::update_timers_and_animations()