Improve error handling in C++ Skia Renderer API

- Don't try to create a GLX context when we only have an XCB window handle,
  XLib is required for that.
- Make it possible to create a NativeWindowHandle from Xlib data types.

Fixes #2978
This commit is contained in:
Simon Hausmann 2023-07-14 13:48:59 +02:00 committed by Simon Hausmann
parent 57e9b5b796
commit 3565023a15
4 changed files with 37 additions and 8 deletions

View file

@ -249,7 +249,7 @@ pub mod skia {
}
#[no_mangle]
pub unsafe extern "C" fn slint_new_raw_window_handle_x11(
pub unsafe extern "C" fn slint_new_raw_window_handle_x11_xcb(
window: u32,
visual_id: u32,
connection: *mut c_void,
@ -263,6 +263,21 @@ pub mod skia {
Box::into_raw(Box::new(handle)) as CppRawHandleOpaque
}
#[no_mangle]
pub unsafe extern "C" fn slint_new_raw_window_handle_x11_xlib(
window: core::ffi::c_ulong,
visual_id: core::ffi::c_ulong,
display: *mut c_void,
screen: core::ffi::c_int,
) -> CppRawHandleOpaque {
use raw_window_handle::{XlibDisplayHandle, XlibWindowHandle};
let handle = CppRawHandle(
RawWindowHandle::Xlib(init_raw!(XlibWindowHandle { window, visual_id })),
RawDisplayHandle::Xlib(init_raw!(XlibDisplayHandle { display, screen })),
);
Box::into_raw(Box::new(handle)) as CppRawHandleOpaque
}
#[no_mangle]
pub unsafe extern "C" fn slint_new_raw_window_handle_wayland(
surface: *mut c_void,