Merge remote-tracking branch 'origin/5.12' into 5.13

Change-Id: I60bb714ef11bced075d94addb74d23c3a3975519
This commit is contained in:
Qt Forward Merge Bot 2019-08-24 01:00:08 +02:00
commit b29505bb37
10 changed files with 70 additions and 36 deletions

View File

@ -3257,8 +3257,11 @@ void QGuiApplication::setFont(const QFont &font)
*QGuiApplicationPrivate::app_font = font;
applicationResourceFlags |= ApplicationFontExplicitlySet;
if (emitChange && qGuiApp)
emit qGuiApp->fontChanged(*QGuiApplicationPrivate::app_font);
if (emitChange && qGuiApp) {
auto font = *QGuiApplicationPrivate::app_font;
locker.unlock();
emit qGuiApp->fontChanged(font);
}
}
/*!

View File

@ -264,10 +264,8 @@ public:
bool QOpenGLProgramBinaryCache::load(const QByteArray &cacheKey, uint programId)
{
QMutexLocker lock(&m_mutex);
if (m_memCache.contains(cacheKey)) {
const MemCacheEntry *e = m_memCache[cacheKey];
if (const MemCacheEntry *e = m_memCache.object(cacheKey))
return setProgramBinary(programId, e->format, e->blob.constData(), e->blob.size());
}
QByteArray buf;
const QString fn = cacheFileName(cacheKey);

View File

@ -103,17 +103,20 @@ CONFIG += no_app_extension_api_only
qtHaveModule(widgets) {
QT_FOR_CONFIG += widgets
SOURCES += \
qpaintengine_mac.mm \
qprintengine_mac.mm \
qcocoaprintersupport.mm \
qcocoaprintdevice.mm \
SOURCES += qpaintengine_mac.mm
HEADERS += qpaintengine_mac_p.h
HEADERS += \
qpaintengine_mac_p.h \
qprintengine_mac_p.h \
qcocoaprintersupport.h \
qcocoaprintdevice.h \
qtHaveModule(printsupport) {
QT += printsupport-private
SOURCES += \
qprintengine_mac.mm \
qcocoaprintersupport.mm \
qcocoaprintdevice.mm
HEADERS += \
qcocoaprintersupport.h \
qcocoaprintdevice.h \
qprintengine_mac_p.h
}
qtConfig(colordialog) {
SOURCES += qcocoacolordialoghelper.mm
@ -130,7 +133,7 @@ qtHaveModule(widgets) {
HEADERS += qcocoafontdialoghelper.h
}
QT += widgets-private printsupport-private
QT += widgets-private
}
OTHER_FILES += cocoa.json

View File

@ -54,6 +54,8 @@ class QCocoaBackingStore : public QRasterBackingStore
protected:
QCocoaBackingStore(QWindow *window);
QCFType<CGColorSpaceRef> colorSpace() const;
QMacNotificationObserver m_backingPropertiesObserver;
virtual void backingPropertiesChanged() = 0;
};
class QNSWindowBackingStore : public QCocoaBackingStore
@ -69,6 +71,7 @@ private:
bool windowHasUnifiedToolbar() const;
QImage::Format format() const override;
void redrawRoundedBottomCorners(CGRect) const;
void backingPropertiesChanged() override;
};
class QCALayerBackingStore : public QCocoaBackingStore
@ -115,6 +118,8 @@ private:
bool recreateBackBufferIfNeeded();
bool prepareForFlush();
void backingPropertiesChanged() override;
std::list<std::unique_ptr<GraphicsBuffer>> m_buffers;
};

View File

@ -51,6 +51,17 @@ QT_BEGIN_NAMESPACE
QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
: QRasterBackingStore(window)
{
// Ideally this would be plumbed from the platform layer to QtGui, and
// the QBackingStore would be recreated, but we don't have that code yet,
// so at least make sure we invalidate our backingstore when the backing
// properties (color space e.g.) are changed.
NSView *view = static_cast<QCocoaWindow *>(window->handle())->view();
m_backingPropertiesObserver = QMacNotificationObserver(view.window,
NSWindowDidChangeBackingPropertiesNotification, [this]() {
qCDebug(lcQpaBackingStore) << "Backing properties for"
<< this->window() << "did change";
backingPropertiesChanged();
});
}
QCFType<CGColorSpaceRef> QCocoaBackingStore::colorSpace() const
@ -212,9 +223,6 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const
CGRect viewRect = viewLocalRect.toCGRect();
if (windowHasUnifiedToolbar())
NSDrawWindowBackground(viewRect);
[backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect()
operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil];
@ -302,6 +310,11 @@ void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const
#endif
}
void QNSWindowBackingStore::backingPropertiesChanged()
{
m_image = QImage();
}
// ----------------------------------------------------------------------------
QCALayerBackingStore::QCALayerBackingStore(QWindow *window)
@ -565,6 +578,12 @@ QImage QCALayerBackingStore::toImage() const
return imageCopy;
}
void QCALayerBackingStore::backingPropertiesChanged()
{
m_buffers.clear();
m_buffers.resize(1);
}
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
{
return m_buffers.back().get();

View File

@ -59,7 +59,7 @@
#include "qguiapplication.h"
#include <qdebug.h>
#ifndef QT_NO_WIDGETS
#if !defined(QT_NO_WIDGETS) && defined(QT_PRINTSUPPORT_LIB)
#include "qcocoaprintersupport.h"
#include "qprintengine_mac_p.h"
#include <qpa/qplatformprintersupport.h>
@ -153,24 +153,24 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
{
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) && defined(QT_PRINTSUPPORT_LIB)
return new QCocoaPrinterSupport();
#else
qFatal("Printing is not supported when Qt is configured with -no-widgets");
qFatal("Printing is not supported when Qt is configured with -no-widgets or -no-feature-printer");
return nullptr;
#endif
}
void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine)
{
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) && defined(QT_PRINTSUPPORT_LIB)
QMacPrintEnginePrivate *macPrintEnginePriv = static_cast<QMacPrintEngine *>(printEngine)->d_func();
if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized())
macPrintEnginePriv->initialize();
return macPrintEnginePriv->printInfo;
#else
Q_UNUSED(printEngine);
qFatal("Printing is not supported when Qt is configured with -no-widgets");
qFatal("Printing is not supported when Qt is configured with -no-widgets or -no-feature-printer");
return nullptr;
#endif
}

View File

@ -161,6 +161,7 @@ public:
Q_NOTIFICATION_HANDLER(NSWindowDidOrderOffScreenNotification) void windowDidOrderOffScreen();
Q_NOTIFICATION_HANDLER(NSWindowDidChangeOcclusionStateNotification) void windowDidChangeOcclusionState();
Q_NOTIFICATION_HANDLER(NSWindowDidChangeScreenNotification) void windowDidChangeScreen();
Q_NOTIFICATION_HANDLER(NSWindowDidChangeBackingPropertiesNotification) void windowDidChangeBackingProperties();
Q_NOTIFICATION_HANDLER(NSWindowWillCloseNotification) void windowWillClose();
bool windowShouldClose();

View File

@ -1262,6 +1262,17 @@ void QCocoaWindow::windowDidChangeScreen()
currentScreen->requestUpdate();
}
}
/*
The window's backing scale factor or color space has changed.
*/
void QCocoaWindow::windowDidChangeBackingProperties()
{
// Ideally we would plumb this thought QPA in a way that lets clients
// invalidate their own caches, and recreate QBackingStore. For now we
// trigger an expose, and let QCocoaBackingStore deal with its own
// buffer invalidation.
[m_view setNeedsDisplay:YES];
}
void QCocoaWindow::windowWillClose()
{

View File

@ -253,20 +253,10 @@ static bool isMouseEvent(NSEvent *ev)
return m_platformWindow ? m_platformWindow->isOpaque() : [super isOpaque];
}
/*!
Borderless windows need a transparent background
Technically windows with NSWindowStyleMaskTexturedBackground
(such as windows with unified toolbars) need to draw the textured
background of the NSWindow, and can't have a transparent
background, but as NSWindowStyleMaskBorderless is 0, you can't
have a window with NSWindowStyleMaskTexturedBackground that is
also borderless.
*/
- (NSColor *)backgroundColor
{
return self.styleMask == NSWindowStyleMaskBorderless
? [NSColor clearColor] : [super backgroundColor];
return self.styleMask & NSWindowStyleMaskTexturedBackground ?
[super backgroundColor] : [NSColor clearColor];
}
- (void)sendEvent:(NSEvent*)theEvent

View File

@ -38,14 +38,18 @@
****************************************************************************/
#include "qpaintengine_mac_p.h"
#if defined(QT_PRINTSUPPORT_LIB)
#include "qprintengine_mac_p.h"
#endif
#include <qbitmap.h>
#include <qpaintdevice.h>
#include <qpainterpath.h>
#include <qpixmapcache.h>
#include <private/qpaintengine_raster_p.h>
#if defined(QT_PRINTSUPPORT_LIB)
#include <qprinter.h>
#endif
#include <qstack.h>
#include <qwidget.h>
#include <qvarlengtharray.h>