Send text input to the LO code

Change-Id: I28070fb1a8b85c9737d2a78a8a713243ce47dde9
This commit is contained in:
Tor Lillqvist 2013-02-27 21:00:02 +02:00
parent 86d734c03b
commit 7cf5fea499
2 changed files with 33 additions and 1 deletions

View File

@ -45,6 +45,7 @@ public class Desktop
/* implementend by vcl */
public static native void renderVCL(Bitmap bitmap);
public static native void setViewSize(int width, int height);
public static native void key(char c, short timestamp);
/**
* This class contains the state that is initialized once and never changes
@ -217,6 +218,10 @@ public class Desktop
@Override public boolean commitText(CharSequence text, int newCursorPosition) {
Log.i(TAG, "commitText(" + text + ", " + newCursorPosition + ")");
short timestamp = (short) (System.currentTimeMillis() % Short.MAX_VALUE);
for (int i = 0; i < text.length(); i++) {
Desktop.key(text.charAt(i), timestamp);
}
return true;
}
}

View File

@ -39,6 +39,7 @@
#define LOGTAG "LibreOffice/androidinst"
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOGTAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOGTAG, __VA_ARGS__))
static bool bHitIdle = false;
@ -463,6 +464,8 @@ void AndroidSalInstance::onAppCmd (struct android_app* app, int32_t cmd)
}
}
#endif
/*
* Try too hard to get a frame, in the absence of anything better to do
*/
@ -486,6 +489,8 @@ SalFrame *AndroidSalInstance::getFocusFrame() const
return pFocus;
}
#if 0
int32_t AndroidSalInstance::onInputEvent (struct android_app* app, AInputEvent* event)
{
bool bHandled = false;
@ -960,7 +965,7 @@ typedef struct ANativeWindow_Buffer {
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */,
jobject /* object */,
jobject /* clazz */,
jint width,
jint height)
{
@ -969,4 +974,26 @@ Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */
viewHeight = height;
}
extern "C" SAL_JNI_EXPORT void JNICALL
Java_org_libreoffice_experimental_desktop_Desktop_key(JNIEnv * /* env */,
jobject /* clazz */,
jchar c,
jshort timestamp)
{
SalKeyEvent aEvent;
aEvent.mnCharCode = c;
aEvent.mnTime = timestamp;
aEvent.mnCode = c;
aEvent.mnRepeat = 0;
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
pFocus->CallCallback( SALEVENT_KEYINPUT, &aEvent );
pFocus->CallCallback( SALEVENT_KEYUP, &aEvent );
}
else
LOGW("No focused frame to emit event on");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */