From 836a2fb8872217d2a04a209b89f2ac2ff86a4b99 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 28 Sep 2018 17:37:58 +0200 Subject: [macOS] Fix position of sheets when using unifiedTitleAndToolBarOnMac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modal sheets are supposed to appear below the toolbar if a toolbar exists, or below the title bar if a toolbar doesn't exist. In the unified title and toolbar mode, sheets should to appear directly below the toolbar, if the toolbar is positioned at the top of the window. Code-wise we achieve that by calling setUnifiedTitleAndToolBarOnMac on a QMainWindow, which results in adjusting the top content border of the NSWindow via [NSWindow setContentBorderThickness:forEdge], which Cocoa uses to position a modal sheet (the sheet top edge is aligned with the top edge of the content view + the Y border thickness value). The issue is that because NSWindow.titlebarAppearsTransparent is set to YES, for sheet presentation purposes, Cocoa considers the content view to begin at the position of the top left corner of the frame (where the title bar is), and thus sheets appear somewhere in the middle of the unified toolbar. To fix that we need to account for the title bar height in the border thickness value. Compute the title bar height from the window frame height - window content view height, and add it to the top border thickness value. Amends 8ac9addd946637401e4685c6e91d1a3cd5b2d768 Change-Id: Icf85c513035cc3710b438e60eb14dc04c5bbaced Fixes: QTBUG-65451 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 9b10c8b053..00c3f7c22c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1714,6 +1714,14 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask]; window.titlebarAppearsTransparent = YES; + // Setting titlebarAppearsTransparent to YES means that the border thickness has to account + // for the title bar height as well, otherwise sheets will not be presented at the correct + // position, which should be (title bar height + top content border size). + const NSRect frameRect = window.frame; + const NSRect contentRect = [window contentRectForFrameRect:frameRect]; + const CGFloat titlebarHeight = frameRect.size.height - contentRect.size.height; + effectiveTopContentBorderThickness += titlebarHeight; + [window setContentBorderThickness:effectiveTopContentBorderThickness forEdge:NSMaxYEdge]; [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; -- cgit v1.2.3 From 091a386eaf91ad8932332a8aefc2df793de59f6c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 9 Oct 2018 11:01:37 +0200 Subject: Use native visual ID when creating GBM surfaces for KMS According to the Khronos documentation, gbm_surface_create() will give a BAD_MATCH error if the format does not match the EGL_NATIVE_VISUAL_ID. Newer drivers have started to enforce this. Change-Id: I61360b0f52965ad8057e7de8f824ffca64fea904 Reviewed-by: Laszlo Agocs Reviewed-by: Dominik Holland --- .../eglfs_kms/qeglfskmsgbmscreen.cpp | 24 ++++++++++++++++++---- .../eglfs_kms/qeglfskmsgbmscreen.h | 2 +- .../eglfs_kms/qeglfskmsgbmwindow.cpp | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 4742143121..1b52bdf3ec 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -148,16 +148,32 @@ QPlatformCursor *QEglFSKmsGbmScreen::cursor() const } } -gbm_surface *QEglFSKmsGbmScreen::createSurface() +gbm_surface *QEglFSKmsGbmScreen::createSurface(EGLConfig eglConfig) { if (!m_gbm_surface) { - uint32_t gbmFormat = drmFormatToGbmFormat(m_output.drm_format); - qCDebug(qLcEglfsKmsDebug, "Creating gbm_surface for screen %s with format 0x%x", qPrintable(name()), gbmFormat); - m_gbm_surface = gbm_surface_create(static_cast(device())->gbmDevice(), + qCDebug(qLcEglfsKmsDebug, "Creating gbm_surface for screen %s", qPrintable(name())); + + const auto gbmDevice = static_cast(device())->gbmDevice(); + EGLint native_format = -1; + EGLBoolean success = eglGetConfigAttrib(display(), eglConfig, EGL_NATIVE_VISUAL_ID, &native_format); + qCDebug(qLcEglfsKmsDebug) << "Got native format" << hex << native_format << dec << "from eglGetConfigAttrib() with return code" << bool(success); + + if (success) + m_gbm_surface = gbm_surface_create(gbmDevice, + rawGeometry().width(), + rawGeometry().height(), + native_format, + GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + + if (!m_gbm_surface) { // fallback for older drivers + uint32_t gbmFormat = drmFormatToGbmFormat(m_output.drm_format); + qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat); + m_gbm_surface = gbm_surface_create(gbmDevice, rawGeometry().width(), rawGeometry().height(), gbmFormat, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + } } return m_gbm_surface; // not owned, gets destroyed in QEglFSKmsGbmIntegration::destroyNativeWindow() via QEglFSKmsGbmWindow::invalidateSurface() } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h index f5a2122723..b94f44b7b1 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h @@ -59,7 +59,7 @@ public: QPlatformCursor *cursor() const override; - gbm_surface *createSurface(); + gbm_surface *createSurface(EGLConfig eglConfig); void resetSurface(); void initCloning(QPlatformScreen *screenThisScreenClones, diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmwindow.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmwindow.cpp index 110a592dec..65a7c4f38a 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmwindow.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmwindow.cpp @@ -53,7 +53,7 @@ void QEglFSKmsGbmWindow::resetSurface() m_config = QEglFSDeviceIntegration::chooseConfig(display, platformFormat); m_format = q_glFormatFromConfig(display, m_config, platformFormat); // One fullscreen window per screen -> the native window is simply the gbm_surface the screen created. - m_window = reinterpret_cast(gbmScreen->createSurface()); + m_window = reinterpret_cast(gbmScreen->createSurface(m_config)); PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createPlatformWindowSurface = nullptr; const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); -- cgit v1.2.3 From dc5f9d0c3101f95185d3c562d001e0af18f46a0b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 2 Oct 2018 15:05:32 +0200 Subject: Only use a translucent background if there is support for alpha Change-Id: Ia8d9e543fac4b6e790fa38cf04c5a782d72d72df Reviewed-by: Eirik Aavitsland Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp index 8851ea59e5..ed482e5dae 100644 --- a/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qbackingstore_x11.cpp @@ -62,8 +62,10 @@ QXcbNativeBackingStore::QXcbNativeBackingStore(QWindow *window) : QPlatformBackingStore(window) , m_translucentBackground(false) { - if (QXcbWindow *w = static_cast(window->handle())) - m_translucentBackground = w->connection()->hasXRender() && QImage::toPixelFormat(w->imageFormat()).alphaSize() > 0; + if (QXcbWindow *w = static_cast(window->handle())) { + m_translucentBackground = w->connection()->hasXRender() && + QImage::toPixelFormat(w->imageFormat()).alphaUsage() == QPixelFormat::UsesAlpha; + } } QXcbNativeBackingStore::~QXcbNativeBackingStore() -- cgit v1.2.3 From 3eebadc1734463afa469dcd08eab8c5d2557dec6 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 28 Sep 2018 11:40:10 +0200 Subject: Modernize the "mimetype" feature Change-Id: I9b67c2cbc0891a38ece18d521c86fbc7344dce7a Reviewed-by: Edward Welbourne Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/cocoa/qcocoaprintdevice.h | 2 ++ src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 4 ++++ src/plugins/platformthemes/platformthemes.pro | 2 +- src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 +- src/plugins/printsupport/cups/qppdprintdevice.h | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.h b/src/plugins/platforms/cocoa/qcocoaprintdevice.h index 20b27f3286..d267343b0e 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.h +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.h @@ -98,7 +98,9 @@ protected: void loadOutputBins() const override; void loadDuplexModes() const override; void loadColorModes() const override; +#if QT_CONFIG(mimetype) void loadMimeTypes() const override; +#endif private: QPageSize createPageSize(const PMPaper &paper) const; diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index bfe6cd09b6..0c54a3b771 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -39,7 +39,9 @@ #include "qcocoaprintdevice.h" +#if QT_CONFIG(mimetype) #include +#endif #include QT_BEGIN_NAMESPACE @@ -417,6 +419,7 @@ QPrint::ColorMode QCocoaPrintDevice::defaultColorMode() const return QPrint::GrayScale; } +#if QT_CONFIG(mimetype) void QCocoaPrintDevice::loadMimeTypes() const { // TODO Check how settings affect returned list @@ -438,6 +441,7 @@ void QCocoaPrintDevice::loadMimeTypes() const } m_haveMimeTypes = true; } +#endif // mimetype bool QCocoaPrintDevice::openPpdFile() { diff --git a/src/plugins/platformthemes/platformthemes.pro b/src/plugins/platformthemes/platformthemes.pro index 17b1d91c6a..02ed3406e7 100644 --- a/src/plugins/platformthemes/platformthemes.pro +++ b/src/plugins/platformthemes/platformthemes.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs QT_FOR_CONFIG += widgets-private -qtConfig(dbus):qtConfig(regularexpression): SUBDIRS += flatpak +qtConfig(dbus):qtConfig(regularexpression):qtConfig(mimetype): SUBDIRS += flatpak qtHaveModule(widgets):qtConfig(gtk3): SUBDIRS += gtk3 diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp index 340b1a1ff4..f0a8105d21 100644 --- a/src/plugins/printsupport/cups/qppdprintdevice.cpp +++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp @@ -463,7 +463,7 @@ bool QPpdPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey ke return QPlatformPrintDevice::isFeatureAvailable(key, params); } -#ifndef QT_NO_MIMETYPE +#if QT_CONFIG(mimetype) void QPpdPrintDevice::loadMimeTypes() const { // TODO No CUPS api? Need to manually load CUPS mime.types file? diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h index 9867083bd7..596f9aa3f5 100644 --- a/src/plugins/printsupport/cups/qppdprintdevice.h +++ b/src/plugins/printsupport/cups/qppdprintdevice.h @@ -100,7 +100,7 @@ protected: void loadOutputBins() const override; void loadDuplexModes() const override; void loadColorModes() const override; -#ifndef QT_NO_MIMETYPE +#if QT_CONFIG(mimetype) void loadMimeTypes() const override; #endif -- cgit v1.2.3