[Keyboard Manager] Cleanup header file references to improve incremental build time (#4880)

* Remove WinUI include in KeyboardManagerState.h

* Changed include steps

* Clean up headers in KeyboardManagerUI except XamlBridge.h

* Cleaned up headers in KeyboardManager common and test

* Cleaned up headers in KeyboardManager project

* Removed headers from XamlBridge

* Removed some headers from kbm common pch

* Added MP flag to reduce build time

* Added missing include
This commit is contained in:
Arjun Balgovind
2020-07-13 11:49:09 -07:00
committed by GitHub
parent 7db5d6a307
commit 6a9badd31b
37 changed files with 291 additions and 180 deletions

View File

@@ -1,5 +1,7 @@
#include "pch.h"
#include "KeyboardManagerState.h"
#include <../common/settings_helpers.h>
#include "KeyDelay.h"
// Constructor
KeyboardManagerState::KeyboardManagerState() :
@@ -179,15 +181,15 @@ bool KeyboardManagerState::AddAppSpecificShortcut(const std::wstring& app, const
void KeyboardManagerState::ConfigureDetectShortcutUI(const StackPanel& textBlock1, const StackPanel& textBlock2)
{
std::lock_guard<std::mutex> lock(currentShortcutUI_mutex);
currentShortcutUI1 = textBlock1;
currentShortcutUI2 = textBlock2;
currentShortcutUI1 = textBlock1.as<winrt::Windows::Foundation::IInspectable>();
currentShortcutUI2 = textBlock2.as<winrt::Windows::Foundation::IInspectable>();
}
// Function to set the textblock of the detect remap key UI so that it can be accessed by the hook
void KeyboardManagerState::ConfigureDetectSingleKeyRemapUI(const StackPanel& textBlock)
{
std::lock_guard<std::mutex> lock(currentSingleKeyUI_mutex);
currentSingleKeyUI = textBlock;
currentSingleKeyUI = textBlock.as<winrt::Windows::Foundation::IInspectable>();
}
void KeyboardManagerState::AddKeyToLayout(const StackPanel& panel, const hstring& key)
@@ -226,34 +228,34 @@ void KeyboardManagerState::UpdateDetectShortcutUI()
detectedShortcut_lock.unlock();
// Since this function is invoked from the back-end thread, in order to update the UI the dispatcher must be used.
currentShortcutUI1.Dispatcher().RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, [this, detectedShortcutCopy]() {
currentShortcutUI1.as<StackPanel>().Dispatcher().RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, [this, detectedShortcutCopy]() {
std::vector<hstring> shortcut = detectedShortcutCopy.GetKeyVector(keyboardMap);
currentShortcutUI1.Children().Clear();
currentShortcutUI2.Children().Clear();
currentShortcutUI1.as<StackPanel>().Children().Clear();
currentShortcutUI2.as<StackPanel>().Children().Clear();
// The second row should be hidden if there are 3 keys or lesser to avoid an extra margin
if (shortcut.size() > 3)
{
currentShortcutUI2.Visibility(Visibility::Visible);
currentShortcutUI2.as<StackPanel>().Visibility(Visibility::Visible);
}
else
{
currentShortcutUI2.Visibility(Visibility::Collapsed);
currentShortcutUI2.as<StackPanel>().Visibility(Visibility::Collapsed);
}
for (int i = 0; i < shortcut.size(); i++)
{
if (i < 3)
{
AddKeyToLayout(currentShortcutUI1, shortcut[i]);
AddKeyToLayout(currentShortcutUI1.as<StackPanel>(), shortcut[i]);
}
else
{
AddKeyToLayout(currentShortcutUI2, shortcut[i]);
AddKeyToLayout(currentShortcutUI2.as<StackPanel>(), shortcut[i]);
}
}
currentShortcutUI1.UpdateLayout();
currentShortcutUI2.UpdateLayout();
currentShortcutUI1.as<StackPanel>().UpdateLayout();
currentShortcutUI2.as<StackPanel>().UpdateLayout();
});
}
@@ -265,13 +267,12 @@ void KeyboardManagerState::UpdateDetectSingleKeyRemapUI()
{
return;
}
// Since this function is invoked from the back-end thread, in order to update the UI the dispatcher must be used.
currentSingleKeyUI.Dispatcher().RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, [this]() {
currentSingleKeyUI.Children().Clear();
currentSingleKeyUI.as<StackPanel>().Dispatcher().RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, [this]() {
currentSingleKeyUI.as<StackPanel>().Children().Clear();
hstring key = winrt::to_hstring(keyboardMap.GetKeyName(detectedRemapKey).c_str());
AddKeyToLayout(currentSingleKeyUI, key);
currentSingleKeyUI.UpdateLayout();
AddKeyToLayout(currentSingleKeyUI.as<StackPanel>(), key);
currentSingleKeyUI.as<StackPanel>().UpdateLayout();
});
}