Merge remote-tracking branch 'origin/5.15' into dev

Change-Id: I7be168303fc4fec5892f20f8dcbdf1bdfcd4986f
This commit is contained in:
Qt Forward Merge Bot 2020-01-09 01:00:25 +01:00
commit 6074ebf728
24 changed files with 202 additions and 223 deletions

View File

@ -257,6 +257,7 @@ Network options:
-no-openssl .......... Do not use OpenSSL [default on Apple and WinRT] -no-openssl .......... Do not use OpenSSL [default on Apple and WinRT]
-openssl-linked ...... Use OpenSSL and link to libssl [no] -openssl-linked ...... Use OpenSSL and link to libssl [no]
-openssl-runtime ..... Use OpenSSL and dynamically load libssl [auto] -openssl-runtime ..... Use OpenSSL and dynamically load libssl [auto]
-schannel ............ Use Secure Channel [no] (Windows only)
-securetransport ..... Use SecureTransport [auto] (Apple only) -securetransport ..... Use SecureTransport [auto] (Apple only)
-sctp ................ Enable SCTP support [no] -sctp ................ Enable SCTP support [no]

View File

@ -775,12 +775,12 @@
}, },
"debug": { "debug": {
"label": "Build for debugging", "label": "Build for debugging",
"autoDetect": "features.developer-build || config.win32 || config.darwin" "autoDetect": "features.developer-build || (config.win32 && !config.gcc) || config.darwin"
}, },
"debug_and_release": { "debug_and_release": {
"label": "Compile libs in debug and release mode", "label": "Compile libs in debug and release mode",
"autoDetect": "input.debug == ''", "autoDetect": "input.debug == '' && !(config.win32 && config.gcc)",
"condition": "config.darwin || (config.win32 && !config.gcc)", "condition": "config.darwin || config.win32",
"output": [ "publicFeature", "publicQtConfig", "debugAndRelease" ] "output": [ "publicFeature", "publicQtConfig", "debugAndRelease" ]
}, },
"force_debug_info": { "force_debug_info": {

View File

@ -72,18 +72,28 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura
string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends \"${_prl_strings}\") string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends \"${_prl_strings}\")
string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries \"${CMAKE_CXX_STANDARD_LIBRARIES}\") string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries \"${CMAKE_CXX_STANDARD_LIBRARIES}\")
set(_search_paths) set(_search_paths)
set(_framework_flag)
string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\") string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\")
foreach(_flag ${_static_depends}) foreach(_flag ${_static_depends})
string(REPLACE \"\\\"\" \"\" _flag ${_flag}) string(REPLACE \"\\\"\" \"\" _flag ${_flag})
if(_flag MATCHES \"^-l(.*)$\") if(_flag MATCHES \"^-framework$\")
# Handle normal libraries passed as -lfoo # Handle the next flag as framework name
set(_lib \"${CMAKE_MATCH_1}\") set(_framework_flag 1)
foreach(_standard_library ${_standard_libraries}) elseif(_framework_flag OR _flag MATCHES \"^-l(.*)$\")
if(_standard_library MATCHES \"^${_lib}(\\\\.lib)?$\") if(_framework_flag)
set(_lib_is_default_linked TRUE) # Handle Darwin framework bundles passed as -framework Foo
break() unset(_framework_flag)
endif() set(_lib ${_flag})
endforeach() else()
# Handle normal libraries passed as -lfoo
set(_lib \"${CMAKE_MATCH_1}\")
foreach(_standard_library ${_standard_libraries})
if(_standard_library MATCHES \"^${_lib}(\\\\.lib)?$\")
set(_lib_is_default_linked TRUE)
break()
endif()
endforeach()
endif()
if (_lib_is_default_linked) if (_lib_is_default_linked)
unset(_lib_is_default_linked) unset(_lib_is_default_linked)
elseif(_lib MATCHES \"^pthread$\") elseif(_lib MATCHES \"^pthread$\")

View File

@ -5,7 +5,7 @@ defineReplace(qtPlatformTargetSuffix) {
else: CONFIG(debug, debug|release) { else: CONFIG(debug, debug|release) {
!debug_and_release|build_pass { !debug_and_release|build_pass {
mac: return($${suffix}_debug) mac: return($${suffix}_debug)
win32:!gcc: return($${suffix}d) win32: return($${suffix}d)
} }
} }
return($$suffix) return($$suffix)

View File

@ -1577,6 +1577,12 @@
\l{CONFIG}{CONFIG += lrelease} will be installed to. Does not have any \l{CONFIG}{CONFIG += lrelease} will be installed to. Does not have any
effect if \l{CONFIG}{CONFIG += embed_translations} is set. effect if \l{CONFIG}{CONFIG += embed_translations} is set.
\target QML_IMPORT_PATH
\section1 QML_IMPORT_PATH
This variable is only used by \l{Qt Creator Manual}{Qt Creator}.
See \l{Qt Creator: Using QML Modules with Plugins} for details.
\target QMAKE_systemvariable \target QMAKE_systemvariable
\section1 QMAKE \section1 QMAKE

View File

@ -121,10 +121,6 @@ public class QtActivityDelegate
private static final String EXTRACT_STYLE_KEY = "extract.android.style"; private static final String EXTRACT_STYLE_KEY = "extract.android.style";
private static final String EXTRACT_STYLE_MINIMAL_KEY = "extract.android.style.option"; private static final String EXTRACT_STYLE_MINIMAL_KEY = "extract.android.style.option";
public static final int SYSTEM_UI_VISIBILITY_NORMAL = 0;
public static final int SYSTEM_UI_VISIBILITY_FULLSCREEN = 1;
public static final int SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2;
private static String m_environmentVariables = null; private static String m_environmentVariables = null;
private static String m_applicationParameters = null; private static String m_applicationParameters = null;
@ -135,7 +131,7 @@ public class QtActivityDelegate
private long m_metaState; private long m_metaState;
private int m_lastChar = 0; private int m_lastChar = 0;
private int m_softInputMode = 0; private int m_softInputMode = 0;
private int m_systemUiVisibility = SYSTEM_UI_VISIBILITY_NORMAL; private boolean m_fullScreen = false;
private boolean m_started = false; private boolean m_started = false;
private HashMap<Integer, QtSurface> m_surfaces = null; private HashMap<Integer, QtSurface> m_surfaces = null;
private HashMap<Integer, View> m_nativeViews = null; private HashMap<Integer, View> m_nativeViews = null;
@ -157,51 +153,38 @@ public class QtActivityDelegate
private CursorHandle m_rightSelectionHandle; private CursorHandle m_rightSelectionHandle;
private EditPopupMenu m_editPopupMenu; private EditPopupMenu m_editPopupMenu;
public void setFullScreen(boolean enterFullScreen)
public void setSystemUiVisibility(int systemUiVisibility)
{ {
if (m_systemUiVisibility == systemUiVisibility) if (m_fullScreen == enterFullScreen)
return; return;
m_systemUiVisibility = systemUiVisibility; if (m_fullScreen = enterFullScreen) {
int systemUiVisibilityFlags = 0;
switch (m_systemUiVisibility) {
case SYSTEM_UI_VISIBILITY_NORMAL:
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE;
break;
case SYSTEM_UI_VISIBILITY_FULLSCREEN:
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION try {
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
| View.SYSTEM_UI_FLAG_FULLSCREEN flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
| View.INVISIBLE; flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").getInt(null);
break; m_activity.getWindow().getDecorView().setSystemUiVisibility(flags | View.INVISIBLE);
case SYSTEM_UI_VISIBILITY_TRANSLUCENT: } catch (Exception e) {
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN e.printStackTrace();
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION }
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } else {
m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE; m_activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
break; }
};
m_activity.getWindow().getDecorView().setSystemUiVisibility(systemUiVisibilityFlags);
m_layout.requestLayout(); m_layout.requestLayout();
} }
public void updateFullScreen() public void updateFullScreen()
{ {
if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) { if (m_fullScreen) {
m_systemUiVisibility = SYSTEM_UI_VISIBILITY_NORMAL; m_fullScreen = false;
setSystemUiVisibility(SYSTEM_UI_VISIBILITY_FULLSCREEN); setFullScreen(true);
} }
} }
@ -960,7 +943,7 @@ public class QtActivityDelegate
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
outState.putInt("SystemUiVisibility", m_systemUiVisibility); outState.putBoolean("FullScreen", m_fullScreen);
outState.putBoolean("Started", m_started); outState.putBoolean("Started", m_started);
// It should never // It should never
} }

View File

@ -46,7 +46,6 @@ import android.util.AttributeSet;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowInsets;
public class QtLayout extends ViewGroup public class QtLayout extends ViewGroup
{ {
@ -70,32 +69,10 @@ public class QtLayout extends ViewGroup
@Override @Override
protected void onSizeChanged (int w, int h, int oldw, int oldh) protected void onSizeChanged (int w, int h, int oldw, int oldh)
{ {
WindowInsets insets = getRootWindowInsets(); DisplayMetrics metrics = new DisplayMetrics();
((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
DisplayMetrics realMetrics = new DisplayMetrics(); QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, w, h,
((Activity) getContext()).getWindowManager().getDefaultDisplay().getRealMetrics(realMetrics); metrics.xdpi, metrics.ydpi, metrics.scaledDensity, metrics.density);
boolean isFullScreenView = h == realMetrics.heightPixels;
int insetLeft = isFullScreenView ? insets.getSystemWindowInsetLeft() : 0;
int insetTop = isFullScreenView ? insets.getSystemWindowInsetTop() : 0;
int insetRight = isFullScreenView ? insets.getSystemWindowInsetRight() : 0;
int insetBottom = isFullScreenView ? insets.getSystemWindowInsetBottom() : 0;
int usableAreaWidth = w - insetLeft - insetRight;
int usableAreaHeight = h - insetTop - insetBottom;
QtNative.setApplicationDisplayMetrics(realMetrics.widthPixels,
realMetrics.heightPixels,
insetLeft,
insetTop,
usableAreaWidth,
usableAreaHeight,
realMetrics.xdpi,
realMetrics.ydpi,
realMetrics.scaledDensity,
realMetrics.density);
if (m_startApplicationRunnable != null) { if (m_startApplicationRunnable != null) {
m_startApplicationRunnable.run(); m_startApplicationRunnable.run();
m_startApplicationRunnable = null; m_startApplicationRunnable = null;

View File

@ -91,10 +91,8 @@ public class QtNative
private static boolean m_started = false; private static boolean m_started = false;
private static int m_displayMetricsScreenWidthPixels = 0; private static int m_displayMetricsScreenWidthPixels = 0;
private static int m_displayMetricsScreenHeightPixels = 0; private static int m_displayMetricsScreenHeightPixels = 0;
private static int m_displayMetricsAvailableLeftPixels = 0; private static int m_displayMetricsDesktopWidthPixels = 0;
private static int m_displayMetricsAvailableTopPixels = 0; private static int m_displayMetricsDesktopHeightPixels = 0;
private static int m_displayMetricsAvailableWidthPixels = 0;
private static int m_displayMetricsAvailableHeightPixels = 0;
private static double m_displayMetricsXDpi = .0; private static double m_displayMetricsXDpi = .0;
private static double m_displayMetricsYDpi = .0; private static double m_displayMetricsYDpi = .0;
private static double m_displayMetricsScaledDensity = 1.0; private static double m_displayMetricsScaledDensity = 1.0;
@ -378,10 +376,8 @@ public class QtNative
res[0] = startQtAndroidPlugin(qtParams, environment); res[0] = startQtAndroidPlugin(qtParams, environment);
setDisplayMetrics(m_displayMetricsScreenWidthPixels, setDisplayMetrics(m_displayMetricsScreenWidthPixels,
m_displayMetricsScreenHeightPixels, m_displayMetricsScreenHeightPixels,
m_displayMetricsAvailableLeftPixels, m_displayMetricsDesktopWidthPixels,
m_displayMetricsAvailableTopPixels, m_displayMetricsDesktopHeightPixels,
m_displayMetricsAvailableWidthPixels,
m_displayMetricsAvailableHeightPixels,
m_displayMetricsXDpi, m_displayMetricsXDpi,
m_displayMetricsYDpi, m_displayMetricsYDpi,
m_displayMetricsScaledDensity, m_displayMetricsScaledDensity,
@ -402,10 +398,8 @@ public class QtNative
public static void setApplicationDisplayMetrics(int screenWidthPixels, public static void setApplicationDisplayMetrics(int screenWidthPixels,
int screenHeightPixels, int screenHeightPixels,
int availableLeftPixels, int desktopWidthPixels,
int availableTopPixels, int desktopHeightPixels,
int availableWidthPixels,
int availableHeightPixels,
double XDpi, double XDpi,
double YDpi, double YDpi,
double scaledDensity, double scaledDensity,
@ -421,10 +415,8 @@ public class QtNative
if (m_started) { if (m_started) {
setDisplayMetrics(screenWidthPixels, setDisplayMetrics(screenWidthPixels,
screenHeightPixels, screenHeightPixels,
availableLeftPixels, desktopWidthPixels,
availableTopPixels, desktopHeightPixels,
availableWidthPixels,
availableHeightPixels,
XDpi, XDpi,
YDpi, YDpi,
scaledDensity, scaledDensity,
@ -432,10 +424,8 @@ public class QtNative
} else { } else {
m_displayMetricsScreenWidthPixels = screenWidthPixels; m_displayMetricsScreenWidthPixels = screenWidthPixels;
m_displayMetricsScreenHeightPixels = screenHeightPixels; m_displayMetricsScreenHeightPixels = screenHeightPixels;
m_displayMetricsAvailableLeftPixels = availableLeftPixels; m_displayMetricsDesktopWidthPixels = desktopWidthPixels;
m_displayMetricsAvailableTopPixels = availableTopPixels; m_displayMetricsDesktopHeightPixels = desktopHeightPixels;
m_displayMetricsAvailableWidthPixels = availableWidthPixels;
m_displayMetricsAvailableHeightPixels = availableHeightPixels;
m_displayMetricsXDpi = XDpi; m_displayMetricsXDpi = XDpi;
m_displayMetricsYDpi = YDpi; m_displayMetricsYDpi = YDpi;
m_displayMetricsScaledDensity = scaledDensity; m_displayMetricsScaledDensity = scaledDensity;
@ -696,13 +686,13 @@ public class QtNative
}); });
} }
private static void setSystemUiVisibility(final int systemUiVisibility) private static void setFullScreen(final boolean fullScreen)
{ {
runAction(new Runnable() { runAction(new Runnable() {
@Override @Override
public void run() { public void run() {
if (m_activityDelegate != null) { if (m_activityDelegate != null) {
m_activityDelegate.setSystemUiVisibility(systemUiVisibility); m_activityDelegate.setFullScreen(fullScreen);
} }
updateWindow(); updateWindow();
} }
@ -1045,10 +1035,8 @@ public class QtNative
// screen methods // screen methods
public static native void setDisplayMetrics(int screenWidthPixels, public static native void setDisplayMetrics(int screenWidthPixels,
int screenHeightPixels, int screenHeightPixels,
int availableLeftPixels, int desktopWidthPixels,
int availableTopPixels, int desktopHeightPixels,
int availableWidthPixels,
int availableHeightPixels,
double XDpi, double XDpi,
double YDpi, double YDpi,
double scaledDensity, double scaledDensity,

View File

@ -115,7 +115,7 @@ public class QtServiceDelegate
QtNative.setService(m_service, this); QtNative.setService(m_service, this);
QtNative.setClassLoader(classLoader); QtNative.setClassLoader(classLoader);
QtNative.setApplicationDisplayMetrics(10, 10, 0, 0, 10, 10, 120, 120, 1.0, 1.0); QtNative.setApplicationDisplayMetrics(10, 10, 10, 10, 120, 120, 1.0, 1.0);
if (loaderParams.containsKey(STATIC_INIT_CLASSES_KEY)) { if (loaderParams.containsKey(STATIC_INIT_CLASSES_KEY)) {
for (String className: loaderParams.getStringArray(STATIC_INIT_CLASSES_KEY)) { for (String className: loaderParams.getStringArray(STATIC_INIT_CLASSES_KEY)) {

View File

@ -1507,7 +1507,7 @@ QDebug operator<<(QDebug debug, const QEasingCurve &item)
{ {
QDebugStateSaver saver(debug); QDebugStateSaver saver(debug);
debug << "type:" << item.d_ptr->type debug << "type:" << item.d_ptr->type
<< "func:" << item.d_ptr->func; << "func:" << reinterpret_cast<const void *>(item.d_ptr->func);
if (item.d_ptr->config) { if (item.d_ptr->config) {
debug << QString::fromLatin1("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20) debug << QString::fromLatin1("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20)
<< QString::fromLatin1("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20) << QString::fromLatin1("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20)

View File

@ -2301,10 +2301,8 @@ static QStringList resolvedFontFamilies(const QTextCharFormat &format)
{ {
QStringList fontFamilies = format.fontFamilies().toStringList(); QStringList fontFamilies = format.fontFamilies().toStringList();
const QString mainFontFamily = format.fontFamily(); const QString mainFontFamily = format.fontFamily();
if (!mainFontFamily.isEmpty() && !fontFamilies.startsWith(mainFontFamily)) { if (!mainFontFamily.isEmpty() && !fontFamilies.contains(mainFontFamily))
fontFamilies.removeAll(mainFontFamily); fontFamilies.append(mainFontFamily);
fontFamilies.prepend(mainFontFamily);
}
return fontFamilies; return fontFamilies;
} }

View File

@ -247,8 +247,8 @@ namespace QtAndroidInput
break; break;
} }
const int dw = availableWidthPixels(); const int dw = desktopWidthPixels();
const int dh = availableHeightPixels(); const int dh = desktopHeightPixels();
QWindowSystemInterface::TouchPoint touchPoint; QWindowSystemInterface::TouchPoint touchPoint;
touchPoint.id = id; touchPoint.id = id;
touchPoint.pressure = pressure; touchPoint.pressure = pressure;

View File

@ -111,8 +111,8 @@ static int m_surfaceId = 1;
static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr; static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr;
static int m_availableWidthPixels = 0; static int m_desktopWidthPixels = 0;
static int m_availableHeightPixels = 0; static int m_desktopHeightPixels = 0;
static double m_scaledDensity = 0; static double m_scaledDensity = 0;
static double m_density = 1.0; static double m_density = 1.0;
@ -155,14 +155,14 @@ namespace QtAndroid
: 0; : 0;
} }
int availableWidthPixels() int desktopWidthPixels()
{ {
return m_availableWidthPixels; return m_desktopWidthPixels;
} }
int availableHeightPixels() int desktopHeightPixels()
{ {
return m_availableHeightPixels; return m_desktopHeightPixels;
} }
double scaledDensity() double scaledDensity()
@ -200,9 +200,22 @@ namespace QtAndroid
return m_serviceObject; return m_serviceObject;
} }
void setSystemUiVisibility(SystemUiVisibility uiVisibility) void showStatusBar()
{ {
QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setSystemUiVisibility", "(I)V", jint(uiVisibility)); if (m_statusBarShowing)
return;
QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", false);
m_statusBarShowing = true;
}
void hideStatusBar()
{
if (!m_statusBarShowing)
return;
QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", true);
m_statusBarShowing = false;
} }
jobject createBitmap(QImage img, JNIEnv *env) jobject createBitmap(QImage img, JNIEnv *env)
@ -607,33 +620,35 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface,
} }
static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/,
jint screenWidthPixels, jint screenHeightPixels, jint widthPixels, jint heightPixels,
jint availableLeftPixels, jint availableTopPixels, jint desktopWidthPixels, jint desktopHeightPixels,
jint availableWidthPixels, jint availableHeightPixels,
jdouble xdpi, jdouble ydpi, jdouble xdpi, jdouble ydpi,
jdouble scaledDensity, jdouble density) jdouble scaledDensity, jdouble density)
{ {
m_availableWidthPixels = availableWidthPixels; // Android does not give us the correct screen size for immersive mode, but
m_availableHeightPixels = availableHeightPixels; // the surface does have the right size
widthPixels = qMax(widthPixels, desktopWidthPixels);
heightPixels = qMax(heightPixels, desktopHeightPixels);
m_desktopWidthPixels = desktopWidthPixels;
m_desktopHeightPixels = desktopHeightPixels;
m_scaledDensity = scaledDensity; m_scaledDensity = scaledDensity;
m_density = density; m_density = density;
QMutexLocker lock(&m_platformMutex); QMutexLocker lock(&m_platformMutex);
if (!m_androidPlatformIntegration) { if (!m_androidPlatformIntegration) {
QAndroidPlatformIntegration::setDefaultDisplayMetrics(availableLeftPixels, QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels,
availableTopPixels, desktopHeightPixels,
availableWidthPixels, qRound(double(widthPixels) / xdpi * 25.4),
availableHeightPixels, qRound(double(heightPixels) / ydpi * 25.4),
qRound(double(screenWidthPixels) / xdpi * 25.4), widthPixels,
qRound(double(screenHeightPixels) / ydpi * 25.4), heightPixels);
screenWidthPixels,
screenHeightPixels);
} else { } else {
m_androidPlatformIntegration->setPhysicalSize(qRound(double(screenWidthPixels) / xdpi * 25.4), m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4),
qRound(double(screenHeightPixels) / ydpi * 25.4)); qRound(double(heightPixels) / ydpi * 25.4));
m_androidPlatformIntegration->setScreenSize(screenWidthPixels, screenHeightPixels); m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels);
m_androidPlatformIntegration->setAvailableGeometry(QRect(availableLeftPixels, availableTopPixels, m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels);
availableWidthPixels, availableHeightPixels));
} }
} }
@ -759,7 +774,7 @@ 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},
{"setDisplayMetrics", "(IIIIIIDDDD)V", (void *)setDisplayMetrics}, {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics},
{"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface},
{"updateWindow", "()V", (void *)updateWindow}, {"updateWindow", "()V", (void *)updateWindow},
{"updateApplicationState", "(I)V", (void *)updateApplicationState}, {"updateApplicationState", "(I)V", (void *)updateApplicationState},

View File

@ -77,8 +77,8 @@ namespace QtAndroid
void bringChildToBack(int surfaceId); void bringChildToBack(int surfaceId);
QWindow *topLevelWindowAt(const QPoint &globalPos); QWindow *topLevelWindowAt(const QPoint &globalPos);
int availableWidthPixels(); int desktopWidthPixels();
int availableHeightPixels(); int desktopHeightPixels();
double scaledDensity(); double scaledDensity();
double pixelDensity(); double pixelDensity();
JavaVM *javaVM(); JavaVM *javaVM();
@ -88,13 +88,8 @@ namespace QtAndroid
jobject activity(); jobject activity();
jobject service(); jobject service();
// Keep synchronized with flags in ActivityDelegate.java void showStatusBar();
enum SystemUiVisibility { void hideStatusBar();
SYSTEM_UI_VISIBILITY_NORMAL = 0,
SYSTEM_UI_VISIBILITY_FULLSCREEN = 1,
SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2
};
void setSystemUiVisibility(SystemUiVisibility uiVisibility);
jobject createBitmap(QImage img, JNIEnv *env = 0); jobject createBitmap(QImage img, JNIEnv *env = 0);
jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env); jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env);

View File

@ -76,9 +76,12 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QSize QAndroidPlatformIntegration::m_defaultScreenSize = QSize(320, 455); int QAndroidPlatformIntegration::m_defaultGeometryWidth = 320;
QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry = QRect(0, 0, 320, 455); int QAndroidPlatformIntegration::m_defaultGeometryHeight = 455;
QSize QAndroidPlatformIntegration::m_defaultPhysicalSize = QSize(50, 71); int QAndroidPlatformIntegration::m_defaultScreenWidth = 320;
int QAndroidPlatformIntegration::m_defaultScreenHeight = 455;
int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth = 50;
int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71;
Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation;
Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation;
@ -171,9 +174,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &para
m_primaryScreen = new QAndroidPlatformScreen(); m_primaryScreen = new QAndroidPlatformScreen();
QWindowSystemInterface::handleScreenAdded(m_primaryScreen); QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight));
m_primaryScreen->setSize(m_defaultScreenSize); m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight));
m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight));
m_mainThread = QThread::currentThread(); m_mainThread = QThread::currentThread();
@ -263,7 +266,6 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const
case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity(); case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity();
case RasterGLSurface: return QtAndroid::activity(); case RasterGLSurface: return QtAndroid::activity();
case TopStackedNativeChildWindows: return false; case TopStackedNativeChildWindows: return false;
case MaximizeUsingFullscreenGeometry: return true;
default: default:
return QPlatformIntegration::hasCapability(cap); return QPlatformIntegration::hasCapability(cap);
} }
@ -413,19 +415,20 @@ QPlatformTheme *QAndroidPlatformIntegration::createPlatformTheme(const QString &
return 0; return 0;
} }
void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int availableLeft, void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int screenWidth, int screenHeight)
int availableTop,
int availableWidth,
int availableHeight,
int physicalWidth,
int physicalHeight,
int screenWidth,
int screenHeight)
{ {
m_defaultAvailableGeometry = QRect(availableLeft, availableTop, m_defaultGeometryWidth = gw;
availableWidth, availableHeight); m_defaultGeometryHeight = gh;
m_defaultPhysicalSize = QSize(physicalWidth, physicalHeight); m_defaultPhysicalSizeWidth = sw;
m_defaultScreenSize = QSize(screenWidth, screenHeight); m_defaultPhysicalSizeHeight = sh;
m_defaultScreenWidth = screenWidth;
m_defaultScreenHeight = screenHeight;
}
void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh)
{
m_defaultGeometryWidth = gw;
m_defaultGeometryHeight = gh;
} }
void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation, void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation,
@ -437,9 +440,10 @@ void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation cur
void QAndroidPlatformIntegration::flushPendingUpdates() void QAndroidPlatformIntegration::flushPendingUpdates()
{ {
m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth,
m_primaryScreen->setSize(m_defaultScreenSize); m_defaultPhysicalSizeHeight));
m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight));
m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight));
} }
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
@ -449,13 +453,13 @@ QPlatformAccessibility *QAndroidPlatformIntegration::accessibility() const
} }
#endif #endif
void QAndroidPlatformIntegration::setAvailableGeometry(const QRect &availableGeometry) void QAndroidPlatformIntegration::setDesktopSize(int width, int height)
{ {
if (m_primaryScreen) if (m_primaryScreen)
QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, availableGeometry)); QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height)));
} }
void QAndroidPlatformIntegration::setPhysicalSize(int width, int height) void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height)
{ {
if (m_primaryScreen) if (m_primaryScreen)
QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height))); QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height)));

