Android: remove unused top/left inset params of setDisplayMetrics()

Those two params are already marked as unused, so there's no point in
calculating them passing them and then not using them.

Task-number: QTBUG-132716
Change-Id: I840473a42ac4256164252df805b52b859d2fa3de
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
This commit is contained in:
Assam Boudjelthia 2025-01-06 17:05:32 +02:00
parent 97605760ae
commit c13e2213a8
3 changed files with 12 additions and 30 deletions

View File

@ -33,7 +33,6 @@ class QtDisplayManager {
// screen methods
static native void setDisplayMetrics(int screenWidthPixels, int screenHeightPixels,
int availableLeftPixels, int availableTopPixels,
int availableWidthPixels, int availableHeightPixels,
double XDpi, double YDpi, double scaledDensity,
double density);
@ -277,27 +276,15 @@ class QtDisplayManager {
if (activity == null)
return;
final WindowInsets rootInsets = activity.getWindow().getDecorView().getRootWindowInsets();
int insetLeft;
int insetTop;
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
insetLeft = rootInsets.getStableInsetLeft();
insetTop = rootInsets.getStableInsetTop();
} else {
insetLeft = rootInsets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()).left;
insetTop = rootInsets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()).top;
}
final DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics();
double density = displayMetrics.density;
double scaledDensity = displayMetrics.scaledDensity;
Size displaySize = getDisplaySize(activity, QtDisplayManager.getDisplay(activity));
setDisplayMetrics(displaySize.getWidth(), displaySize.getHeight(), insetLeft, insetTop,
width, height, getXDpi(displayMetrics), getYDpi(displayMetrics),
setDisplayMetrics(displaySize.getWidth(), displaySize.getHeight(),
width, height,
getXDpi(displayMetrics), getYDpi(displayMetrics),
scaledDensity, density);
}

View File

@ -41,11 +41,9 @@ class QtServiceEmbeddedDelegate implements QtEmbeddedViewInterface, QtNative.App
final int maxWidth = metrics.widthPixels;
final int maxHeight = metrics.heightPixels;
final int insetLeft = 0;
final int insetTop = 0;
QtDisplayManager.setDisplayMetrics(
maxWidth, maxHeight, insetLeft, insetTop, maxWidth, maxHeight,
maxWidth, maxHeight, maxWidth, maxHeight,
QtDisplayManager.getXDpi(metrics), QtDisplayManager.getYDpi(metrics),
metrics.scaledDensity, metrics.density);

View File

@ -571,15 +571,12 @@ static void terminateQt(JNIEnv *env, jclass /*clazz*/)
sem_post(&m_exitSemaphore);
}
static void setDisplayMetrics(JNIEnv * /*env*/, jclass /*clazz*/, jint screenWidthPixels,
jint screenHeightPixels, jint availableLeftPixels,
jint availableTopPixels, jint availableWidthPixels,
jint availableHeightPixels, jdouble xdpi, jdouble ydpi,
static void setDisplayMetrics(JNIEnv * /*env*/, jclass /*clazz*/,
jint screenWidthPixels, jint screenHeightPixels,
jint availableWidthPixels, jint availableHeightPixels,
jdouble xdpi, jdouble ydpi,
jdouble scaledDensity, jdouble density)
{
Q_UNUSED(availableLeftPixels)
Q_UNUSED(availableTopPixels)
m_availableWidthPixels = availableWidthPixels;
m_availableHeightPixels = availableHeightPixels;
m_scaledDensity = scaledDensity;