mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-25 13:43:50 +00:00
Create the window adapter lazily in C++
This commit is contained in:
parent
d48e7192d8
commit
cd9994306e
5 changed files with 29 additions and 19 deletions
|
|
@ -21,21 +21,21 @@ template<typename Component>
|
|||
inline void send_mouse_click(const Component *component, float x, float y)
|
||||
{
|
||||
auto crc = *component->self_weak.into_dyn().lock();
|
||||
cbindgen_private::slint_send_mouse_click(&crc, x, y, &component->m_window.window_handle());
|
||||
cbindgen_private::slint_send_mouse_click(&crc, x, y, &component->window().window_handle());
|
||||
}
|
||||
|
||||
template<typename Component>
|
||||
inline void send_keyboard_char(const Component *component, const slint::SharedString &str,
|
||||
bool pressed)
|
||||
{
|
||||
cbindgen_private::slint_send_keyboard_char(&str, pressed, &component->m_window.window_handle());
|
||||
cbindgen_private::slint_send_keyboard_char(&str, pressed, &component->window().window_handle());
|
||||
}
|
||||
|
||||
template<typename Component>
|
||||
inline void send_keyboard_string_sequence(const Component *component,
|
||||
const slint::SharedString &str)
|
||||
{
|
||||
cbindgen_private::send_keyboard_string_sequence(&str, &component->m_window.window_handle());
|
||||
cbindgen_private::send_keyboard_string_sequence(&str, &component->window().window_handle());
|
||||
}
|
||||
|
||||
#define assert_eq(A, B) \
|
||||
|
|
|
|||
|
|
@ -29,6 +29,15 @@ pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowAdapterRcOpaque) {
|
|||
core::ptr::write(out as *mut Rc<dyn WindowAdapter>, win);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_ensure_backend() {
|
||||
i_slint_backend_selector::with_platform(|_b| {
|
||||
// Nothing to do, just make sure a backend was created
|
||||
Ok(())
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_run_event_loop() {
|
||||
i_slint_backend_selector::with_platform(|b| b.run_event_loop()).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue