code wiki / (root) / nx_x11_connect.nx

nx_x11_connect.nx

buildroot/runtime/nx_x11_connect.nx

8779 B258 linesdepth 3pulls 3 transitivereach 23 importersview sourcekind tooltopic x11
docsdependenciesstructsconstsfunctions

about

nx_x11_connect.nx -- bits-up X11 wire-protocol connection setup. Opens an AF_UNIX socket to the local X server (typically WSLg's /tmp/.X11-unix/X0 on Windows/WSL2, or an X11/Xorg server on Linux), sends the connection-setup request, and reads the server's reply. Returns the connected fd + parsed server info. X11 protocol reference: X Window System Protocol ยง8 (Connection Setup), public wire spec (X11 Release 11.0+). Same flavor of bits-up work as TLS/HTTP: we read the spec, write the bytes, no third-party client library. Setup request bytes (12 + auth-name + auth-data, padded to 4): byte 0: byte-order ('l' = 0x6c = little-endian, 'B' = big) byte 1: pad (0) bytes 2-3: major version (11) [u16 LE] bytes 4-5: minor version (0) [u16 LE] bytes 6-7: auth_proto_name_len [u16 LE] bytes 8-9: auth_proto_data_len [u16 LE] bytes 10-11: pad auth_proto_name (padded to 4) auth_proto_data (padded to 4) Server reply byte 0: 1 = success (info follows) 0 = failed (reason string follows) 2 = authenticate (more auth needed) For local WSLg, anonymous auth (zero-length name/data) is accepted when the connecting uid matches the server's owner. If WSLg rejects this, we'll add MIT-MAGIC-COOKIE-1 via ~/.Xauthority parse. Public API: nx_x11_connect_local(display_num) Connects to /tmp/.X11-unix/X<display_num>, performs setup handshake. Returns negative verdict or positive fd. Sealed verdict (negative on failure): NX_X11_OK positive fd returned NX_X11_SOCKET_FAIL socket()/connect() failed

dependencies 2 imports · 16 importers

nx_syscalls.nx nx_unix_socket.nx nx_x11_connect.nx nx_browser.nx nx_browser_demo_test.nx nx_render_wiki_styled_window.nx nx_render_wiki_window.nx nx_x11_connect_real_test.nx nx_x11_font_test.nx nx_x11_get_image.nx nx_x11_keyboard.nx nx_x11_paint.nx nx_x11_paint_text_5x7.nx

diagram shows first 10 each side; +0 more imports, +6 more importers in the complete lists below.

imports: nx_syscalls.nxnx_unix_socket.nx

imported by: nx_browser.nxnx_browser_demo_test.nxnx_render_wiki_styled_window.nxnx_render_wiki_window.nxnx_x11_connect_real_test.nxnx_x11_font_test.nxnx_x11_get_image.nxnx_x11_keyboard.nxnx_x11_paint.nxnx_x11_paint_text_5x7.nxnx_x11_pixmap.nxnx_x11_pixmap_kat_test.nxnx_x11_put_image.nxnx_x11_screenshot.nxnx_x11_window.nxnx_x11_window_real_test.nx

structs

64struct X11Conn

consts

52const NX_X11_OK: i64 = 1
53const NX_X11_SOCKET_FAIL: i64 = 2
54const NX_X11_WRITE_FAIL: i64 = 3
55const NX_X11_READ_FAIL: i64 = 4
56const NX_X11_REJECTED: i64 = 5
57const NX_X11_VERDICT_N: i64 = 6
77const NX_X11_CONN_BYTES: i64 = 80

functions

80func _x11_rd_u16(buf: *u8, off: i64) -> i64
85func _x11_rd_u32(buf: *u8, off: i64) -> i64
93func nx_x11_alloc_id(c: *X11Conn) -> i64
100func _x11_build_path(out: *u8, display_num: i64) -> i64
118func _x11_write_n(fd: i64, buf: *u8, n: i64) -> i64
called by 1: nx_x11_connect_local calls 1: sys_write
129func _x11_read_n(fd: i64, buf: *u8, n: i64) -> i64
called by 1: nx_x11_connect_local calls 1: sys_read
142func nx_x11_connect_local(display_num: i64) -> i64
256func main() -> i64