common: refactor common library pt2 (#8588)

- remove common lib
- split settings, remove common-md
- move ipc interop/kb_layout to interop
- rename core -> settings, settings -> old_settings
- os-detect header-only; interop -> PowerToysInterop
- split notifications, move single-use headers where they're used
- winstore lib
- rename com utils
- rename Updating and Telemetry projects
- rename core -> settings-ui and remove examples folder
- rename settings-ui folder + consisent common/version include
This commit is contained in:
Andrey Nekrasov
2020-12-15 15:16:09 +03:00
committed by GitHub
parent cddf48547d
commit 212ea2de30
588 changed files with 3304 additions and 3328 deletions

View File

@@ -1,13 +1,16 @@
#include "pch.h"
#include "Helpers.h"
#include <sstream>
#include "../common/shared_constants.h"
#include <common/interop/keyboard_layout.h>
#include <common/interop/shared_constants.h>
#include <common/utils/process_path.h>
#include <common/utils/resources.h>
#include <shlwapi.h>
#include "../../common/common.h"
#include "keyboardmanager/dll/Generated Files/resource.h"
#include "../common/keyboard_layout.h"
#include <common/interop/keyboard_layout.h>
#include "KeyboardManagerConstants.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
using namespace winrt::Windows::Foundation;
@@ -196,7 +199,7 @@ namespace KeyboardManagerHelper
}
keyEventArray[index].ki.dwExtraInfo = extraInfo;
// Set wScan to the value from MapVirtualKey as some applications may use the scan code for handling input, for instance, Windows Terminal ignores non-character input which has scancode set to 0.
// Set wScan to the value from MapVirtualKey as some applications may use the scan code for handling input, for instance, Windows Terminal ignores non-character input which has scancode set to 0.
// MapVirtualKey returns 0 if the key code does not correspond to a physical key (such as unassigned/reserved keys). More details at https://github.com/microsoft/PowerToys/pull/7143#issue-498877747
keyEventArray[index].ki.wScan = (WORD)MapVirtualKey(keyCode, MAPVK_VK_TO_VSC);
}

View File