View File

@ -91,8 +91,8 @@ public:
QAndroidPlatformScreen *screen() { return m_primaryScreen; } QAndroidPlatformScreen *screen() { return m_primaryScreen; }
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
void setAvailableGeometry(const QRect &availableGeometry); virtual void setDesktopSize(int width, int height);
void setPhysicalSize(int width, int height); virtual void setDisplayMetrics(int width, int height);
void setScreenSize(int width, int height); void setScreenSize(int width, int height);
bool isVirtualDesktop() { return true; } bool isVirtualDesktop() { return true; }
@ -116,17 +116,16 @@ public:
QStringList themeNames() const override; QStringList themeNames() const override;
QPlatformTheme *createPlatformTheme(const QString &name) const override; QPlatformTheme *createPlatformTheme(const QString &name) const override;
static void setDefaultDisplayMetrics(int availableLeft, static void setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int width, int height);
int availableTop, static void setDefaultDesktopSize(int gw, int gh);
int availableWidth,
int availableHeight,
int physicalWidth,
int physicalHeight,
int screenWidth,
int screenHeight);
static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, static void setScreenOrientation(Qt::ScreenOrientation currentOrientation,
Qt::ScreenOrientation nativeOrientation); Qt::ScreenOrientation nativeOrientation);
static QSize defaultDesktopSize()
{
return QSize(m_defaultGeometryWidth, m_defaultGeometryHeight);
}
QTouchDevice *touchDevice() const { return m_touchDevice; } QTouchDevice *touchDevice() const { return m_touchDevice; }
void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; }
@ -144,9 +143,12 @@ private:
QThread *m_mainThread; QThread *m_mainThread;
static QRect m_defaultAvailableGeometry; static int m_defaultGeometryWidth;
static QSize m_defaultPhysicalSize; static int m_defaultGeometryHeight;
static QSize m_defaultScreenSize; static int m_defaultPhysicalSizeWidth;
static int m_defaultPhysicalSizeHeight;
static int m_defaultScreenWidth;
static int m_defaultScreenHeight;
static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_orientation;
static Qt::ScreenOrientation m_nativeOrientation; static Qt::ScreenOrientation m_nativeOrientation;

