mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-16 10:50:49 -08:00
Update Android port
* src/android.c (android_query_tree, android_get_geometry) (android_translate_coordinates, android_wc_lookup_string) (android_get_keysym_name, android_browse_url) (android_query_battery): * src/androidmenu.c (android_dismiss_menu, android_menu_show): Circumvent JNI dynamic method dispatch overhead.
This commit is contained in:
parent
ef8458558d
commit
19857b51b0
2 changed files with 56 additions and 42 deletions
|
|
@ -4963,15 +4963,17 @@ android_query_tree (android_window handle, android_window *root_return,
|
||||||
jsize nelements, i;
|
jsize nelements, i;
|
||||||
android_window *children;
|
android_window *children;
|
||||||
jshort *shorts;
|
jshort *shorts;
|
||||||
|
jmethodID method;
|
||||||
|
|
||||||
window = android_resolve_handle (handle, ANDROID_HANDLE_WINDOW);
|
window = android_resolve_handle (handle, ANDROID_HANDLE_WINDOW);
|
||||||
|
|
||||||
/* window can be NULL, so this is a service method. */
|
/* window can be NULL, so this is a service method. */
|
||||||
|
method = service_class.query_tree;
|
||||||
array
|
array
|
||||||
= (*android_java_env)->CallObjectMethod (android_java_env,
|
= (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
|
||||||
emacs_service,
|
emacs_service,
|
||||||
service_class.query_tree,
|
service_class.class,
|
||||||
window);
|
method, window);
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
/* The first element of the array is the parent window. The rest
|
/* The first element of the array is the parent window. The rest
|
||||||
|
|
@ -5024,9 +5026,10 @@ android_get_geometry (android_window handle,
|
||||||
get_geometry = window_class.get_window_geometry;
|
get_geometry = window_class.get_window_geometry;
|
||||||
|
|
||||||
window_geometry
|
window_geometry
|
||||||
= (*android_java_env)->CallObjectMethod (android_java_env,
|
= (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
|
||||||
window,
|
window,
|
||||||
get_geometry);
|
window_class.class,
|
||||||
|
get_geometry);
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
/* window_geometry is an array containing x, y, width and
|
/* window_geometry is an array containing x, y, width and
|
||||||
|
|
@ -5084,9 +5087,11 @@ android_translate_coordinates (android_window src, int x,
|
||||||
window = android_resolve_handle (src, ANDROID_HANDLE_WINDOW);
|
window = android_resolve_handle (src, ANDROID_HANDLE_WINDOW);
|
||||||
method = window_class.translate_coordinates;
|
method = window_class.translate_coordinates;
|
||||||
coordinates
|
coordinates
|
||||||
= (*android_java_env)->CallObjectMethod (android_java_env,
|
= (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
|
||||||
window, method,
|
window,
|
||||||
(jint) x, (jint) y);
|
window_class.class,
|
||||||
|
method, (jint) x,
|
||||||
|
(jint) y);
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
/* The array must contain two elements: X, Y translated to the root
|
/* The array must contain two elements: X, Y translated to the root
|
||||||
|
|
@ -5124,7 +5129,9 @@ android_wc_lookup_string (android_key_pressed_event *event,
|
||||||
const jchar *characters;
|
const jchar *characters;
|
||||||
jsize size;
|
jsize size;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
JNIEnv *env;
|
||||||
|
|
||||||
|
env = android_java_env;
|
||||||
status = ANDROID_LOOKUP_NONE;
|
status = ANDROID_LOOKUP_NONE;
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
|
|
@ -5175,9 +5182,10 @@ android_wc_lookup_string (android_key_pressed_event *event,
|
||||||
{
|
{
|
||||||
window = android_handles[event->window].handle;
|
window = android_handles[event->window].handle;
|
||||||
string
|
string
|
||||||
= (*android_java_env)->CallObjectMethod (android_java_env, window,
|
= (*env)->CallNonvirtualObjectMethod (env, window,
|
||||||
window_class.lookup_string,
|
window_class.class,
|
||||||
(jint) event->serial);
|
window_class.lookup_string,
|
||||||
|
(jint) event->serial);
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
if (!string)
|
if (!string)
|
||||||
|
|
@ -5185,13 +5193,11 @@ android_wc_lookup_string (android_key_pressed_event *event,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Now return this input method string. */
|
/* Now return this input method string. */
|
||||||
characters = (*android_java_env)->GetStringChars (android_java_env,
|
characters = (*env)->GetStringChars (env, string, NULL);
|
||||||
string, NULL);
|
|
||||||
android_exception_check_nonnull ((void *) characters, string);
|
android_exception_check_nonnull ((void *) characters, string);
|
||||||
|
|
||||||
/* Figure out how big the string is. */
|
/* Establish the size of the the string. */
|
||||||
size = (*android_java_env)->GetStringLength (android_java_env,
|
size = (*env)->GetStringLength (env, string);
|
||||||
string);
|
|
||||||
|
|
||||||
/* Copy over the string data. */
|
/* Copy over the string data. */
|
||||||
for (i = 0; i < MIN ((unsigned int) wchars_buffer, size); ++i)
|
for (i = 0; i < MIN ((unsigned int) wchars_buffer, size); ++i)
|
||||||
|
|
@ -5210,8 +5216,7 @@ android_wc_lookup_string (android_key_pressed_event *event,
|
||||||
else
|
else
|
||||||
rc = size;
|
rc = size;
|
||||||
|
|
||||||
(*android_java_env)->ReleaseStringChars (android_java_env, string,
|
(*env)->ReleaseStringChars (env, string, characters);
|
||||||
characters);
|
|
||||||
ANDROID_DELETE_LOCAL_REF (string);
|
ANDROID_DELETE_LOCAL_REF (string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5425,11 +5430,15 @@ android_get_keysym_name (int keysym, char *name_return, size_t size)
|
||||||
{
|
{
|
||||||
jobject string;
|
jobject string;
|
||||||
const char *buffer;
|
const char *buffer;
|
||||||
|
jmethodID method;
|
||||||
|
|
||||||
string = (*android_java_env)->CallObjectMethod (android_java_env,
|
method = service_class.name_keysym;
|
||||||
emacs_service,
|
string
|
||||||
service_class.name_keysym,
|
= (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
|
||||||
(jint) keysym);
|
emacs_service,
|
||||||
|
service_class.class,
|
||||||
|
method,
|
||||||
|
(jint) keysym);
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
buffer = (*android_java_env)->GetStringUTFChars (android_java_env,
|
buffer = (*android_java_env)->GetStringUTFChars (android_java_env,
|
||||||
|
|
@ -6136,11 +6145,13 @@ android_browse_url (Lisp_Object url, Lisp_Object send)
|
||||||
const char *buffer;
|
const char *buffer;
|
||||||
|
|
||||||
string = android_build_string (url);
|
string = android_build_string (url);
|
||||||
value = (*android_java_env)->CallObjectMethod (android_java_env,
|
value
|
||||||
emacs_service,
|
= (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
|
||||||
service_class.browse_url,
|
emacs_service,
|
||||||
string,
|
service_class.class,
|
||||||
(jboolean) !NILP (send));
|
service_class.browse_url,
|
||||||
|
string,
|
||||||
|
(jboolean) !NILP (send));
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
ANDROID_DELETE_LOCAL_REF (string);
|
ANDROID_DELETE_LOCAL_REF (string);
|
||||||
|
|
@ -6205,10 +6216,14 @@ android_query_battery (struct android_battery_state *status)
|
||||||
{
|
{
|
||||||
jlongArray array;
|
jlongArray array;
|
||||||
jlong *longs;
|
jlong *longs;
|
||||||
|
jmethodID method;
|
||||||
|
|
||||||
array = (*android_java_env)->CallObjectMethod (android_java_env,
|
method = service_class.query_battery;
|
||||||
emacs_service,
|
array
|
||||||
service_class.query_battery);
|
= (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
|
||||||
|
emacs_service,
|
||||||
|
service_class.class,
|
||||||
|
method);
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
/* A NULL return with no exception means that battery information
|
/* A NULL return with no exception means that battery information
|
||||||
|
|
|
||||||
|
|
@ -162,10 +162,11 @@ android_dismiss_menu (void *pointer)
|
||||||
struct android_dismiss_menu_data *data;
|
struct android_dismiss_menu_data *data;
|
||||||
|
|
||||||
data = pointer;
|
data = pointer;
|
||||||
(*android_java_env)->CallVoidMethod (android_java_env,
|
(*android_java_env)->CallNonvirtualVoidMethod (android_java_env,
|
||||||
data->menu,
|
data->menu,
|
||||||
menu_class.dismiss,
|
menu_class.class,
|
||||||
data->window);
|
menu_class.dismiss,
|
||||||
|
data->window);
|
||||||
popup_activated_flag = 0;
|
popup_activated_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,14 +363,12 @@ android_menu_show (struct frame *f, int x, int y, int menuflags,
|
||||||
pane_string++;
|
pane_string++;
|
||||||
|
|
||||||
/* Add the pane. */
|
/* Add the pane. */
|
||||||
temp = (*android_java_env)->NewStringUTF (android_java_env,
|
temp = (*env)->NewStringUTF (env, pane_string);
|
||||||
pane_string);
|
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
|
|
||||||
(*android_java_env)->CallVoidMethod (android_java_env,
|
(*env)->CallNonvirtualVoidMethod (env, current_context_menu,
|
||||||
current_context_menu,
|
menu_class.class,
|
||||||
menu_class.add_pane,
|
menu_class.add_pane, temp);
|
||||||
temp);
|
|
||||||
android_exception_check ();
|
android_exception_check ();
|
||||||
ANDROID_DELETE_LOCAL_REF (temp);
|
ANDROID_DELETE_LOCAL_REF (temp);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue