browser DOM support
This commit is contained in:
parent
3859c43ce3
commit
5352ef69a2
37 changed files with 2637 additions and 59 deletions
|
|
@ -98,8 +98,22 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CRAFTER_GRAPHICS_WINDOW_DOM
|
||||
// Single JS import — the env.js implementation calls navigator.clipboard.writeText.
|
||||
// `bool` return mirrors the native paths so callers don't need to #ifdef the
|
||||
// check; failure cases (no permission, async rejection) just log to console.
|
||||
// Lives in a named namespace (anonymous would give internal linkage and the
|
||||
// import_module attribute would be dropped at link time).
|
||||
namespace Crafter::DomEnv {
|
||||
__attribute__((import_module("env"), import_name("clipboardSetText")))
|
||||
bool DomClipboardSetText(const char* text, std::int32_t len);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Crafter::Clipboard::SetText(std::string_view text) {
|
||||
#ifdef CRAFTER_GRAPHICS_WINDOW_WAYLAND
|
||||
#ifdef CRAFTER_GRAPHICS_WINDOW_DOM
|
||||
return Crafter::DomEnv::DomClipboardSetText(text.data(), static_cast<std::int32_t>(text.size()));
|
||||
#elif defined(CRAFTER_GRAPHICS_WINDOW_WAYLAND)
|
||||
if (Device::dataDeviceManager == nullptr || Device::dataDevice == nullptr) {
|
||||
// Compositor doesn't expose wl_data_device_manager (rare; some
|
||||
// headless / minimal compositors). Caller can fall back.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue