JFLib

plat/win_test.rs (Windows)#

Source: lib/plat/win_test.rs

win_test -- test aids of the Windows platform layer (plattest --test window): they look at
and poke our own windows only (no input is injected into the system)

  win_test(op, w, a) -> i64   op:
    WT_PIXEL      0x00RRGGBB of client pixel a[0], a[1] of window w (GetPixel on its DC; -1
                  outside / no window)
    WT_REDRAW     invalidate the whole window and paint it now (WM_PAINT repaints from the
                  kept copy) -> 1
    WT_MOVE       move / size the window like the user would (SetWindowPos of the frame, not
                  win_set_rect): client origin a[0], a[1], client size a[2], a[3] -> 1
    WT_DPI        a WM_DPICHANGED of dpi a[0] with the suggested rect scaled around the
                  client origin (as Windows sends it when the window changes monitors) -> 1
    WT_CURSOR_IS  the current cursor is the one of shape a[0] (CUR_* / custom) -> 1 / 0
    WT_VISIBLE    window w is visible -> 1 / 0
    WT_POPUP_RECT popup slot w: its window rect x, y, w, h packed as 4 x i16 (-1: not shown)
    WT_POPUP_PIXEL popup slot w: 0x00RRGGBB at a[0], a[1]
    WT_ENABLED    window w takes input -> 1 / 0
    WT_CARET      the system caret's position x | y << 32 (GetCaretPos)
    WT_ACTIVE     window w is the active window -> 1 / 0
    WT_CLIP_ACCESS  0 when the clipboard can be opened, else the error (5: access denied,
                  e.g. in a sandbox that keeps processes off the clipboard)
    WT_POPUP_SEND popup slot w: SendMessageW(msg a[0], wParam a[1], lParam = point a[2], a[3])
    WT_POST_CHARS a burst: a[0] WM_CHAR messages posted to window w, the characters a[1],
                  a[1] + 1, ... a[1] + a[2] - 1 by turns (as an input method commits a long
                  text) -> the number posted
    WT_SCROLL     move the client rows a[0] .. a[0] + a[1] by a[2] rows inside the window
                  (BitBlt from its DC to itself, GdiFlush; what a scroll could cost without
                  sending the pixels again) -> microseconds taken
    WT_NOANIM     no DWM transitions for window w (fade-in, minimise) -> 1
    WT_FROM_POINT WindowFromPoint at client pixel a[0], a[1] of window w: window w -> 1, its GPU
                  child -> 2, another window (of any program) -> 0
    WT_SHOW       ShowWindow(w, a[0]) (SW_SHOWMINNOACTIVE, SW_SHOWNOACTIVATE: a test that leaves the
                  keyboard and the other windows alone) -> 1
  win_test_image(w) -> (w, h, px)   the client area as the window shows it (BitBlt from its DC)
  win_test_composed(w) -> (w, h, px)  the client area as the system composes it, without what
                  lies on top (PrintWindow, PW_RENDERFULLCONTENT: the GPU child's swapchain too)
  win_test_screen(x, y, w, h) -> px  a part of the screen as it shows now (any thread)
  win_test_post(hwnd, msg, wp, lp)  PostMessageW by handle (any thread)
  win_test_window_at(x, y) -> HWND  the window at a screen point (any thread)
  win_test_usage() -> (cpu us, working set, private bytes)  this process
  file_dialog_autoclose(ms, name)   the next file_dialog is closed after ms by a timer of the
                  UI thread: name None = Cancel, Some(name) = the name typed + OK
WT_PIXEL: u32 = 1
WT_REDRAW: u32 = 2
WT_MOVE: u32 = 3
WT_DPI: u32 = 4
WT_CURSOR_IS: u32 = 5
WT_VISIBLE: u32 = 6
WT_POPUP_RECT: u32 = 7
WT_POPUP_PIXEL: u32 = 8
WT_ENABLED: u32 = 9
WT_CARET: u32 = 10
WT_ACTIVE: u32 = 11
WT_CLIP_ACCESS: u32 = 12
WT_POPUP_SEND: u32 = 13
WT_POST_CHARS: u32 = 14
WT_SCROLL: u32 = 15
WT_NOANIM: u32 = 16
WT_FROM_POINT: u32 = 17
WT_SHOW: u32 = 18
  • fn win_test(op: u32, w: i32, a: [i32; 4]) -> i64 see the file header

  • fn win_test_image(w: i32) -> Option<(i32, i32, alloc::vec::Vec<u8>)> (test aid) what window w shows: its client area read back from the window's DC (BitBlt into a DIB section; under DWM the window's own surface, also where other windows cover it) -> (w, h, rows of w * 4 bytes B, G, R, x)

  • fn win_test_composed(w: i32) -> Option<(i32, i32, alloc::vec::Vec<u8>)> (test aid) window w's client area as the system composes it: PrintWindow with PW_RENDERFULLCONTENT, so the swapchain of its GPU child too, and nothing of what lies on top of it (other windows, overlays that take no clicks, shadows) -> (w, h, rows of w * 4 bytes B, G, R, x)

  • fn win_test_usage() -> (u64, u64, u64) (test aid) (CPU time of this process so far in us, its working set in bytes, its private bytes)

  • fn win_test_window_at(x: i32, y: i32) -> isize (test aid) the window at a screen point, from any thread (a screen check: is ours on top there?)

  • fn win_test_post(hwnd: isize, msg: u32, wp: usize, lp: isize) -> bool (test aid) PostMessageW to a window by its handle, from any thread -> posted

  • fn win_test_screen(x: i32, y: i32, w: i32, h: i32) -> Option<alloc::vec::Vec<u8>> (test aid) what the screen shows now in the rectangle x, y, w, h (screen px): BitBlt from the screen's DC, so under DWM the composed desktop -- other windows on top included. Any thread; -> rows of w * 4 bytes B, G, R, x

  • fn file_dialog_autoclose(ms: u32, name: Option<&str>) (test aid) close the next file_dialog after ms: Cancel (name None) or name + OK

Source: docs/API.md in the JFLib repository.