From f6c5452d97c5bc53fd29c32e7f9bee0f5e411283 Mon Sep 17 00:00:00 2001 From: Indrajit Tapadar Date: Wed, 23 Jan 2013 13:08:20 +0100 Subject: Fix for url encoding in QDesktopServices::openUrl(). URLs containing spaces (encoded) couldnt be opened using QDesktopServices::openUrl() -method. This is a regression as it works for 4.8, Using url.toEncoded() instead of url.toString() which removed percent encoding. The NSUrl uses RFC 2396 for parsing, and according to the documentation, of 2.4. Escape Sequences - Data must be escaped if it does not have a representation using an unreserved character; And as a space does not have a representation using unreserved character it needs to be escaped. Example: Using this url, http://www.google.com/search?q=testme%20withspace url.toString() returns "http://www.google.com/search?q=testme withspace" and url.toEncoded() returns, http://www.google.com/search?q=testme%20withspace" which is also the expected result. Task-number: QTBUG-29124 Change-Id: Ieed3d4cfb689b9311f6cf21e5098a1e70256ab03 Reviewed-by: Thiago Macieira --- src/plugins/platforms/cocoa/qcocoaservices.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaservices.mm b/src/plugins/platforms/cocoa/qcocoaservices.mm index dea23e7e53..e4cec8c5f8 100644 --- a/src/plugins/platforms/cocoa/qcocoaservices.mm +++ b/src/plugins/platforms/cocoa/qcocoaservices.mm @@ -55,7 +55,7 @@ bool QCocoaServices::openUrl(const QUrl &url) const QString scheme = url.scheme(); if (scheme.isEmpty()) return openDocument(url); - return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QT_PREPEND_NAMESPACE(QCFString::toNSString)(url.toString())]]; + return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QT_PREPEND_NAMESPACE(QCFString::toNSString)(url.toString(QUrl::FullyEncoded))]]; } bool QCocoaServices::openDocument(const QUrl &url) -- cgit v1.2.3 From 3dc634be36326bc5e60f3baa4c5b8904e22347f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 4 Jan 2013 12:50:40 +0100 Subject: Cocoa: Add basic support for Qt::SubWindow. This allows embedding a QWindow in a foreign NSView hierarchy. Don't create a NSWindow. Add code paths for handling the embedded window case. Avoid changing the other window cases. There is potential for merging some of these cases but that can be done at a later point in time. Change-Id: I54c7b4eb82fad268f90ea6b716fc650ae31bd3af Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.h | 2 ++ src/plugins/platforms/cocoa/qcocoawindow.mm | 9 +++++- src/plugins/platforms/cocoa/qnsview.mm | 46 ++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 324a43c8ae..931319190c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -162,6 +162,8 @@ public: // for QNSView QNSView *m_contentView; NSWindow *m_nsWindow; + bool m_contentViewIsEmbedded; // true if the m_contentView is embedded in a "foregin" NSView hiearchy + QNSWindowDelegate *m_nsWindowDelegate; Qt::WindowFlags m_windowFlags; Qt::WindowState m_synchedWindowState; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 45100f9906..f7348e7dda 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -186,6 +186,7 @@ static bool isMouseEvent(NSEvent *ev) QCocoaWindow::QCocoaWindow(QWindow *tlw) : QPlatformWindow(tlw) , m_nsWindow(0) + , m_contentViewIsEmbedded(false) , m_nsWindowDelegate(0) , m_synchedWindowState(Qt::WindowActive) , m_windowModality(Qt::NonModal) @@ -237,6 +238,10 @@ void QCocoaWindow::setGeometry(const QRect &rect) void QCocoaWindow::setCocoaGeometry(const QRect &rect) { QCocoaAutoReleasePool pool; + + if (m_contentViewIsEmbedded) + return; + if (m_nsWindow) { NSRect bounds = qt_mac_flipRect(rect, window()); [m_nsWindow setContentSize : bounds.size]; @@ -634,7 +639,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) m_nsWindowDelegate = 0; } - if (!parentWindow) { + if (window()->type() == Qt::SubWindow) { + // Subwindows don't have a NSWindow. + } else if (!parentWindow) { // Create a new NSWindow if this is a top-level window. m_nsWindow = createNSWindow(); setNSWindow(m_nsWindow); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 1d59592e7d..02635ea4ec 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -173,6 +173,36 @@ static QTouchDevice *touchDevice = 0; QWindowSystemInterface::handleExposeEvent(m_window, m_window->geometry()); } +- (void)viewDidMoveToSuperview +{ + if (!(m_window->type() & Qt::SubWindow)) + return; + + if ([self superview]) { + m_platformWindow->m_contentViewIsEmbedded = true; + QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry()); + QWindowSystemInterface::handleExposeEvent(m_window, m_platformWindow->geometry()); + QWindowSystemInterface::flushWindowSystemEvents(); + } else { + m_platformWindow->m_contentViewIsEmbedded = false; + } +} + +- (void)viewWillMoveToWindow:(NSWindow *)newWindow +{ + // ### Merge "normal" window code path with this one for 5.1. + if (!(m_window->type() & Qt::SubWindow)) + return; + + if (newWindow) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowNotification:) + name:nil // Get all notifications + object:newWindow]; + } else { + [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]]; + } +} - (void)updateGeometry { QRect geometry; @@ -181,6 +211,9 @@ static QTouchDevice *touchDevice = 0; NSRect rect = [self frame]; NSRect windowRect = [[self window] frame]; geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height); + } else if (m_window->type() & Qt::SubWindow) { + // embedded child window, use the frame rect ### merge with case below + geometry = qt_mac_toQRect([self bounds]); } else { // child window, use the frame rect geometry = qt_mac_toQRect([self frame]); @@ -198,6 +231,12 @@ static QTouchDevice *touchDevice = 0; // an infinite loop when this notification is triggered again.) m_platformWindow->QPlatformWindow::setGeometry(geometry); + // Don't send the geometry change if the QWindow is designated to be + // embedded in a foregin view hiearchy but has not actually been + // embedded yet - it's too early. + if ((m_window->type() & Qt::SubWindow) && !m_platformWindow->m_contentViewIsEmbedded) + return; + // Send a geometry change event to Qt, if it's ready to handle events if (!m_platformWindow->m_inConstructor) { QWindowSystemInterface::handleGeometryChange(m_window, geometry); @@ -317,7 +356,12 @@ static QTouchDevice *touchDevice = 0; ); CGImageRef bsCGImage = m_backingStore->getBackingStoreCGImage(); CGImageRef cleanImg = CGImageCreateWithImageInRect(bsCGImage, backingStoreRect); - CGContextSetBlendMode(cgContext, kCGBlendModeCopy); + + // 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) + CGContextSetBlendMode(cgContext, kCGBlendModeCopy); + CGContextDrawImage(cgContext, dirtyWindowRect, cleanImg); // Clean-up: -- cgit v1.2.3 From 4b54c553058f278cedf1d40edacdc488aaa54f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Mon, 4 Feb 2013 15:59:22 +0100 Subject: Fix OpenGL context creation in the XCB plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it possible to create a core context with OpenGL implementations that don't implement the compatibility profile or the GL_ARB_compatibility extension. Qt was effectively clamping the OpenGL version to 3.0 by assuming that the highest supported backwards compatible version is also the highest supported core version. Since there is no way to check if the implementation supports a context with a given set of attributes without trying to create the context, we have to try every known OpenGL version until we find one that's supported. Note that this commit does not fix similar breakage on other platforms. Change-Id: I9616762b059db9e6182f853ab7f24ff44dc7d529 Reviewed-by: Sean Harmer Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qglxintegration.cpp | 213 +++++++------------------- src/plugins/platforms/xcb/qglxintegration.h | 15 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 1 - src/plugins/platforms/xcb/qxcbintegration.cpp | 29 +--- src/plugins/platforms/xcb/qxcbintegration.h | 10 -- 5 files changed, 56 insertions(+), 212 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 11c74edc45..2a6ef5a6ee 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -104,57 +104,6 @@ static Window createDummyWindow(QXcbScreen *screen, GLXFBConfig config) return window; } -// Per-window data for active OpenGL contexts. -struct QOpenGLContextData -{ - QOpenGLContextData(Display *display, Window window, GLXContext context) - : m_display(display), - m_window(window), - m_context(context) - {} - - QOpenGLContextData() - : m_display(0), - m_window(0), - m_context(0) - {} - - Display *m_display; - Window m_window; - GLXContext m_context; -}; - -static inline QOpenGLContextData currentOpenGLContextData() -{ - QOpenGLContextData result; - result.m_display = glXGetCurrentDisplay(); - result.m_window = glXGetCurrentDrawable(); - result.m_context = glXGetCurrentContext(); - return result; -} - -static inline QOpenGLContextData createDummyWindowOpenGLContextData(QXcbScreen *screen) -{ - QOpenGLContextData result; - result.m_display = DISPLAY_FROM_XCB(screen); - - QSurfaceFormat format; - GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen), screen->screenNumber(), format); - if (config) { - result.m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, true); - result.m_window = createDummyWindow(screen, config); - } else { - XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(screen), screen->screenNumber(), &format); - if (!visualInfo) - qFatal("Could not initialize GLX"); - result.m_context = glXCreateContext(DISPLAY_FROM_XCB(screen), visualInfo, 0, true); - result.m_window = createDummyWindow(screen, visualInfo); - XFree(visualInfo); - } - - return result; -} - static inline QByteArray getGlString(GLenum param) { if (const GLubyte *s = glGetString(param)) @@ -202,70 +151,7 @@ static void updateFormatFromContext(QSurfaceFormat &format) format.setProfile(QSurfaceFormat::CompatibilityProfile); } -/*! - \class QOpenGLTemporaryContext - \brief A temporary context that can be instantiated on the stack. - - Functions like glGetString() only work if there is a current GL context. - - \internal - \ingroup qt-lighthouse-xcb -*/ -class QOpenGLTemporaryContext -{ - Q_DISABLE_COPY(QOpenGLTemporaryContext) -public: - QOpenGLTemporaryContext(QXcbScreen *screen); - ~QOpenGLTemporaryContext(); - -private: - const QOpenGLContextData m_previous; - const QOpenGLContextData m_current; -}; - -QOpenGLTemporaryContext::QOpenGLTemporaryContext(QXcbScreen *screen) - : m_previous(currentOpenGLContextData()), - m_current(createDummyWindowOpenGLContextData(screen)) -{ - // Make our temporary context current on our temporary window - glXMakeCurrent(m_current.m_display, m_current.m_window, m_current.m_context); -} - -QOpenGLTemporaryContext::~QOpenGLTemporaryContext() -{ - // Restore the previous context if possible, otherwise just release our temporary context - if (m_previous.m_display) - glXMakeCurrent(m_previous.m_display, m_previous.m_window, m_previous.m_context); - else - glXMakeCurrent(m_current.m_display, 0, 0); - - // Destroy our temporary window - XDestroyWindow(m_current.m_display, m_current.m_window); - - // Finally destroy our temporary context itself - glXDestroyContext(m_current.m_display, m_current.m_context); -} - -QOpenGLDefaultContextInfo::QOpenGLDefaultContextInfo() - : vendor(getGlString(GL_VENDOR)), - renderer(getGlString(GL_RENDERER)) -{ - updateFormatFromContext(format); -} - -QOpenGLDefaultContextInfo *QOpenGLDefaultContextInfo::create(QXcbScreen *screen) -{ - // We need a current context for getGLString() to work. To have - // the QOpenGLDefaultContextInfo contain the latest supported - // context version, we rely upon the QOpenGLTemporaryContext to - // correctly obtain a context with the latest version - QScopedPointer temporaryContext(new QOpenGLTemporaryContext(screen)); - QOpenGLDefaultContextInfo *result = new QOpenGLDefaultContextInfo; - return result; -} - - -QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformOpenGLContext *share, QOpenGLDefaultContextInfo *defaultContextInfo) +QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlatformOpenGLContext *share) : QPlatformOpenGLContext() , m_screen(screen) , m_context(0) @@ -287,51 +173,60 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat QList glxExt = QByteArray(glXQueryExtensionsString(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber())).split(' '); bool supportsProfiles = glxExt.contains("GLX_ARB_create_context_profile"); - // Use glXCreateContextAttribsARB if is available + // Use glXCreateContextAttribsARB if available if (glxExt.contains("GLX_ARB_create_context") && glXCreateContextAttribsARB != 0) { - // We limit the requested version by the version of the static context as - // glXCreateContextAttribsARB fails and returns NULL if the requested context - // version is not supported. This means that we will get the closest supported - // context format that that which was requested and is supported by the driver - const int maxSupportedVersion = (defaultContextInfo->format.majorVersion() << 8) - + defaultContextInfo->format.minorVersion(); - const int requestedVersion = qMin((format.majorVersion() << 8) + format.minorVersion(), - maxSupportedVersion); - const int majorVersion = requestedVersion >> 8; - const int minorVersion = requestedVersion & 0xFF; - - QVector contextAttributes; - contextAttributes << GLX_CONTEXT_MAJOR_VERSION_ARB << majorVersion - << GLX_CONTEXT_MINOR_VERSION_ARB << minorVersion; - - // If asking for OpenGL 3.2 or newer we should also specify a profile - if (supportsProfiles && (m_format.majorVersion() > 3 || (m_format.majorVersion() == 3 && m_format.minorVersion() > 1))) { - if (m_format.profile() == QSurfaceFormat::CoreProfile) - contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_CORE_PROFILE_BIT_ARB; - else - contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; - } - - int flags = 0; - - if (m_format.testOption(QSurfaceFormat::DebugContext)) - flags |= GLX_CONTEXT_DEBUG_BIT_ARB; - - // A forward-compatible context may be requested for 3.0 and later - if (m_format.majorVersion() >= 3 && !m_format.testOption(QSurfaceFormat::DeprecatedFunctions)) - flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; - - if (flags != 0) - contextAttributes << GLX_CONTEXT_FLAGS_ARB << flags; - - contextAttributes << None; - - m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, m_shareContext, true, contextAttributes.data()); - if (!m_context && m_shareContext) { - // re-try without a shared glx context - m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, 0, true, contextAttributes.data()); - if (m_context) - m_shareContext = 0; + // Try to create an OpenGL context for each known OpenGL version in descending + // order from the requested version. + const int requestedVersion = format.majorVersion() * 10 + qMin(format.minorVersion(), 9); + + QVector glVersions; + if (requestedVersion > 43) + glVersions << requestedVersion; + + // Don't bother with versions below 2.0 + glVersions << 43 << 42 << 41 << 40 << 33 << 32 << 31 << 30 << 21 << 20; + + for (int i = 0; !m_context && i < glVersions.count(); i++) { + const int version = glVersions[i]; + if (version > requestedVersion) + continue; + + const int majorVersion = version / 10; + const int minorVersion = version % 10; + + QVector contextAttributes; + contextAttributes << GLX_CONTEXT_MAJOR_VERSION_ARB << majorVersion + << GLX_CONTEXT_MINOR_VERSION_ARB << minorVersion; + + // If asking for OpenGL 3.2 or newer we should also specify a profile + if (version >= 32 && supportsProfiles) { + if (m_format.profile() == QSurfaceFormat::CoreProfile) + contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + else + contextAttributes << GLX_CONTEXT_PROFILE_MASK_ARB << GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } + + int flags = 0; + + if (m_format.testOption(QSurfaceFormat::DebugContext)) + flags |= GLX_CONTEXT_DEBUG_BIT_ARB; + + // A forward-compatible context may be requested for 3.0 and later + if (version >= 30 && !m_format.testOption(QSurfaceFormat::DeprecatedFunctions)) + flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; + + if (flags != 0) + contextAttributes << GLX_CONTEXT_FLAGS_ARB << flags; + + contextAttributes << None; + + m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, m_shareContext, true, contextAttributes.data()); + if (!m_context && m_shareContext) { + // re-try without a shared glx context + m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, 0, true, contextAttributes.data()); + if (m_context) + m_shareContext = 0; + } } } diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index 78e9985334..98aee78b14 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -54,23 +54,10 @@ QT_BEGIN_NAMESPACE -class QOpenGLDefaultContextInfo -{ - Q_DISABLE_COPY(QOpenGLDefaultContextInfo) - QOpenGLDefaultContextInfo(); -public: - static QOpenGLDefaultContextInfo *create(QXcbScreen *screen); - - const QByteArray vendor; - const QByteArray renderer; - QSurfaceFormat format; -}; - - class QGLXContext : public QPlatformOpenGLContext { public: - QGLXContext(QXcbScreen *xd, const QSurfaceFormat &format, QPlatformOpenGLContext *share, QOpenGLDefaultContextInfo *defaultContextInfo); + QGLXContext(QXcbScreen *xd, const QSurfaceFormat &format, QPlatformOpenGLContext *share); ~QGLXContext(); bool makeCurrent(QPlatformSurface *surface); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 32de54562a..4525cb8ccb 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -222,7 +222,6 @@ void QXcbConnection::updateScreens() // Delete any existing screens which are not in activeScreens for (int i = m_screens.count() - 1; i >= 0; --i) { if (!activeScreens.contains(m_screens[i])) { - ((QXcbIntegration*)QGuiApplicationPrivate::platformIntegration())->removeDefaultOpenGLContextInfo(m_screens[i]); delete m_screens[i]; m_screens.removeAt(i); } diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 1840dd1ce5..60acf1ff02 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -121,9 +121,6 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters) QXcbIntegration::~QXcbIntegration() { -#if !defined(QT_NO_OPENGL) && defined(XCB_USE_GLX) - qDeleteAll(m_defaultContextInfos); -#endif qDeleteAll(m_connections); } @@ -181,14 +178,7 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont { QXcbScreen *screen = static_cast(context->screen()->handle()); #if defined(XCB_USE_GLX) - QOpenGLDefaultContextInfo *defaultContextInfo; - if (m_defaultContextInfos.contains(screen)) { - defaultContextInfo = m_defaultContextInfos.value(screen); - } else { - defaultContextInfo = QOpenGLDefaultContextInfo::create(screen); - m_defaultContextInfos.insert(screen, defaultContextInfo); - } - return new QGLXContext(screen, context->format(), context->shareHandle(), defaultContextInfo); + return new QGLXContext(screen, context->format(), context->shareHandle()); #elif defined(XCB_USE_EGL) return new QEGLXcbPlatformContext(context->format(), context->shareHandle(), screen->connection()->egl_display(), screen->connection()); @@ -293,21 +283,4 @@ QPlatformTheme *QXcbIntegration::createPlatformTheme(const QString &name) const return QGenericUnixTheme::createUnixTheme(name); } -/*! - Called by QXcbConnection prior to a QQnxScreen being deleted. - - Destroys and cleans up any default OpenGL context info for this screen. -*/ -void QXcbIntegration::removeDefaultOpenGLContextInfo(QXcbScreen *screen) -{ -#if !defined(QT_NO_OPENGL) && defined(XCB_USE_GLX) - if (!m_defaultContextInfos.contains(screen)) - return; - QOpenGLDefaultContextInfo* info = m_defaultContextInfos.take(screen); - delete info; -#else - Q_UNUSED(screen); -#endif -} - QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index cd6c2fd73c..1dd8d4576b 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -52,10 +52,6 @@ class QAbstractEventDispatcher; class QXcbNativeInterface; class QXcbScreen; -#if !defined(QT_NO_OPENGL) && defined(XCB_USE_GLX) -class QOpenGLDefaultContextInfo; -#endif - class QXcbIntegration : public QPlatformIntegration { public: @@ -97,8 +93,6 @@ public: QStringList themeNames() const; QPlatformTheme *createPlatformTheme(const QString &name) const; - void removeDefaultOpenGLContextInfo(QXcbScreen *screen); - private: QList m_connections; @@ -108,10 +102,6 @@ private: QScopedPointer m_inputContext; QAbstractEventDispatcher *m_eventDispatcher; -#if !defined(QT_NO_OPENGL) && defined(XCB_USE_GLX) - mutable QHash m_defaultContextInfos; -#endif - #ifndef QT_NO_ACCESSIBILITY QScopedPointer m_accessibility; #endif -- cgit v1.2.3 From d7dfab8cacff688b2f048097dc1a50eee81885f1 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 22 Feb 2013 14:50:14 +1000 Subject: Ofono also changed the context API. This updates it to work Change-Id: Ic3a055cb6a56be89b48a9ac77776217f910dee44 Reviewed-by: Lorn Potter --- src/plugins/bearer/connman/qconnmanengine.cpp | 4 +-- src/plugins/bearer/connman/qofonoservice_linux.cpp | 40 +++++++++++----------- src/plugins/bearer/connman/qofonoservice_linux_p.h | 8 ++--- 3 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 2b28cdbf61..589b0e2c24 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -159,7 +159,7 @@ void QConnmanEngine::connectToId(const QString &id) QOfonoDataConnectionManagerInterface dc(modemPath,0); foreach (const QDBusObjectPath &dcPath,dc.getPrimaryContexts()) { if(dcPath.path().contains(servicePath.section("_",-1))) { - QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); + QOfonoConnectionContextInterface primaryContext(dcPath.path(),0); primaryContext.setActive(true); } } @@ -183,7 +183,7 @@ void QConnmanEngine::disconnectFromId(const QString &id) QOfonoDataConnectionManagerInterface dc(modemPath,0); foreach (const QDBusObjectPath &dcPath,dc.getPrimaryContexts()) { if(dcPath.path().contains(servicePath.section("_",-1))) { - QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); + QOfonoConnectionContextInterface primaryContext(dcPath.path(),0); primaryContext.setActive(false); } } diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp index f6fb55522e..1983276d94 100644 --- a/src/plugins/bearer/connman/qofonoservice_linux.cpp +++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp @@ -108,7 +108,7 @@ QDBusObjectPath QOfonoManagerInterface::currentModem() foreach (const QDBusObjectPath &modem, modems) { QOfonoModemInterface device(modem.path()); if (device.isPowered() && device.isOnline()) - return modem;; + return modem; } return QDBusObjectPath(); } @@ -770,7 +770,7 @@ QVariantMap QOfonoDataConnectionManagerInterface::getProperties() return reply.value(); } -QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent) +QOfonoConnectionContextInterface::QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent) : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), dbusPathName, OFONO_DATA_CONTEXT_INTERFACE, @@ -778,68 +778,68 @@ QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QStri { } -QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface() +QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface() { } -bool QOfonoPrimaryDataContextInterface::isActive() +bool QOfonoConnectionContextInterface::isActive() { QVariant var = getProperty("Active"); return qdbus_cast(var); } -QString QOfonoPrimaryDataContextInterface::getApName() +QString QOfonoConnectionContextInterface::getApName() { QVariant var = getProperty("AccessPointName"); return qdbus_cast(var); } -QString QOfonoPrimaryDataContextInterface::getType() +QString QOfonoConnectionContextInterface::getType() { QVariant var = getProperty("Type"); return qdbus_cast(var); } -QString QOfonoPrimaryDataContextInterface::getName() +QString QOfonoConnectionContextInterface::getName() { QVariant var = getProperty("Name"); return qdbus_cast(var); } -QVariantMap QOfonoPrimaryDataContextInterface::getSettings() +QVariantMap QOfonoConnectionContextInterface::getSettings() { QVariant var = getProperty("Settings"); return qdbus_cast(var); } -QString QOfonoPrimaryDataContextInterface::getInterface() +QString QOfonoConnectionContextInterface::getInterface() { QVariant var = getProperty("Interface"); return qdbus_cast(var); } -QString QOfonoPrimaryDataContextInterface::getAddress() +QString QOfonoConnectionContextInterface::getAddress() { QVariant var = getProperty("Address"); return qdbus_cast(var); } -bool QOfonoPrimaryDataContextInterface::setActive(bool on) +bool QOfonoConnectionContextInterface::setActive(bool on) { // this->setProperty("Active", QVariant(on)); return setProp("Active", QVariant::fromValue(on)); } -bool QOfonoPrimaryDataContextInterface::setApn(const QString &name) +bool QOfonoConnectionContextInterface::setApn(const QString &name) { return setProp("AccessPointName", QVariant::fromValue(name)); } -void QOfonoPrimaryDataContextInterface::connectNotify(const QMetaMethod &signal) +void QOfonoConnectionContextInterface::connectNotify(const QMetaMethod &signal) { Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoPrimaryDataContextInterface::propertyChanged); +// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoConnectionContextInterface::propertyChanged); // if (signal == propertyChangedSignal) { // if (!connection().connect(QLatin1String(OFONO_SERVICE), // this->path(), @@ -850,7 +850,7 @@ void QOfonoPrimaryDataContextInterface::connectNotify(const QMetaMethod &signal) // } // } -// static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoPrimaryDataContextInterface::propertyChangedContext); +// static const QMetaMethod propertyChangedContextSignal = QMetaMethod::fromSignal(&QOfonoConnectionContextInterface::propertyChangedContext); // if (signal == propertyChangedContextSignal) { // QOfonoDBusHelper *helper; // helper = new QOfonoDBusHelper(this); @@ -867,16 +867,16 @@ void QOfonoPrimaryDataContextInterface::connectNotify(const QMetaMethod &signal) // } } -void QOfonoPrimaryDataContextInterface::disconnectNotify(const QMetaMethod &signal) +void QOfonoConnectionContextInterface::disconnectNotify(const QMetaMethod &signal) { Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoPrimaryDataContextInterface::propertyChanged); +// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QOfonoConnectionContextInterface::propertyChanged); // if (signal == propertyChangedSignal) { // } } -QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property) +QVariant QOfonoConnectionContextInterface::getProperty(const QString &property) { QVariant var; QVariantMap map = getProperties(); @@ -888,13 +888,13 @@ QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property) return var; } -QVariantMap QOfonoPrimaryDataContextInterface::getProperties() +QVariantMap QOfonoConnectionContextInterface::getProperties() { QDBusReply reply = this->call(QLatin1String("GetProperties")); return reply.value(); } -bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var) +bool QOfonoConnectionContextInterface::setProp(const QString &property, const QVariant &var) { QList args; args << QVariant::fromValue(property) << QVariant::fromValue(QDBusVariant(var)); diff --git a/src/plugins/bearer/connman/qofonoservice_linux_p.h b/src/plugins/bearer/connman/qofonoservice_linux_p.h index 00be9aa675..c73e8231a2 100644 --- a/src/plugins/bearer/connman/qofonoservice_linux_p.h +++ b/src/plugins/bearer/connman/qofonoservice_linux_p.h @@ -76,7 +76,7 @@ #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator" #define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.DataConnectionManager" #define OFONO_SIM_MANAGER_INTERFACE "org.ofono.SimManager" -#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.PrimaryDataContext" +#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.ConnectionContext" #define OFONO_SMS_MANAGER_INTERFACE "org.ofono.SmsManager" #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook" @@ -281,14 +281,14 @@ protected: }; -class QOfonoPrimaryDataContextInterface : public QDBusAbstractInterface +class QOfonoConnectionContextInterface : public QDBusAbstractInterface { Q_OBJECT public: - explicit QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent = 0); - ~QOfonoPrimaryDataContextInterface(); + explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoConnectionContextInterface(); QVariantMap getProperties(); -- cgit v1.2.3 From d9b04f8575745f699e39256c3c428e5c08d3bb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 8 Jan 2013 13:45:37 +0100 Subject: QCococaWindow: Add NSView hosting support. Add and export QCCoocaView::setContentView(NSView *), making it possible to host a foreign NSView in a QWindow. Change QCoocaWindow::m_contentView to be a generic NSView, instead of a QNSView. Add a separate m_qtView for code paths that expect a QNSView. Change-Id: I47935b69705c70ea7efbb03d6d4bf489947c3487 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 2 +- .../platforms/cocoa/qcocoanativeinterface.h | 3 +++ .../platforms/cocoa/qcocoanativeinterface.mm | 7 +++++++ src/plugins/platforms/cocoa/qcocoawindow.h | 4 +++- src/plugins/platforms/cocoa/qcocoawindow.mm | 22 ++++++++++++++++++---- 5 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 7f022da4c3..d3d8369c9b 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -91,7 +91,7 @@ void QCocoaBackingStore::flush(QWindow *win, const QRegion ®ion, const QPoint CGImageRelease(m_cgImage); m_cgImage = 0; if (QCocoaWindow *cocoaWindow = static_cast(win->handle())) - [cocoaWindow->m_contentView flushBackingStore:this region:region offset:offset]; + [cocoaWindow->m_qtView flushBackingStore:this region:region offset:offset]; } void QCocoaBackingStore::resize(const QSize &size, const QRegion &) diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 9506f86238..2f79b49534 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -102,6 +102,9 @@ private: // QImage <-> CGImage conversion functions static CGImageRef qImageToCGImage(const QImage &image); static QImage cgImageToQImage(CGImageRef image); + + // Embedding NSViews as child QWindows + static void setWindowContentView(QPlatformWindow *window, void *nsViewContentView); }; #endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index bd3a909137..9990537c1f 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -113,6 +113,8 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return NativeResourceForIntegrationFunction(QCocoaNativeInterface::qImageToCGImage); if (resource.toLower() == "cgimagetoqimage") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::cgImageToQImage); + if (resource.toLower() == "setwindowcontentview") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setWindowContentView); return 0; } @@ -198,5 +200,10 @@ QImage QCocoaNativeInterface::cgImageToQImage(CGImageRef image) return qt_mac_toQImage(image); } +void QCocoaNativeInterface::setWindowContentView(QPlatformWindow *window, void *contentView) +{ + QCocoaWindow *cocoaPlatformWindow = static_cast(window); + cocoaPlatformWindow->setContentView(reinterpret_cast(contentView)); +} QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 931319190c..2422788f7a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -119,6 +119,7 @@ public: void setParent(const QPlatformWindow *window); NSView *contentView() const; + void setContentView(NSView *contentView); void windowWillMove(); void windowDidMove(); @@ -160,7 +161,8 @@ public: // for QNSView friend class QCocoaBackingStore; friend class QCocoaNativeInterface; - QNSView *m_contentView; + NSView *m_contentView; + QNSView *m_qtView; NSWindow *m_nsWindow; bool m_contentViewIsEmbedded; // true if the m_contentView is embedded in a "foregin" NSView hiearchy diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f7348e7dda..489c229187 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -201,7 +201,8 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) #endif QCocoaAutoReleasePool pool; - m_contentView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this]; + m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this]; + m_contentView = m_qtView; setGeometry(tlw->geometry()); recreateWindow(parent()); @@ -534,7 +535,7 @@ void QCocoaWindow::setMask(const QRegion ®ion) [m_nsWindow setBackgroundColor:[NSColor clearColor]]; } - [m_contentView setMaskRegion:®ion]; + [m_qtView setMaskRegion:®ion]; } bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) @@ -578,6 +579,19 @@ NSView *QCocoaWindow::contentView() const return m_contentView; } +void QCocoaWindow::setContentView(NSView *contentView) +{ + // Remove and release the previous content view + [m_contentView removeFromSuperview]; + [m_contentView release]; + + // Insert and retain the new content view + [contentView retain]; + m_contentView = contentView; + m_qtView = 0; // The new content view is not a QNSView. + recreateWindow(parent()); // Adds the content view to parent NSView +} + void QCocoaWindow::windowWillMove() { // Close any open popups on window move @@ -590,7 +604,7 @@ void QCocoaWindow::windowWillMove() void QCocoaWindow::windowDidMove() { - [m_contentView updateGeometry]; + [m_qtView updateGeometry]; } void QCocoaWindow::windowDidResize() @@ -598,7 +612,7 @@ void QCocoaWindow::windowDidResize() if (!m_nsWindow) return; - [m_contentView updateGeometry]; + [m_qtView updateGeometry]; } void QCocoaWindow::windowWillClose() -- cgit v1.2.3 From cf885ee8363252a263bdbdde7cfcf3cf46a62835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 19 Feb 2013 14:42:05 +0100 Subject: Cocoa: Compile with Qt in a namespace. Task-number: QTBUG-29710 Change-Id: I28a4c213b78723aa369c7e00167401ec643155e6 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index d78ff73bb6..bdcad6f490 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -315,9 +315,12 @@ NSMenuItem *QCocoaMenuItem::sync() return m_native; } +QT_BEGIN_NAMESPACE +extern QString qt_mac_applicationmenu_string(int type); +QT_END_NAMESPACE + QString QCocoaMenuItem::mergeText() { - extern QString qt_mac_applicationmenu_string(int type); QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); if (m_native == [loader aboutMenuItem]) { return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()); -- cgit v1.2.3 From 153d613353863987322db81f3c31e33541ef7226 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 10 Dec 2012 14:48:19 +0100 Subject: Transient QWindows centered; default-constructed geometry Default-constructed geometry does not mean put the window at 0,0, and it does not mean center the window on the screen: it means let the window manager position the window. If the window is explicitly positioned at 0,0 though, that is a higher priority than the transient hint; without this change, the transientFor property had no effect. On X11, transient means use center "gravity" to make the transient window exactly centered. But the user can still override the geometry of a transient window, as with any window. On OSX and Windows, neither transient window functionality nor smart initial positioning are provided, so a window with no position set will be centered on the screen, and a transient window will be put at the center of its transientParent. Change-Id: I4f5e37480eef5d105e45ffd60362a57f13ec55f5 Task-number: QTBUG-26903 Reviewed-by: Gunnar Sletta --- src/plugins/platforms/cocoa/qcocoawindow.mm | 8 +++- src/plugins/platforms/windows/qwindowswindow.cpp | 12 +++++- src/plugins/platforms/xcb/qxcbwindow.cpp | 49 +++++++++++++++++------- 3 files changed, 53 insertions(+), 16 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 489c229187..2adf0d24a1 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -58,6 +58,11 @@ #include +enum { + defaultWindowWidth = 160, + defaultWindowHeight = 160 +}; + static bool isMouseEvent(NSEvent *ev) { switch ([ev type]) { @@ -683,7 +688,8 @@ NSWindow * QCocoaWindow::createNSWindow() { QCocoaAutoReleasePool pool; - NSRect frame = qt_mac_flipRect(window()->geometry(), window()); + QRect rect = initialGeometry(window(), window()->geometry(), defaultWindowWidth, defaultWindowHeight); + NSRect frame = qt_mac_flipRect(rect, window()); Qt::WindowType type = window()->type(); Qt::WindowFlags flags = window()->flags(); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 07dc668b3f..20000ea0a9 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -64,6 +64,11 @@ QT_BEGIN_NAMESPACE +enum { + defaultWindowWidth = 160, + defaultWindowHeight = 160 +}; + Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &); static QByteArray debugWinStyle(DWORD style) @@ -468,6 +473,8 @@ QWindowsWindow::WindowData const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w, isGL); + QRect rect = QPlatformWindow::initialGeometry(w, geometry, defaultWindowWidth, defaultWindowHeight); + if (title.isEmpty() && (result.flags & Qt::WindowTitleHint)) title = topLevel ? qAppName() : w->objectName(); @@ -475,14 +482,14 @@ QWindowsWindow::WindowData const wchar_t *classNameUtf16 = reinterpret_cast(windowClassName.utf16()); // Capture events before CreateWindowEx() returns. - const QWindowCreationContextPtr context(new QWindowCreationContext(w, geometry, style, exStyle)); + const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); if (QWindowsContext::verboseWindows) qDebug().nospace() << "CreateWindowEx: " << w << *this << " class=" <frameWidth << 'x' << context->frameHeight << '+' << context->frameX << '+' << context->frameY; @@ -775,6 +782,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : QWindowsWindow::~QWindowsWindow() { #ifndef Q_OS_WINCE + QWindowSystemInterface::flushWindowSystemEvents(); if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch) QWindowsContext::user32dll.unregisterTouchWindow(m_data.hwnd); #endif // !Q_OS_WINCE diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index c0ddf5c0ae..abd2f7a147 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -113,6 +113,10 @@ #endif #define XCOORD_MAX 16383 +enum { + defaultWindowWidth = 160, + defaultWindowHeight = 160 +}; //#ifdef NET_WM_STATE_DEBUG @@ -219,8 +223,16 @@ void QXcbWindow::create() QRect rect = window()->geometry(); QPlatformWindow::setGeometry(rect); - rect.setWidth(qBound(1, rect.width(), XCOORD_MAX)); - rect.setHeight(qBound(1, rect.height(), XCOORD_MAX)); + QSize minimumSize = window()->minimumSize(); + if (rect.width() > 0 || rect.height() > 0) { + rect.setWidth(qBound(1, rect.width(), XCOORD_MAX)); + rect.setHeight(qBound(1, rect.height(), XCOORD_MAX)); + } else if (minimumSize.width() > 0 || minimumSize.height() > 0) { + rect.setSize(minimumSize); + } else { + rect.setWidth(defaultWindowWidth); + rect.setHeight(defaultWindowHeight); + } xcb_window_t xcb_parent_id = m_screen->root(); if (parent()) @@ -436,15 +448,23 @@ void QXcbWindow::setGeometry(const QRect &rect) propagateSizeHints(); const QRect wmGeometry = windowToWmGeometry(rect); - const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; - const qint32 values[] = { - qBound(-XCOORD_MAX, wmGeometry.x(), XCOORD_MAX), - qBound(-XCOORD_MAX, wmGeometry.y(), XCOORD_MAX), - qBound(1, wmGeometry.width(), XCOORD_MAX), - qBound(1, wmGeometry.height(), XCOORD_MAX), - }; - - Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast(values))); + if (qt_window_private(window())->positionAutomatic) { + const quint32 mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; + const qint32 values[] = { + qBound(1, wmGeometry.width(), XCOORD_MAX), + qBound(1, wmGeometry.height(), XCOORD_MAX), + }; + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast(values))); + } else { + const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; + const qint32 values[] = { + qBound(-XCOORD_MAX, wmGeometry.x(), XCOORD_MAX), + qBound(-XCOORD_MAX, wmGeometry.y(), XCOORD_MAX), + qBound(1, wmGeometry.width(), XCOORD_MAX), + qBound(1, wmGeometry.height(), XCOORD_MAX), + }; + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast(values))); + } xcb_flush(xcb_connection()); } @@ -563,6 +583,7 @@ void QXcbWindow::show() if (!transientXcbParent) transientXcbParent = static_cast(screen())->clientLeader(); if (transientXcbParent) { // ICCCM 4.1.2.6 + m_gravity = XCB_GRAVITY_CENTER; Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, 1, &transientXcbParent)); @@ -1221,8 +1242,10 @@ void QXcbWindow::propagateSizeHints() QWindow *win = window(); - xcb_size_hints_set_position(&hints, true, rect.x(), rect.y()); - xcb_size_hints_set_size(&hints, true, rect.width(), rect.height()); + if (!qt_window_private(win)->positionAutomatic) + xcb_size_hints_set_position(&hints, true, rect.x(), rect.y()); + if (rect.width() < QWINDOWSIZE_MAX || rect.height() < QWINDOWSIZE_MAX) + xcb_size_hints_set_size(&hints, true, rect.width(), rect.height()); xcb_size_hints_set_win_gravity(&hints, m_gravity); QSize minimumSize = win->minimumSize(); -- cgit v1.2.3 From 22bda3360e675d1bac9961769710755c75d22a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 29 Jan 2013 10:24:36 +0100 Subject: Set correct image format for non-alpha windows. Use QImage::Format_RGB32. Change-Id: I4be6b6271034be8dad5cfcb85f89fe33a817b78f Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index d3d8369c9b..31726268f1 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -73,7 +73,9 @@ QPaintDevice *QCocoaBackingStore::paintDevice() } #endif - m_qImage = QImage(m_requestedSize * scaleFactor, QImage::Format_ARGB32_Premultiplied); + QImage::Format format = window()->format().hasAlpha() + ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; + m_qImage = QImage(m_requestedSize * scaleFactor, format); m_qImage.setDevicePixelRatio(scaleFactor); } return &m_qImage; -- cgit v1.2.3 From 0c8487156ea53bf0da84cd149dd504c8e16fee33 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 25 Feb 2013 17:24:47 +0100 Subject: QNX post an expose event when the window is hidden When the window is hidden, an expose event has to be be posted. This is e.g. needed by the qquickwindow. A exposeEvent calles the exposureChanged function of the window manager there. Change-Id: I9d891e07f81192dcd6674743620319c44da19c48 Reviewed-by: Wolfgang Bremer Reviewed-by: Sean Harmer --- src/plugins/platforms/qnx/qqnxwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index ab9c94772b..43e24034c9 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -272,9 +272,9 @@ void QQnxWindow::setVisible(bool visible) window()->requestActivate(); if (window()->isTopLevel()) { - if (visible) { - QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); - } else { + QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); + + if (!visible) { // Flush the context, otherwise it won't disappear immediately screen_flush_context(m_screenContext, 0); } -- cgit v1.2.3 From 47e12eafdd7d2b2bc0e4db67cef5e063dfdc7aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 25 Feb 2013 14:14:47 +0100 Subject: Cocoa: Make grabWindow work on retina displays. Not taking the devicePixelRatio into account causes us to either grab a quarter of the screen or do a low-resolution grab. Change-Id: Ie6b681e3a089f17b63554c8158bb471a14963d7a Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 7fcdab4d97..93831158d0 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -170,13 +170,13 @@ QPixmap QCocoaScreen::grabWindow(WId window, int x, int y, int width, int height windowSize.setHeight(windowRect.height()); } - QPixmap windowPixmap(windowSize); + QPixmap windowPixmap(windowSize * devicePixelRatio()); windowPixmap.fill(Qt::transparent); for (uint i = 0; i < displayCount; ++i) { const CGRect bounds = CGDisplayBounds(displays[i]); - int w = (width < 0 ? bounds.size.width : width); - int h = (height < 0 ? bounds.size.height : height); + int w = (width < 0 ? bounds.size.width : width) * devicePixelRatio(); + int h = (height < 0 ? bounds.size.height : height) * devicePixelRatio(); QRect displayRect = QRect(x, y, w, h); QCFType image = CGDisplayCreateImageForRect(displays[i], CGRectMake(displayRect.x(), displayRect.y(), displayRect.width(), displayRect.height())); -- cgit v1.2.3 From 17501e09b9a812cf41bef2ad5c83da747bb44d9a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 25 Feb 2013 15:29:56 +0100 Subject: Fix warnings about extra tokens after preprocessor directive. Change-Id: I7f18ec42f6f6dd697947654384767c2c6b211498 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsintegration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 24dc01f0bd..ca484415be 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -78,7 +78,7 @@ public: # ifndef QT_NO_DRAGANDDROP virtual QPlatformDrag *drag() const; # endif -#endif !QT_NO_CLIPBOARD +#endif // !QT_NO_CLIPBOARD virtual QPlatformInputContext *inputContext() const; #ifndef QT_NO_ACCESSIBILITY virtual QPlatformAccessibility *accessibility() const; -- cgit v1.2.3 From e265a1a4bd5e161344babe51be424c7e9d561411 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 26 Feb 2013 16:20:43 +0100 Subject: Disable maximize button for fixed-size windows. Task-number: QTBUG-28407 Change-Id: I5bab7fcf4ad3ecc7008ef02b9d3575d75893895d Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 20000ea0a9..7a68cdeb47 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -203,17 +203,16 @@ static inline QSize clientSize(HWND hwnd) return qSizeOfRect(rect); } -// from qwidget_win.cpp/maximum layout size check removed. -static bool shouldShowMaximizeButton(Qt::WindowFlags flags) +// from qwidget_win.cpp +static bool shouldShowMaximizeButton(const QWindow *w) { - if (flags & Qt::MSWindowsFixedSizeDialogHint) + const Qt::WindowFlags flags = w->flags(); + if ((flags & Qt::MSWindowsFixedSizeDialogHint) || !(flags & Qt::WindowMaximizeButtonHint)) return false; // if the user explicitly asked for the maximize button, we try to add // it even if the window has fixed size. - if (flags & Qt::CustomizeWindowHint && - flags & Qt::WindowMaximizeButtonHint) - return true; - return flags & Qt::WindowMaximizeButtonHint; + return (flags & Qt::CustomizeWindowHint) || + w->maximumSize() == QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX); } // Set the WS_EX_LAYERED flag on a HWND if required. This is required for @@ -432,7 +431,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag style |= WS_SYSMENU; if (flags & Qt::WindowMinimizeButtonHint) style |= WS_MINIMIZEBOX; - if (shouldShowMaximizeButton(flags)) + if (shouldShowMaximizeButton(w)) style |= WS_MAXIMIZEBOX; if (tool) exStyle |= WS_EX_TOOLWINDOW; -- cgit v1.2.3 From a2432510915a99c6c2ebf339bc38ceca9b5a7ba1 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Thu, 21 Feb 2013 14:55:38 +0100 Subject: qcocamenubar: force update after destructor Task-number: QTCREATORBUG-8785 Change-Id: I1e782cab36f4fea331561f016ea67a73deb63c37 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index bae52c91b8..c0c8caed05 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -77,8 +77,10 @@ QCocoaMenuBar::~QCocoaMenuBar() [m_nativeMenu release]; static_menubars.removeOne(this); - if (m_window) + if (m_window && m_window->menubar() == this) { m_window->setMenubar(0); + updateMenuBarImmediately(); + } } void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before) -- cgit v1.2.3 From 42507173bd985d8b3875d9fd0141a1dd7ad4e544 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Feb 2013 14:54:38 +0100 Subject: Fix automatic hiding/restoring of transient children. Task-number: QTBUG-28408 Change-Id: I31382c4edc213961dfb132af3bf5202e178e7a57 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowscontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 99ef3aacf3..1ea660d944 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -854,10 +854,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return true; case QtWindows::ShowEvent: platformWindow->handleShown(); - return true; + return false; // Indicate transient children should be shown by windows (SW_PARENTOPENING) case QtWindows::HideEvent: platformWindow->handleHidden(); - return true; + return false;// Indicate transient children should be hidden by windows (SW_PARENTCLOSING) case QtWindows::CloseEvent: QWindowSystemInterface::handleCloseEvent(platformWindow->window()); return true; -- cgit v1.2.3