diff options
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoabackingstore.mm | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 17 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.mm | 24 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 41 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 6 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfshooks.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | 26 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsscreen.cpp | 2 |
11 files changed, 113 insertions, 20 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 665b3d4c13..30c15d823a 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -73,7 +73,8 @@ QPaintDevice *QCocoaBackingStore::paintDevice() } #endif - QImage::Format format = window()->format().hasAlpha() + QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()); + QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; m_qImage = QImage(m_requestedSize * scaleFactor, format); m_qImage.setDevicePixelRatio(scaleFactor); diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index d30b281eb8..5c59c73847 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -132,6 +132,9 @@ private: // touch events, which then will be delivered until the widget // deregisters. static void registerTouchWindow(QWindow *window, bool enable); + + // Request a unified title and toolbar look for the window. + static void setContentBorderThickness(QWindow *window, int topThickness, int bottomThickness); }; #endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 795d1a8149..eb520b97c9 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -123,6 +123,8 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow); if (resource.toLower() == "setembeddedinforeignview") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setEmbeddedInForeignView); + if (resource.toLower() == "setcontentborderthickness") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setContentBorderThickness); return 0; } @@ -268,14 +270,19 @@ void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable) if (!window) return; - // Make sure the QCocoaWindow is created when enabling. Disabling might - // happen on window destruction, don't (re)create the QCocoaWindow then. - if (enable) - window->create(); - QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle()); if (cocoaWindow) cocoaWindow->registerTouch(enable); } +void QCocoaNativeInterface::setContentBorderThickness(QWindow *window, int topThickness, int bottomThickness) +{ + if (!window) + return; + + QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle()); + if (cocoaWindow) + cocoaWindow->setContentBorderThickness(topThickness, bottomThickness); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index bf6c47f273..109649f24e 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -259,13 +259,17 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())]; if (!iconImage) return QPixmap(); - - NSRect iconRect = NSMakeRect(0, 0, size.width(), size.height()); - NSGraphicsContext *gc = [NSGraphicsContext currentContext]; - CGImageRef cgImage = [iconImage CGImageForProposedRect:&iconRect - context:([gc graphicsPort] ? gc : nil) - hints:nil]; - QPixmap pixmap = QPixmap::fromImage(qt_mac_toQImage(cgImage)); + NSSize pixmapSize = NSMakeSize(size.width(), size.height()); + QPixmap pixmap(pixmapSize.width, pixmapSize.height); + pixmap.fill(Qt::transparent); + [iconImage setSize:pixmapSize]; + NSRect iconRect = NSMakeRect(0, 0, pixmapSize.width, pixmapSize.height); + CGContextRef ctx = qt_mac_cg_context(&pixmap); + NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]; + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:gc]; + [iconImage drawInRect:iconRect fromRect:iconRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil]; + [NSGraphicsContext restoreGraphicsState]; return pixmap; } @@ -281,8 +285,12 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const case TabAllWidgets: return QVariant(bool([[NSApplication sharedApplication] isFullKeyboardAccessEnabled])); case IconPixmapSizes: { + qreal devicePixelRatio = qGuiApp->devicePixelRatio(); QList<int> sizes; - sizes << 16 << 32 << 64 << 128; + sizes << 16 * devicePixelRatio + << 32 * devicePixelRatio + << 64 * devicePixelRatio + << 128 * devicePixelRatio; return QVariant::fromValue(sizes); } case QPlatformTheme::PasswordMaskCharacter: diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 69bea31343..c20773601d 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -157,6 +157,8 @@ public: void setWindowCursor(NSCursor *cursor); void registerTouch(bool enable); + void setContentBorderThickness(int topThickness, int bottomThickness); + void applyContentBorderThickness(NSWindow *window); qreal devicePixelRatio() const; bool isWindowExposable(); @@ -215,6 +217,10 @@ public: // for QNSView NSInteger m_alertRequest; id monitor; + bool m_drawContentBorderGradient; + int m_topContentBorderThickness; + int m_bottomContentBorderThickness; + // used by showFullScreen in fake mode QRect m_normalGeometry; Qt::WindowFlags m_oldWindowFlags; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5702689d84..f62a6d29ce 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -220,6 +220,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_overrideBecomeKey(false) , m_alertRequest(NoAlertRequest) , monitor(nil) + , m_drawContentBorderGradient(false) + , m_topContentBorderThickness(0) + , m_bottomContentBorderThickness(0) , m_normalGeometry(QRect(0,0,-1,-1)) { #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG @@ -511,6 +514,9 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags) } } + if (m_drawContentBorderGradient) + styleMask |= NSTexturedBackgroundWindowMask; + #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG qDebug("windowStyleMask of '%s': flags %X -> styleMask %lX", qPrintable(window()->title()), (int)flags, styleMask); #endif @@ -936,6 +942,9 @@ NSWindow * QCocoaWindow::createNSWindow() } m_windowModality = window()->modality(); + + applyContentBorderThickness(createdWindow); + return createdWindow; } @@ -1100,6 +1109,38 @@ void QCocoaWindow::registerTouch(bool enable) [m_contentView setAcceptsTouchEvents:NO]; } +void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness) +{ + m_topContentBorderThickness = topThickness; + m_bottomContentBorderThickness = bottomThickness; + bool enable = (topThickness > 0 || bottomThickness > 0); + m_drawContentBorderGradient = enable; + + applyContentBorderThickness(m_nsWindow); +} + +void QCocoaWindow::applyContentBorderThickness(NSWindow *window) +{ + if (!window) + return; + + if (m_drawContentBorderGradient) + [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask]; + else + [window setStyleMask:[window styleMask] & ~NSTexturedBackgroundWindowMask]; + + if (m_topContentBorderThickness > 0) { + [window setContentBorderThickness:m_topContentBorderThickness forEdge:NSMaxYEdge]; + [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; + } + + if (m_bottomContentBorderThickness > 0) { + [window setContentBorderThickness:m_topContentBorderThickness forEdge:NSMinYEdge]; + [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; + } +} + + qreal QCocoaWindow::devicePixelRatio() const { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index e183f93c6c..f7b129aea1 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -408,6 +408,9 @@ static QTouchDevice *touchDevice = 0; m_shouldSetGLContextinDrawRect = false; } + if (m_platformWindow->m_drawContentBorderGradient) + NSDrawWindowBackground(dirtyRect); + if (!m_backingStore) return; @@ -451,7 +454,8 @@ static QTouchDevice *touchDevice = 0; // Optimization: Copy frame buffer content instead of blending for // top-level windows where Qt fills the entire window content area. - if (m_platformWindow->m_nsWindow) + // (But don't overpaint the title-bar gradient) + if (m_platformWindow->m_nsWindow && !m_platformWindow->m_drawContentBorderGradient) CGContextSetBlendMode(cgContext, kCGBlendModeCopy); CGContextDrawImage(cgContext, dirtyWindowRect, cleanImg); diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h index dfafec73af..67f4d1803d 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks.h +++ b/src/plugins/platforms/eglfs/qeglfshooks.h @@ -77,7 +77,8 @@ public: virtual bool filterConfig(EGLDisplay display, EGLConfig config) const; virtual void waitForVSync() const; - virtual const char *fbDeviceName() const; + virtual QByteArray fbDeviceName() const; + virtual int framebufferIndex() const; static QEglFSHooks *hooks() { diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index f5467fd6a4..b81d260ecb 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -42,6 +42,7 @@ #include "qeglfshooks.h" #include <QtPlatformSupport/private/qeglplatformcursor_p.h> #include <QtPlatformSupport/private/qeglconvenience_p.h> +#include <QtCore/QRegularExpression> #include <fcntl.h> #include <unistd.h> @@ -56,17 +57,34 @@ QT_BEGIN_NAMESPACE // this is a global static to keep the QEglFSHooks interface as clean as possible static int framebuffer = -1; -const char *QEglFSHooks::fbDeviceName() const +QByteArray QEglFSHooks::fbDeviceName() const { - return "/dev/fb0"; + QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB"); + if (fbDev.isEmpty()) + fbDev = QByteArrayLiteral("/dev/fb0"); + + return fbDev; +} + +int QEglFSHooks::framebufferIndex() const +{ + int fbIndex = 0; + QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)")); + QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName()); + if (match.hasMatch()) + fbIndex = match.captured(1).toInt(); + + return fbIndex; } void QEglFSHooks::platformInit() { - framebuffer = qt_safe_open(fbDeviceName(), O_RDONLY); + QByteArray fbDev = fbDeviceName(); + + framebuffer = qt_safe_open(fbDev, O_RDONLY); if (framebuffer == -1) - qWarning("EGLFS: Failed to open %s", fbDeviceName()); + qWarning("EGLFS: Failed to open %s", qPrintable(fbDev)); } void QEglFSHooks::platformDestroy() diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 497d0975af..8ebfd018d0 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -572,6 +572,8 @@ bool QWindowsDialogHelperBase<BaseClass>::show(Qt::WindowFlags, QWindow *parent) { const bool modal = (windowModality != Qt::NonModal); + if (!parent) + parent = QGuiApplication::focusWindow(); // Need a parent window, else the application loses activation when closed. if (parent) { m_ownerWindow = QWindowsWindow::handleOf(parent); } else { diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 234cadcd75..60c8bee286 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -304,6 +304,8 @@ QList<QPlatformScreen *> QWindowsScreen::virtualSiblings() const void QWindowsScreen::handleChanges(const QWindowsScreenData &newData) { + m_data.physicalSizeMM = newData.physicalSizeMM; + if (m_data.geometry != newData.geometry) { m_data.geometry = newData.geometry; QWindowSystemInterface::handleScreenGeometryChange(screen(), |