Files
chandra/compositor/raster/raster_native.mbt
T
Claude 27252a97ab
CI / test (push) Canceled after 0s
Emoji picker (Super+.): search, tabs, skin tones, recents, text-input-v3 insertion
Compositor-drawn Win+. style picker. The focused app keeps keyboard focus so
its text-input-v3 field stays enabled; the emoji goes in with commit_string,
or onto the clipboard with a visible notice when the app has no text field.
Shortcut lives in the shortcut table (rebindable in Settings > Shortcuts).

- compositor/wayland/text_input.mbt: zwp_text_input_manager_v3 (global 12)
- compositor/emoji: Emoji 18.0 + CLDR 49 data (Unicode License), search,
  picker model, CBDT/CBLC + GSUB reader for Noto Color Emoji
- Chandra's own pinned bitmap Noto Color Emoji (scripts/fetch-emoji-font.sh,
  just emoji-font); Fedora's COLRv1 copy can't be drawn. Missing font shows
  an error panel.
- raster WIT: emoji-font, emoji-has, emoji-image; served by wasmhost
- state.edn :emoji {:recent [...] :skin-tone n}
- tests incl. a fake text-input client; docs/emoji-picker.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkABDGJixotaqFv2X2
2026-11-26 07:00:22 +00:00

97 lines
3.0 KiB
MoonBit

///| The native build draws with the software renderer (`@renderer.render_scene`); there is no host
/// to send a scene to.
///|
pub fn submit(_scene : @scene.SceneGraph) -> Unit {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn read_frame(_width : Int, _height : Int) -> @renderer.Pixmap {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn write_frame_png(_path : String) -> Bool {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn grab_recording_frame(_r : @scene.Rect, _pointer : Bool, _px : Int, _py : Int) -> Bool {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn send_recording_frame(_fd : Int) -> Int {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn snapshot_frame() -> Bool {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn snapshot_png(_r : @scene.Rect) -> Bytes {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn snapshot_pixels(_r : @scene.Rect, _w : Int, _h : Int) -> @renderer.Pixmap {
abort("the host rasteriser is only available to the wasm compositor")
}
///| `w` x `h` RGBA pixels as an image (`reuse`: an earlier handle of this kind to overwrite, or 0).
pub fn image_pixels(w : Int, h : Int, rgba : Bytes, reuse : UInt) -> UInt {
if w <= 0 || h <= 0 || w > 16384 || h > 16384 || rgba.length() < w * h * 4 {
return 0U
}
let p : @renderer.Pixmap = { width: w, height: h, data: rgba.to_fixedarray() }
if reuse == 0U {
@renderer.add_image(p)
} else {
@renderer.set_image(reuse, p)
}
}
///| Images already loaded, by path (0: it failed, don't try again).
let loaded_images : Map[String, UInt] = {}
///| Load the image file at `path` for `Image` draw ops: a handle, or 0 when it can't be decoded.
/// The software renderer only reads PNG (an SVG icon gets 0, and the caller's fallback).
pub fn load_image(path : String) -> UInt {
match loaded_images.get(path) {
Some(h) => h
None => {
let h = if path.has_suffix(".png") {
match @renderer.decode_png(@sys.read_file_bytes(path)) {
Some(p) => @renderer.add_image(p)
None => 0U
}
} else {
0U
}
loaded_images.set(path, h)
h
}
}
}
///| The colour emoji font, for the software renderer.
let emoji_source : @emoji.EmojiSource = @emoji.EmojiSource::new()
///| Open the colour emoji font: its path, or what to tell the user (see `@emoji.EmojiSource`).
pub fn emoji_font() -> Result[String, String] {
emoji_source.font()
}
///| For each of `texts`, whether the font has one picture for it.
pub fn emoji_has(texts : Array[String]) -> Array[Bool] {
emoji_source.has(texts)
}
///| The picture for emoji `text` scaled to fit `px` x `px`, for `Image` draw ops; 0 when none.
pub fn emoji_image(text : String, px : Int) -> UInt {
emoji_source.image(text, px, p => @renderer.add_image(p))
}