Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MouseInput from TermAdapter to TermInput #4848

Merged
7 commits merged into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/host/consoleInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ CONSOLE_INFORMATION::CONSOLE_INFORMATION() :
// OutputCPInfo initialized below
_cookedReadData(nullptr),
ConsoleIme{},
terminalMouseInput(HandleTerminalKeyEventCallback),
_vtIo(),
_blinker{},
renderData{}
Expand Down Expand Up @@ -180,18 +179,6 @@ void CONSOLE_INFORMATION::SetCookedReadData(COOKED_READ_DATA* readData) noexcept
_cookedReadData = readData;
}

// Routine Description:
// - Handler for inserting key sequences into the buffer when the terminal emulation layer
// has determined a key can be converted appropriately into a sequence of inputs
// Arguments:
// - events - the input events to write to the input buffer
// Return Value:
// - <none>
void CONSOLE_INFORMATION::HandleTerminalKeyEventCallback(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& events)
{
ServiceLocator::LocateGlobals().getConsoleInformation().pInputBuffer->Write(events);
}

// Method Description:
// - Return the active screen buffer of the console.
// Arguments:
Expand Down
12 changes: 6 additions & 6 deletions src/host/getset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ void DoSrvPrivateTabClear(const bool fClearAll)
void DoSrvPrivateEnableVT200MouseMode(const bool fEnable)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.terminalMouseInput.EnableDefaultTracking(fEnable);
gci.GetActiveInputBuffer()->GetTerminalInput().EnableDefaultTracking(fEnable);
}

// Routine Description:
Expand All @@ -1628,7 +1628,7 @@ void DoSrvPrivateEnableVT200MouseMode(const bool fEnable)
void DoSrvPrivateEnableUTF8ExtendedMouseMode(const bool fEnable)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.terminalMouseInput.SetUtf8ExtendedMode(fEnable);
gci.GetActiveInputBuffer()->GetTerminalInput().SetUtf8ExtendedMode(fEnable);
}

// Routine Description:
Expand All @@ -1640,7 +1640,7 @@ void DoSrvPrivateEnableUTF8ExtendedMouseMode(const bool fEnable)
void DoSrvPrivateEnableSGRExtendedMouseMode(const bool fEnable)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.terminalMouseInput.SetSGRExtendedMode(fEnable);
gci.GetActiveInputBuffer()->GetTerminalInput().SetSGRExtendedMode(fEnable);
}

// Routine Description:
Expand All @@ -1652,7 +1652,7 @@ void DoSrvPrivateEnableSGRExtendedMouseMode(const bool fEnable)
void DoSrvPrivateEnableButtonEventMouseMode(const bool fEnable)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.terminalMouseInput.EnableButtonEventTracking(fEnable);
gci.GetActiveInputBuffer()->GetTerminalInput().EnableButtonEventTracking(fEnable);
}

// Routine Description:
Expand All @@ -1664,7 +1664,7 @@ void DoSrvPrivateEnableButtonEventMouseMode(const bool fEnable)
void DoSrvPrivateEnableAnyEventMouseMode(const bool fEnable)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.terminalMouseInput.EnableAnyEventTracking(fEnable);
gci.GetActiveInputBuffer()->GetTerminalInput().EnableAnyEventTracking(fEnable);
}

// Routine Description:
Expand All @@ -1676,7 +1676,7 @@ void DoSrvPrivateEnableAnyEventMouseMode(const bool fEnable)
void DoSrvPrivateEnableAlternateScroll(const bool fEnable)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.terminalMouseInput.EnableAlternateScroll(fEnable);
gci.GetActiveInputBuffer()->GetTerminalInput().EnableAlternateScroll(fEnable);
}

