From f694d1a7c172168e86c04207f771827c61ce6866 Mon Sep 17 00:00:00 2001 From: Junseok Kim Date: Tue, 4 Jun 2024 20:20:03 +0900 Subject: [PATCH] [NUI.WindowSystem] KVMService: Add new API to perform drop on given target --- .../src/internal/Interop/Interop.KVMService.cs | 3 +++ .../src/public/KVMService.cs | 26 ++++++++++++++++++++++ test/NUIWindowKVMSample/NUIWindowKVMSample.cs | 21 ++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs index 1429838..63eebfb 100644 --- a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs @@ -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); diff --git a/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs b/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs index d67b516..d9f5131 100644 --- a/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs +++ b/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs @@ -40,6 +40,22 @@ namespace Tizen.NUI.WindowSystem.Shell private event EventHandler _dragStarted; private event EventHandler _dragEnded; + + /// + /// Drop target type of PerformDrop request of KVM Service. + /// + public enum DropTarget + { + /// + /// Drop to KVM Service window self. + /// + KVMServiceWin = 0, + /// + /// Drop to the window that under pointer. + /// + UnderPointer = 1, + }; + /// /// Creates a new KVM Service handle. /// @@ -189,6 +205,16 @@ namespace Tizen.NUI.WindowSystem.Shell } /// + /// Requests to perform drop to given target. + /// + /// Thrown when failed of invalid argument. + public void PerformDrop(DropTarget target) + { + int res = Interop.KVMService.PerformDropTarget(_kvmService, (uint)target); + _tzsh.ErrorCodeThrow(res); + } + + /// /// Requests to cancel current drag. /// /// Thrown when failed of invalid argument. diff --git a/test/NUIWindowKVMSample/NUIWindowKVMSample.cs b/test/NUIWindowKVMSample/NUIWindowKVMSample.cs index 52cdb4c..19432dd 100644 --- a/test/NUIWindowKVMSample/NUIWindowKVMSample.cs +++ b/test/NUIWindowKVMSample/NUIWindowKVMSample.cs @@ -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) -- 2.7.4