mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
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:
parent
57e9b5b796
commit
3565023a15
4 changed files with 37 additions and 8 deletions
|
@ -255,13 +255,22 @@ public:
|
|||
}
|
||||
|
||||
# if !defined(__APPLE__) && !defined(_WIN32) && !defined(_WIN64)
|
||||
static NativeWindowHandle from_x11(uint32_t /*xcb_window_t*/ window,
|
||||
uint32_t /*xcb_visualid_t*/ visual_id,
|
||||
xcb_connection_t *connection, int screen)
|
||||
static NativeWindowHandle from_x11_xcb(uint32_t /*xcb_window_t*/ window,
|
||||
uint32_t /*xcb_visualid_t*/ visual_id,
|
||||
xcb_connection_t *connection, int screen)
|
||||
{
|
||||
|
||||
return { cbindgen_private::slint_new_raw_window_handle_x11(window, visual_id, connection,
|
||||
screen) };
|
||||
return { cbindgen_private::slint_new_raw_window_handle_x11_xcb(window, visual_id,
|
||||
connection, screen) };
|
||||
}
|
||||
|
||||
static NativeWindowHandle from_x11_xlib(uint32_t /*Window*/ window,
|
||||
unsigned long /*VisualID*/ visual_id,
|
||||
void /*Display*/ *display, int screen)
|
||||
{
|
||||
|
||||
return { cbindgen_private::slint_new_raw_window_handle_x11_xlib(window, visual_id, display,
|
||||
screen) };
|
||||
}
|
||||
|
||||
static NativeWindowHandle from_wayland(wl_surface *surface, wl_display *display)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -45,7 +45,7 @@ static slint_platform::NativeWindowHandle window_handle_for_qt_window(QWindow *w
|
|||
native->nativeResourceForWindow(QByteArray("connection"), window));
|
||||
auto screen = quintptr(native->nativeResourceForWindow(QByteArray("screen"), window));
|
||||
|
||||
return slint_platform::NativeWindowHandle::from_x11(wid, wid, connection, screen);
|
||||
return slint_platform::NativeWindowHandle::from_x11_xcb(wid, wid, connection, screen);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ class MyWindow : public QWindow, public slint_platform::WindowAdapter
|
|||
public:
|
||||
MyWindow(QWindow *parentWindow = nullptr) : QWindow(parentWindow)
|
||||
{
|
||||
resize(640, 480);
|
||||
m_renderer.emplace(window_handle_for_qt_window(this), physical_size());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue