Respect the console's Quick Edit mode -- it suppresses mouse events
* winpty-agent: Respect the ENABLE_QUICK_EDIT_MODE flag. If it's set, then mouse events are not generated (because they're supposed to control selection). * winpty-agent: Because of the above, turn ENABLE_QUICK_EDIT_MODE off at startup. * winpty-agent --show-input: Enable ENABLE_WINDOW_INPUT so we can see buffer resize events. * winpty-agent --show-input: Disable ENABLE_QUICK_EDIT_MODE with --with-mouse. When Quick Edit mode is enabled, the mouse controls selection and does not produce mouse events in the input queue.
This commit is contained in:
parent
f7e5e1f69a
commit
75fe19ae96
@ -160,7 +160,20 @@ Agent::Agent(LPCWSTR controlPipeName,
|
||||
SetConsoleCtrlHandler(NULL, FALSE);
|
||||
SetConsoleCtrlHandler(consoleCtrlHandler, TRUE);
|
||||
|
||||
updateMouseInputFlag(true);
|
||||
// Disable Quick Edit mode. The user has little control over winpty's
|
||||
// console, and I think it's better to default it off for the sake of
|
||||
// programs that care about mouse input.
|
||||
DWORD mode = 0;
|
||||
if (!GetConsoleMode(m_console->conin(), &mode)) {
|
||||
trace("Agent startup: GetConsoleMode failed");
|
||||
} else {
|
||||
mode &= ~ENABLE_QUICK_EDIT_MODE;
|
||||
if (!SetConsoleMode(m_console->conin(), mode)) {
|
||||
trace("Agent startup: SetConsoleMode failed");
|
||||
}
|
||||
}
|
||||
|
||||
updateMouseInputFlags(true);
|
||||
setPollInterval(25);
|
||||
}
|
||||
|
||||
@ -361,23 +374,28 @@ void Agent::pollDataSocket()
|
||||
}
|
||||
}
|
||||
|
||||
void Agent::updateMouseInputFlag(bool forceTrace)
|
||||
void Agent::updateMouseInputFlags(bool forceTrace)
|
||||
{
|
||||
DWORD mode = 0;
|
||||
GetConsoleMode(m_console->conin(), &mode);
|
||||
bool newFlag = mode & ENABLE_MOUSE_INPUT;
|
||||
if (forceTrace || newFlag != m_consoleMouseInputFlag) {
|
||||
trace("CONIN mode ENABLE_MOUSE_INPUT: %s",
|
||||
newFlag ? "enabled" : "disabled");
|
||||
bool newFlagMI = mode & ENABLE_MOUSE_INPUT;
|
||||
bool newFlagQE = mode & ENABLE_QUICK_EDIT_MODE;
|
||||
if (forceTrace ||
|
||||
newFlagMI != m_consoleMouseInputEnabled ||
|
||||
newFlagQE != m_consoleQuickEditEnabled) {
|
||||
trace("CONIN mode: ENABLE_MOUSE_INPUT=%s ENABLE_QUICK_EDIT_MODE=%s",
|
||||
newFlagMI ? "enabled" : "disabled",
|
||||
newFlagQE ? "enabled" : "disabled");
|
||||
}
|
||||
m_consoleMouseInputFlag = newFlag;
|
||||
m_consoleInput->setMouseInputEnabled(newFlag);
|
||||
m_consoleMouseInputEnabled = newFlagMI;
|
||||
m_consoleQuickEditEnabled = newFlagQE;
|
||||
m_consoleInput->setMouseInputEnabled(newFlagMI && !newFlagQE);
|
||||
}
|
||||
|
||||
void Agent::onPollTimeout()
|
||||
{
|
||||
// Check the mouse input flag so we can output a trace message.
|
||||
updateMouseInputFlag();
|
||||
updateMouseInputFlags();
|
||||
|
||||
// Give the ConsoleInput object a chance to flush input from an incomplete
|
||||
// escape sequence (e.g. pressing ESC).
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
int handleStartProcessPacket(ReadBuffer &packet);
|
||||
int handleSetSizePacket(ReadBuffer &packet);
|
||||
void pollDataSocket();
|
||||
void updateMouseInputFlag(bool forceTrace=false);
|
||||
void updateMouseInputFlags(bool forceTrace=false);
|
||||
|
||||
protected:
|
||||
virtual void onPollTimeout();
|
||||
@ -95,7 +95,8 @@ private:
|
||||
private:
|
||||
bool m_useMark;
|
||||
Win32Console *m_console;
|
||||
bool m_consoleMouseInputFlag;
|
||||
bool m_consoleMouseInputEnabled;
|
||||
bool m_consoleQuickEditEnabled;
|
||||
NamedPipe *m_controlSocket;
|
||||
NamedPipe *m_dataSocket;
|
||||
bool m_closingDataSocket;
|
||||
|
@ -145,8 +145,10 @@ void debugShowInput(bool enableMouse) {
|
||||
newConsoleMode &= ~ENABLE_PROCESSED_INPUT;
|
||||
newConsoleMode &= ~ENABLE_LINE_INPUT;
|
||||
newConsoleMode &= ~ENABLE_ECHO_INPUT;
|
||||
newConsoleMode |= ENABLE_WINDOW_INPUT;
|
||||
if (enableMouse) {
|
||||
newConsoleMode |= ENABLE_MOUSE_INPUT;
|
||||
newConsoleMode &= ~ENABLE_QUICK_EDIT_MODE;
|
||||
} else {
|
||||
newConsoleMode &= ~ENABLE_MOUSE_INPUT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user