diff --git a/app/src/main/java/helium314/keyboard/keyboard/KeyboardActionListenerImpl.kt b/app/src/main/java/helium314/keyboard/keyboard/KeyboardActionListenerImpl.kt index fad78ee8f..faf9b963b 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/KeyboardActionListenerImpl.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/KeyboardActionListenerImpl.kt @@ -43,8 +43,10 @@ class KeyboardActionListenerImpl(private val latinIME: LatinIME, private val inp keyboardSwitcher.onReleaseKey(primaryCode, withSliding, latinIME.currentAutoCapsState, latinIME.currentRecapitalizeState) } - override fun onCodeInput(primaryCode: Int, x: Int, y: Int, isKeyRepeat: Boolean) = - latinIME.onCodeInput(primaryCode, metaState, x, y, isKeyRepeat) + override fun onCodeInput(primaryCode: Int, x: Int, y: Int, isKeyRepeat: Boolean) { + val mkv = keyboardSwitcher.mainKeyboardView + latinIME.onCodeInput(primaryCode, metaState, mkv.getKeyX(x), mkv.getKeyY(y), isKeyRepeat) + } override fun onTextInput(text: String?) = latinIME.onTextInput(text) diff --git a/app/src/main/java/helium314/keyboard/latin/LatinIME.java b/app/src/main/java/helium314/keyboard/latin/LatinIME.java index f2d31cf74..592af48d7 100644 --- a/app/src/main/java/helium314/keyboard/latin/LatinIME.java +++ b/app/src/main/java/helium314/keyboard/latin/LatinIME.java @@ -1487,22 +1487,12 @@ public class LatinIME extends InputMethodService implements case KeyCode.TOGGLE_INCOGNITO_MODE -> {mSettings.toggleAlwaysIncognitoMode(); return; } } } - // TODO: this processing does not belong inside LatinIME, the caller should be doing this. - final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - // x and y include some padding, but everything down the line (especially native - // code) needs the coordinates in the keyboard frame. - // TODO: We should reconsider which coordinate system should be used to represent - // keyboard event. Also we should pull this up -- LatinIME has no business doing - // this transformation, it should be done already before calling onEvent. - final int keyX = mainKeyboardView.getKeyX(x); - final int keyY = mainKeyboardView.getKeyY(y); final Event event; - // checking if the character is a combining accent if (0x300 <= codePoint && codePoint <= 0x35b) { event = Event.createSoftwareDeadEvent(codePoint, 0, metaState, x, y, null); } else { - event = createSoftwareKeypressEvent(codePoint, metaState, keyX, keyY, isKeyRepeat); + event = createSoftwareKeypressEvent(codePoint, metaState, x, y, isKeyRepeat); } onEvent(event);