summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-06-30 22:59:21 +0200
committerLiang Qi <liang.qi@qt.io>2018-07-02 11:23:45 +0200
commite3ed2281c0c891cf3b15c95f9f7cdae42e9f233a (patch)
treeaae8da6ce616eae02b69fb1fcdcb4383c8fe6811 /src/plugins/platforms/cocoa
parent3be141d5bc199080b524d8f6f5ce514e8f74d23a (diff)
parente75e4b39b78ba05ea2cd45dc96acf99fc89c5915 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/cocoa/qnsview_dragging.mm src/plugins/platforms/ios/qiosinputcontext.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/tools/androiddeployqt/main.cpp Was moved from qttools into qtbase in 5.11. So re-apply 32398e4d here. tests/auto/corelib/global/qlogging/test/test.pro tests/auto/corelib/global/qlogging/tst_qlogging.cpp tests/auto/corelib/io/qfile/tst_qfile.cpp tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp tests/auto/corelib/thread/qthreadstorage/test/test.pro tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp tests/auto/widgets/kernel/qapplication/test/test.pro Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Done-with: MÃ¥rten Nordheim <marten.nordheim@qt.io> Done-with: Oliver Wolff <oliver.wolff@qt.io> Change-Id: Id970486c5315a1718c540f00deb2633533e8fc7b
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm7
-rw-r--r--src/plugins/platforms/cocoa/qnsview_dragging.mm6
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm35
4 files changed, 40 insertions, 13 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 2493181bc5..348a9b0c24 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -117,6 +117,9 @@ static void updateFormatFromContext(QSurfaceFormat *format)
format->setProfile(QSurfaceFormat::CompatibilityProfile);
}
+ // NSOpenGLContext is not re-entrant (https://openradar.appspot.com/37064579)
+static QMutex s_contextMutex;
+
QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share,
const QVariant &nativeHandle)
: m_context(nil),
@@ -248,6 +251,7 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
setActiveWindow(window);
+ QMutexLocker locker(&s_contextMutex);
[m_context flushBuffer];
}
@@ -400,6 +404,7 @@ QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName)
void QCocoaGLContext::update()
{
+ QMutexLocker locker(&s_contextMutex);
[m_context update];
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 022242130b..9e168835f1 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -503,7 +503,10 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
{
const Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
const bool frameless = (flags & Qt::FramelessWindowHint) || windowIsPopupType(type);
- const bool resizeable = !(flags & Qt::CustomizeWindowHint); // Remove zoom button by disabling resize
+
+ // Remove zoom button by disabling resize for CustomizeWindowHint windows, except for
+ // Qt::Tool windows (e.g. dock windows) which should always be resizeable.
+ const bool resizeable = !(flags & Qt::CustomizeWindowHint) || (type == Qt::Tool);
// Select base window type. Note that the value of NSBorderlessWindowMask is 0.
NSUInteger styleMask = (frameless || !resizeable) ? NSBorderlessWindowMask : NSResizableWindowMask;
@@ -517,6 +520,8 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
styleMask |= NSClosableWindowMask;
if (flags & Qt::WindowMinimizeButtonHint)
styleMask |= NSMiniaturizableWindowMask;
+ if (flags & Qt::WindowMaximizeButtonHint)
+ styleMask |= NSResizableWindowMask;
} else {
styleMask |= NSClosableWindowMask | NSTitledWindowMask;
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
index 01df0e9337..e61329f169 100644
--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
+++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
@@ -165,7 +165,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
[nativeCursor set];
// Make sure the cursor is updated correctly if the mouse does not move and window is under cursor
- // by creating a fake move event
+ // by creating a fake move event, unless on 10.14 and later where doing so will trigger a security
+ // warning dialog. FIXME: Find a way to update the cursor without fake mouse events.
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSMojave)
+ return;
+
if (m_updatingDrag)
return;
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index 6079a35d05..1c21879a89 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -72,25 +72,38 @@ static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*"));
/*!
Overridden to ensure that the zoomed state always results in a maximized
window, which would otherwise not be the case for borderless windows.
+
+ We also keep the window on the same screen as before; something AppKit
+ sometimes fails to do using its built in logic.
*/
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)proposedFrame
{
Q_UNUSED(proposedFrame);
Q_ASSERT(window == m_cocoaWindow->nativeWindow());
-
- // We compute the maximized state based on the maximum size, and
- // the current position of the window. This may result in the window
- // geometry falling outside of the current screen's available geometry,
- // e.g. when there is not maximize size set, but this is okey, AppKit
- // will then shift and possibly clip the geometry for us.
const QWindow *w = m_cocoaWindow->window();
- QRect maximizedRect = QRect(w->framePosition(), w->maximumSize());
- // QWindow::maximumSize() refers to the client size,
- // but AppKit expects the full frame size.
- maximizedRect.adjust(0, 0, 0, w->frameMargins().top());
+ // maximumSize() refers to the client size, but AppKit expects the full frame size
+ QSizeF maximumSize = w->maximumSize() + QSize(0, w->frameMargins().top());
+
+ // The window should never be larger than the current screen geometry
+ const QRectF screenGeometry = m_cocoaWindow->screen()->geometry();
+ maximumSize = maximumSize.boundedTo(screenGeometry.size());
+
+ // Use the current frame position for the initial maximized frame,
+ // so that the window stays put and just expand, in case its maximum
+ // size is within the screen bounds.
+ QRectF maximizedFrame = QRectF(w->framePosition(), maximumSize);
+
+ // But constrain the frame to the screen bounds in case the frame
+ // extends beyond the screen bounds as a result of starting out
+ // with the current frame position.
+ maximizedFrame.translate(QPoint(
+ qMax(screenGeometry.left() - maximizedFrame.left(), 0.0) +
+ qMin(screenGeometry.right() - maximizedFrame.right(), 0.0),
+ qMax(screenGeometry.top() - maximizedFrame.top(), 0.0) +
+ qMin(screenGeometry.bottom() - maximizedFrame.bottom(), 0.0)));
- return QCocoaScreen::mapToNative(maximizedRect);
+ return QCocoaScreen::mapToNative(maximizedFrame);
}
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu