1
0
Fork 0

added support for RustDesk

This commit is contained in:
sspanak 2024-07-04 12:57:40 +03:00 committed by Dimo Karaivanov
parent 3e1c210118
commit 852eab0d64
5 changed files with 35 additions and 3 deletions

View file

@ -70,6 +70,19 @@ public class AppHacks {
}
/**
* Handles applications that always report no text around the cursor, preventing the cursor from
* moving the usual way.
*/
public boolean onMoveCursor(boolean backward) {
if (inputType.isRustDesk() || inputType.isTermux()) {
return sendDownUpKeyEvents(backward ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT);
}
return false;
}
/**
* Performs extra operations when the cursor moves and returns "true" if the selection was handled, "false" otherwise.
*/

View file

@ -65,6 +65,21 @@ public class InputType extends StandardInputType {
}
/**
* RustDesk does not support composing text when connected to a remote computer. This detects the
* "remote input field", so that we can prevent inserting any composing text, but still perform
* the composing operation behind the scenes.
*/
public boolean isRustDesk() {
final int OPTIONS_MASK = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_FULLSCREEN;
return isAppField(
"com.carriez.flutter_hbb",
EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS
) && (field.imeOptions & OPTIONS_MASK) == OPTIONS_MASK;
}
/**
* Simulate the behavior of the Sonim native keyboard. In search fields with integrated lists,
* ENTER is used to select an item from the list. But some of them have actionId = NEXT, instead of NONE,

View file

@ -102,7 +102,7 @@ public abstract class HotkeyHandler extends CommandHandler {
public boolean onKeyMoveCursor(boolean backward) {
return textField.moveCursor(backward);
return appHacks.onMoveCursor(backward) || textField.moveCursor(backward);
}

View file

@ -77,6 +77,10 @@ public abstract class TypingHandler extends KeyPadHandler {
protected void setInputField(InputConnection connection, EditorInfo field) {
if (textField.equals(connection, field)) {
return;
}
currentInputConnection = connection;
inputType = new InputType(currentInputConnection, field);
textField = new TextField(currentInputConnection, field);
@ -198,7 +202,7 @@ public abstract class TypingHandler extends KeyPadHandler {
private void autoCorrectSpace(String currentWord, boolean isWordAcceptedManually, int nextKey) {
if (mInputMode.shouldDeletePrecedingSpace(inputType)) {
if (!inputType.isRustDesk() && mInputMode.shouldDeletePrecedingSpace(inputType)) {
textField.deletePrecedingSpace(currentWord);
}

View file

@ -27,7 +27,7 @@ public class TextField extends InputField {
super(inputConnection, inputField);
InputType inputType = new InputType(inputConnection, inputField);
isComposingSupported = !inputType.isNumeric() && !inputType.isLimited();
isComposingSupported = !inputType.isNumeric() && !inputType.isLimited() && !inputType.isRustDesk();
}