summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McDonnell <jmcdonnell@blackberry.com>2018-03-15 10:39:07 -0400
committerJames McDonnell <jmcdonnell@blackberry.com>2018-05-07 14:01:10 +0000
commit370c48039bfa0fe4325852358d603cf4438c3f47 (patch)
tree617913b0148f4553991680375af47c1a25ed8efe
parent5b7bd00d2c03f7035b21534003662e931bd04eb8 (diff)
downloadqtmultimedia-370c48039bfa0fe4325852358d603cf4438c3f47.tar.gz
Switch WindowGrabber to a private parent window
The code that it was using to retrieve a parent window didn't always get the right window. Using a private window prevents any confusion. Change-Id: Ic368460c6bf150891ff51f1f3b00bbe93c6cf780 Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
-rw-r--r--src/plugins/qnx/common/windowgrabber.cpp42
-rw-r--r--src/plugins/qnx/common/windowgrabber.h1
2 files changed, 25 insertions, 18 deletions
diff --git a/src/plugins/qnx/common/windowgrabber.cpp b/src/plugins/qnx/common/windowgrabber.cpp
index ca7224a4f..9a65ad3a0 100644
--- a/src/plugins/qnx/common/windowgrabber.cpp
+++ b/src/plugins/qnx/common/windowgrabber.cpp
@@ -58,6 +58,7 @@ static PFNEGLDESTROYIMAGEKHRPROC s_eglDestroyImageKHR;
WindowGrabber::WindowGrabber(QObject *parent)
: QObject(parent),
+ m_windowParent(nullptr),
m_screenContext(0),
m_active(false),
m_currentFrame(0),
@@ -81,10 +82,26 @@ WindowGrabber::WindowGrabber(QObject *parent)
s_eglCreateImageKHR = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
s_eglDestroyImageKHR = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
}
+
+ QPlatformNativeInterface *const nativeInterface = QGuiApplication::platformNativeInterface();
+ if (nativeInterface) {
+ m_screenContext = static_cast<screen_context_t>(
+ nativeInterface->nativeResourceForIntegration("screenContext"));
+ }
+
+ // Create a parent window for the window whose content will be grabbed. Since the
+ // window is only a buffer conduit, the characteristics of the parent window are
+ // irrelevant. The contents of the window can be grabbed so long as the window
+ // joins the parent window's group and the parent window is in this process.
+ // Using the window that displays this content isn't possible because there's no
+ // way to reliably retrieve it from this code or any calling code.
+ screen_create_window(&m_windowParent, m_screenContext);
+ screen_create_window_group(m_windowParent, nullptr);
}
WindowGrabber::~WindowGrabber()
{
+ screen_destroy_window(m_windowParent);
QCoreApplication::eventDispatcher()->removeNativeEventFilter(this);
cleanup();
}
@@ -184,24 +201,13 @@ bool WindowGrabber::nativeEventFilter(const QByteArray &eventType, void *message
QByteArray WindowGrabber::windowGroupId() const
{
- QWindow *window = QGuiApplication::allWindows().isEmpty() ? 0 : QGuiApplication::allWindows().first();
- if (!window)
- return QByteArray();
-
- QPlatformNativeInterface * const nativeInterface = QGuiApplication::platformNativeInterface();
- if (!nativeInterface) {
- qWarning() << "WindowGrabber: Unable to get platform native interface";
- return QByteArray();
- }
-
- const char * const groupIdData = static_cast<const char *>(
- nativeInterface->nativeResourceForWindow("windowGroup", window));
- if (!groupIdData) {
- qWarning() << "WindowGrabber: Unable to find window group for window" << window;
- return QByteArray();
- }
-
- return QByteArray(groupIdData);
+ char groupName[256];
+ memset(groupName, 0, sizeof(groupName));
+ screen_get_window_property_cv(m_windowParent,
+ SCREEN_PROPERTY_GROUP,
+ sizeof(groupName) - 1,
+ groupName);
+ return QByteArray(groupName);
}
bool WindowGrabber::eglImageSupported()
diff --git a/src/plugins/qnx/common/windowgrabber.h b/src/plugins/qnx/common/windowgrabber.h
index 4b2217f74..3ebd0e8a6 100644
--- a/src/plugins/qnx/common/windowgrabber.h
+++ b/src/plugins/qnx/common/windowgrabber.h
@@ -126,6 +126,7 @@ private:
QByteArray m_windowId;
+ screen_window_t m_windowParent;
screen_window_t m_window;
screen_context_t m_screenContext;