Android: rename and move updateWindow native method to QtWindow
That method is related to window management so move it to QtWindow where it belongs, and any related C++ code from androidjnimain.cpp to QAndroidPlatformWindow. Rename the method to updateWindows since it's operating on all windows and not one window. Change-Id: I91e729b0749b6a8168b7126f9140d79c542b23d3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
10805e7d8a
commit
5c37d3f06b
@ -143,7 +143,7 @@ public class QtActivityBase extends Activity
|
|||||||
QtNative.setApplicationState(QtNative.ApplicationState.ApplicationActive);
|
QtNative.setApplicationState(QtNative.ApplicationState.ApplicationActive);
|
||||||
if (QtNative.getStateDetails().isStarted) {
|
if (QtNative.getStateDetails().isStarted) {
|
||||||
m_delegate.displayManager().registerDisplayListener();
|
m_delegate.displayManager().registerDisplayListener();
|
||||||
QtNative.updateWindow();
|
QtWindow.updateWindows();
|
||||||
// Suspending the app clears the immersive mode, so we need to set it again.
|
// Suspending the app clears the immersive mode, so we need to set it again.
|
||||||
m_delegate.displayManager().updateFullScreen();
|
m_delegate.displayManager().updateFullScreen();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ class QtActivityDelegate extends QtActivityDelegateBase
|
|||||||
if (m_layout != null) {
|
if (m_layout != null) {
|
||||||
m_displayManager.setSystemUiVisibility(systemUiVisibility);
|
m_displayManager.setSystemUiVisibility(systemUiVisibility);
|
||||||
m_layout.requestLayout();
|
m_layout.requestLayout();
|
||||||
QtNative.updateWindow();
|
QtWindow.updateWindows();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase
|
|||||||
public void onActivityResumed(Activity activity) {
|
public void onActivityResumed(Activity activity) {
|
||||||
if (m_activity == activity && m_stateDetails.isStarted) {
|
if (m_activity == activity && m_stateDetails.isStarted) {
|
||||||
QtNative.setApplicationState(ApplicationActive);
|
QtNative.setApplicationState(ApplicationActive);
|
||||||
QtNative.updateWindow();
|
QtWindow.updateWindows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,10 +437,6 @@ public class QtNative
|
|||||||
static native boolean updateNativeActivity();
|
static native boolean updateNativeActivity();
|
||||||
// application methods
|
// application methods
|
||||||
|
|
||||||
// window methods
|
|
||||||
static native void updateWindow();
|
|
||||||
// window methods
|
|
||||||
|
|
||||||
// application methods
|
// application methods
|
||||||
static native void updateApplicationState(int state);
|
static native void updateApplicationState(int state);
|
||||||
static native void updateLocale();
|
static native void updateLocale();
|
||||||
|
@ -26,6 +26,7 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
|
|||||||
|
|
||||||
private static native void setSurface(int windowId, Surface surface);
|
private static native void setSurface(int windowId, Surface surface);
|
||||||
static native void windowFocusChanged(boolean hasFocus, int id);
|
static native void windowFocusChanged(boolean hasFocus, int id);
|
||||||
|
static native void updateWindows();
|
||||||
|
|
||||||
QtWindow(Context context, boolean isForeignWindow, QtWindow parentWindow,
|
QtWindow(Context context, boolean isForeignWindow, QtWindow parentWindow,
|
||||||
QtInputConnection.QtInputConnectionListener listener)
|
QtInputConnection.QtInputConnectionListener listener)
|
||||||
|
@ -581,26 +581,6 @@ static void setDisplayMetrics(JNIEnv * /*env*/, jclass /*clazz*/, jint screenWid
|
|||||||
}
|
}
|
||||||
Q_DECLARE_JNI_NATIVE_METHOD(setDisplayMetrics)
|
Q_DECLARE_JNI_NATIVE_METHOD(setDisplayMetrics)
|
||||||
|
|
||||||
static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/)
|
|
||||||
{
|
|
||||||
if (!m_androidPlatformIntegration)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (QGuiApplication::instance() != nullptr) {
|
|
||||||
const auto tlw = QGuiApplication::topLevelWindows();
|
|
||||||
for (QWindow *w : tlw) {
|
|
||||||
|
|
||||||
// Skip non-platform windows, e.g., offscreen windows.
|
|
||||||
if (!w->handle())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QRect availableGeometry = w->screen()->availableGeometry();
|
|
||||||
if (w->geometry().width() > 0 && w->geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
|
|
||||||
QWindowSystemInterface::handleExposeEvent(w, QRegion(QRect(QPoint(), w->geometry().size())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state)
|
static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_platformMutex);
|
QMutexLocker lock(&m_platformMutex);
|
||||||
@ -745,7 +725,6 @@ static JNINativeMethod methods[] = {
|
|||||||
{ "quitQtCoreApplication", "()V", (void *)quitQtCoreApplication },
|
{ "quitQtCoreApplication", "()V", (void *)quitQtCoreApplication },
|
||||||
{ "terminateQt", "()V", (void *)terminateQt },
|
{ "terminateQt", "()V", (void *)terminateQt },
|
||||||
{ "waitForServiceSetup", "()V", (void *)waitForServiceSetup },
|
{ "waitForServiceSetup", "()V", (void *)waitForServiceSetup },
|
||||||
{ "updateWindow", "()V", (void *)updateWindow },
|
|
||||||
{ "updateApplicationState", "(I)V", (void *)updateApplicationState },
|
{ "updateApplicationState", "(I)V", (void *)updateApplicationState },
|
||||||
{ "onActivityResult", "(IILandroid/content/Intent;)V", (void *)onActivityResult },
|
{ "onActivityResult", "(IILandroid/content/Intent;)V", (void *)onActivityResult },
|
||||||
{ "onNewIntent", "(Landroid/content/Intent;)V", (void *)onNewIntent },
|
{ "onNewIntent", "(Landroid/content/Intent;)V", (void *)onNewIntent },
|
||||||
|
@ -382,6 +382,34 @@ void QAndroidPlatformWindow::windowFocusChanged(JNIEnv *env, jobject object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void updateWindows(JNIEnv *env, jobject object)
|
||||||
|
{
|
||||||
|
Q_UNUSED(env)
|
||||||
|
Q_UNUSED(object)
|
||||||
|
|
||||||
|
if (QGuiApplication::instance() != nullptr) {
|
||||||
|
const auto tlw = QGuiApplication::topLevelWindows();
|
||||||
|
for (QWindow *w : tlw) {
|
||||||
|
|
||||||
|
// Skip non-platform windows, e.g., offscreen windows.
|
||||||
|
if (!w->handle())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const QRect availableGeometry = w->screen()->availableGeometry();
|
||||||
|
const QRect geometry = w->geometry();
|
||||||
|
const bool isPositiveGeometry = (geometry.width() > 0 && geometry.height() > 0);
|
||||||
|
const bool isPositiveAvailableGeometry =
|
||||||
|
(availableGeometry.width() > 0 && availableGeometry.height() > 0);
|
||||||
|
|
||||||
|
if (isPositiveGeometry && isPositiveAvailableGeometry) {
|
||||||
|
const QRegion region = QRegion(QRect(QPoint(), w->geometry().size()));
|
||||||
|
QWindowSystemInterface::handleExposeEvent(w, region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Q_DECLARE_JNI_NATIVE_METHOD(updateWindows)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Due to calls originating from Android, it is possible for native methods to
|
Due to calls originating from Android, it is possible for native methods to
|
||||||
try to manipulate any given instance of QAndroidPlatformWindow when it is
|
try to manipulate any given instance of QAndroidPlatformWindow when it is
|
||||||
@ -398,6 +426,7 @@ bool QAndroidPlatformWindow::registerNatives(QJniEnvironment &env)
|
|||||||
{
|
{
|
||||||
if (!env.registerNativeMethods(QtJniTypes::Traits<QtJniTypes::QtWindow>::className(),
|
if (!env.registerNativeMethods(QtJniTypes::Traits<QtJniTypes::QtWindow>::className(),
|
||||||
{
|
{
|
||||||
|
Q_JNI_NATIVE_METHOD(updateWindows),
|
||||||
Q_JNI_NATIVE_SCOPED_METHOD(setSurface, QAndroidPlatformWindow),
|
Q_JNI_NATIVE_SCOPED_METHOD(setSurface, QAndroidPlatformWindow),
|
||||||
Q_JNI_NATIVE_SCOPED_METHOD(windowFocusChanged, QAndroidPlatformWindow)
|
Q_JNI_NATIVE_SCOPED_METHOD(windowFocusChanged, QAndroidPlatformWindow)
|
||||||
})) {
|
})) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user