Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mac): clean up code obsoleted by core #10877

Merged
merged 5 commits into from
Mar 20, 2024

Conversation

sgschantz
Copy link
Contributor

Remove code that is no longer used because of the adoption of Keyman Core and design changes around it. Instead of several classes descending from KMInputMethodEventHandler to handle different degrees of compliance, we now use the class TextApiCompliance to repeatedly evaluate what the current state of compliance is. This is better because compliance can vary within the same application: for example, moving from the url search bar in Google Chrome to a Google Docs document in the content area, causes a change in compliance. When this happens, we do not want to switch event handlers because we are actually in the process of handling an event.

@keymanapp-test-bot skip

@sgschantz sgschantz added the mac/ label Feb 28, 2024
@sgschantz sgschantz added this to the B17S2 milestone Feb 28, 2024
@sgschantz sgschantz self-assigned this Feb 28, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Feb 28, 2024

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

@github-actions github-actions bot added the chore label Feb 28, 2024
@mcdurdin mcdurdin modified the milestones: B17S2, B17S3 Mar 3, 2024
@sgschantz sgschantz marked this pull request as ready for review March 7, 2024 05:24
Copy link
Contributor

@SabineSIL SabineSIL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am slightly uncertain about the scope of some of these changes and how we verify that they haven't changed interactions with client apps -- particularly the changes in sendKeymanKeyCodeForEvent.

handledEvent = NO;
} else {
[self.appDelegate logDebugMessage:@"KXMInputMethodHandler applyOutputToTextInputClient, delete only scenario"];
[self sendEvents:event forOutput:output];
}
} else if (output.isDeleteAndInsertScenario) {
/*
// needs further testing to fix backspace bug in google docs (without breaking other apps)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an issue number for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, #10246, adding it in the comment

Comment on lines +76 to +77
// use nil as source, as this generated event is not directly tied to the originating event
CGEventRef keyDownEvent = CGEventCreateKeyboardEvent(nil, kKeymanEventKeyCode, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change in behaviour. Are there possible ramifications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change from my previous version of the code, but Keyman 16 specifies nil as the source for this event, so I decided to switch back to that as I could see no difference in the behavior. The impact of the event source is not clearly documented. It seems reasonable that if any event we generate is going to have a nil event source it would be this one because it is a message to ourselves, and we do not want it to be interpreted by anyone but Keyman.

// use nil as source, as this generated event is not directly tied to the originating event
CGEventRef keyDownEvent = CGEventCreateKeyboardEvent(nil, kKeymanEventKeyCode, true);

CGEventPostToPSN(&psn, keyDownEvent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this been changed from CGEventPostToPid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CGEventPostToPid is only supported with macOS 10.11 and later, and we still support macOS 10.10 in 17. CGEventPostToPSN, though deprecated, still works ok with Sonoma. I prefer CGEventPostToPid, and it is a cleaner interface, but I'll wait until 18 when we move to the Xcode 15 and stop supporting 10.10.

@@ -90,23 +63,20 @@ - (void)postKeyboardEventWithSource: (CGEventSourceRef)source code:(CGKeyCode) v
- (void)sendKeymanKeyCodeForEvent:(NSEvent *)event {
[self.appDelegate logDebugMessage:@"KeySender sendKeymanKeyCodeForEvent"];

[self sendKeyDown:kKeymanEventKeyCode forSourceEvent:event includeKeyUp:NO];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a significant change for beta?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did not seem to be causing an issue, but it was definitely a bug and resulted in duplicate generation of the event that triggers insertion of the text.

@darcywong00 darcywong00 modified the milestones: B17S3, B17S4 Mar 16, 2024
@mcdurdin
Copy link
Member

OK happy to go ahead on this.

@sgschantz sgschantz merged commit 8dc9014 into beta Mar 20, 2024
5 checks passed
@sgschantz sgschantz deleted the chore/mac/old-engine-cleanup branch March 20, 2024 02:24
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.291-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants