From 029b26beb2ece201dd8c83adc8e80cc760ce2542 Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Wed, 23 Aug 2023 10:04:24 +0200 Subject: [PATCH] main.c: window size needs to be set before calling set_up_handle_cache() the Context class init creates a static DisplayMetric --- src/main-executable/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main-executable/main.c b/src/main-executable/main.c index bbd80d4c..199224a0 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -307,6 +307,10 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h 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); /* -- 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 -- */ - 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 jclass context_class = (*env)->FindClass(env, "android/content/Context"); _SET_STATIC_OBJ_FIELD(context_class, "apk_path", "Ljava/lang/String;", _JSTRING(apk_classpath));