Open LubosD opened 3 years ago
Nice to see Wayland being worked on! What is the reasoning behind rewriting the X11 backend as part of CoreGraphics? Do some programs rely on internal CoreGraphics API calls?
1) Yes 2) The main reason is to also properly integrate CGEvents and later Carbon.
Not sure this is useful but I just stepped through CreateEventWithCGEvent()
and looking at the argument registers x0 - x8, one of the arguments is of type HIDEvent *
, also known as its __bridged type IOHIDEventRef
. Maybe that's the type of the event being created. You can find the source code for HIDEvent *
in Apple's open source IOKit code.
This issue documents how Cocotron's integration to lower API layers should work.
Backends for X11 and Wayland
cocotron/CoreGraphics/*.backend
that implement the new CGS interfaces.Event Processing
CGEventCreateWithEventRecord()
) and later NSEvents (for AppKit apps).CGSGetEventPort()
)Another call stack:
Call stack of event reception by AppKit:
HIToolbox (Carbon) APIs return the event as an
EventRef
, which is converted to CGSEventRecord by AppKit using_GetEventPlatformEventRecord()
and then toNSEvent
usingNSEvent _initWithCGSEvent
.NSEvent most likely contains both
CGSEventRecord
andEventRef
:+[NSEvent eventWithCGEvent:]
callsCGEventRecordPointer()
andCreateEventWithCGEvent()
to pass the return values to-[NSEvent _initWithCGSEvent:eventRef:]
.Event Lifecycle
The lifecycle of a HID event seems to be:
CGSEventRecord
CGSGetEventPort()
CGEventCreateNextEvent()
, convert it into aCGEventRef
CGEventRef
into anEventRef
and stores it in an internal queueEventRef
, it then converts theEventRef
into aCGSEventRecord
CGSEventRecord
is converted to anNSEvent
and passed through further processing