Skip to content

Commit

Permalink
Fix: Fixed issue where drag and drop from Edge didn't work (#14976)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu committed Mar 18, 2024
1 parent 0965661 commit d50ed7c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs
Expand Up @@ -245,14 +245,14 @@ public async Task<ReturnResult> RestoreItemsFromTrashAsync(IEnumerable<IStorageI
{
return await RecycleItemsFromClipboard(packageView, destination, UserSettingsService.FoldersSettingsService.DeleteConfirmationPolicy, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Copy))
{
return await CopyItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Move))
{
return await MoveItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Copy))
{
return await CopyItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Link))
{
// Open with piggybacks off of the link operation, since there isn't one for it
Expand Down
9 changes: 6 additions & 3 deletions src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs
Expand Up @@ -123,7 +123,8 @@ public async Task DragOverAsync(DragEventArgs e)
if (pwd.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (e.Modifiers.HasFlag(DragDropModifiers.Alt) || e.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
{
Expand All @@ -138,7 +139,8 @@ public async Task DragOverAsync(DragEventArgs e)
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (draggedItems.Any(x =>
x.Item is ZipStorageFile ||
Expand All @@ -151,7 +153,8 @@ public async Task DragOverAsync(DragEventArgs e)
else if (draggedItems.AreItemsInSameDrive(_associatedInstance.FilesystemViewModel.WorkingDirectory))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), folderName);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down
Expand Up @@ -410,7 +410,8 @@ public async Task PathBoxItem_DragOver(object sender, DragEventArgs e)
{
e.DragUIOverride.IsCaptionVisible = true;
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), pathBoxItem.Title);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}

deferral.Complete();
Expand Down
15 changes: 10 additions & 5 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Expand Up @@ -1130,7 +1130,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
if (locationItem.Path.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (rawEvent.Modifiers.HasFlag(DragDropModifiers.Alt) || rawEvent.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
{
Expand All @@ -1145,7 +1146,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
else if (rawEvent.Modifiers.HasFlag(DragDropModifiers.Shift))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (storageItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
|| ZipStorageFolder.IsZipPath(locationItem.Path))
Expand All @@ -1156,7 +1158,8 @@ private async Task HandleLocationItemDragOverAsync(LocationItem locationItem, It
else if (locationItem.IsDefaultLocation || storageItems.AreItemsInSameDrive(locationItem.Path))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), locationItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down Expand Up @@ -1204,12 +1207,14 @@ private async Task HandleDriveItemDragOverAsync(DriveItem driveItem, ItemDragOve
else if (args.RawEvent.Modifiers.HasFlag(DragDropModifiers.Shift))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), driveItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (storageItems.AreItemsInSameDrive(driveItem.Path))
{
captionText = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), driveItem.Text);
operationType = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
operationType = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions src/Files.App/Views/Layouts/BaseLayoutPage.cs
Expand Up @@ -1052,7 +1052,8 @@ private async void Item_DragOver(object sender, DragEventArgs e)
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else if (draggedItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
|| ZipStorageFolder.IsZipPath(item.ItemPath))
Expand All @@ -1063,7 +1064,8 @@ private async void Item_DragOver(object sender, DragEventArgs e)
else if (draggedItems.AreItemsInSameDrive(item.ItemPath))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Move;
// Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
e.AcceptedOperation = DataPackageOperation.Move | DataPackageOperation.Copy;
}
else
{
Expand Down

0 comments on commit d50ed7c

Please sign in to comment.