Skip to content

Fix the clipboard built-in #527

Open
@zadjii-msft

Description

@zadjii-msft

I think after #518, I really messed up the clipboard built-in extension.

Everything gets a -2147221008 / CO_E_NOTINITIALIZED now.

Details

This looks vaguely like microsoft/WindowsAppSDK#3932 which suggests doing

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]

private static extern IntPtr CreateEvent(
IntPtr lpEventAttributes, bool bManualReset,
bool bInitialState, string lpName);

[DllImport("kernel32.dll")]
private static extern bool SetEvent(IntPtr hEvent);

[DllImport("ole32.dll")]
private static extern uint CoWaitForMultipleObjects(
uint dwFlags, uint dwMilliseconds, ulong nHandles,
IntPtr[] pHandles, out uint dwIndex);

private static IntPtr redirectEventHandle = IntPtr.Zero;

// Do the redirection on another thread, and use a non-blocking
// wait method to wait for the redirection to complete.
public static void RedirectActivationTo(AppActivationArguments args, AppInstance keyInstance)
{
redirectEventHandle = CreateEvent(IntPtr.Zero, true, false, null);
Task.Run(() =>
{
keyInstance.RedirectActivationToAsync(args).AsTask().Wait();
SetEvent(redirectEventHandle);
});
uint CWMO_DEFAULT = 0;
uint INFINITE = 0xFFFFFFFF;
_ = CoWaitForMultipleObjects(
CWMO_DEFAULT, INFINITE, 1,
new IntPtr[] { redirectEventHandle }, out uint handleIndex);
}

but I don't think I have time to validate that right now, so I'm just disabling it for now

Ah fuck everything about the WinRT clipboard sucks.

microsoft/windows-rs#317
microsoft/terminal#17006

I idly wonder if the clipboard extension as a separate process would just fix it. Either way, we gotta fix this in the toolkit it would seem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions