[NUI.WindowSystem] KVMService: Add new API to perform drop on given target
authorJunseok Kim <juns.kim@samsung.com>
Tue, 4 Jun 2024 11:20:03 +0000 (20:20 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 21 Jun 2024 01:28:24 +0000 (10:28 +0900)
src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs
src/Tizen.NUI.WindowSystem/src/public/KVMService.cs
test/NUIWindowKVMSample/NUIWindowKVMSample.cs

index 14298385a3be41392303536481bf520c1ee7ef57..63eebfb407e955218fdc54e2c12634e7c0e82cea 100644 (file)
@@ -37,6 +37,9 @@ namespace Tizen.NUI.WindowSystem.Shell
             [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_unset")]
             internal static extern int UnsetSecondarySelection(IntPtr kvmService);
 
+            [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop_target")]
+            internal static extern int PerformDropTarget(IntPtr kvmService, uint drop_target);
+
             internal delegate void KVMDragStartEventCallback(IntPtr data, IntPtr kvmService);
             [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_drag_start_cb_set")]
             internal static extern int SetDragStartEventHandler(IntPtr kvmService, KVMDragStartEventCallback func, IntPtr data);
index d67b516f59cff5c9a563edf988d092fbf4a126d2..d9f513103270d5e1817405707e8483eff0912ed3 100644 (file)
@@ -40,6 +40,22 @@ namespace Tizen.NUI.WindowSystem.Shell
         private event EventHandler _dragStarted;
         private event EventHandler _dragEnded;
 
+
+        /// <summary>
+        /// Drop target type of PerformDrop request of KVM Service.
+        /// </summary>
+        public enum DropTarget
+        {
+            /// <summary>
+            /// Drop to KVM Service window self.
+            /// </summary>
+            KVMServiceWin = 0,
+            /// <summary>
+            /// Drop to the window that under pointer.
+            /// </summary>
+            UnderPointer = 1,
+        };
+
         /// <summary>
         /// Creates a new KVM Service handle.
         /// </summary>
@@ -188,6 +204,16 @@ namespace Tizen.NUI.WindowSystem.Shell
             _tzsh.ErrorCodeThrow(res);
         }
 
+        /// <summary>
+        /// Requests to perform drop to given target.
+        /// </summary>
+        /// <exception cref="ArgumentException">Thrown when failed of invalid argument.</exception>
+        public void PerformDrop(DropTarget target)
+        {
+            int res = Interop.KVMService.PerformDropTarget(_kvmService, (uint)target);
+            _tzsh.ErrorCodeThrow(res);
+        }
+
         /// <summary>
         /// Requests to cancel current drag.
         /// </summary>
index 52cdb4cef45766f688a94400e96784a4914d38ff..19432ddf4ac49d6e94eb7f2f06dfabc6e2f71159 100644 (file)
@@ -39,7 +39,7 @@ namespace NUIWindowKVMSample
             text.WidthResizePolicy = ResizePolicyType.FillToParent;
             windowView.Add(text);
 
-            KVMServiceWindow kvmServiceWindow = new KVMServiceWindow(new Rectangle(2500, 0, 60, 1440));
+            kvmServiceWindow = new KVMServiceWindow(new Rectangle(2500, 0, 60, 1440));
             kvmServiceWindow.Show();
         }
 
@@ -49,6 +49,18 @@ namespace NUIWindowKVMSample
             {
                 Exit();
             }
+            if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "d" || e.Key.KeyPressedName == "D"))
+            {
+                Log.Debug("KVMSample", e.Key.KeyPressedName + " pressed!");
+                dropTimer = new Timer(5000);
+                dropTimer.Tick += (source, args) => {
+                    Log.Debug("KVMSample", "Timer tick!");
+                    kvmServiceWindow.PerformDrop();
+                    dropTimer.Stop();
+                    return false;
+                };
+                dropTimer.Start();
+            }
         }
 
         private bool OnTouchEvent(object sender, View.TouchEventArgs e)
@@ -96,6 +108,8 @@ namespace NUIWindowKVMSample
         }
 
         private DragAndDrop dnd;
+        private KVMServiceWindow kvmServiceWindow;
+        private Timer dropTimer;
     }
 
     class KVMServiceWindow : Window
@@ -123,6 +137,11 @@ namespace NUIWindowKVMSample
             kvmService.DragEnded += OnDragEnded;
         }
 
+        public void PerformDrop()
+        {
+            kvmService.PerformDrop(Tizen.NUI.WindowSystem.Shell.KVMService.DropTarget.UnderPointer);
+        }
+
         private void OnDnDEvent(object sender, DragEvent e)
         {
             if (e.DragType == DragType.Enter)