I wasn't going to do this, but realised that crash reporting was going
to be a problem on mac because it still used crashlytics/fabric. Turned
out to be a good exercise to get me back into macOS world, and fairly
straightforward to get right (helps that the other platforms broke the
ice for me).
The handleEvent function has somewhat convoluted logic around emitting
the final transform to the client application. This starts to refactor
that code to move all client interaction to a single point at the end
of the event sequence.
Next phase will be to update delete and insert events to turn them into
a single action where possible.
Fixes#2375.
For applications that do not provide context to Keyman, Keyman was losing
the context buffer whenever a modifier key was pressed or released. This
change modifies the cache reset to occur only when the Command modifier is
pressed.
1) Enable/disable event tap depending on whether Keyman is the active IM; 2) Made code dealing with keeping track of activating/deactivating servers thread-safe; 3) Improved clean-up when event tap cannot be re-enabled; 4) Improved and cleaned up some comments and code aesthetics.
When a special event comes in indicating the event tap has been disabled by timeout or by the user, we attempt to re-enable it. Otherwise, use fallback logic.
This commit does not include the project and plist changes necessary to build/work because they have the APIKey in them and we don't want to publish that. Also, I haven't completely worked out where the frameworks should go or how that plumbing should be hooked up to work well on the build machines and for other developers.
Replaced logic in updateContextBufferIfNeeded to be based on tapping of low-level mouse events instead of relying on list of clients that might have unexpected selection changes.
I had previously made a change to do this in the base class but overloooked that it was also a factor in this subclass, so I refactored a little to have a single method in the base class that handles this. (Note: the base class method also checks to be sure that the client responds to the attributedSubstringFromRange method before calling it. This used to be done only in the subclass, but it seems like a useful safeguard in case some other client fails to implement this.
Turns out that length is not really a supported method/property on IMKTextInput, and it returns unreliable information. (It appears that perhaps this was actually causing Word to work incorrectly.) The diagnostic call to markedRange was pointless since Keyman keyboards to not compose text in this way.
Major refactoring to break long methods up by factoring out into meaningful sub-methods. Also removed small amount of unused code left over from previous refactoring step.
Added logic to correct bug in Safari Google Docs introduced a few months back to clear selection after replacement. Refactored code and fixed bug to correctly handle Chrome's need to replace characters individually.