Skip to content

chore(mac): use core actions struct#10066

Merged
sgschantz merged 10 commits intomasterfrom
chore/mac/use-core-actions-struct
Dec 14, 2023
Merged

chore(mac): use core actions struct#10066
sgschantz merged 10 commits intomasterfrom
chore/mac/use-core-actions-struct

Conversation

@sgschantz
Copy link
Copy Markdown
Contributor

@sgschantz sgschantz commented Nov 23, 2023

Instead of processing an array of action structs, get a single struct from core that encapsulates all the impacts of the most recently processed key.

Fixes #7916
Fixes #7542
Fixes #7526
Fixes #7021
Fixes #5012
Fixes #10116

User Testing

TEST_AMHARIC_STICKIES:

  • Open the Stickies app on the Mac and create a new note
  • Switch to the gff_amharic keyboard
  • Type selam
  • Verify that the output is ሰላም

TEST_AMHARIC_TEXSTUDIO_9506:

  • Open texstudio on the Mac and create a new document
  • Switch to the gff_amharic keyboard
  • Type selam
  • Verify that the output is ሰላም

TEST_YIDDISH_STICKIES:

  • Open the Stickies app on the Mac and create a new note
  • Switch to the Yiddish Pasekh keyboard
  • Type key
  • Confirm that ouput is קײ
  • Type rey
  • Verify that ouput is רײ

TEST_YIDDISH_GOOGLE_DOCS_7916:

  • Open an empty document in Google Docs
  • Switch to the Yiddish Pasekh keyboard
  • Type key
  • Confirm that ouput is קײ
  • Type rey
  • Verify that ouput is רײ

TEST_KENYA_BTL_STICKIES:

  • Open the Stickies app on the Mac and create a new note
  • Switch to the Kenya (BTL) keyboard
  • Type b^ug
  • Verify that ouput is bûg

TEST_KENYA_BTL_GOOGLE_CHROME_7542:

  • Open Google Chrome on the Mac
  • Switch to the Kenya (BTL) keyboard
  • Click on the URL field and type b^ug
  • Verify that ouput is bûg

TEST_HEBREW_ENTER_STICKIES:

  • Open the Stickies app on the Mac and create a new note
  • Switch to the Galaxie Hebrew (Positional) keyboard
  • Type mm
  • Verify that ouput is ממ
  • Type return
  • Verify that ouput has changed to מם

TEST_POLYTONIC_GREEK_CHROME_BACKSPACE_7526:

  • Open Google Chrome and select the URL text field
  • Switch to the keyboard 'Polytonic Greek (SIL)'
  • Type abc backspace backspace backspace
  • Verify that the output changes as follows: ἀ, ἀβ, ἀβχ, ἀβ, ἀ, [empty]

TEST_POLYTONIC_GREEK_BACKSPACE_7021:

  • Open the Stickies app and create a new note
  • Switch to the keyboard 'Polytonic Greek (SIL)'
  • Type antos
  • Verify that pressing backspace will delete one character at a time
  • Five backspaces will delete the entire word

@sgschantz sgschantz added the mac/ label Nov 23, 2023
@sgschantz sgschantz self-assigned this Nov 23, 2023
@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot bot commented Nov 23, 2023

User Test Results

