mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 15:17:25 +00:00
Invert slint:🪟:WindowInner and PlatformWindow ownership
Previously: Window is an Rc<WindowInner>, which has an Rc<dyn PLatformWindow> - and weak references the other way around. Now: Rc<dyn PlatformWindow> is the root of window ownership. The impl PlatformWindow has a slint::api::Window, which just holds a WindowInner. This change is incomplete on a few levels, mainly that neither of the code generators nor the interpreter is ported.
This commit is contained in:
parent
f88b688fbf
commit
af86f36157
32 changed files with 494 additions and 533 deletions
|
@ -5,8 +5,7 @@
|
|||
|
||||
use core::ffi::c_void;
|
||||
use i_slint_backend_selector::backend;
|
||||
use i_slint_core::api::Window;
|
||||
use i_slint_core::window::{ffi::WindowRcOpaque, WindowRc};
|
||||
use i_slint_core::window::{ffi::PlatformWindowRcOpaque, PlatformWindowRc};
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cold]
|
||||
|
@ -18,9 +17,12 @@ pub fn use_modules() -> usize {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowRcOpaque) {
|
||||
assert_eq!(core::mem::size_of::<Window>(), core::mem::size_of::<WindowRcOpaque>());
|
||||
core::ptr::write(out as *mut Window, crate::backend().create_window());
|
||||
pub unsafe extern "C" fn slint_windowrc_init(out: *mut PlatformWindowRcOpaque) {
|
||||
assert_eq!(
|
||||
core::mem::size_of::<PlatformWindowRc>(),
|
||||
core::mem::size_of::<PlatformWindowRcOpaque>()
|
||||
);
|
||||
core::ptr::write(out as *mut PlatformWindowRc, crate::backend().create_window());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -63,14 +65,17 @@ pub unsafe extern "C" fn slint_quit_event_loop() {
|
|||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_register_font_from_path(
|
||||
win: *const WindowRcOpaque,
|
||||
win: *const PlatformWindowRcOpaque,
|
||||
path: &i_slint_core::SharedString,
|
||||
error_str: *mut i_slint_core::SharedString,
|
||||
) {
|
||||
let window = &*(win as *const WindowRc);
|
||||
let platform_window = &*(win as *const PlatformWindowRc);
|
||||
core::ptr::write(
|
||||
error_str,
|
||||
match window.renderer().register_font_from_path(std::path::Path::new(path.as_str())) {
|
||||
match platform_window
|
||||
.renderer()
|
||||
.register_font_from_path(std::path::Path::new(path.as_str()))
|
||||
{
|
||||
Ok(()) => Default::default(),
|
||||
Err(err) => err.to_string().into(),
|
||||
},
|
||||
|
@ -79,14 +84,14 @@ pub unsafe extern "C" fn slint_register_font_from_path(
|
|||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_register_font_from_data(
|
||||
win: *const WindowRcOpaque,
|
||||
win: *const PlatformWindowRcOpaque,
|
||||
data: i_slint_core::slice::Slice<'static, u8>,
|
||||
error_str: *mut i_slint_core::SharedString,
|
||||
) {
|
||||
let window = &*(win as *const WindowRc);
|
||||
let platform_window = &*(win as *const PlatformWindowRc);
|
||||
core::ptr::write(
|
||||
error_str,
|
||||
match window.renderer().register_font_from_memory(data.as_slice()) {
|
||||
match platform_window.renderer().register_font_from_memory(data.as_slice()) {
|
||||
Ok(()) => Default::default(),
|
||||
Err(err) => err.to_string().into(),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue