From 7d3b76d0434c957c93f7ca7cfebf050416d917fa Mon Sep 17 00:00:00 2001 From: Junseok Kim Date: Wed, 30 Aug 2023 16:23:02 +0900 Subject: [PATCH] [NUI.WindowSystem] Add new request of KVM Service Add new request of KVM Service as below: - ReceiveDragData: Request to get current drag data. - CancelDrag: Request to cancel current drag. --- .../src/internal/Interop/Interop.KVMService.cs | 6 ++++++ src/Tizen.NUI.WindowSystem/src/public/KVMService.cs | 21 +++++++++++++++++++++ test/NUIWindowKVMSample/NUIWindowKVMSample.cs | 18 ++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) 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 52ee625..4fc52fd 100644 --- a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs @@ -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); diff --git a/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs b/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs index febc473..78f8ac4 100644 --- a/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs +++ b/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs @@ -188,6 +188,27 @@ namespace Tizen.NUI.WindowSystem.Shell } /// + /// Requests to cancel current drag. + /// + /// Thrown when failed of invalid argument. + public void CancelDrag() + { + int res = Interop.KVMService.CancelDrag(_kvmService); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to receive the current drag data. + /// the drag data will be received by the DragEvent of the window. + /// + /// Thrown when failed of invalid argument. + public void ReceiveDragData(string mimeType) + { + int res = Interop.KVMService.ReceiveDragData(_kvmService, mimeType); + _tzsh.ErrorCodeThrow(res); + } + + /// /// Requests to set KVM window as secondary selection window. /// /// Thrown when failed of invalid argument. diff --git a/test/NUIWindowKVMSample/NUIWindowKVMSample.cs b/test/NUIWindowKVMSample/NUIWindowKVMSample.cs index 3fcc072..0c266d3 100644 --- a/test/NUIWindowKVMSample/NUIWindowKVMSample.cs +++ b/test/NUIWindowKVMSample/NUIWindowKVMSample.cs @@ -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) -- 2.7.4