Migrate OSS up to 3f1befb06 (Touch Keyboard Invocation)

This commit is contained in:
Dustin Howett 2021-11-09 13:39:23 -06:00
commit 88d58d313a
6 changed files with 30 additions and 7 deletions

View file

@ -29,8 +29,9 @@ extern "C" {
#endif #endif
typedef RECT (*GetSuggestionWindowPos)(); typedef RECT (*GetSuggestionWindowPos)();
typedef RECT (*GetTextBoxAreaPos)();
BOOL ActivateTextServices(HWND hwndConsole, GetSuggestionWindowPos pfnPosition); BOOL ActivateTextServices(HWND hwndConsole, GetSuggestionWindowPos pfnPosition, GetTextBoxAreaPos pfnTextArea);
void DeactivateTextServices(); void DeactivateTextServices();
BOOL NotifyTextServices(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* lplResult); BOOL NotifyTextServices(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* lplResult);

View file

@ -54,3 +54,15 @@ RECT GetImeSuggestionWindowPos()
return rcSuggestion; return rcSuggestion;
} }
// Routine Description:
// - This method gives a rectangle to where text box is currently rendered
// such that the touch keyboard can pop up when the rectangle is tapped.
// Arguments:
// - <none>
// Return Value:
// - Rectangle specifying current text box area.
RECT GetTextBoxArea()
{
return Microsoft::Console::Interactivity::ServiceLocator::LocateConsoleWindow()->GetWindowRect();
}

View file

@ -6,3 +6,4 @@
#pragma hdrstop #pragma hdrstop
RECT GetImeSuggestionWindowPos(); RECT GetImeSuggestionWindowPos();
RECT GetTextBoxArea();

View file

@ -263,7 +263,7 @@ using namespace Microsoft::Console::Types;
HandleFocusEvent(TRUE); HandleFocusEvent(TRUE);
// ActivateTextServices does nothing if already active so this is OK to be called every focus. // ActivateTextServices does nothing if already active so this is OK to be called every focus.
ActivateTextServices(ServiceLocator::LocateConsoleWindow()->GetWindowHandle(), GetImeSuggestionWindowPos); ActivateTextServices(ServiceLocator::LocateConsoleWindow()->GetWindowHandle(), GetImeSuggestionWindowPos, GetTextBoxArea);
// set the text area to have focus for accessibility consumers // set the text area to have focus for accessibility consumers
if (_pUiaProvider) if (_pUiaProvider)

View file

@ -33,9 +33,11 @@ class CConsoleTSF final :
{ {
public: public:
CConsoleTSF(HWND hwndConsole, CConsoleTSF(HWND hwndConsole,
GetSuggestionWindowPos pfnPosition) : GetSuggestionWindowPos pfnPosition,
GetTextBoxAreaPos pfnTextArea) :
_hwndConsole(hwndConsole), _hwndConsole(hwndConsole),
_pfnPosition(pfnPosition), _pfnPosition(pfnPosition),
_pfnTextArea(pfnTextArea),
_cRef(1), _cRef(1),
_tid() _tid()
{ {
@ -66,21 +68,27 @@ public:
return S_OK; return S_OK;
} }
// This returns Rectangle of the text box of whole console.
// When a user taps inside the rectangle while hardware keyboard is not available,
// touch keyboard is invoked.
STDMETHODIMP GetScreenExt(RECT* pRect) STDMETHODIMP GetScreenExt(RECT* pRect)
{ {
if (pRect) if (pRect)
{ {
*pRect = _pfnPosition(); *pRect = _pfnTextArea();
} }
return S_OK; return S_OK;
} }
// This returns rectangle of current command line edit area.
// When a user types in East Asian language, candidate window is shown at this position.
// Emoji and more panel (Win+.) is shown at the position, too.
STDMETHODIMP GetTextExt(LONG, LONG, RECT* pRect, BOOL* pbClipped) STDMETHODIMP GetTextExt(LONG, LONG, RECT* pRect, BOOL* pbClipped)
{ {
if (pRect) if (pRect)
{ {
GetScreenExt(pRect); *pRect = _pfnPosition();
} }
if (pbClipped) if (pbClipped)
@ -198,6 +206,7 @@ private:
// Console info. // Console info.
HWND _hwndConsole; HWND _hwndConsole;
GetSuggestionWindowPos _pfnPosition; GetSuggestionWindowPos _pfnPosition;
GetTextBoxAreaPos _pfnTextArea;
// Miscellaneous flags // Miscellaneous flags
BOOL _fModifyingDoc = FALSE; // Set TRUE, when calls ITfRange::SetText BOOL _fModifyingDoc = FALSE; // Set TRUE, when calls ITfRange::SetText

View file

@ -5,11 +5,11 @@
CConsoleTSF* g_pConsoleTSF = nullptr; CConsoleTSF* g_pConsoleTSF = nullptr;
extern "C" BOOL ActivateTextServices(HWND hwndConsole, GetSuggestionWindowPos pfnPosition) extern "C" BOOL ActivateTextServices(HWND hwndConsole, GetSuggestionWindowPos pfnPosition, GetTextBoxAreaPos pfnTextArea)
{ {
if (!g_pConsoleTSF && hwndConsole) if (!g_pConsoleTSF && hwndConsole)
{ {
g_pConsoleTSF = new (std::nothrow) CConsoleTSF(hwndConsole, pfnPosition); g_pConsoleTSF = new (std::nothrow) CConsoleTSF(hwndConsole, pfnPosition, pfnTextArea);
if (g_pConsoleTSF && SUCCEEDED(g_pConsoleTSF->Initialize())) if (g_pConsoleTSF && SUCCEEDED(g_pConsoleTSF->Initialize()))
{ {
// Conhost calls this function only when the console window has focus. // Conhost calls this function only when the console window has focus.