Some finetuning.

This commit is contained in:
Ottermandias 2023-06-13 20:55:22 +02:00
parent 07a92ba025
commit b99d62e450
2 changed files with 11 additions and 12 deletions

View file

@ -13,14 +13,6 @@ namespace Dalamud.Interface.DragDrop;
/// <summary> Implements interop enums and function calls to interact with external drag and drop. </summary> /// <summary> Implements interop enums and function calls to interact with external drag and drop. </summary>
internal partial class DragDropManager internal partial class DragDropManager
{ {
internal struct POINTL
{
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
public int x;
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
public int y;
}
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("00000122-0000-0000-C000-000000000046")] [Guid("00000122-0000-0000-C000-000000000046")]
[ComImport] [ComImport]
@ -39,6 +31,14 @@ internal partial class DragDropManager
void Drop([MarshalAs(UnmanagedType.Interface), In] IDataObject pDataObj, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.DWORD"), In] uint grfKeyState, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.POINTL"), In] POINTL pt, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.DWORD"), In, Out] ref uint pdwEffect); void Drop([MarshalAs(UnmanagedType.Interface), In] IDataObject pDataObj, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.DWORD"), In] uint grfKeyState, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.POINTL"), In] POINTL pt, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.DWORD"), In, Out] ref uint pdwEffect);
} }
internal struct POINTL
{
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
public int x;
[ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
public int y;
}
private static class DragDropInterop private static class DragDropInterop
{ {
[Flags] [Flags]

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
using System.Text; using System.Text;
@ -19,7 +18,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget
private DragDropInterop.ModifierKeys lastKeyState = DragDropInterop.ModifierKeys.MK_NONE; private DragDropInterop.ModifierKeys lastKeyState = DragDropInterop.ModifierKeys.MK_NONE;
/// <summary> Create the drag and drop formats we accept. </summary> /// <summary> Create the drag and drop formats we accept. </summary>
private static FORMATETC FormatEtc = private FORMATETC formatEtc =
new() new()
{ {
cfFormat = (short)DragDropInterop.ClipboardFormat.CF_HDROP, cfFormat = (short)DragDropInterop.ClipboardFormat.CF_HDROP,
@ -41,7 +40,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget
this.IsDragging = true; this.IsDragging = true;
this.lastKeyState = UpdateIo((DragDropInterop.ModifierKeys)grfKeyState, true); this.lastKeyState = UpdateIo((DragDropInterop.ModifierKeys)grfKeyState, true);
if (pDataObj.QueryGetData(ref FormatEtc) != 0) if (pDataObj.QueryGetData(ref this.formatEtc) != 0)
{ {
pdwEffect = 0; pdwEffect = 0;
} }
@ -203,7 +202,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget
try try
{ {
data.GetData(ref FormatEtc, out var stgMedium); data.GetData(ref this.formatEtc, out var stgMedium);
var numFiles = DragDropInterop.DragQueryFile(stgMedium.unionmember, uint.MaxValue, new StringBuilder(), 0); var numFiles = DragDropInterop.DragQueryFile(stgMedium.unionmember, uint.MaxValue, new StringBuilder(), 0);
var files = new string[numFiles]; var files = new string[numFiles];
var sb = new StringBuilder(1024); var sb = new StringBuilder(1024);