View File

@ -90,8 +90,8 @@ private:
QAndroidPlatformScreen::QAndroidPlatformScreen() QAndroidPlatformScreen::QAndroidPlatformScreen()
: QObject(), QPlatformScreen() : QObject(), QPlatformScreen()
{ {
m_availableGeometry = QAndroidPlatformIntegration::m_defaultAvailableGeometry; m_availableGeometry = QRect(0, 0, QAndroidPlatformIntegration::m_defaultGeometryWidth, QAndroidPlatformIntegration::m_defaultGeometryHeight);
m_size = QAndroidPlatformIntegration::m_defaultScreenSize; m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight);
// Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16
// is way much faster than 32 // is way much faster than 32
if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) {
@ -101,7 +101,8 @@ QAndroidPlatformScreen::QAndroidPlatformScreen()
m_format = QImage::Format_ARGB32_Premultiplied; m_format = QImage::Format_ARGB32_Premultiplied;
m_depth = 32; m_depth = 32;
} }
m_physicalSize = QAndroidPlatformIntegration::m_defaultPhysicalSize; m_physicalSize.setHeight(QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight);
m_physicalSize.setWidth(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth);
connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QAndroidPlatformScreen::applicationStateChanged); connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QAndroidPlatformScreen::applicationStateChanged);
} }
@ -293,7 +294,7 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w)
if (w != 0) { if (w != 0) {
QAndroidPlatformWindow *platformWindow = static_cast<QAndroidPlatformWindow *>(w->handle()); QAndroidPlatformWindow *platformWindow = static_cast<QAndroidPlatformWindow *>(w->handle());
if (platformWindow != 0) if (platformWindow != 0)
platformWindow->updateSystemUiVisibility(); platformWindow->updateStatusBarVisibility();
} }
} }
@ -333,7 +334,7 @@ void QAndroidPlatformScreen::doRedraw()
} }
QMutexLocker lock(&m_surfaceMutex); QMutexLocker lock(&m_surfaceMutex);
if (m_id == -1 && m_rasterSurfaces) { if (m_id == -1 && m_rasterSurfaces) {
m_id = QtAndroid::createSurface(this, geometry(), true, m_depth); m_id = QtAndroid::createSurface(this, m_availableGeometry, true, m_depth);
AndroidDeadlockProtector protector; AndroidDeadlockProtector protector;
if (!protector.acquire()) if (!protector.acquire())
return; return;

View File

@ -67,39 +67,25 @@ void QAndroidPlatformWindow::lower()
void QAndroidPlatformWindow::raise() void QAndroidPlatformWindow::raise()
{ {
updateSystemUiVisibility(); updateStatusBarVisibility();
platformScreen()->raise(this); platformScreen()->raise(this);
} }
QMargins QAndroidPlatformWindow::safeAreaMargins() const
{
if ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint)) {
QRect availableGeometry = platformScreen()->availableGeometry();
return QMargins(availableGeometry.left(), availableGeometry.top(),
availableGeometry.right(), availableGeometry.bottom());
} else {
return QPlatformWindow::safeAreaMargins();
}
}
void QAndroidPlatformWindow::setGeometry(const QRect &rect) void QAndroidPlatformWindow::setGeometry(const QRect &rect)
{ {
QPlatformWindow::setGeometry(rect);
QWindowSystemInterface::handleGeometryChange(window(), rect); QWindowSystemInterface::handleGeometryChange(window(), rect);
} }
void QAndroidPlatformWindow::setVisible(bool visible) void QAndroidPlatformWindow::setVisible(bool visible)
{ {
if (visible) if (visible)
updateSystemUiVisibility(); updateStatusBarVisibility();
if (visible) { if (visible) {
if ((m_windowState & Qt::WindowFullScreen) if (m_windowState & Qt::WindowFullScreen)
|| ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint))) {
setGeometry(platformScreen()->geometry()); setGeometry(platformScreen()->geometry());
} else if (m_windowState & Qt::WindowMaximized) { else if (m_windowState & Qt::WindowMaximized)
setGeometry(platformScreen()->availableGeometry()); setGeometry(platformScreen()->availableGeometry());
}
} }
if (visible) if (visible)
@ -121,7 +107,7 @@ void QAndroidPlatformWindow::setWindowState(Qt::WindowStates state)
m_windowState = state; m_windowState = state;
if (window()->isVisible()) if (window()->isVisible())
updateSystemUiVisibility(); updateStatusBarVisibility();
} }
void QAndroidPlatformWindow::setWindowFlags(Qt::WindowFlags flags) void QAndroidPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
@ -157,17 +143,15 @@ void QAndroidPlatformWindow::requestActivateWindow()
platformScreen()->topWindowChanged(window()); platformScreen()->topWindowChanged(window());
} }
void QAndroidPlatformWindow::updateSystemUiVisibility() void QAndroidPlatformWindow::updateStatusBarVisibility()
{ {
Qt::WindowFlags flags = window()->flags(); Qt::WindowFlags flags = window()->flags();
bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window; bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window;
if (!isNonRegularWindow) { if (!isNonRegularWindow) {
if (m_windowState & Qt::WindowFullScreen) if (m_windowState & Qt::WindowFullScreen)
QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_FULLSCREEN); QtAndroid::hideStatusBar();
else if (flags & Qt::MaximizeUsingFullscreenGeometryHint)
QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_TRANSLUCENT);
else else
QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_NORMAL); QtAndroid::showStatusBar();
} }
} }

