Skip to content

Commit

Permalink
Merge pull request #5 from dend/microsoft-master
Browse files Browse the repository at this point in the history
Merge latest changes
  • Loading branch information
dend authored Apr 29, 2021
2 parents c2d54b0 + b01b878 commit 1e46c77
Show file tree
Hide file tree
Showing 150 changed files with 5,198 additions and 2,585 deletions.
10 changes: 10 additions & 0 deletions .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ abcdef
abcdefgh
abgr
ABlocked
ABOUTBOX
Abug
accctrl
Acceleratorkeys
Expand Down Expand Up @@ -118,6 +119,7 @@ atlstr
attr
Attribs
aumid
Aut
AUTHN
AUTOAPPEND
autocomplete
Expand Down Expand Up @@ -396,6 +398,7 @@ davidegiacometti
Dayof
dbdfc
Dbg
Dbghelp
DBLCLKS
DBLEPSILON
DCOM
Expand Down Expand Up @@ -1117,6 +1120,7 @@ KEYBDINPUT
keyboardeventhandlers
keyboardmanager
keyboardmanagercommon
KEYBOARDMANAGEREDITOR
keyboardmanagerstate
keyboardmanagerui
keycode
Expand Down Expand Up @@ -1510,6 +1514,7 @@ oldnewthing
oldpath
oldtheme
oleaut
OleAut
OLECHAR
OLEDB
OLIVEGREEN
Expand Down Expand Up @@ -1737,6 +1742,7 @@ readme
READMODE
readonly
READWRITE
REALTIME
RECTDESTINATION
RECTL
rectp
Expand Down Expand Up @@ -2008,6 +2014,7 @@ stdcall
stdcpp
stdcpplatest
stdexcept
stdio
stdin
stdlib
STDMETHODCALLTYPE
Expand All @@ -2027,6 +2034,7 @@ Strikethrough
Stringified
stringify
STRINGIZE
stringstream
stringtable
stringval
Strmiids
Expand Down Expand Up @@ -2179,6 +2187,7 @@ Tz
UAC
UAL
uap
UCHAR
udit
UIA
Uid
Expand Down Expand Up @@ -2423,6 +2432,7 @@ wstr
wstring
wstringstream
wsz
wtoi
WTS
WTSAT
wu
Expand Down
3 changes: 2 additions & 1 deletion .pipelines/ci/templates/build-powertoys-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ steps:
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\KeyboardManagerTest.dll
**\KeyboardManagerEngineTest.dll
**\KeyboardManagerEditorTest.dll
**\UnitTests-CommonLib.dll
**\PowerRenameUnitTests.dll
**\powerpreviewTest.dll
Expand Down
2 changes: 2 additions & 0 deletions .pipelines/pipeline.user.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ build:
- 'modules\ImageResizer\ManagedTelemetry.dll'
- 'modules\ImageResizer\Microsoft.PowerToys.Common.UI.dll'
- 'modules\KeyboardManager\KeyboardManager.dll'
- 'modules\KeyboardManager\KeyboardManagerEditor\PowerToys.KeyboardManagerEditor.exe'
- 'modules\KeyboardManager\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe'
- 'modules\launcher\Microsoft.PowerToys.Settings.UI.Lib.dll'
- 'modules\launcher\ManagedCommon.dll'
- 'modules\launcher\Microsoft.PowerToys.Common.UI.dll'
Expand Down
237 changes: 43 additions & 194 deletions PowerToys.sln

Large diffs are not rendered by default.

25 changes: 22 additions & 3 deletions installer/PowerToysSetup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@
<Directory Id="ShortcutGuideInstallFolder" Name="$(var.ShortcutGuideProjectName)"/>
<Directory Id="FileExplorerPreviewInstallFolder" Name="FileExplorerPreview" />
<Directory Id="FancyZonesInstallFolder" Name="$(var.FancyZonesProjectName)" />
<Directory Id="KeyboardManagerInstallFolder" Name="$(var.KeyboardManagerProjectName)" />
<Directory Id="KeyboardManagerInstallFolder" Name="$(var.KeyboardManagerProjectName)">
<Directory Id="KeyboardManagerEditorInstallFolder" Name="KeyboardManagerEditor" />
<Directory Id="KeyboardManagerEngineInstallFolder" Name="KeyboardManagerEngine" />
</Directory>
<Directory Id="ColorPickerInstallFolder" Name="$(var.ColorPickerProjectName)">
<Directory Id="ColorPickerResourcesFolder" Name="Resources"/>
</Directory>
Expand Down Expand Up @@ -385,6 +388,8 @@
<File Id="FancyZones_Microsoft.PowerToys.Common.UI" Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\Microsoft.PowerToys.Common.UI.dll" />
<File Id="FancyZones_Telemetry.dll" Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\ManagedTelemetry.dll" />
<File Id="FancyZone_System.IO.Abstractions.dll" Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\System.IO.Abstractions.dll" />
<File Id="FancyZones_System.Runtime.CompilerServices.Unsafe.dll" Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\System.Runtime.CompilerServices.Unsafe.dll" />
<File Id="FancyZones_System.Text.Encodings.Web.dll" Source="$(var.BinX64Dir)modules\$(var.FancyZonesProjectName)\System.Text.Encodings.Web.dll" />
</Component>
</DirectoryRef>

Expand Down Expand Up @@ -589,9 +594,21 @@
</Component>
</DirectoryRef>

<DirectoryRef Id="KeyboardManagerEditorInstallFolder" FileSource="$(var.BinX64Dir)modules\$(var.KeyboardManagerProjectName)\KeyboardManagerEditor">
<Component Id="Module_KeyboardManager_Editor" Guid="1240F1B8-17FE-4D68-B9AF-91882B0B1933" Win64="yes">
<File Source="$(var.BinX64Dir)modules\$(var.KeyboardManagerProjectName)\KeyboardManagerEditor\PowerToys.KeyboardManagerEditor.exe" />
</Component>
</DirectoryRef>

<DirectoryRef Id="KeyboardManagerEngineInstallFolder" FileSource="$(var.BinX64Dir)modules\$(var.KeyboardManagerProjectName)\KeyboardManagerEngine">
<Component Id="Module_KeyboardManager_Engine" Guid="14DBAA38-B98D-431F-9439-8EDE1C0670DB" Win64="yes">
<File Source="$(var.BinX64Dir)modules\$(var.KeyboardManagerProjectName)\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe" />
</Component>
</DirectoryRef>

<DirectoryRef Id="ColorPickerInstallFolder" FileSource="$(var.BinX64Dir)modules\$(var.ColorPickerProjectName)">
<Component Id="Module_ColorPicker" Guid="8A52A69E-37B2-4BEA-9D73-77763066052F" Win64="yes">
<?foreach File in ColorPicker.dll;System.IO.Abstractions.dll;ColorPickerUI.exe;ColorPickerUI.dll;ColorPickerUI.deps.json;ColorPickerUI.runtimeconfig.json;Microsoft.PowerToys.Settings.UI.Lib.dll;PowerToysInterop.dll;System.Text.Json.dll;ManagedTelemetry.dll;ManagedCommon.dll;ControlzEx.dll;Microsoft.Xaml.Behaviors.dll;ModernWpf.Controls.dll;ModernWpf.dll;System.ComponentModel.Composition.dll;Microsoft.PowerToys.Common.UI.dll?>
<?foreach File in ColorPicker.dll;System.IO.Abstractions.dll;ColorPickerUI.exe;ColorPickerUI.dll;ColorPickerUI.deps.json;ColorPickerUI.runtimeconfig.json;Microsoft.PowerToys.Settings.UI.Lib.dll;PowerToysInterop.dll;System.Text.Json.dll;ManagedTelemetry.dll;ManagedCommon.dll;ControlzEx.dll;Microsoft.Xaml.Behaviors.dll;ModernWpf.Controls.dll;ModernWpf.dll;System.ComponentModel.Composition.dll;Microsoft.PowerToys.Common.UI.dll;System.Runtime.CompilerServices.Unsafe.dll;System.Text.Encodings.Web.dll?>
<File Id="ColorPickerFile_$(var.File)" Source="$(var.BinX64Dir)modules\$(var.ColorPickerProjectName)\$(var.File)" />
<?endforeach?>
</Component>
Expand Down Expand Up @@ -779,6 +796,8 @@
<ComponentRef Id="Module_PowerPreview" />
<ComponentRef Id="Module_PowerPreview_PerUserRegistry" />
<ComponentRef Id="Module_KeyboardManager" />
<ComponentRef Id="Module_KeyboardManager_Editor" />
<ComponentRef Id="Module_KeyboardManager_Engine" />
<ComponentRef Id="Module_ColorPicker" />
<ComponentRef Id="Module_ColorPicker_Resources"/>
<ComponentRef Id="SettingsV2" />
Expand Down Expand Up @@ -908,7 +927,7 @@

<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
<File Source="$(var.BinX64Dir)modules\Launcher\Microsoft.Launcher.dll" />
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;ManagedTelemetry.dll;PowerLauncher.Telemetry.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;ManagedCommon.dll;System.IO.Abstractions.dll;Microsoft.PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll?>
<?foreach File in concrt140_app.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;Newtonsoft.Json.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerLauncher.deps.json;PowerLauncher.dll;PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToysInterop.dll;ManagedTelemetry.dll;PowerLauncher.Telemetry.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;ManagedCommon.dll;System.IO.Abstractions.dll;Microsoft.PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll;System.Runtime.CompilerServices.Unsafe.dll;System.Text.Encodings.Web.dll?>
<File Id="File_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\$(var.File)" />
<?endforeach?>
<File Source="$(var.BinX64Dir)Settings\Microsoft.PowerToys.Settings.UI.Lib.dll" />
Expand Down
4 changes: 0 additions & 4 deletions src/common/interop/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,5 @@ public
static String ^ ShowShortcutGuideSharedEvent() {
return gcnew String(CommonSharedConstants::SHOW_SHORTCUT_GUIDE_SHARED_EVENT);
}

