TerminalEmulator: Do not send mouse clicks out of range
This commit is contained in:
parent
da90304011
commit
3836fe4f09
@ -62,7 +62,6 @@
|
||||
<activity
|
||||
android:name=".ui.term.NeoTermRemoteInterface"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:excludeFromRecents="false"
|
||||
android:exported="true"
|
||||
android:theme="@style/AppTheme.Dark"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden">
|
||||
|
@ -391,6 +391,11 @@ public final class TerminalEmulator {
|
||||
* @param mouseButton one of the MOUSE_* constants of this class.
|
||||
*/
|
||||
public void sendMouseEvent(int mouseButton, int column, int row, boolean pressed) {
|
||||
if (column < 1) column = 1;
|
||||
if (column > mColumns) column = mColumns;
|
||||
if (row < 1) row = 1;
|
||||
if (row > mRows) row = mRows;
|
||||
|
||||
if (mouseButton == MOUSE_LEFT_BUTTON_MOVED && !isDecsetInternalBitSet(DECSET_BIT_MOUSE_TRACKING_BUTTON_EVENT)) {
|
||||
// Do not send tracking.
|
||||
} else if (isDecsetInternalBitSet(DECSET_BIT_MOUSE_PROTOCOL_SGR)) {
|
||||
@ -398,7 +403,7 @@ public final class TerminalEmulator {
|
||||
} else {
|
||||
mouseButton = pressed ? mouseButton : 3; // 3 for release of all buttons.
|
||||
// Clip to screen, and clip to the limits of 8-bit data.
|
||||
boolean out_of_bounds = column < 1 || row < 1 || column > mColumns || row > mRows || column > 255 - 32 || row > 255 - 32;
|
||||
boolean out_of_bounds = column > 255 - 32 || row > 255 - 32;
|
||||
if (!out_of_bounds) {
|
||||
byte[] data = {'\033', '[', 'M', (byte) (32 + mouseButton), (byte) (32 + column), (byte) (32 + row)};
|
||||
mSession.write(data, 0, data.length);
|
||||
|
Loading…
Reference in New Issue
Block a user