From: InHong Han Date: Thu, 6 Oct 2022 10:23:26 +0000 (+0900) Subject: Support Korean input X-Git-Tag: accepted/tizen/unified/20230113.091227~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=879b073e744c7d24a8db5a3566c172ec1fc7aa73;p=platform%2Fcore%2Fuifw%2Fise-default-nui.git Support Korean input Change-Id: I9ce34ef42fd1d48fc9b1ffbe60b4e9e3e6415a2e --- diff --git a/ISEDefaultNUI/Common/LanguageManager.cs b/ISEDefaultNUI/Common/LanguageManager.cs index be768a2..99f236c 100644 --- a/ISEDefaultNUI/Common/LanguageManager.cs +++ b/ISEDefaultNUI/Common/LanguageManager.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Tizen; +using static Interop.SclNuiCSharp; namespace ISEDefaultNUI { @@ -162,9 +159,9 @@ namespace ISEDefaultNUI { List languageInfos = languageInfoList.FindAll(x => x.Enabled == true); int index = languageInfos.FindIndex(x => x.Name == languageInfoList[currentLanguage].Name); - if (index == languageInfos.Count - 1) + if (index == languageInfos.Count - 1) return languageInfos[0]; - else + else return languageInfos[index + 1]; } @@ -172,9 +169,9 @@ namespace ISEDefaultNUI { List languageInfos = languageInfoList.FindAll(x => x.Enabled == true); int index = languageInfos.FindIndex(x => x.Name == languageInfoList[currentLanguage].Name); - if (index == 0) + if (index == 0) return languageInfos[languageInfos.Count - 1]; - else + else return languageInfos[index - 1]; } @@ -183,9 +180,11 @@ namespace ISEDefaultNUI int index = -1; index = languageInfoList.FindIndex(x => x.Name == language.Name); if (index == -1) - return false; - else - return true; + return false; + + Log.Info("NUIIME", "Current Language : " + languageInfoList[index].Name); + currentLanguage = index; + return true; } public string GetUuid(string name) @@ -204,9 +203,32 @@ namespace ISEDefaultNUI if (!languageInfo.Enabled && !languageInfo.EnabledTemporarily) return false; - //Reset Language (flush imengine) + Log.Info("NUIIME", "Reset Language : " + GetCurrentLanguage()); + if (languageInfo.Name.Equals(name)) + FlushImengine(languageInfo.Name); return true; } + + public void FlushImengine(string language) + { + Log.Info("NUIIME", "Flush Imengine : " + language); + + KeyboardState keyboardState = KeyboardState.Instance; + if (keyboardState.PreviousModifier == (uint)SclNuiKeyModifier.MultitapStart || keyboardState.PreviousModifier == (uint)SclNuiKeyModifier.MultitapRepeat) + Common.SendString(keyboardState.MultitapValue); + + keyboardState.MultitapValue = ""; + keyboardState.PreviousModifier = (uint)SclNuiKeyModifier.None; + + LanguageInfo currentLanguage = GetLanguageInfo(language); + if (currentLanguage != null) + { + if (currentLanguage.LoadInIME) + SclResetImengine(); + else + SclDbusResetImengine(); + } + } } } diff --git a/ISEDefaultNUI/ISEDefaultNUI.cs b/ISEDefaultNUI/ISEDefaultNUI.cs index ab24bdb..5fcc79b 100644 --- a/ISEDefaultNUI/ISEDefaultNUI.cs +++ b/ISEDefaultNUI/ISEDefaultNUI.cs @@ -79,6 +79,9 @@ namespace ISEDefaultNUI if (node.Attributes["accepts_caps_mode"] != null) languageInfo.AcceptsCapsMode = Convert.ToBoolean(node.Attributes["accepts_caps_mode"].Value); + if (node.Attributes["need_surrounding_text"] != null) + languageInfo.NeedSurroundingText = Convert.ToBoolean(node.Attributes["need_surrounding_text"].Value); + languageInfo.Enabled = false; languageInfo.SelectedInputMode = inputModeInfo.Name; @@ -135,16 +138,6 @@ namespace ISEDefaultNUI SclNui.EnableSound(false); SclNui.EnableVibration(false); SclNui.EnableMagnifier(false); - - LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage); - if (!currentLanguage.LoadInIME) - { - /* FIXME : This comment should be removed when using IMEngine - string uuid = LanguageManager.Instance.GetUuid(currentLanguage.KeyboardISEUuid); - ApplicationInfo applicationInfo = new ApplicationInfo(uuid); - SclDbus.SetImengine(uuid, applicationInfo.PackageId); - */ - } } private static void Terminate() @@ -225,15 +218,18 @@ namespace ISEDefaultNUI private static void IMEShow(int ic) { + IseConfig.Instance.ReadIseConfig(); + LanguageManager.Instance.SetEnabledLanguages(IseConfig.Instance.EnabledLanguages); + switch (KeyboardState.Instance.Layout) { case KeyboardLayout.PhoneNumber: case KeyboardLayout.IP: case KeyboardLayout.Month: case KeyboardLayout.NumberOnly: - /* FIXME : This comment should be removed when using IMEngine - * InputMethodEditor.SetIMEngine(ResourceManager.DefaultKeyboardUuid); - */ + + ApplicationInfo applicationInfo = new ApplicationInfo(ResourceManager.DefaultKeyboardUuid); + SclDbusSetImengine(ResourceManager.DefaultKeyboardUuid, applicationInfo.PackageId); break; default: break; @@ -335,6 +331,24 @@ namespace ISEDefaultNUI { SclNui.SetInputMode(defaultValue.Values[(int)layoutIndex].InputMode); } + else + { + LanguageInfo selectLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage); + LanguageManager.Instance.SelectLanguage(selectLanguage); + if (forcePrimaryLatin || selectLanguage.LoadInIME) + { + SclSetEngineLoaderFlag(false); + SclSetImengine(LanguageManager.Instance.GetUuid(selectLanguage.KeyboardISEUuid)); + } + else + { + SclSetImengine(ResourceManager.DefaultKeyboardUuid); + SclSetEngineLoaderFlag(true); + string uuid = LanguageManager.Instance.GetUuid(selectLanguage.KeyboardISEUuid); + ApplicationInfo applicationInfo = new ApplicationInfo(uuid); + SclDbusSetImengine(uuid, applicationInfo.PackageId); + } + } SclNui.SetCurrentSublayout(defaultValue.Values[(int)layoutIndex].SublayoutName); } diff --git a/ISEDefaultNUI/ISEDefaultNUI.sln b/ISEDefaultNUI/ISEDefaultNUI.sln index 6828a1f..6dff342 100644 --- a/ISEDefaultNUI/ISEDefaultNUI.sln +++ b/ISEDefaultNUI/ISEDefaultNUI.sln @@ -1,31 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31129.286 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ISEDefaultNUI", "ISEDefaultNUI.csproj", "{0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingKeyboard", "..\SettingKeyboard\SettingKeyboard.csproj", "{D3191982-0DF3-4E08-A4BD-5AADC746BC7C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.Build.0 = Release|Any CPU - {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {90570B69-2C91-4F6C-8751-2BD5B81E11D6} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ISEDefaultNUI", "ISEDefaultNUI.csproj", "{0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SettingKeyboard", "..\SettingKeyboard\SettingKeyboard.csproj", "{D3191982-0DF3-4E08-A4BD-5AADC746BC7C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0AA1B59F-5B99-4FE8-BB34-3FE03FD16418}.Release|Any CPU.Build.0 = Release|Any CPU + {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3191982-0DF3-4E08-A4BD-5AADC746BC7C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {90570B69-2C91-4F6C-8751-2BD5B81E11D6} + EndGlobalSection +EndGlobal diff --git a/ISEDefaultNUI/Interop/Interop.SclNui.cs b/ISEDefaultNUI/Interop/Interop.SclNui.cs index dce7326..97c50e6 100644 --- a/ISEDefaultNUI/Interop/Interop.SclNui.cs +++ b/ISEDefaultNUI/Interop/Interop.SclNui.cs @@ -135,6 +135,9 @@ internal static partial class Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void UpdateWindowPositionCallback(int type, int x, int y, int rotationX, int rotationY, IntPtr user_data); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void ProcessKeyEventWithImengineCallback(UInt32 code, UInt32 mask, UInt32 layout, UInt32 devClass, UInt32 devSubclass, string devName, UInt32 serial, IntPtr user_data); + [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_init")] internal static extern int SclNuiInit(string entry_filepath); @@ -320,5 +323,23 @@ internal static partial class Interop [DllImport(Libraries.SclNui, EntryPoint = "scl_dbus_long_press_candidate_item")] internal static extern void SclDbusLongPressCandidateItem(UInt32 index); + + [DllImport(Libraries.SclNui, EntryPoint = "scl_set_imengine")] + internal static extern int SclSetImengine(string engineId); + + [DllImport(Libraries.SclNui, EntryPoint = "scl_flush_imengine")] + internal static extern int SclFlushImengine(); + + [DllImport(Libraries.SclNui, EntryPoint = "scl_reset_imengine")] + internal static extern int SclResetImengine(); + + [DllImport(Libraries.SclNui, EntryPoint = "scl_send_imengine_event")] + internal static extern int SclSendImengineEvent(int command, UInt32 value); + + [DllImport(Libraries.SclNui, EntryPoint = "scl_set_engine_loader_flag")] + internal static extern int SclSetEngineLoaderFlag(bool flag); + + [DllImport(Libraries.SclNui, EntryPoint = "scl_set_process_key_event_with_imengine_cb")] + internal static extern int SclSetProcessKeyEventWithImengineCb(ProcessKeyEventWithImengineCallback callbackFunction, IntPtr userData); } } diff --git a/ISEDefaultNUI/SCLNUI.cs b/ISEDefaultNUI/SCLNUI.cs index 17e836b..ade5b5a 100644 --- a/ISEDefaultNUI/SCLNUI.cs +++ b/ISEDefaultNUI/SCLNUI.cs @@ -9,7 +9,7 @@ using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; using Tizen.Uix.InputMethod; using static Interop.SclNuiCSharp; - + namespace ISEDefaultNUI { class SCLNUI : Page @@ -22,6 +22,7 @@ namespace ISEDefaultNUI private DragStateChangedCallback _onDragStateChangedEvent = null; private EventNotificationCallback _onEventNotification = null; private UpdateWindowPositionCallback _updateWindowPositionChangedEvent = null; + private ProcessKeyEventWithImengineCallback _onProcessKeyEventWithImengineEvent = null; private List image_list; private List label_list; @@ -44,7 +45,7 @@ namespace ISEDefaultNUI private Timer commitTimer; private Timer showEmoticonTimer; private View emoticonView = null; - private EmoticonPage emoticonPage = null; + private EmoticonPage emoticonPage = null; enum LabelAlignment { @@ -82,9 +83,9 @@ namespace ISEDefaultNUI label_list = new List(); commitTimer = new Timer(1000); - commitTimer.Tick += CommitTimerTick; - - showEmoticonTimer = new Timer(10); + commitTimer.Tick += CommitTimerTick; + + showEmoticonTimer = new Timer(10); showEmoticonTimer.Tick += showEmoticonTimerTick; /* Draw text callback */ @@ -378,8 +379,8 @@ namespace ISEDefaultNUI SclNuiSetShiftState((uint)ShiftState.Off); KeyboardState.Instance.ResetMultitapState(true); InputMethodEditor.RequestHide(); - } - + } + else if (key_event > 0) { Common.SendKeyEvent((KeyCode)key_event); @@ -387,13 +388,13 @@ namespace ISEDefaultNUI break; case SclNuiKeyType.Modechange: break; - case SclNuiKeyType.User: + case SclNuiKeyType.User: { String substring = keyValue.Substring(0, 15); Log.Info("NUIIME", "key substring " + substring); - if (substring.Equals("EMOTICON_GROUP_")) - emoticonPage?.SetEmoticonGroup(keyValue); - } + if (substring.Equals("EMOTICON_GROUP_")) + emoticonPage?.SetEmoticonGroup(keyValue); + } break; case SclNuiKeyType.Max: break; @@ -410,9 +411,9 @@ namespace ISEDefaultNUI appControl.LaunchMode = AppControlLaunchMode.Group; AppControl.SendLaunchRequest(appControl); } - else if (keyValue.Equals("EMOTICON_LAYOUT")) - { - ShowEmoticonLayout(); + else if (keyValue.Equals("EMOTICON_LAYOUT")) + { + ShowEmoticonLayout(); } if (keyValue.Equals("Space") && afterPositionX != 0 && Math.Abs(beforePositionX - afterPositionX) > 100 && !inputMode.Equals("SYM_QTY_1")) @@ -425,15 +426,21 @@ namespace ISEDefaultNUI IseConfig.Instance.SelectedLanguage = nextLanguage.Name; IseConfig.Instance.WriteIseConfig(); - if (!nextLanguage.LoadInIME) + if (nextLanguage.LoadInIME) + { + SclSetEngineLoaderFlag(false); + SclSetImengine(LanguageManager.Instance.GetUuid(nextLanguage.KeyboardISEUuid)); + } + else { - /* FIXME : This comment should be removed when using IMEngine + SclSetImengine(ResourceManager.DefaultKeyboardUuid); + SclSetEngineLoaderFlag(true); string uuid = LanguageManager.Instance.GetUuid(nextLanguage.KeyboardISEUuid); ApplicationInfo applicationInfo = new ApplicationInfo(uuid); SclDbusSetImengine(uuid, applicationInfo.PackageId); - */ } + LanguageManager.Instance.FlushImengine(nextLanguage.Name); SclNui.SetInputMode(nextLanguage.SelectedInputMode); SclNui.SetCurrentSublayout("DEFAULT"); SclNui.SetStringSubstitution("_LANGUAGE_", nextLanguage.DisplayName); @@ -460,6 +467,22 @@ namespace ISEDefaultNUI }; SclNuiKeyClickEventCb(_onKeyClickEvent); + InputMethodEditor.SetProcessKeyCallback((KeyCode code, KeyMask mask, InputMethodDeviceInformation device) => { + if (keyboardState.VisibleState) + { + + } + + return false; + }); + + _onProcessKeyEventWithImengineEvent = (UInt32 code, UInt32 mask, UInt32 layout, UInt32 devClass, UInt32 devSubclass, string devName, UInt32 serial, IntPtr user_data) => + { + LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(LanguageManager.Instance.GetCurrentLanguage()); + SclDbusProcessKeyEvent(code, mask, layout, devClass, devSubclass, devName, serial, currentLanguage.NeedSurroundingText); + }; + SclSetProcessKeyEventWithImengineCb(_onProcessKeyEventWithImengineEvent, (IntPtr)null); + _onDragStateChangedEvent = (IntPtr key_value, int key_event, int key_type, int event_type, int current_x, int current_y) => { return (int)SclNuiEventReturnType.PassOn; @@ -525,19 +548,19 @@ namespace ISEDefaultNUI return true; } - private void ShowEmoticonLayout() + private void ShowEmoticonLayout() { - if (showEmoticonTimer.IsRunning()) - showEmoticonTimer.Stop(); - - showEmoticonTimer.Start(); + if (showEmoticonTimer.IsRunning()) + showEmoticonTimer.Stop(); + + showEmoticonTimer.Start(); } private bool showEmoticonTimerTick(object source, Timer.TickEventArgs e) - { - Log.Info("NUIIME", "emoticon layout timer"); + { + Log.Info("NUIIME", "emoticon layout timer"); OnShowEmoticonLayoutTimer(); - return false; + return false; } private void OnResized(object sender, Window.ResizedEventArgs e)