-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reload settings when the input method changes (#10876)
`VkKeyScanW` as well as `MapVirtualKeyW` are used throughout the project, but are input method sensitive functions. Since #10666 `win+sc(41)` is used as the quake mode keybinding, which is then mapped to a virtual key in order to call `RegisterHotKey`. This mapping is highly dependent on the input method and the quake mode key binding will fail to work once the input method was changed. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #10729 * [x] I work here * [ ] Tests added/passed ## Validation Steps Performed * win+` opens quake window before & after changing keyboard layout ✔️ * keyboard layout changes while WT is minimized trigger reloaded ✔️
- Loading branch information
Showing
7 changed files
with
93 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "LanguageProfileNotifier.h" | ||
|
||
using namespace winrt::TerminalApp::implementation; | ||
|
||
LanguageProfileNotifier::LanguageProfileNotifier(std::function<void()>&& callback) : | ||
_callback{ std::move(callback) }, | ||
_currentKeyboardLayout{ GetKeyboardLayout(0) } | ||
{ | ||
const auto manager = wil::CoCreateInstance<ITfThreadMgr>(CLSID_TF_ThreadMgr); | ||
_source = manager.query<ITfSource>(); | ||
if (FAILED(_source->AdviseSink(IID_ITfInputProcessorProfileActivationSink, static_cast<ITfInputProcessorProfileActivationSink*>(this), &_cookie))) | ||
{ | ||
_cookie = TF_INVALID_COOKIE; | ||
THROW_LAST_ERROR(); | ||
} | ||
} | ||
|
||
LanguageProfileNotifier::~LanguageProfileNotifier() | ||
{ | ||
if (_cookie != TF_INVALID_COOKIE) | ||
{ | ||
_source->UnadviseSink(_cookie); | ||
} | ||
} | ||
|
||
STDMETHODIMP LanguageProfileNotifier::OnActivated(DWORD /*dwProfileType*/, LANGID /*langid*/, REFCLSID /*clsid*/, REFGUID /*catid*/, REFGUID /*guidProfile*/, HKL hkl, DWORD /*dwFlags*/) | ||
{ | ||
if (hkl && hkl != _currentKeyboardLayout) | ||
{ | ||
_currentKeyboardLayout = hkl; | ||
try | ||
{ | ||
_callback(); | ||
} | ||
CATCH_RETURN(); | ||
} | ||
return S_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
class LanguageProfileNotifier : public winrt::implements<LanguageProfileNotifier, ITfInputProcessorProfileActivationSink> | ||
{ | ||
public: | ||
explicit LanguageProfileNotifier(std::function<void()>&& callback); | ||
~LanguageProfileNotifier(); | ||
STDMETHODIMP OnActivated(DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags); | ||
|
||
private: | ||
std::function<void()> _callback; | ||
wil::com_ptr<ITfSource> _source; | ||
DWORD _cookie = TF_INVALID_COOKIE; | ||
HKL _currentKeyboardLayout; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters