@@ -33,11 +33,13 @@ JavaVM *jVM = NULL;
3333
3434static jclass jAndroidInputDeviceRegistryClass ;
3535static jclass jMonocleWindowManagerClass ;
36+ static jclass jScreenClass ;
3637
3738static jmethodID monocle_gotTouchEventFromNative ;
3839static jmethodID monocle_dispatchKeyEventFromNative ;
3940static jmethodID monocle_repaintAll ;
4041static jmethodID monocle_registerDevice ;
42+ static jmethodID screen_init ;
4143
4244ANativeWindow * androidWindow = NULL ;
4345jfloat androidDensity = 0.f ;
@@ -51,16 +53,18 @@ void initializeFromJava (JNIEnv *env) {
5153 (* env )-> FindClass (env , "com/sun/glass/ui/monocle/MonocleWindowManager" ));
5254 jAndroidInputDeviceRegistryClass = (* env )-> NewGlobalRef (env ,
5355 (* env )-> FindClass (env , "com/sun/glass/ui/monocle/AndroidInputDeviceRegistry" ));
56+ jScreenClass = (* env )-> NewGlobalRef (env , (* env )-> FindClass (env , "com/sun/glass/ui/Screen" ));
5457 monocle_repaintAll = (* env )-> GetStaticMethodID (
5558 env , jMonocleWindowManagerClass , "repaintFromNative" ,
56- "()V" );
59+ "(Lcom/sun/glass/ui/Screen; )V" );
5760 monocle_gotTouchEventFromNative = (* env )-> GetStaticMethodID (
5861 env , jAndroidInputDeviceRegistryClass , "gotTouchEventFromNative" ,
5962 "(I[I[I[I[II)V" );
6063 monocle_dispatchKeyEventFromNative = (* env )-> GetStaticMethodID (
6164 env , jAndroidInputDeviceRegistryClass , "dispatchKeyEventFromNative" ,
6265 "(II[CI)V" );
6366 monocle_registerDevice = (* env )-> GetStaticMethodID (env , jAndroidInputDeviceRegistryClass , "registerDevice" ,"()V" );
67+ screen_init = (* env )-> GetMethodID (env , jScreenClass ,"<init>" , "(JIIIIIIIIIIIIIIIFFFF)V" );
6468 GLASS_LOG_FINE ("Initializing native Android Bridge done" );
6569}
6670
@@ -153,7 +157,19 @@ void androidJfx_requestGlassToRedraw() {
153157 GLASS_LOG_WARNING ("we can't do this yet, no monocle_repaintAll\n" );
154158 return ;
155159 }
156- (* javaEnv )-> CallStaticVoidMethod (javaEnv , jMonocleWindowManagerClass , monocle_repaintAll );
160+ if (androidWindow == NULL ) {
161+ GLASS_LOG_WARNING ("we can't do this yet, no androidWindow\n" );
162+ return ;
163+ }
164+ int32_t width = ANativeWindow_getWidth (androidWindow ) / androidDensity ;
165+ int32_t height = ANativeWindow_getHeight (androidWindow ) / androidDensity ;
166+ jobject screen = (* javaEnv )-> NewObject (javaEnv , jScreenClass , screen_init ,
167+ (jlong ) androidWindow , 24 ,
168+ 0 , 0 , (jint ) width , (jint ) height ,
169+ 0 , 0 , (jint ) width , (jint ) height ,
170+ 0 , 0 , (jint ) width , (jint ) height ,
171+ SCREEN_DPI , SCREEN_DPI , (jfloat ) 1 , (jfloat ) 1 , androidDensity , androidDensity );
172+ (* javaEnv )-> CallStaticVoidMethod (javaEnv , jMonocleWindowManagerClass , monocle_repaintAll , screen );
157173}
158174
159175/* ===== called from Java ===== */
0 commit comments