The upstream Cocotron assumes that the implementation of the file panels
is provided by the display, i.e. by the native toolkit. That is what we
ultimately want as well, but we're far from being there yet, and we also
don't want to make any toolkit a hard requirement.
So in order to have our cake and eat it too, these panel implementations
are designed work entirely inside Cocoa but also let the display provide
a native implementation instead if one is available.
X11Display already has the code to drop mouse moved events in case
the window does not want them; but we weren't getting the events in
the first place because they were filtered out on the server side.
Fixes, among other things, NSMenu not reacting to clicks properly,
because it was assuming the clicked item was not the selected one
as it could not see the mouse hovering over it.
There's no need to additionally spin the run loop since runModalSession: does that
already, in a proper way (that is via nextEventMatchingMask:untilDate:inMode:dequeue:]),
and spinning the run loop directly prevents AppKit from getting its events.
As they are so clearly meant to be. This is also a prerequisite for building
the X11 backend as a separate dynamically loaded Mach-O and loading many such
backends at the same time.
localizedInfoDictionary can be nil if the corresponding localization is missing; you have
to either account for that by falling back to infoDictionary, or use objectForInfoDictionaryKey:
which (in addition to being more concise than [[localizedInfoDictionary] objectForKey:]) implements
automatical fallback to the non-localized dictionary.
Turns out it didn't just break the build (269215f670),
it was actually *wrong*; the Apple's version uses a plain int (not even a CFIndex) for some reason. Do the same in O2FontGetGlyphAdvances(),
but keep the internal ivar as an NSInteger array pointer; we're making a copy in O2FontGetGlyphAdvances() anyway.
-[X11Display processPendingEvnets], which dequeues events from the X11 event queue,
converts them to NSEvents and finally enqueues into the NSDisplay event queue, was
only invoked as a result of the X11 socket becoming readable during an iteration of
NSRunLoop. However, events can arrive and be queued by libX11 as a result of some
other interactions with X11, such as querying the mouse position, in which case the
socket won't be readable, but libX11 will still contain queued events.
Fix this by invoking -[X11Display processPendingEvnets] an additional time before
delegating to super's implementation which spins the loop; this way the NSDisplay
implementation can observe pending events in the event queue and deliver them
immediately.