Terminal: add support for mouse press/release events in Extended/SGR 1006 mode

fixes #17532

Change-Id: Ic9f19ace5c728b6823caa5ce8ec35dc35d244220
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4867
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Jérôme Duval
2022-01-15 14:18:41 +00:00
committed by waddlesplash
parent abe423c6e4
commit 9a7f2c2459
4 changed files with 25 additions and 9 deletions
+9 -7
View File
@@ -2462,7 +2462,7 @@ TermView::_MouseDistanceSinceLastClick(BPoint where)
void void
TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y, TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y,
bool motion) bool motion, bool upEvent)
{ {
if (!fEnableExtendedMouseCoordinates) { if (!fEnableExtendedMouseCoordinates) {
char xtermButtons; char xtermButtons;
@@ -2491,13 +2491,16 @@ TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y,
fShell->Write(destBuffer, 6); fShell->Write(destBuffer, 6);
} else { } else {
char xtermButtons; char xtermButtons;
if (buttons == B_PRIMARY_MOUSE_BUTTON) if ((buttons & B_PRIMARY_MOUSE_BUTTON)
!= (fMouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
xtermButtons = 0; xtermButtons = 0;
else if (buttons == B_SECONDARY_MOUSE_BUTTON) } else if ((buttons & B_SECONDARY_MOUSE_BUTTON)
!= (fMouseButtons & B_SECONDARY_MOUSE_BUTTON)) {
xtermButtons = 1; xtermButtons = 1;
else if (buttons == B_TERTIARY_MOUSE_BUTTON) } else if ((buttons & B_TERTIARY_MOUSE_BUTTON)
!= (fMouseButtons & B_TERTIARY_MOUSE_BUTTON)) {
xtermButtons = 2; xtermButtons = 2;
else } else
xtermButtons = 3; xtermButtons = 3;
if (motion) if (motion)
@@ -2519,8 +2522,7 @@ TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y,
destBuffer[9] = xtermY / 100 % 10 + '0'; destBuffer[9] = xtermY / 100 % 10 + '0';
destBuffer[10] = xtermY / 10 % 10 + '0'; destBuffer[10] = xtermY / 10 % 10 + '0';
destBuffer[11] = xtermY % 10 + '0'; destBuffer[11] = xtermY % 10 + '0';
// No support for button press/release destBuffer[12] = upEvent ? 'm' : 'M';
destBuffer[12] = 'M';
fShell->Write(destBuffer, 13); fShell->Write(destBuffer, 13);
} }
} }
+2 -1
View File
@@ -254,7 +254,8 @@ private:
void _ScrollToRange(TermPos start, TermPos end); void _ScrollToRange(TermPos start, TermPos end);
void _SendMouseEvent(int32 button, int32 mode, void _SendMouseEvent(int32 button, int32 mode,
int32 x, int32 y, bool motion); int32 x, int32 y, bool motion,
bool upEvent = false);
void _DrawInlineMethodString(); void _DrawInlineMethodString();
void _HandleInputMethodChanged(BMessage* message); void _HandleInputMethodChanged(BMessage* message);
+13 -1
View File
@@ -423,7 +423,7 @@ TermView::DefaultState::MouseDown(BPoint where, int32 buttons, int32 modifiers)
|| fView->fReportNormalMouseEvent || fView->fReportX10MouseEvent) { || fView->fReportNormalMouseEvent || fView->fReportX10MouseEvent) {
TermPos clickPos = fView->_ConvertToTerminal(where); TermPos clickPos = fView->_ConvertToTerminal(where);
fView->_SendMouseEvent(buttons, modifiers, clickPos.x, clickPos.y, fView->_SendMouseEvent(buttons, modifiers, clickPos.x, clickPos.y,
false); false, false);
return; return;
} }
@@ -452,6 +452,18 @@ TermView::DefaultState::MouseMoved(BPoint where, uint32 transit,
} }
void
TermView::DefaultState::MouseUp(BPoint where, int32 buttons)
{
if (fView->fReportAnyMouseEvent || fView->fReportButtonMouseEvent
|| fView->fReportNormalMouseEvent || fView->fReportX10MouseEvent) {
TermPos clickPos = fView->_ConvertToTerminal(where);
fView->_SendMouseEvent(buttons, 0, clickPos.x, clickPos.y,
false, true);
}
}
void void
TermView::DefaultState::WindowActivated(bool active) TermView::DefaultState::WindowActivated(bool active)
{ {
+1
View File
@@ -72,6 +72,7 @@ public:
int32 modifiers); int32 modifiers);
virtual void MouseMoved(BPoint where, uint32 transit, virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage, int32 modifiers); const BMessage* dragMessage, int32 modifiers);
virtual void MouseUp(BPoint where, int32 buttons);
virtual void WindowActivated(bool active); virtual void WindowActivated(bool active);