View File

@ -70,11 +70,9 @@ public:
QAndroidPlatformScreen *platformScreen() const; QAndroidPlatformScreen *platformScreen() const;
QMargins safeAreaMargins() const override;
void propagateSizeHints() override; void propagateSizeHints() override;
void requestActivateWindow() override; void requestActivateWindow() override;
void updateSystemUiVisibility(); void updateStatusBarVisibility();
inline bool isRaster() const { inline bool isRaster() const {
if (isForeignWindow()) if (isForeignWindow())
return false; return false;

View File

@ -1252,14 +1252,16 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
if (Q_LIKELY(useValuators)) { if (Q_LIKELY(useValuators)) {
const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width()); const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width());
global.setX(value); global.setX(value);
local.setX(value - window->handle()->geometry().x()); // mapFromGlobal is ok for nested/embedded windows, but works only with whole-number QPoint;
// so map it first, then add back the sub-pixel position
local.setX(window->mapFromGlobal(QPoint(int(value), 0)).x() + (value - int(value)));
} }
break; break;
case QXcbAtom::AbsY: case QXcbAtom::AbsY:
if (Q_LIKELY(useValuators)) { if (Q_LIKELY(useValuators)) {
qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height()); qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height());
global.setY(value); global.setY(value);
local.setY(value - window->handle()->geometry().y()); local.setY(window->mapFromGlobal(QPoint(0, int(value))).y() + (value - int(value)));
} }
break; break;
case QXcbAtom::AbsPressure: case QXcbAtom::AbsPressure:

