plat/win_clip.rs (Windows)#
Source: lib/plat/win_clip.rs
win_clip -- Windows clipboard, file drops (WM_DROPFILES) and the IME caret position
[src/plat/win/win_clip.s; docs/modules/CLIPBOARD_DND.md]
clip_set(fmt, data) -> false on failure
CLIP_TEXT: UTF-8 text (converted to CF_UNICODETEXT, "\n" -> "\r\n")
CLIP_PNG: PNG file bytes (registered clipboard format "PNG", the one browsers and
Office exchange; no CF_DIBV5 rendering)
CLIP_IMAGE (K1): data = a CLIPIMG record (clipimg_pack: PNG + BMP file): "PNG" +
CF_DIBV5 (the BMP's V5 header and pixels) + CF_DIB (BITMAPINFOHEADER,
32 bit BI_RGB)
clip_get(fmt) -> bytes text as UTF-8 with "\r\n" -> "\n"; CLIP_IMAGE (K1): "PNG", else
"image/png", else CF_DIBV5, else CF_DIB as a BMP file (clip_dib_to_bmp: header checks,
paint.net's alpha rule)
clip_has(fmt) the clipboard offers the format (no data is read; K1)
win_drop_files(hdrop) -> (files, x, y) (K1) WM_DROPFILES: the paths go to the pending
drop list (drop_*); shell32 (DragQueryFileW, DragQueryPoint, DragFinish) is loaded on
the first drop. The windows get WS_EX_ACCEPTFILES.
win_drop_selftest(hwnd) (K1, test aid) jfgui_TEST_DROPFILES="path|path..." posts a
WM_DROPFILES with a real HDROP (GlobalAlloc'd DROPFILES, wide paths, point 100, 100) to
the new main window, so the whole shell32 path runs in a real window
ime_pos(x, y, h) place a hidden system caret at client px (x, y) with height h in
the window that has the keyboard, so IME composition / candidate windows open next to
the text caret and screen magnifiers follow it (Magnifier, ZoomText: GetGUIThreadInfo
and the caret's location events); h <= 0 removes it, so does the window's WM_KILLFOCUS
(caret_focus_lost)
The clipboard is opened for the main window; opening is retried for a moment while another
program holds it. Every block of another program is checked (sizes, NUL, surrogates).
fn clip_set_many(entries: &[(u32, &[u8])]) -> boolPublish TEXT/HTML/RTF/DOCX together, allocating every handle before replacing the clipboard.fn clip_set(fmt: u32, data: &[u8]) -> boolCLIP_TEXT / CLIP_PNG / CLIP_IMAGE (a CLIPIMG record) -> false on failure [plat_clip_set]fn clip_get(fmt: u32) -> Option<Vec<u8>>the clipboard contents (text as UTF-8 with "\n"; CLIP_IMAGE: PNG or BMP file bytes) [plat_clip_get]fn clip_has(fmt: u32) -> boolthe clipboard offers fmt (CLIP_TEXT / CLIP_PNG / CLIP_IMAGE) [plat_clip_has]fn ime_pos(x: i32, y: i32, h: i32)place a hidden system caret at client px (x, y) with height h in the window of ours that has the keyboard (h <= 0, or none of ours has it: removed)