static String ^ KeyboardManagerConfigFileMutexName() {
return gcnew String(CommonSharedConstants::KEYBOARD_MANAGER_CONFIG_FILE_MUTEX_NAME);
}
};
}
3 changes: 0 additions & 3 deletions src/common/interop/shared_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ namespace CommonSharedConstants

// Max DWORD for key code to disable keys.
const int VK_DISABLED = 0x100;

// Name of the mutex which controls access to the configuration file for Keyboard Manager
const wchar_t KEYBOARD_MANAGER_CONFIG_FILE_MUTEX_NAME[] = L"Local\\PowerToys_KeyboardManager_ConfigFileMutex";
}
5 changes: 5 additions & 0 deletions src/common/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ class Logger
{
logger->critical(fmt, args...);
}

static void flush()
{
logger->flush();
}
};
61 changes: 61 additions & 0 deletions src/common/utils/EventLocker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <windows.h>
#include <string>

class EventLocker
{
public:
EventLocker(HANDLE h)
{
eventHandle = h;
SetEvent(eventHandle);
}

static std::optional<EventLocker> Get(std::wstring eventName)
{
EventLocker locker(eventName);
if (!locker.eventHandle)
{
return {};
}

return locker;
}

EventLocker(EventLocker& e) = delete;
EventLocker& operator=(EventLocker& e) = delete;

EventLocker(EventLocker&& e) noexcept
{
this->eventHandle = e.eventHandle;
e.eventHandle = nullptr;
}

EventLocker& operator=(EventLocker&& e) noexcept
{
this->eventHandle = e.eventHandle;
e.eventHandle = nullptr;
}

~EventLocker()
{
if (eventHandle)
{
ResetEvent(eventHandle);
CloseHandle(eventHandle);
eventHandle = nullptr;
}
}
private:
EventLocker(std::wstring eventName)
{
eventHandle = CreateEvent(nullptr, true, false, eventName.c_str());
if (!eventHandle)
{
return;
}

SetEvent(eventHandle);
}

HANDLE eventHandle;
};
78 changes: 78 additions & 0 deletions src/common/utils/EventWaiter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include <functional>
#include <thread>
#include <string>
#include <windows.h>

class EventWaiter
{
public:
EventWaiter() {}
EventWaiter(const std::wstring& name, std::function<void(DWORD)> callback)
{
// Create localExitThreadEvent and localWaitingEvent for capturing. We can not capture 'this' as we implement move constructor.
auto localExitThreadEvent = exitThreadEvent = CreateEvent(nullptr, false, false, nullptr);
HANDLE localWaitingEvent = waitingEvent = CreateEvent(nullptr, false, false, name.c_str());
std::thread([=]() {
HANDLE events[2] = { localWaitingEvent, localExitThreadEvent };
while (true)
{
auto waitResult = WaitForMultipleObjects(2, events, false, INFINITE);
if (waitResult == WAIT_OBJECT_0 + 1)
{
break;
}

if (waitResult == WAIT_FAILED)
{
callback(GetLastError());
continue;
}

if (waitResult == WAIT_OBJECT_0)
{
callback(ERROR_SUCCESS);
}
}
}).detach();
}

EventWaiter(EventWaiter&) = delete;
EventWaiter& operator=(EventWaiter&) = delete;

EventWaiter(EventWaiter&& a) noexcept
{
this->exitThreadEvent = a.exitThreadEvent;
this->waitingEvent = a.waitingEvent;

a.exitThreadEvent = nullptr;
a.waitingEvent = nullptr;
}

EventWaiter& operator=(EventWaiter&& a) noexcept
{
this->exitThreadEvent = a.exitThreadEvent;
this->waitingEvent = a.waitingEvent;

a.exitThreadEvent = nullptr;
a.waitingEvent = nullptr;
return *this;
}

~EventWaiter()
{
if (exitThreadEvent)
{
SetEvent(exitThreadEvent);
CloseHandle(exitThreadEvent);
}

if (waitingEvent)
{
CloseHandle(waitingEvent);
}
}

private:
HANDLE exitThreadEvent = nullptr;
HANDLE waitingEvent = nullptr;
};
32 changes: 32 additions & 0 deletions src/common/utils/ProcessWaiter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <functional>
#include <string>
#include <Windows.h>
#include <thread>

namespace ProcessWaiter
{
void OnProcessTerminate(std::wstring parent_pid, std::function<void(DWORD)> callback)
{
DWORD pid = std::stol(parent_pid);
std::thread([=]() {
HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
if (process != nullptr)
{
if (WaitForSingleObject(process, INFINITE) == WAIT_OBJECT_0)
{
CloseHandle(process);
callback(ERROR_SUCCESS);
}
else
{
CloseHandle(process);
callback(GetLastError());
}
}
else
{
callback(GetLastError());
}
}).detach();
}
}
Loading

0 comments on commit 1e46c77

Please sign in to comment.