Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builds/azure-pipelines-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
targetType: 'inline'
script: |
gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process {
(Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\${{parameters.iconVariant}}"}) | Set-Content $_ -NoNewline
(Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\AppTiles\Dev", "Assets\AppTiles\${{parameters.iconVariant}}"}) | Set-Content $_ -NoNewline
}
failOnStderr: true

Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
targetType: 'inline'
script: |
gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process {
(Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\${{parameters.iconVariant}}"}) | Set-Content $_ -NoNewline
(Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\AppTiles\\Dev", "Assets\AppTiles\Release"}) | Set-Content $_ -NoNewline
}
failOnStderr: true

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App (Package)/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
IgnorableNamespaces="uap uap5 mp rescap desktop6 desktop4 desktop">
<Identity Name="FilesDev" Publisher="CN=Files" Version="2.4.11.0" />
<Identity Name="FilesDev" Publisher="CN=Files" Version="2.4.13.0" />
<Properties>
<DisplayName>Files - Dev</DisplayName>
<PublisherDisplayName>Yair A</PublisherDisplayName>
Expand Down
22 changes: 19 additions & 3 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using System.Threading.Tasks;
using Vanara.PInvoke;
using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel.DataTransfer.DragDrop;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.System;
using static Files.App.Helpers.PathNormalization;
using VA = Vanara.Windows.Shell;
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;

namespace Files.App
Expand Down Expand Up @@ -751,11 +755,23 @@ protected virtual void Page_CharacterReceived(UIElement sender, CharacterReceive
protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
{
SelectedItems!.AddRange(e.Items.OfType<ListedItem>());

try
{
// Only support IStorageItem capable paths
var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x));
e.Data.SetStorageItems(itemList, false);
var itemList = e.Items.OfType<ListedItem>().Select(x => new VA.ShellItem(x.ItemPath)).ToArray();
var iddo = itemList[0].Parent.GetChildrenUIObjects<IDataObject>(HWND.NULL, itemList);
itemList.ForEach(x => x.Dispose());
var wfdo = new System.Windows.Forms.DataObject(iddo);
var formats = wfdo.GetFormats(false);
foreach (var format in formats)
{
var clipFrmtId = (uint)System.Windows.Forms.DataFormats.GetFormat(format).Id;
if (iddo.TryGetData<byte[]>(clipFrmtId, out var data))
{
var mem = new MemoryStream(data).AsRandomAccessStream();
e.Data.SetData(format, mem);
}
}
}
catch (Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Vanara.PInvoke;
using Windows.ApplicationModel.DataTransfer;
using Windows.Graphics.Imaging;
using Windows.Storage;
using Windows.Storage.Streams;
using FileAttributes = System.IO.FileAttributes;

namespace Files.App.Filesystem
{
Expand Down Expand Up @@ -733,7 +737,7 @@ public async Task<ReturnResult> RecycleItemsFromClipboard(DataPackageView packag

public static bool HasDraggedStorageItems(DataPackageView packageView)
{
return packageView is not null && (packageView.Contains(StandardDataFormats.StorageItems) || (packageView.Properties.TryGetValue("FileDrop", out _)));
return packageView is not null && packageView.Contains(StandardDataFormats.StorageItems);
}

public static async Task<bool> CheckDragNeedsFulltrust(DataPackageView packageView)
Expand Down Expand Up @@ -761,6 +765,7 @@ public static async Task<bool> CheckDragNeedsFulltrust(DataPackageView packageVi
public static async Task<IEnumerable<IStorageItemWithPath>> GetDraggedStorageItems(DataPackageView packageView)
{
var itemsList = new List<IStorageItemWithPath>();

if (packageView.Contains(StandardDataFormats.StorageItems))
{
try
Expand All @@ -778,13 +783,58 @@ public static async Task<IEnumerable<IStorageItemWithPath>> GetDraggedStorageIte
return itemsList;
}
}
if (packageView.Properties.TryGetValue("FileDrop", out var data))

// workaround for GetStorageItemsAsync() bug that only yields 16 items at most
// https://learn.microsoft.com/en-us/windows/win32/shell/clipboard#cf_hdrop
if (packageView.Contains("FileDrop"))
{
if (data is List<IStorageItemWithPath> source)
var fileDropData = await packageView.GetDataAsync("FileDrop");
if (fileDropData is IRandomAccessStream stream)
{
itemsList.AddRange(source);
stream.Seek(0);

byte[] dropBytes = new byte[stream.Size];
int bytesRead = await stream.AsStreamForRead().ReadAsync(dropBytes);

if (bytesRead > 0)
{
IntPtr dropStructPointer = Marshal.AllocHGlobal(dropBytes.Length);

try
{
Marshal.Copy(dropBytes, 0, dropStructPointer, dropBytes.Length);
HDROP dropStructHandle = new(dropStructPointer);

var itemPaths = new List<string>();
uint filesCount = Shell32.DragQueryFile(dropStructHandle, 0xffffffff, null, 0);
for (uint i = 0; i < filesCount; i++)
{
uint charsNeeded = Shell32.DragQueryFile(dropStructHandle, i, null, 0);
uint bufferSpaceRequired = charsNeeded + 1; // include space for terminating null character
string buffer = new('\0', (int)bufferSpaceRequired);
uint charsCopied = Shell32.DragQueryFile(dropStructHandle, i, buffer, bufferSpaceRequired);

if (charsCopied > 0)
{
string path = buffer[..(int)charsCopied];
itemPaths.Add(path);
}
}

foreach (var path in itemPaths)
{
var isDirectory = NativeFileOperationsHelper.HasFileAttribute(path, FileAttributes.Directory);
itemsList.Add(StorageHelpers.FromPathAndType(path, isDirectory ? FilesystemItemType.Directory : FilesystemItemType.File));
}
}
finally
{
Marshal.FreeHGlobal(dropStructPointer);
}
}
}
}

itemsList = itemsList.DistinctBy(x => string.IsNullOrEmpty(x.Path) ? x.Item.Name : x.Path).ToList();
return itemsList;
}
Expand Down
140 changes: 0 additions & 140 deletions src/Files.App/Filesystem/StorageItems/VirtualStorageItem.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Files.App/UserControls/AddressToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void VisiblePath_KeyDown(object _, KeyRoutedEventArgs e)
}
private void VisiblePath_LostFocus(object _, RoutedEventArgs e)
{
var element = FocusManager.GetFocusedElement();
var element = FocusManager.GetFocusedElement(XamlRoot);
if (element is FlyoutBase or AppBarButton or Popup)
return;

Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@
DragItemsStarting="FileList_DragItemsStarting"
DragOver="ItemsLayout_DragOver"
Drop="ItemsLayout_Drop"
FocusVisualPrimaryThickness="0"
FocusVisualSecondaryThickness="0"
Holding="FileList_Holding"
IsDoubleTapEnabled="True"
IsRightTapEnabled="True"
IsTabStop="True"
ItemsSource="{x:Bind CollectionViewSource.View, Mode=OneWay}"
PreviewKeyDown="FileList_PreviewKeyDown"
PreviewKeyUp="FileList_PreviewKeyUp"
Expand Down
19 changes: 11 additions & 8 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ private void ItemManipulationModel_SelectAllItemsInvoked(object? sender, EventAr

private void ItemManipulationModel_FocusFileListInvoked(object? sender, EventArgs e)
{
FileList.Focus(FocusState.Programmatic);
var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement(XamlRoot);
var isFileListFocused = DependencyObjectHelpers.FindParent<ListViewBase>(focusedElement) == FileList;
if (!isFileListFocused)
FileList.Focus(FocusState.Programmatic);
}

private void ZoomIn(object? sender, GroupOption option)
Expand Down Expand Up @@ -279,7 +282,7 @@ private void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
private void RenameTextBox_LostFocus(object sender, RoutedEventArgs e)
{
// This check allows the user to use the text box context menu without ending the rename
if (!(FocusManager.GetFocusedElement() is AppBarButton or Popup))
if (!(FocusManager.GetFocusedElement(XamlRoot) is AppBarButton or Popup))
{
TextBox textBox = (TextBox)e.OriginalSource;
CommitRename(textBox);
Expand Down Expand Up @@ -407,12 +410,12 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
if (IsRenamingItem)
return;

e.Handled = true;

if (IsItemSelected && SelectedItem.PrimaryItemAttribute == StorageItemTypes.Folder)
ItemInvoked?.Invoke(new ColumnParam { NavPathParam = (SelectedItem is ShortcutItem sht ? sht.TargetPath : SelectedItem.ItemPath), ListView = FileList }, EventArgs.Empty);
else
_ = NavigationHelpers.OpenSelectedItems(ParentShellPageInstance, false);

e.Handled = true;
await NavigationHelpers.OpenSelectedItems(ParentShellPageInstance, false);
}
else if (e.Key == VirtualKey.Enter && e.KeyStatus.IsMenuKeyDown)
{
Expand All @@ -430,12 +433,12 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
{
// Unfocus the GridView so keyboard shortcut can be handled
NavToolbar?.Focus(FocusState.Pointer);
this.Focus(FocusState.Pointer);
}
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
{
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
NavToolbar?.Focus(FocusState.Pointer);
this.Focus(FocusState.Pointer);
}
else if (e.Key == VirtualKey.Up || e.Key == VirtualKey.Down)
{
Expand Down Expand Up @@ -477,7 +480,7 @@ protected override void Page_CharacterReceived(UIElement sender, CharacterReceiv
return;

// Don't block the various uses of enter key (key 13)
var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement();
var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement(XamlRoot);

if
(
Expand Down
Loading