#ifndef DISPLAYMODE_WINDOW_LAYOUT_TAP_H #define DISPLAYMODE_WINDOW_LAYOUT_TAP_H /* The window manager's event tap: what it listens to, and nothing else. * * This header is the single place that fixes the event mask of the tap the * window manager daemon opens for drag-to-snap. It is published as-is (see * /verify/ on the website) so that anyone can read the mask and compare it * with the one the running binary reports through the public * CGGetEventTapList API. The mask is the only thing this file decides: the * left mouse button going down, dragging and coming up. No keyboard event * type is in it, so no keystroke ever reaches the tap. What the daemon does * with the events it receives is not part of this file. * * Measured on the shipped binary (2026-09-17): mask 0x46, the keyboard bits * 0x1c00 (kCGEventKeyDown, kCGEventKeyUp, kCGEventFlagsChanged) absent. * test_taps.c keeps it that way. */ #include /* The mask, built from the event types by name so the intent is readable. */ static inline CGEventMask DMWindowLayoutTapMask(void) { return CGEventMaskBit(kCGEventLeftMouseDown) | CGEventMaskBit(kCGEventLeftMouseDragged) | CGEventMaskBit(kCGEventLeftMouseUp); } /* Opens the tap: session-wide, inserted at the head, active (the callback may * change the event), with the mask above. The caller owns the returned port * and enables it. NULL when the system refuses (no Accessibility consent). */ static inline CFMachPortRef DMWindowLayoutTapCreate(CGEventTapCallBack callback, void *userInfo) { return CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, DMWindowLayoutTapMask(), callback, userInfo); } #endif