keygrab & ecore-wl-window-handle c# binding
authordongsug.song <dongsug.song@samsung.com>
Fri, 21 Apr 2017 08:02:46 +0000 (17:02 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Fri, 21 Apr 2017 08:02:58 +0000 (17:02 +0900)
- this is a pair with dali-adaptor patch of https://review.tizen.org/gerrit/#/c/126398/

Change-Id: Id1c776151c9a683f985bbea54f6d6dc9c3f4fcdd
Signed-off-by: dongsug.song <dongsug.song@samsung.com>
NUISamples/NUISamples/NUISamples.TizenTV/examples/Main.cs
NUISamples/NUISamples/NUISamples.TizenTV/examples/visual-view-test2.cs
src/Tizen.NUI/src/internal/FriendAssembly.cs
src/Tizen.NUI/src/internal/ManualPINVOKE.cs
src/Tizen.NUI/src/public/Window.cs

index 8af6814..707c82c 100755 (executable)
@@ -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);
         }
     }
 }
index 021ac5e..1b3d030 100755 (executable)
@@ -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)
index 60b87e6..7bcae89 100755 (executable)
@@ -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
index a70ec5c..0aeea92 100755 (executable)
@@ -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);
+
     }
 }
index 83f66a1..587fb9e 100755 (executable)
@@ -349,6 +349,69 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Grabs the key specified by a key for a window only when a window is the topmost window. <br>
+        /// This function can be used for following example scenarios: <br>
+        /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
+        /// </summary>
+        /// <param name="DaliKey">The key code to grab</param>
+        /// <returns>true if the grab succeeds</returns>
+        public bool GrabKeyTopmost(int DaliKey)
+        {
+            bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Ungrabs the key specified by a key for a window. <br>
+        /// 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.<br>
+        /// </summary>
+        /// <param name="DaliKey">The key code to ungrab</param>
+        /// <returns>true if the ungrab succeeds</returns>
+        public bool UngrabKeyTopmost(int DaliKey)
+        {
+            bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+        /// <summary>
+        ///  Grabs the key specified by a key for a window in a GrabMode. <br>
+        ///  Details: This function can be used for following example scenarios: <br>
+        ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br>
+        ///  - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app. <br>
+        ///  - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
+        /// </summary>
+        /// <param name="DaliKey">The key code to grab</param>
+        /// <param name="GrabMode">The grab mode for the key</param>
+        /// <returns>true if the grab succeeds</returns>
+        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;
+        }
+        /// <summary>
+        /// Ungrabs the key specified by a key for a window.  <br>
+        /// 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. <br>
+        /// </summary>
+        /// <param name="DaliKey">The key code to ungrab</param>
+        /// <returns>true if the ungrab succeeds</returns>
+        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;
+        }
+
+
+
+        /// <summary>
         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
         /// </summary>
         public enum WindowOrientation
@@ -360,6 +423,29 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Enumeration for key grab mode for platform-level APIs.
+        /// </summary>
+        public enum KeyGrabMode
+        {
+            /// <summary>
+            /// Grab a key only when on the top of the grabbing-window stack mode.
+            /// </summary>
+            Topmost = 0,
+            /// <summary>
+            /// Grab a key together with the other client window(s) mode.
+            /// </summary>
+            Shared,
+            /// <summary>
+            /// 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.
+            /// </summary>
+            OverrideExclusive,
+            /// <summary>
+            /// Grab a key exclusively regardless of the grabbing-window's position on the window stack mode.
+            /// </summary>
+            Exclusive
+        };
+
+        /// <summary>
         /// Enumeration for opacity of the indicator.
         /// </summary>
         internal enum IndicatorBgOpacity
@@ -378,7 +464,5 @@ namespace Tizen.NUI
             Visible = 1,
             Auto = 2
         }
-
     }
-
 }