main.c: window size needs to be set before calling set_up_handle_cache()

the Context class init creates a static DisplayMetric
This commit is contained in:
Julian Winkler
2023-08-23 10:04:24 +02:00
parent e694973a1f
commit 029b26beb2

View File

@@ -307,6 +307,10 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
free(app_lib_dir); free(app_lib_dir);
jclass display_class = (*env)->FindClass(env, "android/view/Display");
_SET_STATIC_INT_FIELD(display_class, "window_width", d->window_width);
_SET_STATIC_INT_FIELD(display_class, "window_height", d->window_height);
set_up_handle_cache(env); set_up_handle_cache(env);
/* -- register our JNI library under the appropriate classloader -- */ /* -- register our JNI library under the appropriate classloader -- */
@@ -326,10 +330,6 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
/* -- misc -- */ /* -- misc -- */
jclass display_class = (*env)->FindClass(env, "android/view/Display");
_SET_STATIC_INT_FIELD(display_class, "window_width", d->window_width);
_SET_STATIC_INT_FIELD(display_class, "window_height", d->window_height);
// some apps need the apk path since they directly read their apk // some apps need the apk path since they directly read their apk
jclass context_class = (*env)->FindClass(env, "android/content/Context"); jclass context_class = (*env)->FindClass(env, "android/content/Context");
_SET_STATIC_OBJ_FIELD(context_class, "apk_path", "Ljava/lang/String;", _JSTRING(apk_classpath)); _SET_STATIC_OBJ_FIELD(context_class, "apk_path", "Ljava/lang/String;", _JSTRING(apk_classpath));