-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor]Port C++/CX to C++/WinRT (#34198)
## Summary of the Pull Request Removes all C++/CX code, replacing it with C++/WinRT. ## Detailed Description of the Pull Request / Additional comments Removes all C++/CX code. Renames interop namespaces to be better consumed by CsWinRT. Standardizes all projects on net8.0-windows10.0.20348.0, which is a requirement for C++/WinRT usage. FileLocksmithLibInterop brought to stdcpplatest and static analysis errors were corrected. Removed now unneeded string conversion code from FileLocksmithLibInterop. Changed interop KeyboardHook to use a single hook across all instances. Required because on C++/WinRT we don't have the .NET runtime to bind a object instance to a delegate and be able to pass it to a C function pointer argument (still no idea why this worked correctly on C++/CX to be honest). This change actually makes us create less low level keyboard hooks. Changed some code that depended on arrays since WinRT/C++ returns null instead of an empty array through the interface. ## Validation Steps Performed Built and tested runtime.
- Loading branch information
1 parent
b16e82c
commit fb5ed13
Showing
136 changed files
with
1,486 additions
and
1,094 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "pch.h" | ||
#include "CommonManaged.h" | ||
#include "CommonManaged.g.cpp" | ||
#include <common/version/version.h> | ||
#include "../../modules/videoconference/VideoConferenceShared/MicrophoneDevice.h" | ||
#include "../../modules/videoconference/VideoConferenceShared/VideoCaptureDeviceList.h" | ||
|
||
namespace winrt::PowerToys::Interop::implementation | ||
{ | ||
hstring CommonManaged::GetProductVersion() | ||
{ | ||
return hstring{ get_product_version() }; | ||
} | ||
winrt::Windows::Foundation::Collections::IVector<hstring> CommonManaged::GetAllActiveMicrophoneDeviceNames() | ||
{ | ||
auto names = std::vector<winrt::hstring>(); | ||
for (const auto& device : MicrophoneDevice::getAllActive()) | ||
{ | ||
names.push_back(device->name().data()); | ||
} | ||
return winrt::multi_threaded_vector(std::move(names)); | ||
} | ||
winrt::Windows::Foundation::Collections::IVector<hstring> CommonManaged::GetAllVideoCaptureDeviceNames() | ||
{ | ||
auto names = std::vector<winrt::hstring>(); | ||
VideoCaptureDeviceList vcdl; | ||
vcdl.EnumerateDevices(); | ||
|
||
for (UINT32 i = 0; i < vcdl.Count(); ++i) | ||
{ | ||
auto name = vcdl.GetDeviceName(i).data(); | ||
if (name != L"PowerToys VideoConference Mute") | ||
{ | ||
names.push_back(name); | ||
} | ||
} | ||
return winrt::multi_threaded_vector(std::move(names)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "CommonManaged.g.h" | ||
|
||
namespace winrt::PowerToys::Interop::implementation | ||
{ | ||
struct CommonManaged : CommonManagedT<CommonManaged> | ||
{ | ||
CommonManaged() = default; | ||
|
||
static hstring GetProductVersion(); | ||
static winrt::Windows::Foundation::Collections::IVector<hstring> GetAllActiveMicrophoneDeviceNames(); | ||
static winrt::Windows::Foundation::Collections::IVector<hstring> GetAllVideoCaptureDeviceNames(); | ||
}; | ||
} | ||
namespace winrt::PowerToys::Interop::factory_implementation | ||
{ | ||
struct CommonManaged : CommonManagedT<CommonManaged, implementation::CommonManaged> | ||
{ | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace PowerToys | ||
{ | ||
namespace Interop | ||
{ | ||
[default_interface] static runtimeclass CommonManaged { | ||
static String GetProductVersion(); | ||
static Windows.Foundation.Collections.IVector<String> GetAllActiveMicrophoneDeviceNames(); | ||
static Windows.Foundation.Collections.IVector<String> GetAllVideoCaptureDeviceNames(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#include "pch.h" | ||
#include "Constants.h" | ||
#include "Constants.g.cpp" | ||
#include "shared_constants.h" | ||
#include <ShlObj.h> | ||
|
||
namespace winrt::PowerToys::Interop::implementation | ||
{ | ||
uint32_t Constants::VK_WIN_BOTH() | ||
{ | ||
return CommonSharedConstants::VK_WIN_BOTH; | ||
} | ||
hstring Constants::AppDataPath() | ||
{ | ||
PWSTR local_app_path; | ||
winrt::check_hresult(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &local_app_path)); | ||
winrt::hstring result{ local_app_path }; | ||
CoTaskMemFree(local_app_path); | ||
result = result + L"\\" + CommonSharedConstants::APPDATA_PATH; | ||
return result; | ||
} | ||
hstring Constants::PowerLauncherSharedEvent() | ||
{ | ||
return CommonSharedConstants::POWER_LAUNCHER_SHARED_EVENT; | ||
} | ||
hstring Constants::PowerLauncherCentralizedHookSharedEvent() | ||
{ | ||
return CommonSharedConstants::POWER_LAUNCHER_CENTRALIZED_HOOK_SHARED_EVENT; | ||
} | ||
hstring Constants::RunSendSettingsTelemetryEvent() | ||
{ | ||
return CommonSharedConstants::RUN_SEND_SETTINGS_TELEMETRY_EVENT; | ||
} | ||
hstring Constants::RunExitEvent() | ||
{ | ||
return CommonSharedConstants::RUN_EXIT_EVENT; | ||
} | ||
hstring Constants::FZEExitEvent() | ||
{ | ||
return CommonSharedConstants::FZE_EXIT_EVENT; | ||
} | ||
hstring Constants::FZEToggleEvent() | ||
{ | ||
return CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT; | ||
} | ||
hstring Constants::ColorPickerSendSettingsTelemetryEvent() | ||
{ | ||
return CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT; | ||
} | ||
hstring Constants::ShowColorPickerSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_COLOR_PICKER_SHARED_EVENT; | ||
} | ||
hstring Constants::ShowAdvancedPasteSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_ADVANCED_PASTE_SHARED_EVENT; | ||
} | ||
hstring Constants::AdvancedPasteMarkdownEvent() | ||
{ | ||
return CommonSharedConstants::ADVANCED_PASTE_MARKDOWN_EVENT; | ||
} | ||
hstring Constants::AdvancedPasteJsonEvent() | ||
{ | ||
return CommonSharedConstants::ADVANCED_PASTE_JSON_EVENT; | ||
} | ||
hstring Constants::ShowPowerOCRSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_POWEROCR_SHARED_EVENT; | ||
} | ||
hstring Constants::MouseJumpShowPreviewEvent() | ||
{ | ||
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT; | ||
} | ||
hstring Constants::AwakeExitEvent() | ||
{ | ||
return CommonSharedConstants::AWAKE_EXIT_EVENT; | ||
} | ||
hstring Constants::ShowPeekEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_PEEK_SHARED_EVENT; | ||
} | ||
hstring Constants::PowerAccentExitEvent() | ||
{ | ||
return CommonSharedConstants::POWERACCENT_EXIT_EVENT; | ||
} | ||
hstring Constants::ShortcutGuideTriggerEvent() | ||
{ | ||
return CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT; | ||
} | ||
hstring Constants::RegistryPreviewTriggerEvent() | ||
{ | ||
return CommonSharedConstants::REGISTRY_PREVIEW_TRIGGER_EVENT; | ||
} | ||
hstring Constants::MeasureToolTriggerEvent() | ||
{ | ||
return CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT; | ||
} | ||
hstring Constants::GcodePreviewResizeEvent() | ||
{ | ||
return CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT; | ||
} | ||
hstring Constants::QoiPreviewResizeEvent() | ||
{ | ||
return CommonSharedConstants::QOI_PREVIEW_RESIZE_EVENT; | ||
} | ||
hstring Constants::DevFilesPreviewResizeEvent() | ||
{ | ||
return CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT; | ||
} | ||
hstring Constants::MarkdownPreviewResizeEvent() | ||
{ | ||
return CommonSharedConstants::MARKDOWN_PREVIEW_RESIZE_EVENT; | ||
} | ||
hstring Constants::PdfPreviewResizeEvent() | ||
{ | ||
return CommonSharedConstants::PDF_PREVIEW_RESIZE_EVENT; | ||
} | ||
hstring Constants::SvgPreviewResizeEvent() | ||
{ | ||
return CommonSharedConstants::SVG_PREVIEW_RESIZE_EVENT; | ||
} | ||
hstring Constants::ShowHostsSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_HOSTS_EVENT; | ||
} | ||
hstring Constants::ShowHostsAdminSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_HOSTS_ADMIN_EVENT; | ||
} | ||
hstring Constants::CropAndLockThumbnailEvent() | ||
{ | ||
return CommonSharedConstants::CROP_AND_LOCK_THUMBNAIL_EVENT; | ||
} | ||
hstring Constants::CropAndLockReparentEvent() | ||
{ | ||
return CommonSharedConstants::CROP_AND_LOCK_REPARENT_EVENT; | ||
} | ||
hstring Constants::ShowEnvironmentVariablesSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_EVENT; | ||
} | ||
hstring Constants::ShowEnvironmentVariablesAdminSharedEvent() | ||
{ | ||
return CommonSharedConstants::SHOW_ENVIRONMENT_VARIABLES_ADMIN_EVENT; | ||
} | ||
} |
Oops, something went wrong.