Skip to content

Commit

Permalink
Revert and fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflord committed Dec 3, 2023
1 parent 2110310 commit 0fe0807
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
NULL,
hInst,
NULL);

if (_hWndEditShortcutsWindow == NULL)
{
MessageBox(NULL, GET_RESOURCE_STRING(IDS_CREATEWINDOWFAILED_ERRORMESSAGE).c_str(), GET_RESOURCE_STRING(IDS_CREATEWINDOWFAILED_ERRORTITLE).c_str(), NULL);
return;
}

// Ensures the window is in foreground on first startup. If this is not done, the window appears behind because the thread is not on the foreground.
if (_hWndEditShortcutsWindow)
{
Expand All @@ -157,7 +157,7 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa

// Create the xaml bridge object
XamlBridge2 xamlBridge(_hWndEditShortcutsWindow);

// Create the desktop window xaml source object and set its content
hWndXamlIslandEditShortcutsWindow = xamlBridge.InitBridge();

Expand Down Expand Up @@ -227,15 +227,15 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa

// Store handle of edit shortcuts window
ShortcutControl::editShortcutsWindowHandle = _hWndEditShortcutsWindow;

// Store keyboard manager state
ShortcutControl::keyboardManagerState = &keyboardManagerState;
KeyDropDownControl::keyboardManagerState = &keyboardManagerState;
KeyDropDownControl::mappingConfiguration = &mappingConfiguration;

// Clear the shortcut remap buffer
ShortcutControl::shortcutRemapBuffer.clear();

// Vector to store dynamically allocated control objects to avoid early destruction
std::vector<std::vector<std::unique_ptr<ShortcutControl>>> keyboardRemapControlObjects;

Expand Down Expand Up @@ -459,8 +459,7 @@ LRESULT CALLBACK EditShortcutsWindowProc(HWND hWnd, UINT messageCode, WPARAM wPa
rect->top,
rect->right - rect->left,
rect->bottom - rect->top,
SWP_NOZORDER | SWP_NOACTIVATE
);
SWP_NOZORDER | SWP_NOACTIVATE);

Logger::trace(L"WM_DPICHANGED: new dpi {} rect {} {} ", newDPI, rect->right - rect->left, rect->bottom - rect->top);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ namespace LoadingAndSavingRemappingHelper
{
if (remappings[i].second == L"")
{


bool result = mappingConfiguration.AddOSLevelShortcut(originalShortcut, newShortcut);
if (result)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
}

const bool textSelected = newKeys.index() == 2;
bool isRunProgram = false;
if (textSelected)
{
typeCombo.SelectedIndex(1);
Expand All @@ -244,6 +245,12 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
auto shortCut = std::get<Shortcut>(newKeys);
if (shortCut.isRunProgram)
{
Shortcut tempShortcut;
isRunProgram = true;
tempShortcut.isRunProgram = true;
tempShortcut.runProgramPath = runProgramPathInput.Text().c_str();
// Assign instead of setting the value in the buffer since the previous value may not be a Shortcut
//shortcutRemapBuffer[index].first[1] = tempShortcut;
runProgramPathInput.Text(shortCut.runProgramPath);
typeCombo.SelectedIndex(2);
}
Expand Down Expand Up @@ -424,7 +431,17 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
if (EditorHelpers::IsValidShortcut(originalKeys) && !(newKeys.index() == 0 && std::get<DWORD>(newKeys) == NULL) && !(newKeys.index() == 1 && !EditorHelpers::IsValidShortcut(std::get<Shortcut>(newKeys))))
{
// change to load app name
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring(targetAppName)));

if (isRunProgram)
{
auto newShortcut = std::get<Shortcut>(newKeys);
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), newShortcut }, std::wstring(targetAppName)));
}
else
{
shortcutRemapBuffer.push_back(std::make_pair<RemapBufferItem, std::wstring>(RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring(targetAppName)));
}

KeyDropDownControl::AddShortcutToControl(originalKeys, parent, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->shortcutDropDownVariableSizedWrapGrid.as<VariableSizedWrapGrid>(), *keyboardManagerState, 0, keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->keyDropDownControlObjects, shortcutRemapBuffer, row, targetAppTextBox, false, false);

if (newKeys.index() == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,15 @@ namespace KeyboardEventHandlers
if (remapToShortcut)
{
// Get the common keys between the two shortcuts
int commonKeys = it->first.GetCommonModifiersCount(std::get<Shortcut>(it->second.targetShortcut));

auto shortcut = std::get<Shortcut>(it->second.targetShortcut);
if (shortcut.isRunProgram)
{
// we don't need to do anything here, since we'll handle it in CentralizedKeyboardHook
continue;
}

int commonKeys = it->first.GetCommonModifiersCount(shortcut);

// If the original shortcut modifiers are a subset of the new shortcut
if (commonKeys == src_size - 1)
Expand Down
15 changes: 10 additions & 5 deletions src/modules/keyboardmanager/common/MappingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ bool MappingConfiguration::AddOSLevelShortcut(const Shortcut& originalSC, const
return false;
}

auto shortCut = std::get<Shortcut>(newSC);

if (!shortCut.isRunProgram)
/*if (newSC.index() == 1 && (std::get<Shortcut>(newSC)).isRunProgram)
{
osLevelShortcutReMap[originalSC] = RemapShortcut(newSC);
osLevelShortcutReMapSortedKeys.push_back(originalSC);
Helpers::SortShortcutVectorBasedOnSize(osLevelShortcutReMapSortedKeys);
}
else
{
}*/


osLevelShortcutReMap[originalSC] = RemapShortcut(newSC);
osLevelShortcutReMapSortedKeys.push_back(originalSC);
Helpers::SortShortcutVectorBasedOnSize(osLevelShortcutReMapSortedKeys);

return true;
}
Expand Down

1 comment on commit 0fe0807

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (8)

cmdow
PROCESSENTRY
ritchielawrence
SNAPPROCESS
splitw
tlhelp
Toolhelp
wcsicmp

Previously acknowledged words that are now absent CHT constexpr DEU hashcode HEB JPN nodiscard pcs qps roundf RUS RValue SVE wifi 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:jefflord/PowerToys.git repository
on the launch-apps-3350 branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/jefflord/PowerToys/actions/runs/7074081945/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (1848) from .github/actions/spell-check/expect.txt and unrecognized words (8)

Dictionary Entries Covers Uniquely
cspell:r/src/r.txt 543 1 1
cspell:cpp/src/people.txt 23 1
cspell:cpp/src/ecosystem.txt 51 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:r/src/r.txt
          cspell:cpp/src/people.txt
          cspell:cpp/src/ecosystem.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.