mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Merge branch '2.6.x' into feature/backmerge
This commit is contained in:
commit
f648ae8f35
@ -166,6 +166,8 @@ For a closer look at breaking changes and how to migrate from SFML 2, check out
|
|||||||
- [Android] Removed use of deprecated `ALooper_pollAll` (#3181, #3189)
|
- [Android] Removed use of deprecated `ALooper_pollAll` (#3181, #3189)
|
||||||
- [macOS] Fix how macOS fullscreen video modes are detected (#2300, #3151)
|
- [macOS] Fix how macOS fullscreen video modes are detected (#2300, #3151)
|
||||||
- [macOS] Prevent unnecessary macOS input monitoring permission prompts (#2843, #3235)
|
- [macOS] Prevent unnecessary macOS input monitoring permission prompts (#2843, #3235)
|
||||||
|
- [Linux] Fix DRM mode setting to use SFML window dimensions (#3136)
|
||||||
|
- [Android] Fix wrong fullscreen resolution (#1349, #1559, #2396)
|
||||||
|
|
||||||
### Graphics
|
### Graphics
|
||||||
|
|
||||||
|
@ -221,6 +221,53 @@ void getScreenSizeInPixels(ANativeActivity& activity, int& width, int& height)
|
|||||||
height = lJNIEnv->GetIntField(objectDisplayMetrics, fieldHeightPixels);
|
height = lJNIEnv->GetIntField(objectDisplayMetrics, fieldHeightPixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void getFullScreenSizeInPixels(ANativeActivity& activity, int& width, int& height)
|
||||||
|
{
|
||||||
|
// Perform the following Java code:
|
||||||
|
//
|
||||||
|
// DisplayMetrics dm = new DisplayMetrics();
|
||||||
|
// getWindowManager().getDefaultDisplay().getRealMetrics(dm);
|
||||||
|
|
||||||
|
JNIEnv* lJNIEnv = activity.env;
|
||||||
|
|
||||||
|
jobject objectActivity = activity.clazz;
|
||||||
|
jclass classActivity = lJNIEnv->GetObjectClass(objectActivity);
|
||||||
|
|
||||||
|
jclass classDisplayMetrics = lJNIEnv->FindClass("android/util/DisplayMetrics");
|
||||||
|
jmethodID initDisplayMetrics = lJNIEnv->GetMethodID(classDisplayMetrics, "<init>", "()V");
|
||||||
|
jobject objectDisplayMetrics = lJNIEnv->NewObject(classDisplayMetrics, initDisplayMetrics);
|
||||||
|
|
||||||
|
jmethodID methodGetWindowManager = lJNIEnv->GetMethodID(classActivity,
|
||||||
|
"getWindowManager",
|
||||||
|
"()Landroid/view/WindowManager;");
|
||||||
|
jobject objectWindowManager = lJNIEnv->CallObjectMethod(objectActivity, methodGetWindowManager);
|
||||||
|
|
||||||
|
jclass classWindowManager = lJNIEnv->FindClass("android/view/WindowManager");
|
||||||
|
jmethodID methodGetDefaultDisplay = lJNIEnv->GetMethodID(classWindowManager,
|
||||||
|
"getDefaultDisplay",
|
||||||
|
"()Landroid/view/Display;");
|
||||||
|
jobject objectDisplay = lJNIEnv->CallObjectMethod(objectWindowManager, methodGetDefaultDisplay);
|
||||||
|
|
||||||
|
jclass classDisplay = lJNIEnv->FindClass("android/view/Display");
|
||||||
|
jmethodID methodGetMetrics = nullptr;
|
||||||
|
|
||||||
|
// getRealMetrics is only supported on API level 17 and above, if we are below that, we will fall back to getMetrics
|
||||||
|
if (getAndroidApiLevel(activity) >= 17)
|
||||||
|
methodGetMetrics = lJNIEnv->GetMethodID(classDisplay, "getRealMetrics", "(Landroid/util/DisplayMetrics;)V");
|
||||||
|
else
|
||||||
|
methodGetMetrics = lJNIEnv->GetMethodID(classDisplay, "getMetrics", "(Landroid/util/DisplayMetrics;)V");
|
||||||
|
lJNIEnv->CallVoidMethod(objectDisplay, methodGetMetrics, objectDisplayMetrics);
|
||||||
|
|
||||||
|
jfieldID fieldWidthPixels = lJNIEnv->GetFieldID(classDisplayMetrics, "widthPixels", "I");
|
||||||
|
jfieldID fieldHeightPixels = lJNIEnv->GetFieldID(classDisplayMetrics, "heightPixels", "I");
|
||||||
|
|
||||||
|
width = lJNIEnv->GetIntField(objectDisplayMetrics, fieldWidthPixels);
|
||||||
|
height = lJNIEnv->GetIntField(objectDisplayMetrics, fieldHeightPixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void onResume(ANativeActivity* activity)
|
void onResume(ANativeActivity* activity)
|
||||||
{
|
{
|
||||||
@ -502,6 +549,7 @@ JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedSt
|
|||||||
eglInitialize(states->display, nullptr, nullptr);
|
eglInitialize(states->display, nullptr, nullptr);
|
||||||
|
|
||||||
getScreenSizeInPixels(*activity, states->screenSize.x, states->screenSize.y);
|
getScreenSizeInPixels(*activity, states->screenSize.x, states->screenSize.y);
|
||||||
|
getFullScreenSizeInPixels(*activity, states->fullScreenSize.x, states->fullScreenSize.y);
|
||||||
|
|
||||||
// Redirect error messages to logcat
|
// Redirect error messages to logcat
|
||||||
sf::err().rdbuf(&states->logcat);
|
sf::err().rdbuf(&states->logcat);
|
||||||
|
@ -82,6 +82,7 @@ struct ActivityStates
|
|||||||
bool mainOver{};
|
bool mainOver{};
|
||||||
|
|
||||||
Vector2i screenSize;
|
Vector2i screenSize;
|
||||||
|
Vector2i fullScreenSize;
|
||||||
|
|
||||||
bool initialized{};
|
bool initialized{};
|
||||||
bool terminated{};
|
bool terminated{};
|
||||||
|
@ -38,7 +38,11 @@ namespace sf::priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
||||||
{
|
{
|
||||||
const VideoMode desktop = getDesktopMode();
|
// Get the activity states
|
||||||
|
priv::ActivityStates& states = priv::getActivity();
|
||||||
|
|
||||||
|
const std::lock_guard lock(states.mutex);
|
||||||
|
const auto desktop = VideoMode(Vector2u(states.fullScreenSize));
|
||||||
|
|
||||||
// Return both portrait and landscape resolutions
|
// Return both portrait and landscape resolutions
|
||||||
return {desktop, VideoMode(Vector2u(desktop.size.y, desktop.size.x), desktop.bitsPerPixel)};
|
return {desktop, VideoMode(Vector2u(desktop.size.y, desktop.size.x), desktop.bitsPerPixel)};
|
||||||
|
Loading…
Reference in New Issue
Block a user