Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: orientation between portrait<->landscape doesn't work #2968

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Android: orientation between portrait<->landscape doesn't work #2968

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2018-09-03 07:18:10 +0000, Trent Gamblin wrote:

All is fine if you want only landscape or only portrait, but if you want fullSensor it doesn't work. It will start in the correct orientation but not switch after that. I think the problem may be in SDL_androidwindow.c the resizable window flag is toggled off after creating the window, which is later checked in the Java code. My personal temporary fix was to comment all the SENSOR/hints stuff in SDLActivity.java and just stick in an orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Another possible fix is to check for multiple hints and if they're all included then set it to UNSPECIFIED.

If you have a preference on a way to fix this (I have a feeling removing the unset of RESIZABLE would cause problems) I can send a patch.

On 2018-09-03 19:51:43 +0000, Sam Lantinga wrote:

Yes, a patch checking for all hints is fine.

Thanks!

On 2018-09-03 20:22:57 +0000, Trent Gamblin wrote:

Created attachment 3294
Fix for orientation just working between portrait<->landscape

Here's a patch. I can change if it's not OK. Thanks.

On 2018-09-03 20:29:41 +0000, Trent Gamblin wrote:

Created attachment 3295
Documentation fix (Add Android)

Here's a small documentation fix too. This previously only mentioned iOS so confused me a bit.

On 2018-09-08 22:25:18 +0000, Trent Gamblin wrote:

Any changes you'd like to see to these patches? I know it's a bit funky, but can't just set orientation to UNSPECIFIED because that's equal to -1 according to Android docs and my testing.

On 2018-10-03 22:47:09 +0000, Sam Lantinga wrote:

If your window is not resizable then you're not actually allowed to set an orientation that changes the display size. What's your use case where this works?

On 2018-10-03 22:56:24 +0000, Trent Gamblin wrote:

The window is resizable. The internal SDL code of the Android driver toggles that flag off for some reason though. I figured it does it for a reason so it was best not to mess with it. See SDL_androidwindow.c line 175.

On 2018-10-04 00:01:12 +0000, Trent Gamblin wrote:

If you meant how does it work with that flag toggled off, honestly I don't know the internals of SDL much but it just works with the same code as on desktops in my game.

On 2018-10-09 13:00:22 +0000, Sylvain wrote:

Created attachment 3356
patch

A reworked patch for setting the orientation. it also doesn't keep the RESIZABLE flags.

  • The hint is used, as documentation states it, to "explicitly control which UI orientations are allowed".
  • RESIZABLE allows to have both landscape and portrait, provided it's not restricted by the hint.

But there is another issue, this time with SDL_WINDOW_FULLSCREEN, because it exchanges w/h and mislead the choice of orientation is nothing is specified.

(I think the issue is there: https://hg.libsdl.org/SDL/file/18f3294b230e/src/video/SDL_video.c#l1512 )

On 2020-01-12 12:46:40 +0000, Richard Russell wrote:

This bug seems not to be fixed in SDL 2.0.10. Both patches are effective for me (I don't use the hint), so what is the current status as regards incorporation in a release?

On 2020-01-14 16:30:37 +0000, Sylvain wrote:

Hi Richard:

Which one of the 2/3 patches is working for you ?

I you don't use the hint, only the part clearing the RESIZEABLE flag should matter ?

On 2020-01-17 10:02:15 +0000, Richard Russell wrote:

(In reply to Sylvain from comment # 10)

Which one of the 2/3 patches is working for you ?

I used your patch because I need the 'full sensor' mode of operation. But since I don't use the hint anyway, most of your code is redundant in my case.

I you don't use the hint, only the part clearing the RESIZEABLE flag should
matter ?

I'm not sure, I don't think I tried that.

On 2020-01-17 11:04:26 +0000, Sylvain wrote:

Ok thanks for the feedback !
I've commit the patch: https://hg.libsdl.org/SDL/rev/094b752ee72d

On 2020-01-19 12:24:12 +0000, Richard Russell wrote:

(In reply to Sylvain from comment # 10)

I you don't use the hint, only the part clearing the RESIZEABLE flag should
matter ?

You're absolutely right. I've reverted SDLActivity.java to the original SDL2.0.10 version and orientation changes are still working correctly for me, with the change to SDL_androidwindow.c so it no longer clears the SDL_WINDOW_RESIZABLE flag. I should have tried that change first!

So I'm afraid my experience doesn't verify whether your patch is effective, in the presence of the hint. In my application I prefer to set the allowed orientation(s) in AndroidManifest.xml anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant