From d82122887184ab7b61551c6db8ac647cd29b483b Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 29 Jul 2021 14:31:03 +0900 Subject: [PATCH] Modified to get IME size from libscl-ui-nui Change-Id: Ib007851f8d9ed32d450728eb89bf019ace16b46c --- ISEDefaultNUI/ISEDefaultNUI.cs | 30 ++++++++++++++++++++++++++++-- ISEDefaultNUI/Interop/Interop.SclNui.cs | 3 +++ ISEDefaultNUI/SCLNUI.cs | 3 +-- ISEDefaultNUI/WindowAttribute.cs | 6 ++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ISEDefaultNUI/ISEDefaultNUI.cs b/ISEDefaultNUI/ISEDefaultNUI.cs index 9f561ee..5f452ba 100644 --- a/ISEDefaultNUI/ISEDefaultNUI.cs +++ b/ISEDefaultNUI/ISEDefaultNUI.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Xml; using Tizen; using Tizen.Applications; using Tizen.NUI; -using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; using Tizen.Uix.InputMethod; using static Interop.SclNuiCSharp; @@ -108,6 +108,13 @@ namespace ISEDefaultNUI Window.Instance.AddAvailableOrientation(Window.WindowOrientation.Landscape); Window.Instance.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse); + List availableList = new List(); + availableList.Add(Window.WindowOrientation.Portrait); + availableList.Add(Window.WindowOrientation.Landscape); + availableList.Add(Window.WindowOrientation.PortraitInverse); + availableList.Add(Window.WindowOrientation.LandscapeInverse); + Window.Instance.SetAvailableOrientations(availableList); + Window window = NUIApplication.GetDefaultWindow(); navigator = new Navigator() { @@ -186,6 +193,7 @@ namespace ISEDefaultNUI break; } UpdateCursorPosition(b.CursorPosition); + SetIMESize(); SclNui = new SCLNUI(navigator); LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage); @@ -446,11 +454,29 @@ namespace ISEDefaultNUI SclDbusFocusIn(); } + private static void SetIMESize() + { + IntPtr inputModePtr; + SclNuiGetInputMode(out inputModePtr); + string inputMode = Marshal.PtrToStringAnsi(inputModePtr); + + int portraitWidth, portraitHeight, landscapeWidth, landscapeHeight; + SclNuiGetInputModeSize(inputMode, (int)WindowAttribute.DisplayMode.Portrait, out portraitWidth, out portraitHeight); + SclNuiGetInputModeSize(inputMode, (int)WindowAttribute.DisplayMode.Landscape, out landscapeWidth, out landscapeHeight); + + Rectangle portraitRectangle = new Rectangle(0, 0, portraitWidth, portraitHeight); + Rectangle landscapeRectangle = new Rectangle(0, 0, landscapeHeight, landscapeWidth); + Window.Instance.SetPositionSizeWithOrientation(portraitRectangle, Window.WindowOrientation.Portrait); + Window.Instance.SetPositionSizeWithOrientation(landscapeRectangle, Window.WindowOrientation.Landscape); + Window.Instance.SetPositionSizeWithOrientation(portraitRectangle, Window.WindowOrientation.PortraitInverse); + Window.Instance.SetPositionSizeWithOrientation(landscapeRectangle, Window.WindowOrientation.LandscapeInverse); + } + static void Main(string[] args) { InputMethodEditor.Run(Create, Terminate, Show, Hide); - Size2D initSize = new Size2D(720, 442); + Size2D initSize = new Size2D(0, 0); Position2D initPosition = new Position2D(0, 0); var app = new Program("", WindowMode.Opaque, initSize, initPosition, WindowType.Ime); diff --git a/ISEDefaultNUI/Interop/Interop.SclNui.cs b/ISEDefaultNUI/Interop/Interop.SclNui.cs index e6ef9fc..503c5a3 100644 --- a/ISEDefaultNUI/Interop/Interop.SclNui.cs +++ b/ISEDefaultNUI/Interop/Interop.SclNui.cs @@ -180,6 +180,9 @@ internal static partial class Interop [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_get_input_mode")] internal static extern int SclNuiGetInputMode(out IntPtr mode); + [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_get_input_mode_size")] + internal static extern int SclNuiGetInputModeSize(string mode, int display_mode, out int width, out int height); + [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_input_mode")] internal static extern int SclNuiSetInputMode(string mode); diff --git a/ISEDefaultNUI/SCLNUI.cs b/ISEDefaultNUI/SCLNUI.cs index e6b575f..778d7e7 100644 --- a/ISEDefaultNUI/SCLNUI.cs +++ b/ISEDefaultNUI/SCLNUI.cs @@ -119,7 +119,7 @@ namespace ISEDefaultNUI { int dimOrder = DimView.Instance.GetDimView().SiblingOrder; keyText.SiblingOrder = dimOrder - 1; - } + } break; } case WindowAttribute.WindowType.Magnifier: @@ -474,7 +474,6 @@ namespace ISEDefaultNUI return true; } - //FIXME: This should use RotationChanged of the Inputmethod. private void OnResized(object sender, Window.ResizedEventArgs e) { SclNuiSetRotation((int)Window.Instance.GetCurrentOrientation()); diff --git a/ISEDefaultNUI/WindowAttribute.cs b/ISEDefaultNUI/WindowAttribute.cs index 5a18503..9828fa4 100644 --- a/ISEDefaultNUI/WindowAttribute.cs +++ b/ISEDefaultNUI/WindowAttribute.cs @@ -17,6 +17,12 @@ namespace ISEDefaultNUI AutoPopup, } + public enum DisplayMode + { + Portrait = 0, + Landscape, + } + public class BackgroundColor { public int Red; -- 2.7.4