Test specification and instructions

  • TEST_AMHARIC_STICKIES (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed gff_amharic keyboard. 2. Opened a Note app. 3. Typed 'selam'. 4. Verified the output shows ሰላም in the note app. (notes)
  • 🟩 TEST_AMHARIC_TEXSTUDIO_9506 (SKIPPED): bug(mac): not replacing on Texstudio (QT6) for Amharic #9506 can still happen -- need to document exact steps to reproduce as it is sometimes successful
  • TEST_YIDDISH_STICKIES (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed Yiddish Pasekh keyboard keyboard. 2. Opened a Stickey app. 3. Typed 'key'. 4. Verified the output shows קײ in the stickey app. 5. Typed 'rey'. Verified the output shows רײ the app. (notes)
  • TEST_YIDDISH_GOOGLE_DOCS_7916 (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed Yiddish Pasekh keyboard keyboard. 2. Opened Google doc. 3. Typed 'key'. 4. Verified the output shows קײ in the document. 5. Typed 'rey'. Verified the output shows רײ the document. I noticed that the alignment of the document has been changed from right to left. (?) (notes)
  • TEST_KENYA_BTL_STICKIES (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'Kenya (BTL)' keyboard. 2. Opened Stickies app. 3. Typed 'b^ug'. 4. Verified the output shows 'bûg' in the note. (notes)
  • TEST_KENYA_BTL_GOOGLE_CHROME_7542 (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'Kenya (BTL)' keyboard. 2. Opened Chrome browser. 3. Typed 'b^ug' in the URL text field. 4. Verified the output shows 'bûg' in the URL text field. (notes)
  • TEST_HEBREW_ENTER_STICKIES (PASSED): Retested as per Shawn's suggestion and here is my observation: 1. After pressing the key, I was able to see the expected output on the screen. (notes)
  • TEST_POLYTONIC_GREEK_CHROME_BACKSPACE_7526 (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'Polytonic Greek (SIL)' keyboard. 2. Opened Chrome browser. 3. Typed 'abc'. 4. Verified the output shows ἀβχ in the URL text field. 5. Then, typed 'backspace backspace backspace' shows an empty space in the URL text field. (notes)
  • TEST_POLYTONIC_GREEK_BACKSPACE_7021 (PASSED): 1. Opened Stickies app. 2. Installed 'Polytonic Greek (SIL)' keyboard. Typed 'antos'. 3. Verified that pressing backspace deleted one character at a time. 4. Verified that pressing Five backspaces deleted the entire word.

@sgschantz sgschantz marked this pull request as ready for review December 8, 2023 07:38
@sgschantz sgschantz requested a review from SabineSIL as a code owner December 8, 2023 07:38
@mcdurdin mcdurdin modified the milestones: A17S27, A17S28 Dec 8, 2023
@bharanidharanj
Copy link
Copy Markdown

Test Results

  • TEST_AMHARIC_STICKIES (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed gff_amharic keyboard. 2. Opened a Note app. 3. Typed 'selam'. 4. Verified the output shows ሰላም in the note app.

@bharanidharanj
Copy link
Copy Markdown

  • TEST_YIDDISH_STICKIES (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed Yiddish Pasekh keyboard keyboard. 2. Opened a Stickey app. 3. Typed 'key'. 4. Verified the output shows קײ in the stickey app. 5. Typed 'rey'. Verified the output shows רײ the app.

@bharanidharanj
Copy link
Copy Markdown

  • TEST_YIDDISH_GOOGLE_DOCS_7916 (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed Yiddish Pasekh keyboard keyboard. 2. Opened Google doc. 3. Typed 'key'. 4. Verified the output shows קײ in the document. 5. Typed 'rey'. Verified the output shows רײ the document. I noticed that the alignment of the document has been changed from right to left. (?)

@bharanidharanj
Copy link
Copy Markdown

  • TEST_HEBREW_ENTER_STICKIES (FAILED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed Galaxie Hebrew (Positional) keyboard. 2. Opened Stickey app. 3. Typed 'mm'. 4. Verified the output shows ממ in the app. 5. Typed 'return'. Noticed that it shows different output in the app.

@bharanidharanj
Copy link
Copy Markdown

  • TEST_POLYTONIC_GREEK_CHROME_BACKSPACE_7526 (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'Polytonic Greek (SIL)' keyboard. 2. Opened Chrome browser. 3. Typed 'abc'. 4. Verified the output shows ἀβχ in the URL text field. 5. Then, typed 'backspace backspace backspace' shows an empty space in the URL text field.

..Typed 'abc' letters

..Pressing Backspace three times

  • TEST_POLYTONIC_GREEK_BACKSPACE_7021 (PASSED): 1. Opened Stickies app. 2. Installed 'Polytonic Greek (SIL)' keyboard. Typed 'antos'. 3. Verified that pressing backspace deleted one character at a time. 4. Verified that pressing Five backspaces deleted the entire word.

@bharanidharanj
Copy link
Copy Markdown

  • TEST_KENYA_BTL_STICKIES (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'Kenya (BTL)' keyboard. 2. Opened Stickies app. 3. Typed 'b^ug'. 4. Verified the output shows 'bûg' in the note.

  • TEST_KENYA_BTL_GOOGLE_CHROME_7542 (PASSED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'Kenya (BTL)' keyboard. 2. Opened Chrome browser. 3. Typed 'b^ug' in the URL text field. 4. Verified the output shows 'bûg' in the URL text field.

@bharanidharanj
Copy link
Copy Markdown

Test Results

  • TEST_AMHARIC_TEXSTUDIO_9506 (FAILED): Tested with the attached PR build Keyman 17.0.202-alpha-test-10066 on macOS Sonoma 14.1.2 and here is my observation: 1. Installed 'gff_amharic' keyboard. 2. Opened a new document. 3. Typed 'selam' in the document. 4. Verified it displays the wrong output.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Dec 8, 2023
Copy link
Copy Markdown
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.

This is looking fantastic. Most of my comments are nits, but a couple of things I don't fully understand.

-(void) dealloc {
CFRelease(self.eventSource);
- (void)sendBackspaceforEventSource:(CGEventSourceRef)eventSource {
[self.appDelegate logDebugMessage:@"KeySender sendBackspaceforSourceEvent"];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
[self.appDelegate logDebugMessage:@"KeySender sendBackspaceforSourceEvent"];
[self.appDelegate logDebugMessage:@"KeySender sendBackspaceforEventSource"];

Comment on lines +69 to +76
CGEventRef ev = CGEventCreateKeyboardEvent (source, virtualKey, true); //down
if (postEvent)
postEvent(ev);
CFRelease(ev);
ev = CGEventCreateKeyboardEvent (source, virtualKey, false); //up
if (postEvent)
postEvent(ev);
CFRelease(ev);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like it has a precondition of if(!postEvent) return;?

Suggested change
CGEventRef ev = CGEventCreateKeyboardEvent (source, virtualKey, true); //down
if (postEvent)
postEvent(ev);
CFRelease(ev);
ev = CGEventCreateKeyboardEvent (source, virtualKey, false); //up
if (postEvent)
postEvent(ev);
CFRelease(ev);
if(!postEvent) {
// TODO: add logging? how could this happen?
return;
}
CGEventRef ev = CGEventCreateKeyboardEvent (source, virtualKey, true); //down
postEvent(ev);
CFRelease(ev);
ev = CGEventCreateKeyboardEvent (source, virtualKey, false); //up
postEvent(ev);
CFRelease(ev);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should never happen, but I'll change to add logging.

// Returns the frontmost app, which is the app that receives key events.
NSRunningApplication *app = NSWorkspace.sharedWorkspace.frontmostApplication;
pid_t processId = app.processIdentifier;
NSString *appName = app.localizedName;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is localizedName the most helpful string for debug logging? Might not be better to use an identifier of some kind?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed to use bundleId

[clientAppId isEqual: @"com.adobe.InDesign"] ||
[clientAppId isEqual: @"com.adobe.Photoshop"] ||
[clientAppId isEqual: @"com.adobe.AfterEffects"] ||
// Adobe apps automatically detected as non-compliant
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, but I'll include the date in my comment to show when I removed these from the hard-coded list.

for (CoreAction *action in actions) {
if (action.isCharacter) {
NSString *output = action.content;
CoreKeyOutput *coreKeyOutput = [kme processEvent:mEvent];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm curious, because this function seems to ignore backspaces entirely?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the old sample app which I have tried to ignore other than making sure it still builds. However, I often confuse it for Keyman IM when it comes up in search results, so I should eventually either confirm that it is actually useful or remove it from the project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, yes, I make the same mistake too. At the very least, let's rename it!

}

-(void) persistOptions:(NSDictionary*)options{
if(options.count>0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this test? Because the loop will be a no-op anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed it

Comment on lines +529 to +537
case On:
//TODO: handle this
break;
case Off:
//TODO: handle this
break;
case Unchanged:
// do nothing
break;
Copy link
Copy Markdown
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 to track this? If so, can you put it into the TODO comments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

created #10244

Comment on lines 594 to 595
for (int i = 0; i < output.codePointsToDeleteBeforeInsert; i++)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
for (int i = 0; i < output.codePointsToDeleteBeforeInsert; i++)
{
for (int i = 0; i < output.codePointsToDeleteBeforeInsert; i++) {

}

- (void)testCoreProcessEvent_eventDeleteWithElNuerKmx_EmptiesContextReturnsDelete {
// TODO: enable after resolving issue getting options from Keyman Core
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you tracking this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will enable after merging to ensure that the core changes cause this test to pass.

@sgschantz
Copy link
Copy Markdown
Contributor Author

@sgschantz
Copy link
Copy Markdown
Contributor Author

@bharanidharanj Can you provide more detail on what the text the note contained with each step for TEST_HEBREW_ENTER_STICKIES? I don't understand how that whole line of text could have appeared after you pressed return, and I am not seeing anything similar.

@bharanidharanj
Copy link
Copy Markdown

@bharanidharanj Can you provide more detail on what the text the note contained with each step for TEST_HEBREW_ENTER_STICKIES? I don't understand how that whole line of text could have appeared after you pressed return, and I am not seeing anything similar.

Hi @sgschantz Sorry for the confusion! When I followed the steps you mentioned in the test, I thought "Type Return" meant "Type the word Return" on the input screen. So, I typed the text "Return" and it was displayed on the screen. Now, I tried with the key and got the expected result.

@sgschantz
Copy link
Copy Markdown
Contributor Author

@keymanapp-test-bot retest TEST_HEBREW_ENTER_STICKIES

Please retest and simply press the return key as the last step

@keymanapp-test-bot keymanapp-test-bot bot added user-test-required User tests have not been completed and removed user-test-failed labels Dec 13, 2023
@bharanidharanj
Copy link
Copy Markdown

bharanidharanj commented Dec 13, 2023

Test Results

  • TEST_HEBREW_ENTER_STICKIES (PASSED): Retested as per Shawn's suggestion and here is my observation: 1. After pressing the key, I was able to see the expected output on the screen.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Dec 13, 2023
Copy link
Copy Markdown
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.

LGTM, one tiny tweak which is probably unlikely to ever arise but should be done anyway 😁

add guard clause

Co-authored-by: Marc Durdin <marc@durdin.net>
@sgschantz sgschantz merged commit 55f69ae into master Dec 14, 2023
@sgschantz sgschantz deleted the chore/mac/use-core-actions-struct branch December 14, 2023 04:58
@keyman-server
Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.230-alpha

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