@@ -4,7 +4,7 @@
#include <queue>
#include <mutex>
#include <LowlevelKeyboardEvent.h>
#include <common/hooks/LowlevelKeyboardEvent.h>
// Available states for the KeyDelay state machine.
enum class KeyDelayState
{

View File

@@ -31,20 +31,20 @@
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;..\..\..\common;..\..\..\common\telemetry;..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\;..\..\..\;..\..\..\common\telemetry;..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4002</DisableSpecificWarnings>
<AdditionalOptions>%(AdditionalOptions) /Zm200</AdditionalOptions>
</ClCompile>
<Lib>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
</Lib>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\common\interop\keyboard_layout.cpp" />
<ClCompile Include="Helpers.cpp" />
<ClCompile Include="KeyboardManagerState.cpp" />
<ClCompile Include="KeyDelay.cpp" />
@@ -68,8 +68,11 @@
<ClInclude Include="trace.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\common.vcxproj">
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
<ProjectReference Include="..\..\..\common\COMUtils\COMUtils.vcxproj">
<Project>{7319089e-46d6-4400-bc65-e39bdf1416ee}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\common\Display\Display.vcxproj">
<Project>{caba8dfb-823b-4bf2-93ac-3f31984150d9}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>

View File

@@ -36,6 +36,9 @@
<ClCompile Include="Trace.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\common\interop\keyboard_layout.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="KeyboardManagerState.h">

View File

@@ -1,9 +1,8 @@
#pragma once
#include <string>
#include <winrt/base.h>
#include "../../common/common.h"
#include <common/utils/resources.h>
#include "keyboardmanager/dll/Generated Files/resource.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
namespace KeyboardManagerConstants
{

View File

@@ -2,7 +2,7 @@
#include "KeyboardManagerState.h"
#include "Shortcut.h"
#include "RemapShortcut.h"
#include <../common/settings_helpers.h>
#include <common/SettingsAPI/settings_helpers.h>
#include "KeyDelay.h"
#include "Helpers.h"

View File

@@ -1,8 +1,8 @@
#pragma once
#include <mutex>
#include "KeyboardManagerConstants.h"
#include "../common/keyboard_layout.h"
#include "../common/LowlevelKeyboardEvent.h"
#include <common/interop/keyboard_layout.h>
#include "../common/hooks/LowlevelKeyboardEvent.h"
#include <functional>
#include <variant>
#include "Shortcut.h"

View File

@@ -1,7 +1,7 @@
#include "pch.h"
#include "Shortcut.h"
#include "../common/keyboard_layout.h"
#include "../common/shared_constants.h"
#include <common/interop/keyboard_layout.h>
#include <common/interop/shared_constants.h>
#include "Helpers.h"
#include "InputInterface.h"

View File

@@ -2,7 +2,7 @@
#include "KeyboardEventHandlers.h"
#include "keyboardmanager/common/Shortcut.h"
#include "keyboardmanager/common/RemapShortcut.h"
#include "../common/shared_constants.h"
#include <common/interop/shared_constants.h>
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/common/InputInterface.h>
#include <keyboardmanager/common/Helpers.h>

View File

@@ -3,7 +3,7 @@
#include <mutex>
#include "keyboardmanager/common/KeyboardManagerConstants.h"
#include <common/LowlevelKeyboardEvent.h>
#include <common/hooks/LowlevelKeyboardEvent.h>
class InputInterface;
class KeyboardManagerState;

View File

@@ -1,6 +1,6 @@
#include <windows.h>
#include "resource.h"
#include "../../../../common/version.h"
#include "../../../../common/version/version.h"
#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"

View File

@@ -58,8 +58,8 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)src\common\common.vcxproj">
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
<ProjectReference Include="..\..\..\common\SettingsAPI\SetttingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
<ProjectReference Include="..\common\KeyboardManagerCommon.vcxproj">
<Project>{8affa899-0b73-49ec-8c50-0fadda57b2fc}</Project>

View File

@@ -1,7 +1,7 @@
#include "pch.h"
#include <interface/powertoy_module_interface.h>
#include <common/settings_objects.h>
#include <common/shared_constants.h>
#include <common/SettingsAPI/settings_objects.h>
#include <common/interop/shared_constants.h>
#include "Generated Files/resource.h"
#include <keyboardmanager/ui/EditKeyboardWindow.h>
#include <keyboardmanager/ui/EditShortcutsWindow.h>
@@ -9,15 +9,14 @@
#include <keyboardmanager/common/Shortcut.h>
#include <keyboardmanager/common/RemapShortcut.h>
#include <keyboardmanager/common/KeyboardManagerConstants.h>
#include <common/settings_helpers.h>
#include <common/debug_control.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/utils/winapi_error.h>
#include <keyboardmanager/common/trace.h>
#include <keyboardmanager/common/Helpers.h>
#include "KeyboardEventHandlers.h"
#include "Input.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)

View File

@@ -4,14 +4,14 @@
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/dll/KeyboardEventHandlers.h>
#include "TestHelpers.h"
#include <common/shared_constants.h>
#include <common/interop/shared_constants.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace RemappingLogicTests
{
TEST_CLASS (AppSpecificShortcutRemappingTests)
{
private:
MockedInput mockedInputHandler;

View File

@@ -2,8 +2,8 @@
#include "CppUnitTest.h"
#include <keyboardmanager/ui/BufferValidationHelpers.h>
#include "TestHelpers.h"
#include <common/keyboard_layout.h>
#include <common/shared_constants.h>
#include <common/interop/keyboard_layout.h>
#include <common/interop/shared_constants.h>
#include <functional>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

View File

@@ -2,7 +2,7 @@
#include "CppUnitTest.h"
#include <keyboardmanager/common/Helpers.h>
#include "TestHelpers.h"
#include <common/keyboard_layout.h>
#include <common/interop/keyboard_layout.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

View File

@@ -1,6 +1,6 @@
#include <windows.h>
#include "resource.h"
#include "../../../common/version.h"
#include "../../../common/version/version.h"
1 VERSIONINFO
FILEVERSION FILE_VERSION

View File

@@ -64,6 +64,9 @@
<ClInclude Include="TestHelpers.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\SettingsAPI\SetttingsAPI.vcxproj">
<Project>{6955446d-23f7-4023-9bb3-8657f904af99}</Project>
</ProjectReference>
<ProjectReference Include="..\common\KeyboardManagerCommon.vcxproj">
<Project>{8affa899-0b73-49ec-8c50-0fadda57b2fc}</Project>
</ProjectReference>

View File

@@ -3,7 +3,7 @@
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/ui/LoadingAndSavingRemappingHelper.h>
#include "TestHelpers.h"
#include "../common/shared_constants.h"
#include <common/interop/shared_constants.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

View File

@@ -3,7 +3,7 @@
#include <vector>
#include <functional>
#include <common/LowlevelKeyboardEvent.h>
#include <common/hooks/LowlevelKeyboardEvent.h>
// Class for mocked keyboard input
class MockedInput :

View File

@@ -4,7 +4,7 @@
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/dll/KeyboardEventHandlers.h>
#include "TestHelpers.h"
#include "../common/shared_constants.h"
#include <common/interop/shared_constants.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

View File

@@ -3,7 +3,7 @@
#include <keyboardmanager/common/Shortcut.h>
#include <keyboardmanager/common/Helpers.h>
#include "TestHelpers.h"
#include "../common/keyboard_layout.h"
#include <common/interop/keyboard_layout.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

View File

@@ -4,7 +4,7 @@
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/dll/KeyboardEventHandlers.h>
#include "TestHelpers.h"
#include "../common/shared_constants.h"
#include <common/interop/shared_constants.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

View File

@@ -1,5 +1 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

View File

@@ -1,7 +1,7 @@
#pragma once
#pragma comment(lib, "shlwapi.lib")
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Windows.h>
#include <ProjectTelemetry.h>
#include <shlwapi.h>
#include <stdexcept>

View File

@@ -1,7 +1,7 @@
#include "pch.h"
#include "BufferValidationHelpers.h"
#include <keyboardmanager/common/KeyboardManagerConstants.h>
#include <common/shared_constants.h>
#include <common/interop/shared_constants.h>
#include <modules\keyboardmanager\ui\KeyDropDownControl.h>
namespace BufferValidationHelpers

View File

@@ -1,9 +1,8 @@
#include "pch.h"
#include "Dialog.h"
#include <set>
#include <common/common.h>
#include "keyboardmanager/dll/Generated Files/resource.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
#include <common/utils/resources.h>
using namespace winrt::Windows::Foundation;

View File

@@ -6,17 +6,15 @@
#include <keyboardmanager/common/trace.h>
#include <keyboardmanager/common/KeyboardManagerConstants.h>
#include <set>
#include <common/common.h>
#include <common/windows_colors.h>
#include <common/dpi_aware.h>
#include <common/themes/windows_colors.h>
#include <common/display/dpi_aware.h>
#include "Styles.h"
#include "Dialog.h"
#include <keyboardmanager/dll/Generated Files/resource.h>
#include "../common/shared_constants.h"
#include <common/interop/shared_constants.h>
#include "keyboardmanager/common/KeyboardManagerState.h"
#include "LoadingAndSavingRemappingHelper.h"
#include "UIHelpers.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
using namespace winrt::Windows::Foundation;

View File

@@ -5,16 +5,14 @@
#include "XamlBridge.h"
#include <keyboardmanager/common/trace.h>
#include <keyboardmanager/common/KeyboardManagerConstants.h>
#include <common/common.h>
#include <common/windows_colors.h>
#include <common/dpi_aware.h>
#include <common/themes/windows_colors.h>
#include <common/display/dpi_aware.h>
#include "Styles.h"
#include "Dialog.h"
#include <keyboardmanager/dll/Generated Files/resource.h>
#include <keyboardmanager/common/KeyboardManagerState.h>
#include "LoadingAndSavingRemappingHelper.h"
#include "UIHelpers.h"
extern "C" IMAGE_DOS_HEADER __ImageBase;
using namespace winrt::Windows::Foundation;

View File

@@ -3,9 +3,9 @@
#include "keyboardmanager/common/Helpers.h"
#include <keyboardmanager/common/KeyboardManagerState.h>
#include "BufferValidationHelpers.h"
#include <common/shared_constants.h>
#include <common/keyboard_layout_impl.h>
#include <modules\keyboardmanager\common\Helpers.h>
#include <common/interop/shared_constants.h>
#include <common/interop/keyboard_layout_impl.h>
#include <modules/keyboardmanager/common/Helpers.h>
// Initialized to null
KeyboardManagerState* KeyDropDownControl::keyboardManagerState = nullptr;
@@ -143,7 +143,7 @@ std::pair<KeyboardManagerHelper::ErrorType, int> KeyDropDownControl::ValidateSho
uint32_t dropDownIndex = -1;
bool dropDownFound = parent.Children().IndexOf(currentDropDown, dropDownIndex);
std::pair<KeyboardManagerHelper::ErrorType, BufferValidationHelpers::DropDownAction> validationResult = std::make_pair(KeyboardManagerHelper::ErrorType::NoError, BufferValidationHelpers::DropDownAction::NoAction);
uint32_t rowIndex;
bool controlIindexFound = table.Children().IndexOf(row, rowIndex);
if (controlIindexFound)
@@ -368,7 +368,7 @@ void KeyDropDownControl::SetDropDownError(ComboBox currentDropDown, hstring mess
}
// Function to add a shortcut to the UI control as combo boxes
void KeyDropDownControl::AddShortcutToControl(Shortcut shortcut, StackPanel table, StackPanel parent, KeyboardManagerState& keyboardManagerState, const int colIndex, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects, RemapBuffer& remapBuffer, StackPanel row, TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow)
void KeyDropDownControl::AddShortcutToControl(Shortcut shortcut, StackPanel table, StackPanel parent, KeyboardManagerState& keyboardManagerState, const int colIndex, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects, RemapBuffer& remapBuffer, StackPanel row, TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow)
{
// Delete the existing drop down menus
parent.Children().Clear();

View File

@@ -75,8 +75,8 @@
<ClInclude Include="XamlBridge.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\common\KeyboardManagerCommon.vcxproj">
<Project>{8affa899-0b73-49ec-8c50-0fadda57b2fc}</Project>
<ProjectReference Include="..\..\..\common\Themes\Themes.vcxproj">
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>

View File

@@ -1,7 +1,7 @@
#include "pch.h"
#include "LoadingAndSavingRemappingHelper.h"
#include <set>
#include "../common/shared_constants.h"
#include <common/interop/shared_constants.h>
#include <keyboardmanager/common/KeyboardManagerState.h>
#include <keyboardmanager/common/trace.h>

View File

@@ -3,10 +3,8 @@
#include "KeyDropDownControl.h"
#include "keyboardmanager/common/KeyboardManagerState.h"
#include "keyboardmanager/common/Helpers.h"
#include <common/common.h>
#include "keyboardmanager/dll/Generated Files/resource.h"
#include <common/shared_constants.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
#include <common/interop/shared_constants.h>
//Both static members are initialized to null
HWND ShortcutControl::EditShortcutsWindowHandle = nullptr;
@@ -76,8 +74,8 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
newrow.emplace_back(std::make_unique<ShortcutControl>(parent, row, 0, targetAppTextBox));
newrow.emplace_back(std::make_unique<ShortcutControl>(parent, row, 1, targetAppTextBox));
keyboardRemapControlObjects.push_back(std::move(newrow));
row.Padding({10, 10, 10, 10});
row.Padding({ 10, 10, 10, 10 });
row.Orientation(Orientation::Horizontal);
auto brush = Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundListLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>();
if (keyboardRemapControlObjects.size() % 2)
@@ -124,7 +122,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
{
return;
}
// rowIndex could be out of bounds if the the row got deleted after LostFocus handler was invoked. In this case it should return
if (rowIndex >= keyboardRemapControlObjects.size())
{
@@ -206,9 +204,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
row.Background(i % 2 ? brush : Media::SolidColorBrush(Colors::Transparent()));
StackPanel sourceCol = row.Children().GetAt(0).as<StackPanel>();
StackPanel targetCol = row.Children().GetAt(2).as<StackPanel>();
TextBox targetApp = row.Children().GetAt(3).as<StackPanel>()
.Children().GetAt(0).as<StackPanel>()
.Children().GetAt(0).as<TextBox>();
TextBox targetApp = row.Children().GetAt(3).as<StackPanel>().Children().GetAt(0).as<StackPanel>().Children().GetAt(0).as<TextBox>();
Button delButton = row.Children().GetAt(4).as<StackPanel>().Children().GetAt(0).as<Button>();
UpdateAccessibleNames(sourceCol, targetCol, targetApp, delButton, i);
}

View File

@@ -4,10 +4,8 @@
#include "keyboardmanager/common/KeyboardManagerConstants.h"
#include "keyboardmanager/common/KeyboardManagerState.h"
#include "ShortcutControl.h"
#include <common/common.h>
#include "keyboardmanager/dll/Generated Files/resource.h"
#include <common/shared_constants.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
#include <common/interop/shared_constants.h>
//Both static members are initialized to null
HWND SingleKeyRemapControl::EditKeyboardWindowHandle = nullptr;
@@ -80,7 +78,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
newrow.emplace_back(std::make_unique<SingleKeyRemapControl>(parent, row, 1));
keyboardRemapControlObjects.push_back(std::move(newrow));
row.Padding({10, 10, 10, 10});
row.Padding({ 10, 10, 10, 10 });
row.Orientation(Orientation::Horizontal);
auto brush = Windows::UI::Xaml::Application::Current().Resources().Lookup(box_value(L"SystemControlBackgroundListLowBrush")).as<Windows::UI::Xaml::Media::SolidColorBrush>();
if (keyboardRemapControlObjects.size() % 2)
@@ -147,7 +145,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
{
return;
}
// Update accessible names and background for each row after the deleted row
for (uint32_t i = rowIndex + 1; i < children.Size(); i++)
{

View File

@@ -1,6 +1,6 @@
#include "pch.h"
#include "Styles.h"
#include <common/windows_colors.h>
#include <common/themes/windows_colors.h>
Style AccentButtonStyle()
{