diff --git a/src/inc/contsf.h b/src/inc/contsf.h index d7fbacdb4..07594e104 100644 --- a/src/inc/contsf.h +++ b/src/inc/contsf.h @@ -29,8 +29,9 @@ extern "C" { #endif typedef RECT (*GetSuggestionWindowPos)(); +typedef RECT (*GetTextBoxAreaPos)(); -BOOL ActivateTextServices(HWND hwndConsole, GetSuggestionWindowPos pfnPosition); +BOOL ActivateTextServices(HWND hwndConsole, GetSuggestionWindowPos pfnPosition, GetTextBoxAreaPos pfnTextArea); void DeactivateTextServices(); BOOL NotifyTextServices(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* lplResult); diff --git a/src/interactivity/win32/WindowIme.cpp b/src/interactivity/win32/WindowIme.cpp index 37e722f1f..547f098c0 100644 --- a/src/interactivity/win32/WindowIme.cpp +++ b/src/interactivity/win32/WindowIme.cpp @@ -54,3 +54,15 @@ RECT GetImeSuggestionWindowPos() 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: +// - +// Return Value: +// - Rectangle specifying current text box area. +RECT GetTextBoxArea() +{ + return Microsoft::Console::Interactivity::ServiceLocator::LocateConsoleWindow()->GetWindowRect(); +} diff --git a/src/interactivity/win32/windowime.hpp b/src/interactivity/win32/windowime.hpp index dc44c7f2d..dc7e6d241 100644 --- a/src/interactivity/win32/windowime.hpp +++ b/src/interactivity/win32/windowime.hpp @@ -6,3 +6,4 @@ #pragma hdrstop RECT GetImeSuggestionWindowPos(); +RECT GetTextBoxArea(); diff --git a/src/interactivity/win32/windowproc.cpp b/src/interactivity/win32/windowproc.cpp index ad88dc7fa..1557dbe9a 100644 --- a/src/interactivity/win32/windowproc.cpp +++ b/src/interactivity/win32/windowproc.cpp @@ -263,7 +263,7 @@ using namespace Microsoft::Console::Types; HandleFocusEvent(TRUE); // 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 if (_pUiaProvider) diff --git a/src/tsf/ConsoleTSF.h b/src/tsf/ConsoleTSF.h index 833106078..a38a4f621 100644 --- a/src/tsf/ConsoleTSF.h +++ b/src/tsf/ConsoleTSF.h @@ -33,9 +33,11 @@ class CConsoleTSF final : { public: CConsoleTSF(HWND hwndConsole, - GetSuggestionWindowPos pfnPosition) : + GetSuggestionWindowPos pfnPosition, + GetTextBoxAreaPos pfnTextArea) : _hwndConsole(hwndConsole), _pfnPosition(pfnPosition), + _pfnTextArea(pfnTextArea), _cRef(1), _tid() { @@ -66,21 +68,27 @@ public: 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) { if (pRect) { - *pRect = _pfnPosition(); + *pRect = _pfnTextArea(); } 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) { if (pRect) { - GetScreenExt(pRect); + *pRect = _pfnPosition(); } if (pbClipped) @@ -198,6 +206,7 @@ private: // Console info. HWND _hwndConsole; GetSuggestionWindowPos _pfnPosition; + GetTextBoxAreaPos _pfnTextArea; // Miscellaneous flags BOOL _fModifyingDoc = FALSE; // Set TRUE, when calls ITfRange::SetText diff --git a/src/tsf/contsf.cpp b/src/tsf/contsf.cpp index e83a8080a..81a98c5b8 100644 --- a/src/tsf/contsf.cpp +++ b/src/tsf/contsf.cpp @@ -5,11 +5,11 @@ 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) { - g_pConsoleTSF = new (std::nothrow) CConsoleTSF(hwndConsole, pfnPosition); + g_pConsoleTSF = new (std::nothrow) CConsoleTSF(hwndConsole, pfnPosition, pfnTextArea); if (g_pConsoleTSF && SUCCEEDED(g_pConsoleTSF->Initialize())) { // Conhost calls this function only when the console window has focus.