Terminal: fixes motion events
* fReportButtonMouseEvent 1002 means only drag events are to be reported. * only one of the modes 1000/1002/1003 can be selected. * makes sure to report a button when dragging. * secondary and tertiary buttons were reversed. * extended buffer is now filled with snprintf. * fixes #17684 Change-Id: I59d80937ae193343dc1e7006c4371320fc2182d7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5184 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
dbcbe07a1b
commit
8386ba2747
@ -1903,14 +1903,22 @@ TermView::MessageReceived(BMessage *message)
|
|||||||
if (message->FindBool("reportX10MouseEvent", &value) == B_OK)
|
if (message->FindBool("reportX10MouseEvent", &value) == B_OK)
|
||||||
fReportX10MouseEvent = value;
|
fReportX10MouseEvent = value;
|
||||||
|
|
||||||
if (message->FindBool("reportNormalMouseEvent", &value) == B_OK)
|
// setting one of the three disables the other two
|
||||||
|
if (message->FindBool("reportNormalMouseEvent", &value) == B_OK) {
|
||||||
fReportNormalMouseEvent = value;
|
fReportNormalMouseEvent = value;
|
||||||
|
fReportButtonMouseEvent = false;
|
||||||
if (message->FindBool("reportButtonMouseEvent", &value) == B_OK)
|
fReportAnyMouseEvent = false;
|
||||||
|
}
|
||||||
|
if (message->FindBool("reportButtonMouseEvent", &value) == B_OK) {
|
||||||
fReportButtonMouseEvent = value;
|
fReportButtonMouseEvent = value;
|
||||||
|
fReportNormalMouseEvent = false;
|
||||||
if (message->FindBool("reportAnyMouseEvent", &value) == B_OK)
|
fReportAnyMouseEvent = false;
|
||||||
|
}
|
||||||
|
if (message->FindBool("reportAnyMouseEvent", &value) == B_OK) {
|
||||||
fReportAnyMouseEvent = value;
|
fReportAnyMouseEvent = value;
|
||||||
|
fReportNormalMouseEvent = false;
|
||||||
|
fReportButtonMouseEvent = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (message->FindBool(
|
if (message->FindBool(
|
||||||
"enableExtendedMouseCoordinates", &value) == B_OK)
|
"enableExtendedMouseCoordinates", &value) == B_OK)
|
||||||
@ -2475,7 +2483,8 @@ TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y,
|
|||||||
else
|
else
|
||||||
xtermButtons = 32 + 3;
|
xtermButtons = 32 + 3;
|
||||||
|
|
||||||
if (motion)
|
// dragging motion
|
||||||
|
if (buttons != 0 && motion && fReportButtonMouseEvent)
|
||||||
xtermButtons += 32;
|
xtermButtons += 32;
|
||||||
|
|
||||||
char xtermX = x + 1 + 32;
|
char xtermX = x + 1 + 32;
|
||||||
@ -2492,38 +2501,32 @@ TermView::_SendMouseEvent(int32 buttons, int32 mode, int32 x, int32 y,
|
|||||||
} else {
|
} else {
|
||||||
char xtermButtons;
|
char xtermButtons;
|
||||||
if ((buttons & B_PRIMARY_MOUSE_BUTTON)
|
if ((buttons & B_PRIMARY_MOUSE_BUTTON)
|
||||||
!= (fMouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
|
!= (motion ? 0 : (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)) {
|
!= (motion ? 0 : (fMouseButtons & B_SECONDARY_MOUSE_BUTTON))) {
|
||||||
xtermButtons = 1;
|
|
||||||
} else if ((buttons & B_TERTIARY_MOUSE_BUTTON)
|
|
||||||
!= (fMouseButtons & B_TERTIARY_MOUSE_BUTTON)) {
|
|
||||||
xtermButtons = 2;
|
xtermButtons = 2;
|
||||||
|
} else if ((buttons & B_TERTIARY_MOUSE_BUTTON)
|
||||||
|
!= (motion ? 0 : (fMouseButtons & B_TERTIARY_MOUSE_BUTTON))) {
|
||||||
|
xtermButtons = 1;
|
||||||
} else
|
} else
|
||||||
xtermButtons = 3;
|
xtermButtons = 3;
|
||||||
|
|
||||||
if (motion)
|
// nur button events requested
|
||||||
|
if (buttons == 0 && motion && fReportButtonMouseEvent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// dragging motion
|
||||||
|
if (buttons != 0 && motion && fReportButtonMouseEvent)
|
||||||
xtermButtons += 32;
|
xtermButtons += 32;
|
||||||
|
|
||||||
int16 xtermX = x + 1;
|
int16 xtermX = x + 1;
|
||||||
int16 xtermY = y + 1;
|
int16 xtermY = y + 1;
|
||||||
|
|
||||||
char destBuffer[13];
|
char destBuffer[21];
|
||||||
destBuffer[0] = '\033';
|
int size = snprintf(destBuffer, sizeof(destBuffer), "\033[<%u;%u;%u%c",
|
||||||
destBuffer[1] = '[';
|
xtermButtons, xtermX, xtermY, upEvent ? 'm' : 'M');
|
||||||
destBuffer[2] = '<';
|
fShell->Write(destBuffer, size);
|
||||||
destBuffer[3] = xtermButtons + '0';
|
|
||||||
destBuffer[4] = ';';
|
|
||||||
destBuffer[5] = xtermX / 100 % 10 + '0';
|
|
||||||
destBuffer[6] = xtermX / 10 % 10 + '0';
|
|
||||||
destBuffer[7] = xtermX % 10 + '0';
|
|
||||||
destBuffer[8] = ';';
|
|
||||||
destBuffer[9] = xtermY / 100 % 10 + '0';
|
|
||||||
destBuffer[10] = xtermY / 10 % 10 + '0';
|
|
||||||
destBuffer[11] = xtermY % 10 + '0';
|
|
||||||
destBuffer[12] = upEvent ? 'm' : 'M';
|
|
||||||
fShell->Write(destBuffer, 13);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ TermView::StandardBaseState::_StandardMouseMoved(BPoint where, int32 modifiers)
|
|||||||
|
|
||||||
TermPos clickPos = fView->_ConvertToTerminal(where);
|
TermPos clickPos = fView->_ConvertToTerminal(where);
|
||||||
|
|
||||||
if (fView->fReportButtonMouseEvent) {
|
if (fView->fReportButtonMouseEvent || fView->fEnableExtendedMouseCoordinates) {
|
||||||
if (fView->fPrevPos.x != clickPos.x
|
if (fView->fPrevPos.x != clickPos.x
|
||||||
|| fView->fPrevPos.y != clickPos.y) {
|
|| fView->fPrevPos.y != clickPos.y) {
|
||||||
fView->_SendMouseEvent(fView->fMouseButtons, modifiers,
|
fView->_SendMouseEvent(fView->fMouseButtons, modifiers,
|
||||||
|
Loading…
Reference in New Issue
Block a user