// Routine Description:
Expand Down
13 changes: 11 additions & 2 deletions src/host/inputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ size_t InputBuffer::Prepend(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& in
{
try
{
_vtInputShouldSuppress = true;
auto resetVtInputSupress = wil::scope_exit([&]() { _vtInputShouldSuppress = false; });
_HandleConsoleSuspensionEvents(inEvents);
if (inEvents.empty())
{
Expand Down Expand Up @@ -556,6 +558,8 @@ size_t InputBuffer::Write(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEv
{
try
{
_vtInputShouldSuppress = true;
auto resetVtInputSuppress = wil::scope_exit([&]() { _vtInputShouldSuppress = false; });
_HandleConsoleSuspensionEvents(inEvents);
if (inEvents.empty())
{
Expand Down Expand Up @@ -841,8 +845,7 @@ bool InputBuffer::IsInVirtualTerminalInputMode() const
// - Handler for inserting key sequences into the buffer when the terminal emulation layer
// has determined a key can be converted appropriately into a sequence of inputs
// Arguments:
// - rgInput - Series of input records to insert into the buffer
// - cInput - Length of input records array
// - inEvents - Series of input records to insert into the buffer
// Return Value:
// - <none>
void InputBuffer::_HandleTerminalInputCallback(std::deque<std::unique_ptr<IInputEvent>>& inEvents)
Expand All @@ -856,6 +859,12 @@ void InputBuffer::_HandleTerminalInputCallback(std::deque<std::unique_ptr<IInput
inEvents.pop_front();
_storage.push_back(std::move(inEvent));
}

if (!_vtInputShouldSuppress)
{
ServiceLocator::LocateGlobals().hInputEvent.SetEvent();
WakeUpReadersWaitingForData();
}
}
catch (...)
{
Expand Down
6 changes: 6 additions & 0 deletions src/host/inputBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class InputBuffer final : public ConsoleObjectHeader
std::unique_ptr<IInputEvent> _writePartialByteSequence;
Microsoft::Console::VirtualTerminal::TerminalInput _termInput;

// This flag is used in _HandleTerminalInputCallback
// If the InputBuffer leads to a _HandleTerminalInputCallback call,
// we should suppress the wakeup functions.
// Otherwise, we should be calling them.
bool _vtInputShouldSuppress{ false };

void _ReadBuffer(_Out_ std::deque<std::unique_ptr<IInputEvent>>& outEvents,
const size_t readCount,
_Out_ size_t& eventsRead,
Expand Down
4 changes: 2 additions & 2 deletions src/host/screenInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ const SCREEN_INFORMATION& SCREEN_INFORMATION::GetMainBuffer() const
ScreenBufferSizeChange(psiNewAltBuffer->GetBufferSize().Dimensions());

// Tell the VT MouseInput handler that we're in the Alt buffer now
gci.terminalMouseInput.UseAlternateScreenBuffer();
gci.GetActiveInputBuffer()->GetTerminalInput().UseAlternateScreenBuffer();
}
return Status;
}
Expand Down Expand Up @@ -1924,7 +1924,7 @@ void SCREEN_INFORMATION::UseMainScreenBuffer()
// deleting the alt buffer will give the GetSet back to its main

// Tell the VT MouseInput handler that we're in the main buffer now
gci.terminalMouseInput.UseMainScreenBuffer();
gci.GetActiveInputBuffer()->GetTerminalInput().UseMainScreenBuffer();
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/host/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Revision History:
#include "settings.hpp"

#include "conimeinfo.h"
#include "..\terminal\adapter\MouseInput.hpp"
#include "VtIo.hpp"
#include "CursorBlinker.hpp"

Expand Down Expand Up @@ -107,8 +106,6 @@ class CONSOLE_INFORMATION :

ConsoleImeInfo ConsoleIme;

Microsoft::Console::VirtualTerminal::MouseInput terminalMouseInput;

void LockConsole();
bool TryLockConsole();
void UnlockConsole();
Expand All @@ -117,8 +114,6 @@ class CONSOLE_INFORMATION :

Microsoft::Console::VirtualTerminal::VtIo* GetVtIo();

static void HandleTerminalKeyEventCallback(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& events);

SCREEN_INFORMATION& GetActiveOutputBuffer() override;
const SCREEN_INFORMATION& GetActiveOutputBuffer() const override;
bool HasActiveOutputBuffer() const;
Expand Down
2 changes: 1 addition & 1 deletion src/interactivity/win32/windowio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool HandleTerminalMouseEvent(const COORD cMousePosition,
// Virtual terminal input mode
if (IsInVirtualTerminalInputMode())
{
fWasHandled = gci.terminalMouseInput.HandleMouse(cMousePosition, uiButton, sModifierKeystate, sWheelDelta);
fWasHandled = gci.GetActiveInputBuffer()->GetTerminalInput().HandleMouse(cMousePosition, uiButton, sModifierKeystate, sWheelDelta);
}

return fWasHandled;
Expand Down
100 changes: 0 additions & 100 deletions src/terminal/adapter/MouseInput.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/terminal/adapter/lib/adapter.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<ClCompile Include="..\DispatchCommon.cpp" />
<ClCompile Include="..\InteractDispatch.cpp" />
<ClCompile Include="..\adaptDispatchGraphics.cpp" />
<ClCompile Include="..\MouseInput.cpp" />
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
<ClCompile Include="..\telemetry.cpp" />
<ClCompile Include="..\terminalOutput.cpp" />
<ClCompile Include="..\tracing.cpp" />
Expand All @@ -29,7 +28,6 @@
<ClInclude Include="..\DispatchCommon.hpp" />
<ClInclude Include="..\InteractDispatch.hpp" />
<ClInclude Include="..\conGetSet.hpp" />
<ClInclude Include="..\MouseInput.hpp" />
<ClInclude Include="..\precomp.h" />
<ClInclude Include="..\telemetry.hpp" />
<ClInclude Include="..\terminalOutput.hpp" />
Expand Down
6 changes: 0 additions & 6 deletions src/terminal/adapter/lib/adapter.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
<ClCompile Include="..\InteractDispatch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\MouseInput.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\adaptDefaults.hpp">
Expand All @@ -65,9 +62,6 @@
<ClInclude Include="..\tracing.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\MouseInput.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\DispatchCommon.hpp">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
1 change: 0 additions & 1 deletion src/terminal/adapter/sources.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ SOURCES= \
..\DispatchCommon.cpp \
..\InteractDispatch.cpp \
..\adaptDispatchGraphics.cpp \
..\MouseInput.cpp \
..\terminalOutput.cpp \
..\telemetry.cpp \
..\tracing.cpp \
Expand Down
10 changes: 5 additions & 5 deletions src/terminal/adapter/ut_adapter/MouseInputTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <wextestclass.h>
#include "..\..\inc\consoletaeftemplates.hpp"

#include "MouseInput.hpp"
#include "..\terminal\input\terminalInput.hpp"

using namespace WEX::Common;
using namespace WEX::Logging;
Expand Down Expand Up @@ -280,7 +280,7 @@ class MouseInputTest

Log::Comment(L"Starting test...");

std::unique_ptr<MouseInput> mouseInput = std::make_unique<MouseInput>(s_MouseInputTestCallback);
std::unique_ptr<TerminalInput> mouseInput = std::make_unique<TerminalInput>(s_MouseInputTestCallback);

unsigned int uiModifierKeystate = 0;
VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"uiModifierKeystate", uiModifierKeystate));
Expand Down Expand Up @@ -359,7 +359,7 @@ class MouseInputTest

Log::Comment(L"Starting test...");

std::unique_ptr<MouseInput> mouseInput = std::make_unique<MouseInput>(s_MouseInputTestCallback);
std::unique_ptr<TerminalInput> mouseInput = std::make_unique<TerminalInput>(s_MouseInputTestCallback);

unsigned int uiModifierKeystate = 0;
VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"uiModifierKeystate", uiModifierKeystate));
Expand Down Expand Up @@ -442,7 +442,7 @@ class MouseInputTest

Log::Comment(L"Starting test...");

std::unique_ptr<MouseInput> mouseInput = std::make_unique<MouseInput>(s_MouseInputTestCallback);
std::unique_ptr<TerminalInput> mouseInput = std::make_unique<TerminalInput>(s_MouseInputTestCallback);
unsigned int uiModifierKeystate = 0;
VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"uiModifierKeystate", uiModifierKeystate));
short sModifierKeystate = (SHORT)uiModifierKeystate;
Expand Down Expand Up @@ -520,7 +520,7 @@ class MouseInputTest

Log::Comment(L"Starting test...");

std::unique_ptr<MouseInput> mouseInput = std::make_unique<MouseInput>(s_MouseInputTestCallback);
std::unique_ptr<TerminalInput> mouseInput = std::make_unique<TerminalInput>(s_MouseInputTestCallback);
unsigned int uiModifierKeystate = 0;
VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"uiModifierKeystate", uiModifierKeystate));
short sModifierKeystate = (SHORT)uiModifierKeystate;
Expand Down
6 changes: 4 additions & 2 deletions src/terminal/input/lib/terminalinput.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
<RootNamespace>adapter</RootNamespace>
<ProjectName>TerminalInput</ProjectName>
<TargetName>TerminalInput</TargetName>
<ConfigurationType>StaticLibrary</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(SolutionDir)src\common.build.pre.props" />
<ItemGroup>
<ClCompile Include="..\mouseInput.cpp" />
<ClCompile Include="..\mouseInputState.cpp" />
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
<ClCompile Include="..\terminalInput.cpp" />
<ClCompile Include="..\precomp.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
Expand All @@ -26,4 +28,4 @@
</ItemGroup>
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
<Import Project="$(SolutionDir)src\common.build.post.props" />
</Project>
</Project>
Loading