From 77a06e7e6c517003585ba53b9776e90c8d290e84 Mon Sep 17 00:00:00 2001 From: Matt Hoosier Date: Thu, 16 May 2013 11:01:23 -0500 Subject: QNX: Support window translucency A few tactical changes were necessary to do this: * The root window's buffer must be the full size of the window in order for transparency to work. We now transition this buffer to full-size upon first request of some QWindow to be translucent. At the same time the root window is transitioned to being full- screen, we also set its alpha blending mode to Source-Over in order to permit lower z-ordered apps to show through. * Set the root window's buffer position to (0, 0) to avoid a momentary flicker of unpainted pixels on the far right-hand border as a translucent window comes on-screen. * Use Source-Over alpha blending for normal child windows too. The QtGui core logic for setting the backing surface pixel format to something with an alpha channel if Qt::WA_TranslucentBackground is set on the toplevel QWidget already accomplished the remainder of the work. Change-Id: I1c2b31aa6323b4555fa194313f0f5e06ada494fc Reviewed-by: Kevin Krammer Reviewed-by: Thomas McGuire Reviewed-by: Rafael Roquetto Reviewed-by: Andreas Holzammer --- src/plugins/platforms/qnx/qqnxwindow.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/qnx/qqnxwindow.cpp') diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index f4cbb0e9db..7a1ffb98b8 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -117,9 +117,13 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) if (result != 0) qFatal("QQnxWindow: failed to set window alpha mode, errno=%d", errno); - // Make the window opaque + // Blend the window with Source Over Porter-Duff behavior onto whatever's + // behind it. + // + // If the desired use-case is opaque, the Widget painting framework will + // already fill in the alpha channel with full opacity. errno = 0; - val = SCREEN_TRANSPARENCY_NONE; + val = SCREEN_TRANSPARENCY_SOURCE_OVER; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, &val); if (result != 0) qFatal("QQnxWindow: failed to set window transparency, errno=%d", errno); @@ -370,6 +374,12 @@ void QQnxWindow::setBufferSize(const QSize &size) qWarning() << "QQnxWindow: Buffer size was" << size; qFatal("QQnxWindow: failed to create window buffers, errno=%d", errno); + // If the child window has been configured for transparency, lazily create + // a full-screen buffer to back the root window. + if (window()->requestedFormat().hasAlpha()) { + m_screen->rootWindow()->makeTranslucent(); + } + // check if there are any buffers available int bufferCount = 0; result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount); -- cgit v1.2.3 From 6359f42064cdd9733ac54c3931156fd37448838e Mon Sep 17 00:00:00 2001 From: Matt Hoosier Date: Thu, 23 May 2013 15:49:37 -0500 Subject: QNX: fix buffer creation During some coding style cleanup in 02311c07 ("QNX: normalize braces") some braces which were actually necessary got removed. The result was an spurious report of a fatal error when no underlying error condition had occurred. This change restores the braces to preserve the prior behavior. Change-Id: Ic32fbd5961ce59f6c01476fd2cef6fec0bdae93e Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/qnx/qqnxwindow.cpp') diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 7a1ffb98b8..9523685f70 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -370,9 +370,10 @@ void QQnxWindow::setBufferSize(const QSize &size) errno = 0; result = screen_create_window_buffers(m_window, MAX_BUFFER_COUNT); - if (result != 0) + if (result != 0) { qWarning() << "QQnxWindow: Buffer size was" << size; qFatal("QQnxWindow: failed to create window buffers, errno=%d", errno); + } // If the child window has been configured for transparency, lazily create // a full-screen buffer to back the root window. -- cgit v1.2.3