Module daemon
Expand description
Daemon implementation
ModulesΒ§
StructsΒ§
- Client π
- Representation of a client
- Clients π
- Collection of
Clients maintaining insertion order and a PID-indexed lookup table. - Daemon π
- The daemon is responsible to launch a client for each host, positioning the client windows, forwarding input records to all clients and handling control mode.
- HWND
Wrapper π - Hacky wrapper around a window handle.
EnumsΒ§
- Control
Mode πAction - Top-level control-mode action a keystroke classifies into.
- Control
Mode πState - Enum of all possible control mode states.
- Enable
Disable πSubmenu Action - Enable/disable-submenu action a keystroke classifies into.
- Navigation
Direction π - Direction of a navigation keystroke inside the enable/disable submenu.
ConstantsΒ§
- MODIFIER_
MASK π - Bits in
KEY_EVENT_RECORD::dwControlKeyStatethat represent βrealβ modifier keys (Ctrl / Alt / Shift) as opposed to lock toggles (CAPSLOCK_ON,NUMLOCK_ON,SCROLLLOCK_ON) or theENHANCED_KEYflag. - SENDER_
CAPACITY π - The capacity of the broadcast channel used to send the input records read from the console input buffer to the named pipe servers connected to each client in parallel.
FunctionsΒ§
- arrange_
client_ πwindow - Re-sizes and re-positions the given client window based on the total number of clients, the size of the daemon console window and its index relative to the other client windows.
- build_
client_ πgrid - Build a
ClientGridfromclientsandworkspace_areausing the same aspect-ratio expression the tiler uses. - classify_
control_ πmode_ key - Classifies a top-level control-mode keystroke.
- classify_
enable_ πdisable_ submenu_ key - Classifies an enable/disable-submenu keystroke.
- defer_
windows π - Move all given windows to the foreground.
- determine_
client_ πspatial_ attributes - Calculates the position and dimensions for a client window given its index,
the total number of clients and the
aspect_ratio_adjustmentdaemon configuration. - ensure_
client_ πz_ order_ in_ sync_ with_ daemon - Spawns a background thread that ensures the z-order of all client windows is in sync with the daemon window. I.e. if the daemon window is focussed, all clients should be moved to the foreground.
- expand_
hosts - Resolve cluster tags in
hostsand expand brace expressions (e.g.host{1..3}.local) in each resulting hostname. - get_
console_ πrect - Transform the position and dimensions of a console window based on the workspace area.
- get_
console_ πwindow_ wrapper - Returns a window handle to the current console window.
- get_
foreground_ πwindow_ wrapper - Returns a window handle to the foreground window.
- launch_
client_ πconsole - Launchs a
clientconsole process with its own window with the given CLI arguments/options:host,username,port,debug. - launch_
clients π - Launches a client console for each given host and waits for the client windows to exist before returning their handles.
- main
- The entrypoint for the
daemonsubcommand. - named_
pipe_ πserver_ routine - Correlate the connecting client by PID, then multiplex input records,
ClientStateupdates, and keep-alives onto the named pipe. - next_
submenu_ πselection - Compute the next submenu selection given a grid step.
- probe_
pipe_ πalive - Best-effort, non-blocking probe of the named pipe.
- read_
client_ πpid - Read the connecting clientβs 4 byte little-endian process id from the pipe.
- resolve_
cluster_ tags - Resolve cluster tags into hostnames
- restore_
if_ πminimized - Restore
window_handleif its current placement reports minimized. - toggle_
processed_ πinput_ mode - The processed console input mode controls whether special key combinations
such as
Ctrl + corCtrl + BREAKreceive special handling or are treated as simple key presses. - workspace_
aspect_ πratio - Return the workspace areaβs aspect ratio (width / height) including the frame padding the tiler accounts for.
- write_
framed_ πmessage - Write all of
frameto the named pipe server, retrying partial writes andWouldBlockresults until the buffer is fully drained.