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 src/Files.App/MainWindow.Linux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public sealed partial class MainWindow
#if UNO_WAYLAND
private bool _waylandWindow;
// The Wayland host implements caption regions, move and maximize itself (InputNonClientPointerSource, presenter).
private bool IsWaylandWindow => _waylandWindow;
internal bool IsWaylandWindow => _waylandWindow;
#else
private static bool IsWaylandWindow => false;
internal bool IsWaylandWindow => false;
#endif
public bool UseClientSideDecorations => OperatingSystem.IsLinux() &&
Ioc.Default.GetRequiredService<ILocalSettingsStore>().Get("UseClientSideDecorations", true);
Expand Down
18 changes: 18 additions & 0 deletions src/Files.App/Platforms/Desktop/Services/DesktopFileDragHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ public static async Task<bool> TryPasteFilesAsync(string destinationPath, IShell
}
}

/// <summary>
/// Makes a drag of <paramref name="paths"/> available to other applications. On the native Wayland host the dragged
/// <paramref name="data"/> carries the file list (<c>text/uri-list</c>) and the host offers it to the compositor once the
/// pointer leaves the window; on X11 the Files selection host follows the pointer instead.
/// </summary>
public static void StartDrag(DataPackage data, IEnumerable<string?> paths)
{
if (!MainWindow.Instance.IsWaylandWindow)
{
StartExternalDrag(paths);
return;
}

var existing = ExistingPaths(paths);
if (existing.Count > 0)
data.SetData(Files.Platform.Linux.Clipboard.ClipboardFormats.UriList, Files.Platform.Linux.Clipboard.ClipboardFormats.BuildUriList(existing));
}

/// <summary>
/// Starts offering the dragged items to other applications while the pointer is outside this window. Returns immediately; the
/// drag source follows the pointer until the primary button is released.
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/Pane/ShelfPane.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void ListView_DragItemsStarting(object sender, DragItemsStartingEventArg
return;

e.Data.Properties["Files_ActionBinder"] = "Files_ShelfBinder";
Files.App.Services.Desktop.DesktopFileDragHelper.StartExternalDrag(paths);
Files.App.Services.Desktop.DesktopFileDragHelper.StartDrag(e.Data, paths);
}

private void ShelfItemsList_RightTapped(object sender, Microsoft.UI.Xaml.Input.RightTappedRoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ public static async Task<IEnumerable<IStorageItemWithPath>> GetDraggedStorageIte
IEnumerable<string> paths;
if (packageView.Contains(ClipboardFormats.UriList))
{
var data = await packageView.GetDataAsync(ClipboardFormats.UriList);
paths = data is string text ? ClipboardFormats.ParseUriList(text) : [];
// Uno's X11 host exposes the list as text, the Wayland host as the raw bytes it received.
paths = await packageView.GetDataAsync(ClipboardFormats.UriList) switch
{
string text => ClipboardFormats.ParseUriList(text),
byte[] bytes => ClipboardFormats.ParseUriList(System.Text.Encoding.UTF8.GetString(bytes)),
_ => [],
};
}
else if (packageView.Contains(StandardDataFormats.StorageItems))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/BaseLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ protected virtual void FileList_DragItemsStarting(object sender, DragItemsStarti
// Set can window to front (#13255)
MainWindow.Instance.SetCanWindowToFront(false);
itemDragging = true;
Files.App.Services.Desktop.DesktopFileDragHelper.StartExternalDrag(orderedItems.Select(x => x.ItemPath));
Files.App.Services.Desktop.DesktopFileDragHelper.StartDrag(e.Data, orderedItems.Select(x => x.ItemPath));
}
catch (Exception)
{
Expand Down
Loading