From 285a77940025cf1b4742420cf9b49977ed5d3f8d Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 1 Dec 2022 11:48:43 +1000 Subject: [PATCH 1/3] fix(windows): Enable active keyboard after Doinstall After installing a the keyboard language it makes sense to enable the keyboard. This change adds a step to also enable the keyboard. --- .../install/UfrmInstallKeyboardLanguage.pas | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas b/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas index 78524e79de..229f88fd04 100644 --- a/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas +++ b/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas @@ -147,6 +147,9 @@ uses { TfrmInstallKeyboardLanguage } function InstallKeyboardLanguage(Owner: TForm; const KeyboardID, ISOCode: string; Silent: Boolean): Boolean; +var + n: Integer; + kbd: IKeymanKeyboardInstalled; begin Result := TTIPMaintenance.DoInstall(KeyboardID, ISOCode); if not Result then @@ -157,7 +160,18 @@ begin end else CheckForMitigationWarningFor_Win10_1803(Silent, ''); - + // Enable the keyboard + n := kmcom.Keyboards.IndexOf(KeyboardID); + if n < 0 then + begin + // The Keyboard was successully installed for the BCP47Code + // for some reason the index look up has failed. Still leave + // Result as true, the keyboard will not be enabled. + // TODO: Log error unexpected `KeyboardID` not found + Exit; + end; + kbd := kmcom.Keyboards[n]; + kbd.Loaded := TRUE; kmcom.Apply; Result := True; end; From 5b88ea932ffac20159db357b9d85e5fe0f1004ab Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 20 Dec 2022 16:37:37 +1000 Subject: [PATCH 2/3] fix(windows): add sentry error message keyboardid add sentry error message for when the just installed keyboardid lookup fails. --- .../kmshell/install/UfrmInstallKeyboardLanguage.pas | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas b/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas index 229f88fd04..4ae6406699 100644 --- a/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas +++ b/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas @@ -129,9 +129,11 @@ implementation uses System.Types, Vcl.Themes, + Sentry.Client, Keyman.Configuration.UI.MitigationForWin10_1803, Keyman.System.LanguageCodeUtils, + Keyman.System.KeymanSentryClient, Keyman.Configuration.System.TIPMaintenance, Keyman.UI.UfrmProgress, MessageIdentifierConsts, @@ -165,13 +167,13 @@ begin if n < 0 then begin // The Keyboard was successully installed for the BCP47Code - // for some reason the index look up has failed. Still leave - // Result as true, the keyboard will not be enabled. - // TODO: Log error unexpected `KeyboardID` not found + // for some reason the index look up has failed. Still pass through + // the DoInstall reasult, however the keyboard will not be enabled. + TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR, 'KeyboardID: '+KeyboardID+' not found'); Exit; end; kbd := kmcom.Keyboards[n]; - kbd.Loaded := TRUE; + kbd.Loaded := True; kmcom.Apply; Result := True; end; From 206e619bea6e7eb184f39dab0797b38db9c85f1b Mon Sep 17 00:00:00 2001 From: rc-swag <58423624+rc-swag@users.noreply.github.com> Date: Thu, 22 Dec 2022 08:56:43 +1000 Subject: [PATCH 3/3] fix(windows): more detailed error message Co-authored-by: Marc Durdin --- .../src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas b/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas index 4ae6406699..fab24635f7 100644 --- a/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas +++ b/windows/src/desktop/kmshell/install/UfrmInstallKeyboardLanguage.pas @@ -169,7 +169,7 @@ begin // The Keyboard was successully installed for the BCP47Code // for some reason the index look up has failed. Still pass through // the DoInstall reasult, however the keyboard will not be enabled. - TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR, 'KeyboardID: '+KeyboardID+' not found'); + TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR, 'InstallKeyboardLanguage: KeyboardID "'+KeyboardID+'" not found, attempting to install for language "'+ISOCode+'".'); Exit; end; kbd := kmcom.Keyboards[n];