Skip to content
Draft
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
18 changes: 18 additions & 0 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Windows.Foundation.Metadata;
using Windows.Graphics;
using Windows.UI.Input;
using Windows.Win32;
using WinUIEx;
using GridSplitter = Files.App.Controls.GridSplitter;
using VirtualKey = Windows.System.VirtualKey;
Expand All @@ -32,8 +33,10 @@ public sealed partial class MainPage : Page
public MainPageViewModel ViewModel { get; }

private bool keyReleased = true;
private const int KEY_DOWN_MASK = 0x8000;

private DispatcherQueueTimer _updateDateDisplayTimer;
private InputNonClientPointerSource? _nonClientPointerSource;

private readonly Dictionary<TabBarItem, double> _sidebarScrollByTab = new();
private TabBarItem? _previousSidebarTab;
Expand Down Expand Up @@ -122,6 +125,15 @@ private int SetTitleBarDragRegion(InputNonClientPointerSource source, SizeInt32
return height;
}

private async void NonClientPointerSource_PointerPressed(InputNonClientPointerSource sender, NonClientPointerEventArgs args)
{
if (args.RegionKind is not NonClientRegionKind.Caption ||
(PInvoke.GetKeyState((int)VirtualKey.MiddleButton) & KEY_DOWN_MASK) == 0)
return;

await NavigationHelpers.AddNewTabAsync();
}

public async void TabItemContent_ContentChanged(object? sender, TabBarItemParameter e)
{
if (SidebarAdaptiveViewModel.PaneHolder is null)
Expand Down Expand Up @@ -297,6 +309,12 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
FindName(nameof(TabControl));
FindName(nameof(NavToolbar));

if (_nonClientPointerSource is null)
{
_nonClientPointerSource = InputNonClientPointerSource.GetForWindowId(MainWindow.Instance.AppWindow.Id);
_nonClientPointerSource.PointerPressed += NonClientPointerSource_PointerPressed;
}

// Notify user that drag and drop is disabled
// Prompt is disabled in the dev environment to prevent issues with the automation testing
// ToDo put this in a StartupPromptService
Expand Down
Loading