Skip to content

Commit 92db590

Browse files
committed
Fix HotkeyControl virtual key display
* A new interop project was setup to provide wrappers for C# projects that want to access functionality in the common project.
1 parent d45c474 commit 92db590

32 files changed

+967
-350
lines changed

PowerToys.sln

+14
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Setting
209209
EndProject
210210
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerToys.Settings.UnitTest", "src\core\Microsoft.PowerToys.Settings.UnitTest\Microsoft.PowerToys.Settings.UnitTest.csproj", "{A80355C2-780D-4245-BD80-25B8DE698EE3}"
211211
EndProject
212+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "interop", "src\common\interop\interop.vcxproj", "{F055103B-F80B-4D0C-BF48-057C55620033}"
213+
EndProject
214+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common-md-flag", "src\common\common-md-flag\common-md-flag.vcxproj", "{985B3F2F-CEED-4C0A-A249-69257E719145}"
215+
EndProject
212216
Global
213217
GlobalSection(SolutionConfigurationPlatforms) = preSolution
214218
Debug|x64 = Debug|x64
@@ -393,6 +397,14 @@ Global
393397
{A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.ActiveCfg = Release|x64
394398
{A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.Build.0 = Release|x64
395399
{A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.Deploy.0 = Release|x64
400+
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.ActiveCfg = Debug|x64
401+
{F055103B-F80B-4D0C-BF48-057C55620033}.Debug|x64.Build.0 = Debug|x64
402+
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x64.ActiveCfg = Release|x64
403+
{F055103B-F80B-4D0C-BF48-057C55620033}.Release|x64.Build.0 = Release|x64
404+
{985B3F2F-CEED-4C0A-A249-69257E719145}.Debug|x64.ActiveCfg = Debug|x64
405+
{985B3F2F-CEED-4C0A-A249-69257E719145}.Debug|x64.Build.0 = Debug|x64
406+
{985B3F2F-CEED-4C0A-A249-69257E719145}.Release|x64.ActiveCfg = Release|x64
407+
{985B3F2F-CEED-4C0A-A249-69257E719145}.Release|x64.Build.0 = Release|x64
396408
EndGlobalSection
397409
GlobalSection(SolutionProperties) = preSolution
398410
HideSolutionNode = FALSE
@@ -446,6 +458,8 @@ Global
446458
{C073B057-B157-40F0-8678-1DCD119D841C} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
447459
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
448460
{A80355C2-780D-4245-BD80-25B8DE698EE3} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
461+
{F055103B-F80B-4D0C-BF48-057C55620033} = {1AFB6476-670D-4E80-A464-657E01DFF482}
462+
{985B3F2F-CEED-4C0A-A249-69257E719145} = {1AFB6476-670D-4E80-A464-657E01DFF482}
449463
EndGlobalSection
450464
GlobalSection(ExtensibilityGlobals) = postSolution
451465
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|x64">
5+
<Configuration>Debug</Configuration>
6+
<Platform>x64</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|x64">
9+
<Configuration>Release</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<VCProjectVersion>16.0</VCProjectVersion>
15+
<ProjectGuid>{985B3F2F-CEED-4C0A-A249-69257E719145}</ProjectGuid>
16+
<Keyword>Win32Proj</Keyword>
17+
<RootNamespace>commonmdflag</RootNamespace>
18+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
19+
</PropertyGroup>
20+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
22+
<ConfigurationType>StaticLibrary</ConfigurationType>
23+
<UseDebugLibraries>true</UseDebugLibraries>
24+
<PlatformToolset>v142</PlatformToolset>
25+
<CharacterSet>Unicode</CharacterSet>
26+
</PropertyGroup>
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
28+
<ConfigurationType>StaticLibrary</ConfigurationType>
29+
<UseDebugLibraries>false</UseDebugLibraries>
30+
<PlatformToolset>v142</PlatformToolset>
31+
<WholeProgramOptimization>true</WholeProgramOptimization>
32+
<CharacterSet>Unicode</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
35+
<ConfigurationType>StaticLibrary</ConfigurationType>
36+
<UseDebugLibraries>true</UseDebugLibraries>
37+
<PlatformToolset>v142</PlatformToolset>
38+
<CharacterSet>Unicode</CharacterSet>
39+
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
41+
<ConfigurationType>StaticLibrary</ConfigurationType>
42+
<UseDebugLibraries>false</UseDebugLibraries>
43+
<PlatformToolset>v142</PlatformToolset>
44+
<WholeProgramOptimization>true</WholeProgramOptimization>
45+
<CharacterSet>Unicode</CharacterSet>
46+
</PropertyGroup>
47+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
48+
<ImportGroup Label="ExtensionSettings">
49+
</ImportGroup>
50+
<ImportGroup Label="Shared">
51+
</ImportGroup>
52+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
53+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
54+
</ImportGroup>
55+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
56+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+
</ImportGroup>
58+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<PropertyGroup Label="UserMacros" />
65+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
66+
<LinkIncremental>false</LinkIncremental>
67+
</PropertyGroup>
68+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
69+
<LinkIncremental>true</LinkIncremental>
70+
</PropertyGroup>
71+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
72+
<LinkIncremental>true</LinkIncremental>
73+
</PropertyGroup>
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
75+
<LinkIncremental>false</LinkIncremental>
76+
</PropertyGroup>
77+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
78+
<ClCompile>
79+
<PrecompiledHeader>Use</PrecompiledHeader>
80+
<WarningLevel>Level3</WarningLevel>
81+
<FunctionLevelLinking>true</FunctionLevelLinking>
82+
<IntrinsicFunctions>true</IntrinsicFunctions>
83+
<SDLCheck>true</SDLCheck>
84+
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
85+
<ConformanceMode>true</ConformanceMode>
86+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
87+
</ClCompile>
88+
<Link>
89+
<SubSystem>Windows</SubSystem>
90+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
91+
<OptimizeReferences>true</OptimizeReferences>
92+
<GenerateDebugInformation>true</GenerateDebugInformation>
93+
</Link>
94+
</ItemDefinitionGroup>
95+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
96+
<ClCompile>
97+
<PrecompiledHeader>Use</PrecompiledHeader>
98+
<WarningLevel>Level3</WarningLevel>
99+
<SDLCheck>true</SDLCheck>
100+
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
101+
<ConformanceMode>true</ConformanceMode>
102+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
103+
</ClCompile>
104+
<Link>
105+
<SubSystem>Windows</SubSystem>
106+
<GenerateDebugInformation>true</GenerateDebugInformation>
107+
</Link>
108+
</ItemDefinitionGroup>
109+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
110+
<ClCompile>
111+
<PrecompiledHeader>Use</PrecompiledHeader>
112+
<WarningLevel>Level3</WarningLevel>
113+
<SDLCheck>true</SDLCheck>
114+
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115+
<ConformanceMode>true</ConformanceMode>
116+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
117+
<LanguageStandard>stdcpp17</LanguageStandard>
118+
</ClCompile>
119+
<Link>
120+
<SubSystem>Windows</SubSystem>
121+
<GenerateDebugInformation>true</GenerateDebugInformation>
122+
</Link>
123+
</ItemDefinitionGroup>
124+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
125+
<ClCompile>
126+
<PrecompiledHeader>Use</PrecompiledHeader>
127+
<WarningLevel>Level3</WarningLevel>
128+
<FunctionLevelLinking>true</FunctionLevelLinking>
129+
<IntrinsicFunctions>true</IntrinsicFunctions>
130+
<SDLCheck>true</SDLCheck>
131+
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
132+
<ConformanceMode>true</ConformanceMode>
133+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
134+
</ClCompile>
135+
<Link>
136+
<SubSystem>Windows</SubSystem>
137+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
138+
<OptimizeReferences>true</OptimizeReferences>
139+
<GenerateDebugInformation>true</GenerateDebugInformation>
140+
</Link>
141+
</ItemDefinitionGroup>
142+
<ItemGroup>
143+
<ClInclude Include="..\keyboard_layout.h" />
144+
<ClInclude Include="..\keyboard_layout_impl.h" />
145+
<ClInclude Include="framework.h" />
146+
<ClInclude Include="pch.h" />
147+
</ItemGroup>
148+
<ItemGroup>
149+
<ClCompile Include="..\keyboard_layout.cpp" />
150+
<ClCompile Include="pch.cpp">
151+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
152+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
153+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
154+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
155+
</ClCompile>
156+
</ItemGroup>
157+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
158+
<ImportGroup Label="ExtensionTargets">
159+
</ImportGroup>
160+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="framework.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="pch.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
<ClInclude Include="..\keyboard_layout.h">
25+
<Filter>Header Files</Filter>
26+
</ClInclude>
27+
<ClInclude Include="..\keyboard_layout_impl.h">
28+
<Filter>Header Files</Filter>
29+
</ClInclude>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ClCompile Include="pch.cpp">
33+
<Filter>Source Files</Filter>
34+
</ClCompile>
35+
<ClCompile Include="..\keyboard_layout.cpp">
36+
<Filter>Source Files</Filter>
37+
</ClCompile>
38+
</ItemGroup>
39+
</Project>

src/common/common-md-flag/framework.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

src/common/common-md-flag/pch.cpp

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

src/common/common-md-flag/pch.h

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// pch.h: This is a precompiled header file.
2+
// Files listed below are compiled only once, improving build performance for future builds.
3+
// This also affects IntelliSense performance, including code completion and many code browsing features.
4+
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
5+
// Do not add files here that you will be updating frequently as this negates the performance advantage.
6+
7+
#ifndef PCH_H
8+
#define PCH_H
9+
10+
// add headers that you want to pre-compile here
11+
#include "framework.h"
12+
13+
#endif //PCH_H

src/common/common.vcxproj

+3
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
<ClInclude Include="d2d_window.h" />
122122
<ClInclude Include="dpi_aware.h" />
123123
<ClInclude Include="com_object_factory.h" />
124+
<ClInclude Include="keyboard_layout.h" />
125+
<ClInclude Include="keyboard_layout_impl.h" />
124126
<ClInclude Include="notifications.h" />
125127
<ClInclude Include="timeutil.h" />
126128
<ClInclude Include="VersionHelper.h" />
@@ -149,6 +151,7 @@
149151
<ClCompile Include="d2d_window.cpp" />
150152
<ClCompile Include="dpi_aware.cpp" />
151153
<ClCompile Include="json.cpp" />
154+
<ClCompile Include="keyboard_layout.cpp" />
152155
<ClCompile Include="monitors.cpp" />
153156
<ClCompile Include="notifications.cpp" />
154157
<ClCompile Include="on_thread_executor.cpp" />

src/common/common.vcxproj.filters

+13-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@
9999
<ClInclude Include="com_object_factory.h">
100100
<Filter>Header Files</Filter>
101101
</ClInclude>
102+
<ClInclude Include="keyboard_layout_impl.h">
103+
<Filter>Header Files</Filter>
104+
</ClInclude>
105+
<ClInclude Include="keyboard_layout.h">
106+
<Filter>Header Files</Filter>
107+
</ClInclude>
102108
</ItemGroup>
103109
<ItemGroup>
104110
<ClCompile Include="d2d_svg.cpp">
@@ -159,5 +165,11 @@
159165
<ClCompile Include="VersionHelper.cpp">
160166
<Filter>Source Files</Filter>
161167
</ClCompile>
168+
<ClCompile Include="keyboard_layout.cpp">
169+
<Filter>Source Files</Filter>
170+
</ClCompile>
171+
</ItemGroup>
172+
<ItemGroup>
173+
<None Include="packages.config" />
162174
</ItemGroup>
163-
</Project>
175+
</Project>

src/common/interop/AssemblyInfo.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "pch.h"
2+
3+
using namespace System;
4+
using namespace System::Reflection;
5+
using namespace System::Runtime::CompilerServices;
6+
using namespace System::Runtime::InteropServices;
7+
using namespace System::Security::Permissions;
8+
9+
[assembly:AssemblyTitleAttribute(L"interop")];
10+
[assembly:AssemblyDescriptionAttribute(L"")];
11+
[assembly:AssemblyConfigurationAttribute(L"")];
12+
[assembly:AssemblyCompanyAttribute(L"")];
13+
[assembly:AssemblyProductAttribute(L"interop")];
14+
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2020")];
15+
[assembly:AssemblyTrademarkAttribute(L"")];
16+
[assembly:AssemblyCultureAttribute(L"")];
17+
18+
[assembly:AssemblyVersionAttribute("1.0.*")];
19+
20+
[assembly:ComVisible(false)];
21+
22+
[assembly:CLSCompliantAttribute(true)];

src/common/interop/Resource.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//{{NO_DEPENDENCIES}}
2+
// Microsoft Visual C++ generated include file.
3+
// Used by app.rc

src/common/interop/app.ico

40.4 KB
Binary file not shown.

src/common/interop/app.rc

2.5 KB
Binary file not shown.

src/common/interop/interop.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "pch.h"
2+
3+
#include "interop.h"
4+

src/common/interop/interop.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
#include <common\keyboard_layout.h>
4+
using namespace System;
5+
6+
//https://docs.microsoft.com/en-us/cpp/dotnet/how-to-wrap-native-class-for-use-by-csharp?view=vs-2019
7+
namespace interop
8+
{
9+
public ref class LayoutMapManaged
10+
{
11+
public:
12+
LayoutMapManaged() :
13+
_map(new LayoutMap) {}
14+
15+
~LayoutMapManaged()
16+
{
17+
delete _map;
18+
}
19+
20+
String ^ GetKeyName(DWORD key)
21+
{
22+
return gcnew String(_map->GetKeyName(key).c_str());
23+
}
24+
25+
void Updatelayout()
26+
{
27+
_map->UpdateLayout();
28+
}
29+
30+
protected:
31+
!LayoutMapManaged()
32+
{
33+
delete _map;
34+
}
35+
36+
private:
37+
LayoutMap* _map;
38+
};
39+
}
40+

0 commit comments

Comments
 (0)