View File

@ -88,6 +88,10 @@ class QMainWindowLayoutSeparatorHelper
QWidget *window() { return layout()->parentWidget(); } QWidget *window() { return layout()->parentWidget(); }
public: public:
Q_DISABLE_COPY_MOVE(QMainWindowLayoutSeparatorHelper)
QMainWindowLayoutSeparatorHelper() = default;
QList<int> hoverSeparator; QList<int> hoverSeparator;
QPoint hoverPos; QPoint hoverPos;

View File

@ -3603,7 +3603,18 @@ void tst_QTextDocument::mergeFontFamilies()
cursor.setPosition(QByteArray("Hello World").length(), QTextCursor::KeepAnchor); cursor.setPosition(QByteArray("Hello World").length(), QTextCursor::KeepAnchor);
cursor.mergeCharFormat(newFormat); cursor.mergeCharFormat(newFormat);
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Jokerman','MS Shell Dlg 2';"))); QVERIFY(td.toHtml().contains(QLatin1String("font-family:'MS Shell Dlg 2','Jokerman';")));
QTextCharFormat newFormatFamilies;
newFormatFamilies.setFontFamilies({ QLatin1String("Arial"), QLatin1String("Helvetica") });
cursor.mergeCharFormat(newFormatFamilies);
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Arial','Helvetica','Jokerman'")));
newFormatFamilies.setFontFamilies({ QLatin1String("Arial"), QLatin1String("Jokerman"), QLatin1String("Helvetica") });
cursor.mergeCharFormat(newFormatFamilies);
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Arial','Jokerman','Helvetica'")));
} }
void tst_QTextDocument::clearUndoRedoStacks() void tst_QTextDocument::clearUndoRedoStacks()