Android: Make winId() return the underlying QtWindow jobject
Previously, winId() returned a simple integer ID, incremented by one for each window, instead of a handle to the underlying window. Note, if constructing a QWindow with fromWinId(), the passed jobject will not be the same one returned by winId(), as the passed jobject, assumed to be a View, will be wrapped inside a QtWindow to ensure child windows can be added to it if needed. Pick-to: 6.7 Change-Id: I9d5d977eeb08d4cc3594f7339660fe94c3a55864 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
0a5a9c134e
commit
4376467169
@ -16,8 +16,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window")
|
||||
|
||||
Q_CONSTINIT static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
|
||||
QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window)
|
||||
: QPlatformWindow(window), m_nativeQtWindow(nullptr), m_nativeParentQtWindow(nullptr),
|
||||
m_androidSurfaceObject(nullptr)
|
||||
@ -27,7 +25,6 @@ QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window)
|
||||
// the surfaceType is overwritten in QAndroidPlatformOpenGLWindow ctor so let's save
|
||||
// the fact that it's a raster window for now
|
||||
m_isRaster = window->surfaceType() == QSurface::RasterSurface;
|
||||
m_windowId = winIdGenerator.fetchAndAddRelaxed(1) + 1;
|
||||
setWindowState(window->windowStates());
|
||||
|
||||
// the following is in relation to the virtual geometry
|
||||
@ -174,6 +171,11 @@ void QAndroidPlatformWindow::setParent(const QPlatformWindow *window)
|
||||
}
|
||||
}
|
||||
|
||||
WId QAndroidPlatformWindow::winId() const
|
||||
{
|
||||
return m_nativeQtWindow.isValid() ? reinterpret_cast<WId>(m_nativeQtWindow.object()) : 0L;
|
||||
}
|
||||
|
||||
QAndroidPlatformScreen *QAndroidPlatformWindow::platformScreen() const
|
||||
{
|
||||
return static_cast<QAndroidPlatformScreen *>(window()->screen()->handle());
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
void setWindowFlags(Qt::WindowFlags flags) override;
|
||||
Qt::WindowFlags windowFlags() const;
|
||||
void setParent(const QPlatformWindow *window) override;
|
||||
WId winId() const override { return m_windowId; }
|
||||
|
||||
WId winId() const override;
|
||||
|
||||
bool setMouseGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
|
||||
bool setKeyboardGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
|
||||
@ -73,14 +74,12 @@ protected:
|
||||
Qt::WindowStates m_windowState;
|
||||
bool m_isRaster;
|
||||
|
||||
WId m_windowId;
|
||||
|
||||
int m_nativeViewId = -1;
|
||||
QtJniTypes::QtWindow m_nativeQtWindow;
|
||||
QtJniTypes::QtWindow m_nativeParentQtWindow;
|
||||
// The Android Surface, accessed from multiple threads, guarded by m_surfaceMutex
|
||||
QtJniTypes::Surface m_androidSurfaceObject;
|
||||
QWaitCondition m_surfaceWaitCondition;
|
||||
int m_nativeViewId = -1;
|
||||
bool m_surfaceCreated = false;
|
||||
QMutex m_surfaceMutex;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user