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

Label tracks do not accept input from Keyman Desktop in Audacity 2.1.2 and later #523

Open
mcdurdin opened this issue Jan 13, 2018 · 2 comments
Assignees
Labels
compatibility external Requires changes to other software programs in order to resolve windows/

Comments

@mcdurdin
Copy link
Member

mcdurdin commented Jan 13, 2018

Initial report on community.software.sil.org.

Recent versions of Audacity, from 2.1.2 onward, appear to bypass Keyman entirely for input. Looking at the Audacity 2.1.2 release notes, the major change made was an update to wxWidgets 3.0.2.

So I suspect that we should be looking at wxWidgets 3.0 for this compat issues. In 3.0.0 they merged ANSI and Unicode support and my stab-in-the-dark guess is that they may have inadvertently turned their windows into ANSI windows in the process. Or something like that, I hope, which could be easy to resolve.

@mcdurdin
Copy link
Member Author

mcdurdin commented Jan 17, 2018

I've just installed 2.2.1 here and tested. I can reproduce the issue, e.g. in a Label track. The issue doesn't arise in the Metadata window. A high-level diagnostic showed that Audacity is capturing keystrokes before Keyman sees them and doing an internal translation to characters using Windows API calls. This is not an uncommon pattern for cross-platform projects but it cannot duplicate the Windows internal character translation, even for Windows keyboards, 100% perfectly. So it's the wrong way to go...

Now digging deeper in source code.

@mcdurdin mcdurdin added this to the P2S11 milestone Jan 17, 2018
@mcdurdin mcdurdin self-assigned this Jan 17, 2018
@mcdurdin
Copy link
Member Author

mcdurdin commented Jan 18, 2018

Okay. So the issue with label track edits is in Audacity. Label tracks don't use a standard Windows or wxWidgets edit control, and have instead a bunch of code to implement a basic text edit field. The root issue is in this code in CommandManager.cpp:

   // Convert the key down event to a unicode string.
   wxString GetUnicodeString(const wxKeyEvent & event)
   {
      wxString chars;

#if defined(__WXMSW__)

      BYTE ks[256];
      GetKeyboardState(ks);
      WCHAR ucode[256];
      int res = ToUnicode(event.GetRawKeyCode(), 0, ks, ucode, 256, 0);
      if (res >= 1)
      {
         chars.Append(ucode, res);
      }

Audacity is handling WM_KEYDOWN events (these are wrapped in wxKeyEvent objects), and then calling ToUnicode to convert key events to Unicode characters. This isn't the right way to get character input on Windows. The ToUnicode function doesn't cover all Windows input cases, even for standard Windows keyboards and IMEs. Instead, Audacity should be accepting WM_CHAR events and processing these (MSDN).

From the description in http://bugzilla.audacityteam.org/show_bug.cgi?id=1778, it sounds like similar issues are arising in macOS. See also discussion in http://forum.audacityteam.org/viewtopic.php?p=319325.

@mcdurdin mcdurdin removed this from the P2S11 milestone Jan 18, 2018
@mcdurdin mcdurdin added this to the Future milestone Apr 24, 2018
@mcdurdin mcdurdin changed the title Audacity 2.1.2 and later (possibly wxWidgets 3.0) appears to be incompatible with Keyman Desktop 9.0 Label tracks do not accept input from Keyman Desktop in Audacity 2.1.2 and later Apr 24, 2018
@mcdurdin mcdurdin modified the milestone: Future Jun 29, 2018
@mcdurdin mcdurdin added this to the Waiting-external milestone Oct 23, 2018
@mcdurdin mcdurdin added the external Requires changes to other software programs in order to resolve label Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility external Requires changes to other software programs in order to resolve windows/
Development

No branches or pull requests

1 participant