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

@ -189,7 +189,7 @@ fn gen_corelib(
"slint_property_listener_scope_is_dirty",
"PropertyTrackerOpaque",
"CallbackOpaque",
"WindowRc",
"PlatformWindowRc",
"VoidArg",
"KeyEventArg",
"PointerEventArg",
@ -453,9 +453,9 @@ fn gen_corelib(
.with_after_include(
r"
namespace slint {
namespace private_api { class WindowRc; }
namespace private_api { class PlatformWindowRc; }
namespace cbindgen_private {
using slint::private_api::WindowRc;
using slint::private_api::PlatformWindowRc;
using namespace vtable;
struct KeyEvent; struct PointerEvent;
using private_api::Property;