Port the C++ generator and C++ API to the new window ownership model

One key difference to the Rust way is what `slint::Window` means. In
Rust that holds the `WindowInner` and `slint::Window` is only exposed as
`&slint::Window`. This is possible because the component owns the
`Rc<dyn PlatformWindow>`, which has a function to return the
`&slint::Window`.

In C++ `slint::Window` is also exposed as `slint::Window&` in the
`window()` getter, but there's no way to get a reference to a  C++
wrapper for the Rust `&slint::Window` that the `PlatformWindow` trait
returns. Therefore in C++ `slint::Window` wraps `Rc<dyn
PlatformWindow>`.
This commit is contained in:
Simon Hausmann 2022-08-18 15:00:49 +02:00 committed by Simon Hausmann
parent fd026a3991
commit 98e1befd0d
9 changed files with 26 additions and 30 deletions

View file

@ -585,7 +585,7 @@ public:
const cbindgen_private::PlatformWindowRcOpaque *win_ptr = nullptr;
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::slint_qt_get_widget(
reinterpret_cast<const cbindgen_private::WindowRc *>(win_ptr)));
reinterpret_cast<const cbindgen_private::PlatformWindowRc *>(win_ptr)));
return wid;
}
#endif
@ -1014,6 +1014,6 @@ inline void send_keyboard_string_sequence(const slint::interpreter::ComponentIns
cbindgen_private::slint_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
cbindgen_private::send_keyboard_string_sequence(
&str, modifiers, reinterpret_cast<const cbindgen_private::WindowRc *>(win_ptr));
&str, modifiers, reinterpret_cast<const cbindgen_private::PlatformWindowRc *>(win_ptr));
}
}