[Applications.UI] Add Get window position api (#5085)
authorsukhyungkang <35091460+sukhyungkang@users.noreply.github.com>
Mon, 17 Apr 2023 08:07:01 +0000 (17:07 +0900)
committerGitHub <noreply@github.com>
Mon, 17 Apr 2023 08:07:01 +0000 (17:07 +0900)
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
Co-authored-by: hjhun <36876573+hjhun@users.noreply.github.com>
src/Tizen.Applications.UI/Interop/Interop.Application.cs
src/Tizen.Applications.UI/Tizen.Applications/CoreUIApplication.cs

index 3423151..6b1a619 100755 (executable)
@@ -53,6 +53,8 @@ internal static partial class Interop
         [DllImport(Libraries.Application, EntryPoint = "ui_app_remove_event_handler")]
         internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
 
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_get_window_position")]
+        internal static extern ErrorCode GetWindowPosition(out int x, out int y, out int w, out int h);
 
         [NativeStruct("ui_app_lifecycle_callback_s", Include="app.h", PkgConfig="capi-appfw-application")]
         [StructLayout(LayoutKind.Sequential)]
index d27f2cb..6002da2 100755 (executable)
  */
 
 using System;
+using System.ComponentModel;
 
 using Tizen.Applications.CoreBackend;
+using Tizen.Internals.Errors;
 
 namespace Tizen.Applications
 {
@@ -113,5 +115,22 @@ namespace Tizen.Applications
         {
             Paused?.Invoke(this, EventArgs.Empty);
         }
+
+        /// <summary>
+        /// Gets the window position of the application.
+        /// </summary>
+        /// <returns>The window position.</returns>
+        /// <exception cref="InvalidOperationException">Thrown when there is no window position.</exception>
+        /// <since_tizen> 11 </since_tizen>
+        public WindowPosition GetWindowPosition()
+        {
+            ErrorCode err = Interop.Application.GetWindowPosition(out int x, out int y, out int w, out int h);
+            if (err != ErrorCode.None)
+            {
+                throw new InvalidOperationException("Failed to get window position");
+            }
+
+            return new WindowPosition(x, y, w, h);
+        }
     }
 }