From 04325bdd26810cd9067ad4b0b9e458b06ce2a3db Mon Sep 17 00:00:00 2001 From: Chris Meyer Date: Mon, 9 Sep 2013 14:00:18 -0700 Subject: Fix Invalid Drawable error when using createWindowContainer on Mac. You are not supposed to call NSOpenGLContext -setView: for a view that has not yet called drawRect. Doing this would result in a invalid drawable error. Similar to 4.8 commit cd2a51a66f52767c20e80361033c573651b3a08d Change-Id: Ibb2300a8c6fe52f786f813987e93d4a3dc145366 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 3ee994427b..a7664887bf 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -70,6 +70,7 @@ QT_END_NAMESPACE Qt::KeyboardModifiers currentWheelModifiers; bool m_subscribesForGlobalFrameNotifications; QCocoaGLContext *m_glContext; + bool m_drawRectHasBeenCalled; bool m_shouldSetGLContextinDrawRect; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index c2ffe96f8c..9fc74ea72b 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -87,6 +87,7 @@ static QTouchDevice *touchDevice = 0; m_sendKeyEvent = false; m_subscribesForGlobalFrameNotifications = false; m_glContext = 0; + m_drawRectHasBeenCalled = false; m_shouldSetGLContextinDrawRect = false; currentCustomDragTypes = 0; m_sendUpAsRightButton = false; @@ -153,9 +154,9 @@ static QTouchDevice *touchDevice = 0; - (void) setQCocoaGLContext:(QCocoaGLContext *)context { m_glContext = context; - [m_glContext->nsOpenGLContext() setView:self]; - if (![m_glContext->nsOpenGLContext() view]) { - //was unable to set view + if (m_drawRectHasBeenCalled) { + [m_glContext->nsOpenGLContext() setView:self]; + } else { m_shouldSetGLContextinDrawRect = true; } @@ -392,6 +393,8 @@ static QTouchDevice *touchDevice = 0; m_shouldSetGLContextinDrawRect = false; } + m_drawRectHasBeenCalled = true; + if (!m_backingStore) return; -- cgit v1.2.3 From b7b573ad6d9f50ebff87f5c6204225366a1675bd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 10 Sep 2013 12:03:07 +0200 Subject: Windows: Fix window opacity for non-translucent windows. Use the UpdateLayeredWindow() functions only for windows with alpha. Task-number: QTBUG-33025 Change-Id: I64b0c28ee0997cd3d09dc76babe105ed474c6835 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsbackingstore.cpp | 4 +++- src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index dfbbe3069c..26205eb146 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -88,8 +88,10 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, QWindowsWindow *rw = QWindowsWindow::baseWindowOf(window); #ifndef Q_OS_WINCE + const bool hasAlpha = rw->format().hasAlpha(); const Qt::WindowFlags flags = window->flags(); - if ((flags & Qt::FramelessWindowHint) && QWindowsWindow::setWindowLayered(rw->handle(), flags, rw->format().hasAlpha(), rw->opacity())) { + if ((flags & Qt::FramelessWindowHint) && QWindowsWindow::setWindowLayered(rw->handle(), flags, hasAlpha, rw->opacity()) && hasAlpha) { + // Windows with alpha: Use blend function to update. QRect r = window->frameGeometry(); QPoint frameOffset(window->frameMargins().left(), window->frameMargins().top()); QRect dirtyRect = br.translated(offset + frameOffset); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ace18ddf5b..9d87eaa110 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -250,7 +250,8 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qr Q_UNUSED(level); #else if (QWindowsWindow::setWindowLayered(hwnd, flags, hasAlpha, level)) { - if (flags & Qt::FramelessWindowHint) { + if (hasAlpha && (flags & Qt::FramelessWindowHint)) { + // Windows with alpha: Use blend function to update. BLENDFUNCTION blend = {AC_SRC_OVER, 0, (BYTE)(255.0 * level), AC_SRC_ALPHA}; QWindowsContext::user32dll.updateLayeredWindow(hwnd, NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA); } else { -- cgit v1.2.3 From fddf76f2ac12f219b99a8b877844a473cce27542 Mon Sep 17 00:00:00 2001 From: MyoungSeok Song Date: Thu, 29 Aug 2013 13:53:59 -0700 Subject: QNX: add nativeResourceForScreen Implemented nativeResourceForScreen api to return QObject* which can be used to connect foreignWindowCreated, foreignWindowClosed signal in QQnxScreen. Usecase is to connect signal in custom QML component as below QObject * obs = interface->nativeResourceForScreen("QObject*", screen); connect(obs, SIGNAL(foreignWindowCreated(void*)), d, SLOT(newForeignWindowCreated(void*))); Change-Id: I512c3b6d188a2e90ef7b8e89c413ca420a29dd9b Reviewed-by: Kevin Krammer Reviewed-by: Fabian Bumberger Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxnativeinterface.cpp | 8 ++++++++ src/plugins/platforms/qnx/qqnxnativeinterface.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp index e147ca72e5..4dd3444832 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp @@ -62,4 +62,12 @@ void *QQnxNativeInterface::nativeResourceForWindow(const QByteArray &resource, Q return 0; } +void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen) +{ + if (resource == "QObject*" && screen) + return static_cast(static_cast(screen->handle())); + + return 0; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.h b/src/plugins/platforms/qnx/qqnxnativeinterface.h index d84df205e5..6692da2576 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.h +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.h @@ -50,6 +50,7 @@ class QQnxNativeInterface : public QPlatformNativeInterface { public: void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); + void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen); }; QT_END_NAMESPACE -- cgit v1.2.3 From 30a4114e60ae493c79d3139b46916165978f7b24 Mon Sep 17 00:00:00 2001 From: MyoungSeok Song Date: Thu, 29 Aug 2013 13:42:03 -0700 Subject: QNX: new signals for foreign windows creation/closing Implement the foreignWindowCreated and foreignWindow closed signals, emitted when foreign windows are created and closed, respectively. Change-Id: I72dd5380e6061f191eb8362fda5dd8fb8e9ed06b Reviewed-by: Thomas McGuire Reviewed-by: Kevin Krammer Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxscreen.cpp | 5 ++++- src/plugins/platforms/qnx/qqnxscreen.h | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index 84721c9c2a..855da13681 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -562,8 +562,10 @@ void QQnxScreen::addUnderlayWindow(screen_window_t window) void QQnxScreen::removeOverlayOrUnderlayWindow(screen_window_t window) { const int numRemoved = m_overlays.removeAll(window) + m_underlays.removeAll(window); - if (numRemoved > 0) + if (numRemoved > 0) { updateHierarchy(); + Q_EMIT foreignWindowClosed(window); + } } void QQnxScreen::newWindowCreated(void *window) @@ -597,6 +599,7 @@ void QQnxScreen::newWindowCreated(void *window) addUnderlayWindow(windowHandle); else addOverlayWindow(windowHandle); + Q_EMIT foreignWindowCreated(windowHandle); } } } diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index 6e8c2c6a60..42c490d443 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -98,6 +98,10 @@ public: QPlatformCursor *cursor() const; +Q_SIGNALS: + void foreignWindowCreated(void *window); + void foreignWindowClosed(void *window); + public Q_SLOTS: void setRotation(int rotation); void newWindowCreated(void *window); -- cgit v1.2.3