[NUI.WindowSystem] Add new request of KVM Service
authorJunseok Kim <juns.kim@samsung.com>
Wed, 30 Aug 2023 07:23:02 +0000 (16:23 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 21 Sep 2023 09:34:08 +0000 (18:34 +0900)
Add new request of KVM Service as below:
 - ReceiveDragData: Request to get current drag data.
 - CancelDrag: Request to cancel current drag.

src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs
src/Tizen.NUI.WindowSystem/src/public/KVMService.cs
test/NUIWindowKVMSample/NUIWindowKVMSample.cs

index 52ee625..4fc52fd 100644 (file)
@@ -19,6 +19,12 @@ namespace Tizen.NUI.WindowSystem.Shell
             [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop")]
             internal static extern int PerformDrop(IntPtr kvmService);
 
+            [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_cancel_drag")]
+            internal static extern int CancelDrag(IntPtr kvmService);
+
+            [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_receive_drag_data")]
+            internal static extern int ReceiveDragData(IntPtr kvmService, string mimeType);
+
             [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_set")]
             internal static extern int SetSecondarySelection(IntPtr kvmService);
 
index febc473..78f8ac4 100644 (file)
@@ -188,6 +188,27 @@ namespace Tizen.NUI.WindowSystem.Shell
         }
 
         /// <summary>
+        /// Requests to cancel current drag.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        public void CancelDrag()
+        {
+            int res = Interop.KVMService.CancelDrag(_kvmService);
+            _tzsh.ErrorCodeThrow(res);
+        }
+
+        /// <summary>
+        /// Requests to receive the current drag data.
+        /// the drag data will be received by the DragEvent of the window.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        public void ReceiveDragData(string mimeType)
+        {
+            int res = Interop.KVMService.ReceiveDragData(_kvmService, mimeType);
+            _tzsh.ErrorCodeThrow(res);
+        }
+
+        /// <summary>
         /// Requests to set KVM window as secondary selection window.
         /// </summary>
         /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
index 3fcc072..0c266d3 100644 (file)
@@ -112,7 +112,9 @@ namespace NUIWindowKVMSample
             windowView.BackgroundColor = Color.Yellow;
             this.Add(windowView);
 
-            dnd.AddListener(windowView, OnDnDEvent);
+            // The First argument of listener should be window, not view.
+            // The listener of view couldn't catch receive data from ReceiveDragData of KVMService
+            dnd.AddListener(this, OnDnDEvent);
 
             tzShell = new Tizen.NUI.WindowSystem.Shell.TizenShell();
             kvmService = new Tizen.NUI.WindowSystem.Shell.KVMService(tzShell, this);
@@ -126,7 +128,15 @@ namespace NUIWindowKVMSample
             if (e.DragType == DragType.Enter)
             {
                 Log.Debug("KVMSample", "Target(KVM) App DRagEvnetType: Enter");
-                kvmService.PerformDrop();
+                // PerformDrop is drop into the KVM window and finish the current drag.
+                // If you want to get the current drag data without end the drag,
+                // use ReceiveDragData(mimetype) instead of PerformDrop().
+                //kvmService.PerformDrop();
+
+                // The drag data will be received by ReceiveDragData of OnDragStarted callback and DragEvent of the OnDnDEvent callback.
+                // and the drag will be ended by enter the KVM window as UX of the app.
+                // If you want to end the drag without receive drag data, use CancelDrag().
+                kvmService.CancelDrag();
             }
             if (e.DragType == DragType.Drop)
             {
@@ -137,6 +147,10 @@ namespace NUIWindowKVMSample
         private void OnDragStarted(object sender, EventArgs e)
         {
             Log.Debug("KVMSample", "Tizen KVM: Drag started");
+
+            // Request the drag data to the Display server.
+            // The drag data can get at DnD Listener (OnDnDEvent function)
+            kvmService.ReceiveDragData("text/plain");
         }
 
         private void OnDragEnded(object sender, EventArgs e)