summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-08-05 09:28:48 +0200
committerLiang Qi <liang.qi@qt.io>2019-08-05 10:03:24 +0200
commitf3c816befee4d0cd522e503b4eb04e1b3a892a6d (patch)
treecf283c7a44bdfc4113d48ec12daa0c3d711aae99 /src
parent4d7271087e84096abd75fa806bea234daee0cd94 (diff)
parentf3b28e80211881ab78879eb5acbf5de5d1b1e38c (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13"
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp8
-rw-r--r--src/corelib/global/qoperatingsystemversion.h1
-rw-r--r--src/corelib/global/qsystemdetection.h14
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h20
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp12
-rw-r--r--src/gui/painting/qcompositionfunctions.cpp24
-rw-r--r--src/network/kernel/qhostinfo_p.h12
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm11
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm52
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp11
-rw-r--r--src/tools/qlalr/lalr.cpp10
11 files changed, 116 insertions, 59 deletions
diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp
index 94dc261b41..bc6adb54dc 100644
--- a/src/corelib/global/qoperatingsystemversion.cpp
+++ b/src/corelib/global/qoperatingsystemversion.cpp
@@ -438,6 +438,14 @@ const QOperatingSystemVersion QOperatingSystemVersion::MacOSMojave =
QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 14);
/*!
+ \variable QOperatingSystemVersion::MacOSCatalina
+ \brief a version corresponding to macOS Catalina (version 10.15).
+ \since 5.12.5
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::MacOSCatalina =
+ QOperatingSystemVersion(QOperatingSystemVersion::MacOS, 10, 15);
+
+/*!
\variable QOperatingSystemVersion::AndroidJellyBean
\brief a version corresponding to Android Jelly Bean (version 4.1, API level 16).
\since 5.9
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
index df01e5438a..89c60c4960 100644
--- a/src/corelib/global/qoperatingsystemversion.h
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -71,6 +71,7 @@ public:
static const QOperatingSystemVersion MacOSSierra;
static const QOperatingSystemVersion MacOSHighSierra;
static const QOperatingSystemVersion MacOSMojave;
+ static const QOperatingSystemVersion MacOSCatalina;
static const QOperatingSystemVersion AndroidJellyBean;
static const QOperatingSystemVersion AndroidJellyBean_MR1;
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index a2e51fa330..3e38e6790b 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -231,17 +231,23 @@
# if !defined(__MAC_10_14)
# define __MAC_10_14 101400
# endif
+# if !defined(__MAC_10_15)
+# define __MAC_10_15 101500
+# endif
# if !defined(MAC_OS_X_VERSION_10_11)
-# define MAC_OS_X_VERSION_10_11 101100
+# define MAC_OS_X_VERSION_10_11 __MAC_10_11
# endif
# if !defined(MAC_OS_X_VERSION_10_12)
-# define MAC_OS_X_VERSION_10_12 101200
+# define MAC_OS_X_VERSION_10_12 __MAC_10_12
# endif
# if !defined(MAC_OS_X_VERSION_10_13)
-# define MAC_OS_X_VERSION_10_13 101300
+# define MAC_OS_X_VERSION_10_13 __MAC_10_13
# endif
# if !defined(MAC_OS_X_VERSION_10_14)
-# define MAC_OS_X_VERSION_10_14 101400
+# define MAC_OS_X_VERSION_10_14 __MAC_10_14
+# endif
+# if !defined(MAC_OS_X_VERSION_10_15)
+# define MAC_OS_X_VERSION_10_15 __MAC_10_15
# endif
#
# if !defined(__IPHONE_10_0)
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 3410c1d345..c43641b8c9 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -59,6 +59,7 @@
#include <QtCore/qloggingcategory.h>
#include <QtGui/qregion.h>
#include <QtGui/qscreen.h>
+#include <QtGui/qvector2d.h>
#include <QtGui/qwindow.h>
QT_BEGIN_NAMESPACE
@@ -117,13 +118,26 @@ private:
namespace QHighDpi {
-template <typename T>
-inline T scale(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0))
+inline qreal scale(qreal value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
{
- Q_UNUSED(origin)
return value * scaleFactor;
}
+inline QSize scale(const QSize &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
+{
+ return value * scaleFactor;
+}
+
+inline QSizeF scale(const QSizeF &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
+{
+ return value * scaleFactor;
+}
+
+inline QVector2D scale(const QVector2D &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0))
+{
+ return value * float(scaleFactor);
+}
+
inline QPointF scale(const QPointF &pos, qreal scaleFactor, QPointF origin = QPointF(0, 0))
{
return (pos - origin) * scaleFactor + origin;
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index 1a814ec21f..4e2bcad50f 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -554,10 +554,6 @@ int QSurfaceFormat::alphaBufferSize() const
/*!
Set the desired \a size in bits of the red channel of the color buffer.
-
- \note On Mac OSX, be sure to set the buffer size of all color channels,
- otherwise this setting will have no effect. If one of the buffer sizes is not set,
- the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setRedBufferSize(int size)
{
@@ -569,10 +565,6 @@ void QSurfaceFormat::setRedBufferSize(int size)
/*!
Set the desired \a size in bits of the green channel of the color buffer.
-
- \note On Mac OSX, be sure to set the buffer size of all color channels,
- otherwise this setting will have no effect. If one of the buffer sizes is not set,
- the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setGreenBufferSize(int size)
{
@@ -584,10 +576,6 @@ void QSurfaceFormat::setGreenBufferSize(int size)
/*!
Set the desired \a size in bits of the blue channel of the color buffer.
-
- \note On Mac OSX, be sure to set the buffer size of all color channels,
- otherwise this setting will have no effect. If one of the buffer sizes is not set,
- the current bit-depth of the screen is used.
*/
void QSurfaceFormat::setBlueBufferSize(int size)
{
diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp
index 5c1afe8425..0ce4cfb297 100644
--- a/src/gui/painting/qcompositionfunctions.cpp
+++ b/src/gui/painting/qcompositionfunctions.cpp
@@ -1763,8 +1763,10 @@ void QT_FASTCALL comp_func_Lighten_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QR
}
/*
- if Sca.Da + Dca.Sa >= Sa.Da
+ if Sca.Da + Dca.Sa > Sa.Da
Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa)
+ else if Sca == Sa
+ Dca' = Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
otherwise
Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa)
*/
@@ -1775,8 +1777,10 @@ static inline int color_dodge_op(int dst, int src, int da, int sa)
const int src_da = src * da;
const int temp = src * (255 - da) + dst * (255 - sa);
- if (src_da + dst_sa >= sa_da)
+ if (src_da + dst_sa > sa_da)
return qt_div_255(sa_da + temp);
+ else if (src == sa || sa == 0)
+ return qt_div_255(temp);
else
return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp);
}
@@ -1788,8 +1792,10 @@ static inline uint color_dodge_op_rgb64(qint64 dst, qint64 src, qint64 da, qint6
const qint64 src_da = src * da;
const qint64 temp = src * (65535 - da) + dst * (65535 - sa);
- if (src_da + dst_sa >= sa_da)
+ if (src_da + dst_sa > sa_da)
return qt_div_65535(sa_da + temp);
+ else if (src == sa || sa == 0)
+ return qt_div_65535(temp);
else
return qt_div_65535(65535 * dst_sa / (65535 - 65535 * src / sa) + temp);
}
@@ -1915,8 +1921,10 @@ void QT_FASTCALL comp_func_ColorDodge_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const
}
/*
- if Sca.Da + Dca.Sa <= Sa.Da
+ if Sca.Da + Dca.Sa < Sa.Da
Dca' = Sca.(1 - Da) + Dca.(1 - Sa)
+ else if Sca == 0
+ Dca' = Dca.Sa + Sca.(1 - Da) + Dca.(1 - Sa)
otherwise
Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa)
*/
@@ -1928,8 +1936,10 @@ static inline int color_burn_op(int dst, int src, int da, int sa)
const int temp = src * (255 - da) + dst * (255 - sa);
- if (src == 0 || src_da + dst_sa <= sa_da)
+ if (src_da + dst_sa < sa_da)
return qt_div_255(temp);
+ else if (src == 0)
+ return qt_div_255(dst_sa + temp);
return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp);
}
@@ -1941,8 +1951,10 @@ static inline uint color_burn_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64
const qint64 temp = src * (65535 - da) + dst * (65535 - sa);
- if (src == 0 || src_da + dst_sa <= sa_da)
+ if (src_da + dst_sa < sa_da)
return qt_div_65535(temp);
+ else if (src == 0)
+ return qt_div_65535(dst_sa + temp);
return qt_div_65535(sa * (src_da + dst_sa - sa_da) / src + temp);
}
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index bbf4cc36d1..fa6529bdfd 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -105,12 +105,12 @@ public Q_SLOTS:
inline void emitResultsReady(const QHostInfo &info)
{
if (slotObj) {
- // we used to have a context object, but it's already destroyed
- if (withContextObject && !receiver)
- return;
- QHostInfo copy = info;
- void *args[2] = { 0, reinterpret_cast<void *>(&copy) };
- slotObj->call(const_cast<QObject*>(receiver.data()), args);
+ // we either didn't have a context object, or it's still alive
+ if (!withContextObject || receiver) {
+ QHostInfo copy = info;
+ void *args[2] = { 0, reinterpret_cast<void *>(&copy) };
+ slotObj->call(const_cast<QObject*>(receiver.data()), args);
+ }
slotObj->destroyIfLastRef();
} else {
emit resultsReady(info);
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 7b124ea517..ba7d12ce30 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -197,8 +197,15 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface
attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize();
if (format.alphaBufferSize() > 0)
attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize();
- if (format.redBufferSize() > 0 && format.greenBufferSize() > 0 && format.blueBufferSize() > 0) {
- const int colorSize = format.redBufferSize() + format.greenBufferSize() + format.blueBufferSize();
+
+ auto rbz = format.redBufferSize();
+ auto gbz = format.greenBufferSize();
+ auto bbz = format.blueBufferSize();
+ if (rbz > 0 || gbz > 0 || bbz > 0) {
+ auto fallbackSize = qMax(rbz, qMax(gbz, bbz));
+ auto colorSize = (rbz > 0 ? rbz : fallbackSize)
+ + (gbz > 0 ? gbz : fallbackSize)
+ + (bbz > 0 ? bbz : fallbackSize);
attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy;
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 8f3c192745..0c7ec7f736 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1544,12 +1544,6 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
Qt::WindowType type = window()->type();
Qt::WindowFlags flags = window()->flags();
- // Note: The macOS window manager has a bug, where if a screen is rotated, it will not allow
- // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
- // higher than the height of the screen in its non-rotated state, unless the window is
- // created with the NSWindowStyleMaskBorderless style mask.
- NSWindowStyleMask styleMask = windowStyleMask(flags);
-
QRect rect = geometry();
QScreen *targetScreen = nullptr;
@@ -1560,35 +1554,57 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
}
}
+ NSWindowStyleMask styleMask = windowStyleMask(flags);
+
if (!targetScreen) {
qCWarning(lcQpaWindow) << "Window position" << rect << "outside any known screen, using primary screen";
targetScreen = QGuiApplication::primaryScreen();
- // AppKit will only reposition a window that's outside the target screen area if
- // the window has a title bar. If left out, the window ends up with no screen.
- // The style mask will be corrected to the original style mask in setWindowFlags.
- styleMask |= NSWindowStyleMaskTitled;
+ // Unless the window is created as borderless AppKit won't find a position and
+ // screen that's close to the requested invalid position, and will always place
+ // the window on the primary screen.
+ styleMask = NSWindowStyleMaskBorderless;
}
rect.translate(-targetScreen->geometry().topLeft());
- QCocoaScreen *cocoaScreen = static_cast<QCocoaScreen *>(targetScreen->handle());
- NSRect frame = QCocoaScreen::mapToNative(rect, cocoaScreen);
+ auto *targetCocoaScreen = static_cast<QCocoaScreen *>(targetScreen->handle());
+ NSRect contentRect = QCocoaScreen::mapToNative(rect, targetCocoaScreen);
+
+ if (targetScreen->primaryOrientation() == Qt::PortraitOrientation) {
+ // The macOS window manager has a bug, where if a screen is rotated, it will not allow
+ // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
+ // higher than the height of the screen in its non-rotated state (including a magic padding
+ // of 24 points), unless the window is created with the NSWindowStyleMaskBorderless style mask.
+ if (styleMask && (contentRect.origin.y + 24 > targetScreen->geometry().width())) {
+ qCDebug(lcQpaWindow) << "Window positioned on portrait screen."
+ << "Adjusting style mask during creation";
+ styleMask = NSWindowStyleMaskBorderless;
+ }
+ }
// Create NSWindow
Class windowClass = shouldBePanel ? [QNSPanel class] : [QNSWindow class];
- QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:frame
+ QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:contentRect
+ // Mask will be updated in setWindowFlags if not the final mask
styleMask:styleMask
// Deferring window creation breaks OpenGL (the GL context is
// set up before the window is shown and needs a proper window)
backing:NSBackingStoreBuffered defer:NO
- screen:cocoaScreen->nativeScreen()
+ screen:targetCocoaScreen->nativeScreen()
platformWindow:this];
- Q_ASSERT_X(nsWindow.screen == cocoaScreen->nativeScreen(), "QCocoaWindow",
- "Resulting NSScreen should match the requested NSScreen");
+ // The resulting screen can be different from the screen requested if
+ // for example the application has been assigned to a specific display.
+ auto resultingScreen = QCocoaScreen::get(nsWindow.screen);
+
+ // But may not always be resolved at this point, in which case we fall back
+ // to the target screen. The real screen will be delivered as a screen change
+ // when resolved as part of ordering the window on screen.
+ if (!resultingScreen)
+ resultingScreen = targetCocoaScreen;
- if (targetScreen != window()->screen()) {
+ if (resultingScreen->screen() != window()->screen()) {
QWindowSystemInterface::handleWindowScreenChanged<
- QWindowSystemInterface::SynchronousDelivery>(window(), targetScreen);
+ QWindowSystemInterface::SynchronousDelivery>(window(), resultingScreen->screen());
}
static QSharedPointer<QNSWindowDelegate> sharedDelegate([[QNSWindowDelegate alloc] init],
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 38d0f4d979..79681fd1fa 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2622,7 +2622,8 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
// QTBUG-32663, suppress resize cursor for fixed size windows.
const QWindow *w = window();
if (!w->isTopLevel() // Task 105852, minimized windows need to respond to user input.
- || !(m_windowState & ~Qt::WindowActive)
+ || (m_windowState != Qt::WindowNoState)
+ || !isActive()
|| (m_data.flags & Qt::FramelessWindowHint)) {
return false;
}
@@ -2642,12 +2643,10 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
return true;
}
if (localPos.y() < 0) {
- const QMargins margins = frameMargins();
- const int topResizeBarPos = margins.left() - margins.top();
- if (localPos.y() < topResizeBarPos) {
+ const int topResizeBarPos = -frameMargins().top();
+ if (localPos.y() >= topResizeBarPos)
*result = HTCAPTION; // Extend caption over top resize bar, let's user move the window.
- return true;
- }
+ return true;
}
}
if (fixedWidth && (localPos.x() < 0 || localPos.x() >= size.width())) {
diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp
index ec960925aa..541523d49c 100644
--- a/src/tools/qlalr/lalr.cpp
+++ b/src/tools/qlalr/lalr.cpp
@@ -295,6 +295,12 @@ void Automaton::build ()
buildDefaultReduceActions ();
}
+#if defined(__cpp_lib_not_fn) && __cpp_lib_not_fn >= 201603
+# define Q_NOT_FN std::not_fn
+#else
+# define Q_NOT_FN std::not1
+#endif
+
void Automaton::buildNullables ()
{
bool changed = true;
@@ -305,7 +311,7 @@ void Automaton::buildNullables ()
for (RulePointer rule = _M_grammar->rules.begin (); rule != _M_grammar->rules.end (); ++rule)
{
- NameList::iterator nn = std::find_if (rule->rhs.begin (), rule->rhs.end (), std::not1 (Nullable (this)));
+ NameList::iterator nn = std::find_if(rule->rhs.begin(), rule->rhs.end(), Q_NOT_FN(Nullable(this)));
if (nn == rule->rhs.end ())
changed |= nullables.insert (rule->lhs).second;
@@ -646,7 +652,7 @@ void Automaton::buildIncludesDigraph ()
if (! _M_grammar->isNonTerminal (*A))
continue;
- NameList::iterator first_not_nullable = std::find_if (dot, rule->rhs.end (), std::not1 (Nullable (this)));
+ NameList::iterator first_not_nullable = std::find_if(dot, rule->rhs.end(), Q_NOT_FN(Nullable(this)));
if (first_not_nullable != rule->rhs.end ())
continue;