Skip to content

Commit 3669604

Browse files
committed
Use custom destinations instead
1 parent c75e0ce commit 3669604

File tree

13 files changed

+252
-125
lines changed

13 files changed

+252
-125
lines changed

src/Files.App.BackgroundTasks/UpdateTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private void RefreshJumpList()
4343

4444
_ = STATask.Run(() =>
4545
{
46-
JumpListManager.Default.FetchJumpListFromExplorer();
46+
JumpListManager.Default.PullJumpListFromExplorer();
4747
});
4848
}
4949
}

src/Files.App.CsWin32/Extras.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/Files.App.CsWin32/HRESULT.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ public readonly HRESULT ThrowIfFailedOnDebug()
2121

2222
return this;
2323
}
24+
25+
// #define E_NOT_SET HRESULT_FROM_WIN32(ERROR_NOT_FOUND)
26+
public static readonly HRESULT E_NOT_SET = (HRESULT)(-2147023728);
2427
}
2528
}

src/Files.App.CsWin32/IAutomaticDestinationList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public HRESULT PinItem(IUnknown* pUnk, int index)
8181
/// </remarks>
8282
/// <param name="punk">The native object to get its index in the list.</param>
8383
/// <param name="piIndex">A pointer that points to an int value that takes the index of the item passed.</param>
84-
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise. If the passed item doesn't belong to the <see cref="DESTLISTTYPE.PINNED"/> list, HRESULT.E_NOT_SET is returned.</returns>
84+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise. If the passed item doesn't belong to the <see cref="DESTLISTTYPE.PINNED"/> list, <see cref="HRESULT.E_NOT_SET"/> is returned.</returns>
8585
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8686
public HRESULT GetPinIndex(IUnknown* punk, int* piIndex)
8787
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, int*, int>)lpVtbl[8])
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using System.Runtime.InteropServices;
5+
using System.Runtime.InteropServices.Marshalling;
6+
7+
namespace Windows.Win32
8+
{
9+
namespace Extras
10+
{
11+
[GeneratedComInterface, Guid("EACDD04C-117E-4E17-88F4-D1B12B0E3D89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
12+
public partial interface IDCompositionTarget
13+
{
14+
[PreserveSig]
15+
int SetRoot(nint visual);
16+
}
17+
}
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace Windows.Win32
5+
{
6+
public unsafe static partial class PInvoke
7+
{
8+
public const int PixelFormat32bppARGB = 2498570;
9+
}
10+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using System.Runtime.InteropServices;
5+
using Windows.Win32.Foundation;
6+
7+
namespace Windows.Win32
8+
{
9+
namespace Graphics.Gdi
10+
{
11+
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
12+
public unsafe delegate BOOL MONITORENUMPROC([In] HMONITOR param0, [In] HDC param1, [In][Out] RECT* param2, [In] LPARAM param3);
13+
}
14+
15+
namespace UI.WindowsAndMessaging
16+
{
17+
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
18+
public delegate LRESULT WNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam);
19+
}
20+
}

src/Files.App.CsWin32/ManualGuids.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public static Guid* IID_IStorageProviderStatusUISourceFactory
8080

8181
[GuidRVAGen.Guid("000214F4-0000-0000-C000-000000000046")]
8282
public static partial Guid* IID_IContextMenu2 { get; }
83+
84+
[GuidRVAGen.Guid("92CA9DCD-5622-4BBA-A805-5E9F541BD8C9")]
85+
public static partial Guid* IID_IObjectArray { get; }
8386
}
8487

8588
public static unsafe partial class CLSID
@@ -113,6 +116,12 @@ public static unsafe partial class CLSID
113116

114117
[GuidRVAGen.Guid("D969A300-E7FF-11d0-A93B-00A0C90F2719")]
115118
public static partial Guid* CLSID_NewMenu { get; }
119+
120+
[GuidRVAGen.Guid("2D3468C1-36A7-43B6-AC24-D3F02FD9607A")]
121+
public static partial Guid* CLSID_EnumerableObjectCollection { get; }
122+
123+
[GuidRVAGen.Guid("00021401-0000-0000-C000-000000000046")]
124+
public static partial Guid* CLSID_ShellLink { get; }
116125
}
117126

118127
public static unsafe partial class BHID

src/Files.App.CsWin32/ManualMacros.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
global using static global::Windows.Win32.ManualMacros;
5+
46
using Windows.Win32.Foundation;
57

68
namespace Windows.Win32
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using System.Runtime.InteropServices;
5+
using Windows.Win32.Foundation;
6+
using Windows.Win32.System.Com.StructuredStorage;
7+
using Windows.Win32.System.Variant;
8+
using Windows.Win32.UI.WindowsAndMessaging;
9+
10+
namespace Windows.Win32
11+
{
12+
public unsafe static partial class PInvoke
13+
{
14+
public static HRESULT InitPropVariantFromString(char* psz, PROPVARIANT* ppropvar)
15+
{
16+
HRESULT hr = psz != null ? HRESULT.S_OK : HRESULT.E_INVALIDARG;
17+
18+
if (SUCCEEDED(hr))
19+
{
20+
nuint byteCount = (nuint)((MemoryMarshal.CreateReadOnlySpanFromNullTerminated(psz).Length + 1) * 2);
21+
22+
((ppropvar)->Anonymous.Anonymous.Anonymous.pwszVal) = (char*)(PInvoke.CoTaskMemAlloc(byteCount));
23+
hr = ((ppropvar)->Anonymous.Anonymous.Anonymous.pwszVal) != null ? HRESULT.S_OK : HRESULT.E_OUTOFMEMORY;
24+
if (SUCCEEDED(hr))
25+
{
26+
NativeMemory.Copy(psz, ((ppropvar)->Anonymous.Anonymous.Anonymous.pwszVal), unchecked(byteCount));
27+
((ppropvar)->Anonymous.Anonymous.vt) = VARENUM.VT_LPWSTR;
28+
}
29+
}
30+
31+
if (FAILED(hr))
32+
{
33+
PInvoke.PropVariantInit(ppropvar);
34+
}
35+
36+
return hr;
37+
}
38+
39+
public static void PropVariantInit(PROPVARIANT* pvar)
40+
{
41+
NativeMemory.Fill(pvar, (uint)(sizeof(PROPVARIANT)), 0);
42+
}
43+
44+
public static unsafe nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong)
45+
{
46+
// NOTE:
47+
// Since CsWin32 generates SetWindowLong only on x86, and SetWindowLongPtr only on x64,
48+
// we need to manually define both functions here.
49+
// For more info, visit https://github.com/microsoft/CsWin32/issues/882
50+
return sizeof(nint) is 4
51+
? _SetWindowLong(hWnd, (int)nIndex, (int)dwNewLong)
52+
: _SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
53+
54+
[DllImport("User32", EntryPoint = "SetWindowLongW", ExactSpelling = true)]
55+
static extern int _SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);
56+
57+
[DllImport("User32", EntryPoint = "SetWindowLongPtrW", ExactSpelling = true)]
58+
static extern nint _SetWindowLongPtr(HWND hWnd, int nIndex, nint dwNewLong);
59+
}
60+
61+
[LibraryImport("Shell32.dll", EntryPoint = "SHUpdateRecycleBinIcon")]
62+
public static partial void SHUpdateRecycleBinIcon();
63+
}
64+
}

0 commit comments

Comments
 (0)