Screen position problem on landscape orientation with speaker cutout

Hi everyone,

I’m having a problem across all apps I build for Android, if the device I’m building for has a speaker cutout.

If the phone has one, like my Google Pixel 3XL, the main window is shifted to the left when I rotate the phone counter clockwise and it leaves a space the size of the speaker cutout to the right of the screen… when I rotate clockwise everything is fine.

I uploaded a video on which you can observe the problem here:

Does anyone know how to remedy this? So far I just locked screen rotation for my Android builds, but that is more of a hacky solution to the problem…

1 Like

After more investigation: the problem here is that the whole DocumentWindow seems to be shifted to the left, not only content. Is there a way to remedy this easily and shift the whole DocumentWindow? I could write the JNI needed to use the Android Window Insets class to figure out the speaker inlet size, but how would I then use the determined value to shift the entire window?

I’ve also ran into that exact problem multiple times, and got to this same conclusion… It seems like when there’s a cutout, juce gets confused as to where the origin is.

1 Like

but interestingly it does so only on Landscape orientation… on Portrait orientation the Speaker cutout just gets respected and the window starts on the right y position… because of that fact it seems like the fix should be simple enough, but I have no idea where to even look. The deeper I dig the more confused I get about any way to fix this… maybe @ed95 has a hot tip where to look or how to approach this? How is the DocumentWindow position managed on Android? Where is the cutout being managed for Portrait orientations?

1 Like

same problem here!

So I’ve implemented all the JNI down to WindowInset.getDisplayCutout()

Unfortunately this is where it stops, because, as the documentation for it states, this will return null if it already has been “consumed” and this is what happens… instead of a DisplayCutout object i just get null. Meaning JUCE seems to consume that value but I can’t figure out where that happens…