mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Add support for showing the renderer on macOS with AppKit
This commit is contained in:
parent
fe0e881418
commit
6a87a07e12
3 changed files with 29 additions and 1 deletions
|
@ -41,7 +41,7 @@ default = ["backend-winit", "renderer-winit-femtovg", "backend-qt", "experimenta
|
|||
[dependencies]
|
||||
i-slint-backend-selector = { version = "=0.3.3", path="../../internal/backends/selector" }
|
||||
i-slint-backend-testing = { version = "=0.3.3", path="../../internal/backends/testing", optional = true }
|
||||
i-slint-renderer-skia = { version = "=0.3.3", path="../../internal/renderers/skia", optional = true, features = ["opengl", "x11", "wayland"] }
|
||||
i-slint-renderer-skia = { version = "=0.3.3", path="../../internal/renderers/skia", optional = true, features = ["x11", "wayland"] }
|
||||
i-slint-core = { version = "=0.3.3", path="../../internal/core", features = ["ffi"] }
|
||||
slint-interpreter = { version = "=0.3.3", path="../../internal/interpreter", default-features = false, features = ["ffi", "compat-0-3-0"], optional = true }
|
||||
raw-window-handle = { version = "0.5", optional = true }
|
||||
|
|
|
@ -294,6 +294,7 @@ public:
|
|||
|
||||
void hide() const { cbindgen_private::slint_skia_renderer_hide(inner); }
|
||||
|
||||
# if !defined(__APPLE__) && !defined(_WIN32) && !defined(_WIN64)
|
||||
void show(uint32_t /*xcb_window_t*/ window, uint32_t /*xcb_visualid_t*/ visual_id,
|
||||
xcb_connection_t *connection, int screen, PhysicalSize size) const
|
||||
{
|
||||
|
@ -306,11 +307,21 @@ public:
|
|||
cbindgen_private::slint_skia_renderer_show_wayland(inner, surface, display, size);
|
||||
}
|
||||
|
||||
# elif defined(__APPLE__) && !defined(_WIN32) && !defined(_WIN64)
|
||||
|
||||
void show(void *nsview, void *nswindow, PhysicalSize size) const
|
||||
{
|
||||
cbindgen_private::slint_skia_renderer_show_appkit(inner, nsview, nswindow, size);
|
||||
}
|
||||
|
||||
# elif !defined(__APPLE__) && (defined(_WIN32) || !defined(_WIN64))
|
||||
|
||||
/// Windows handle
|
||||
void show(void *HWND, void *hinstance, PhysicalSize size) const
|
||||
{
|
||||
cbindgen_private::slint_skia_renderer_show_win32(inner, HWND, hinstance, size);
|
||||
}
|
||||
# endif
|
||||
};
|
||||
|
||||
/// Call this function at each iteration of the event loop to call the timer handler and advance
|
||||
|
|
|
@ -284,6 +284,23 @@ pub unsafe extern "C" fn slint_skia_renderer_show_wayland(
|
|||
r.show(handle, PhysicalSize { width: size.width, height: size.height })
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_skia_renderer_show_appkit(
|
||||
r: SkiaRendererOpaque,
|
||||
ns_view: *mut c_void,
|
||||
ns_window: *mut c_void,
|
||||
size: IntSize,
|
||||
) {
|
||||
use raw_window_handle::{AppKitDisplayHandle, AppKitWindowHandle};
|
||||
|
||||
let r = &*(r as *const SkiaRenderer);
|
||||
let handle = CppRawHandle(
|
||||
RawWindowHandle::AppKit(init_raw!(AppKitWindowHandle { ns_view, ns_window })),
|
||||
RawDisplayHandle::AppKit(AppKitDisplayHandle::empty()),
|
||||
);
|
||||
r.show(handle, PhysicalSize { width: size.width, height: size.height })
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_skia_renderer_hide(r: SkiaRendererOpaque) {
|
||||
let r = &*(r as *const SkiaRenderer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue