From e79990b8f2842be7e198e9e879019901fc6b913d Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Fri, 21 Apr 2017 17:02:46 +0900 Subject: [PATCH] keygrab & ecore-wl-window-handle c# binding - this is a pair with dali-adaptor patch of https://review.tizen.org/gerrit/#/c/126398/ Change-Id: Id1c776151c9a683f985bbea54f6d6dc9c3f4fcdd Signed-off-by: dongsug.song --- .../NUISamples.TizenTV/examples/Main.cs | 4 +- .../examples/visual-view-test2.cs | 40 +++++++-- src/Tizen.NUI/src/internal/FriendAssembly.cs | 2 +- src/Tizen.NUI/src/internal/ManualPINVOKE.cs | 15 ++++ src/Tizen.NUI/src/public/Window.cs | 88 ++++++++++++++++++- 5 files changed, 139 insertions(+), 10 deletions(-) diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/Main.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/Main.cs index 8af6814b5..707c82c94 100755 --- a/NUISamples/NUISamples/NUISamples.TizenTV/examples/Main.cs +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/Main.cs @@ -30,11 +30,11 @@ namespace NUISamples.TizenTV.examples //new RelativeVectorTest.Example().Run(args); //new VisaulAnimationExample.Example().Run(args); //new VisualViewTest.Example().Run(args); //o - //new VisualViewTest2.VisualSample().Run(args); + new VisualViewTest2.VisualSample().Run(args); //new VisualsUsingCustomView.VisualsExample().Run(args); //o //new FirstScreen.FirstScreenApp().Run(args); //o //new PositionUsesAnchorPointTest.Example().Run(args); - new TizenVDUIApplication19.Program().Run(args); + //new TizenVDUIApplication19.Program().Run(args); } } } diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test2.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test2.cs index 021ac5e94..1b3d03028 100755 --- a/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test2.cs +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test2.cs @@ -19,6 +19,8 @@ namespace VisualViewTest2 TextVisual textMap1; TextVisual textMap2; + Window _window; + int imgIndex; readonly string resourcePath = "/home/owner/apps_rw/NUISamples.TizenTV/res/images/"; @@ -137,8 +139,15 @@ namespace VisualViewTest2 Stage.Instance.Key += Instance_Key; FocusManager.Instance.SetCurrentFocusView(view[0]); Stage.Instance.Touch += Instance_Touch; + _window = this.Window; + _window.WindowFocusChanged += _window_WindowFocusChanged; + } + private void _window_WindowFocusChanged(object sender, Window.WindowFocusChangedEventArgs e) + { + Tizen.Log.Fatal("NUI", "window focus changed!() focus gained=" + e.FocusGained); + } private void Instance_Touch(object sender, Stage.TouchEventArgs e) { @@ -147,7 +156,7 @@ namespace VisualViewTest2 private bool VisualSample_KeyEvent(object source, View.KeyEventArgs e) { - Tizen.Log.Debug("NUI", "View_KeyEvent" + e.Key.State.ToString() + ", Pressed-" + e.Key.KeyPressedName); + Tizen.Log.Fatal("NUI", "View_KeyEvent" + e.Key.State.ToString() + ", Pressed-" + e.Key.KeyPressedName); if (e.Key.State == Key.StateType.Down) { @@ -158,17 +167,35 @@ namespace VisualViewTest2 textMap1.PointSize = 14; textMap1.TextColor = Color.Red; textMap1.Text = "Hello NY!"; + //this.VersionCheckTest(); + /* + DALI_KEY_VOLUME_UP = 200, ///< Volume up key @SINCE_1_0.0 + DALI_KEY_VOLUME_DOWN = 201, ///< Volume down key @SINCE_1_0.0 + */ + try + { + Tizen.Log.Fatal("NUI", "GrabKeyTopmost (200==vol up) ret=" + _window.GrabKeyTopmost(200)); + } + catch (Exception except) + { + Tizen.Log.Fatal("NUI", "Exception!!! GrabKeyTopmost (200==vol up) msg=" + except.Message); + } + } else if (e.Key.KeyPressedName == "Down") { textMap1.PointSize = 17; textMap1.TextColor = Color.Blue; textMap1.Text = "Goodbye NY."; + + Tizen.Log.Fatal("NUI", "UngrabKeyTopmost (200==vol up) ret=" + _window.UngrabKeyTopmost(200)); + } else if (e.Key.KeyPressedName == "Return") { imgIndex = (imgIndex + 1) % 6; imageMap.URL = resourcePath + "gallery-" + imgIndex + ".jpg"; + //Tizen.Log.Fatal("NUI", "get native ecore wayland hander=" + _window.GetNativeWindowHandler()); } } @@ -179,6 +206,7 @@ namespace VisualViewTest2 textMap2.PointSize = 14; textMap2.TextColor = Color.Red; textMap2.Text = "I'm happy!"; + Tizen.Log.Fatal("NUI", "grab key (201==vol down) ret=" + _window.GrabKey(201, Window.KeyGrabMode.Topmost)); } if (e.Key.KeyPressedName == "Down") @@ -186,11 +214,13 @@ namespace VisualViewTest2 textMap2.PointSize = 17; textMap2.TextColor = Color.Blue; textMap2.Text = "I'm unhappy"; + Tizen.Log.Fatal("NUI", "ungrab key (201==vol down) ret=" + _window.UngrabKey(201)); } else if (e.Key.KeyPressedName == "Return") { imgIndex = (imgIndex + 1) % 6; imageMap2.URL = resourcePath + "gallery-" + imgIndex + ".jpg"; + //Tizen.Log.Fatal("NUI", "get native ecore wayland hander=" + _window.GetNativeWindowHandler()); } } } @@ -201,8 +231,8 @@ namespace VisualViewTest2 { View currentFocusView = FocusManager.Instance.GetCurrentFocusView(); - Tizen.Log.Debug("NUI", "Stage_KeyEvent" + e.Key.State.ToString() + ", Pressed-" + e.Key.KeyPressedName); - //Tizen.Log.Debug("NUI", " CurrentFocusView : " + currentFocusView.HasBody() + currentFocusView?.Name); + Tizen.Log.Fatal("NUI", "Stage_KeyEvent" + e.Key.State.ToString() + ", Pressed-" + e.Key.KeyPressedName); + //Tizen.Log.Fatal("NUI", " CurrentFocusView : " + currentFocusView.HasBody() + currentFocusView?.Name); } private void VisualSample_FocusLost(object sender, EventArgs e) @@ -224,7 +254,7 @@ namespace VisualViewTest2 imageMap.Opacity = 0.5f; } - Tizen.Log.Debug("NUI", "FocusLost-" + view.Name); + Tizen.Log.Fatal("NUI", "FocusLost-" + view.Name); } private void VisualSample_FocusGained(object sender, EventArgs e) @@ -246,7 +276,7 @@ namespace VisualViewTest2 imageMap.Opacity = 1.0f; } - Tizen.Log.Debug("NUI", "FocusGained-" + view.Name); + Tizen.Log.Fatal("NUI", "FocusGained-" + view.Name); } static void _Main(string[] args) diff --git a/src/Tizen.NUI/src/internal/FriendAssembly.cs b/src/Tizen.NUI/src/internal/FriendAssembly.cs index 60b87e664..7bcae89bb 100755 --- a/src/Tizen.NUI/src/internal/FriendAssembly.cs +++ b/src/Tizen.NUI/src/internal/FriendAssembly.cs @@ -21,7 +21,7 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Tizen.NUI.Extension.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001004d7c7c03a196ecb8e7cc5056750e1f40ee2bbe99f0e53a07f2538f2b0f450bd731b9dca3706503a0378baca74a09cf3af6261b330c031f44817ab6ed64189460765a402279d3e0c1fa7295ae1dccb2e3ff329705fd85b58d66ae7cb7e95ba06e0d847c3e3ba918798f579e5caeb1c6149955e6baf24236eec46227a623e494b1")] -[assembly: InternalsVisibleTo("Tizen.MM.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001004d7c7c03a196ecb8e7cc5056750e1f40ee2bbe99f0e53a07f2538f2b0f450bd731b9dca3706503a0378baca74a09cf3af6261b330c031f44817ab6ed64189460765a402279d3e0c1fa7295ae1dccb2e3ff329705fd85b58d66ae7cb7e95ba06e0d847c3e3ba918798f579e5caeb1c6149955e6baf24236eec46227a623e494b1")] +[assembly: InternalsVisibleTo("Tizen.Multimedia, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bd36a93b6d224759632d08a501b9dcb99a533e8ff0c3a1fc7044f5b05e176c005e5a7fc4d1dfa54da4d4cad4868c4518aa1f661380fb90685dc699d5e48dcc697b33c1e38b70845f405612d6827e7337c191ddd0a0aa35fdad654efe4c54881fdaa82ce35dce18ea918953e448c7aa284a47ed6fe3aa9404930b2b973a28cddf")] namespace Tizen.NUI { } \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/ManualPINVOKE.cs b/src/Tizen.NUI/src/internal/ManualPINVOKE.cs index a70ec5c16..0aeea9278 100755 --- a/src/Tizen.NUI/src/internal/ManualPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/ManualPINVOKE.cs @@ -277,5 +277,20 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_Dali_NativeVersionCheck")] public static extern bool NativeVersionCheck(ref int ver1, ref int ver2, ref int ver3); + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_Dali_GrabKeyTopmost")] + public static extern bool GrabKeyTopmost(System.IntPtr Window, int DaliKey); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_Dali_UngrabKeyTopmost")] + public static extern bool UngrabKeyTopmost(System.IntPtr Window, int DaliKey); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_Dali_GrabKey")] + public static extern bool GrabKey(System.IntPtr Window, int DaliKey, int GrabMode); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_Dali_UngrabKey")] + public static extern bool UngrabKey(System.IntPtr Window, int DaliKey); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_Dali_GetNativeWindowHandler")] + public static extern System.IntPtr GetNativeWindowHandler(System.IntPtr Window); + } } diff --git a/src/Tizen.NUI/src/public/Window.cs b/src/Tizen.NUI/src/public/Window.cs index 83f66a11c..587fb9ebd 100755 --- a/src/Tizen.NUI/src/public/Window.cs +++ b/src/Tizen.NUI/src/public/Window.cs @@ -348,6 +348,69 @@ namespace Tizen.NUI return ret; } + /// + /// Grabs the key specified by a key for a window only when a window is the topmost window.
+ /// This function can be used for following example scenarios:
+ /// - Mobile - Using volume up/down as zoom up/down in camera apps.
+ ///
+ /// The key code to grab + /// true if the grab succeeds + public bool GrabKeyTopmost(int DaliKey) + { + bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Ungrabs the key specified by a key for a window.
+ /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.
+ ///
+ /// The key code to ungrab + /// true if the ungrab succeeds + public bool UngrabKeyTopmost(int DaliKey) + { + bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + /// + /// Grabs the key specified by a key for a window in a GrabMode.
+ /// Details: This function can be used for following example scenarios:
+ /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app.
+ /// - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app.
+ /// - Mobile - Using volume up/down as zoom up/down in camera apps.
+ ///
+ /// The key code to grab + /// The grab mode for the key + /// true if the grab succeeds + public bool GrabKey(int DaliKey, KeyGrabMode GrabMode) + { + bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + /// + /// Ungrabs the key specified by a key for a window.
+ /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.
+ ///
+ /// The key code to ungrab + /// true if the ungrab succeeds + public bool UngrabKey(int DaliKey) + { + bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + internal System.IntPtr GetNativeWindowHandler() + { + System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + + /// /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing. /// @@ -359,6 +422,29 @@ namespace Tizen.NUI LandscapeInverse = 270 } + /// + /// Enumeration for key grab mode for platform-level APIs. + /// + public enum KeyGrabMode + { + /// + /// Grab a key only when on the top of the grabbing-window stack mode. + /// + Topmost = 0, + /// + /// Grab a key together with the other client window(s) mode. + /// + Shared, + /// + /// Grab a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode. + /// + OverrideExclusive, + /// + /// Grab a key exclusively regardless of the grabbing-window's position on the window stack mode. + /// + Exclusive + }; + /// /// Enumeration for opacity of the indicator. /// @@ -378,7 +464,5 @@ namespace Tizen.NUI Visible = 1, Auto = 2 } - } - } -- 2.34.1