qtbase/src/plugins/platforms/android/qandroidplatformwindow.h
Axel Spoerl a92ee82651 Fix link to platform window in QAndroidPlatformBackingStore::flush()
The Android QPA implementation requires a 1:1 link between a platform
window and a platform backing store, to correctly flush a backing
store to the screen. QAndroidPlatformBackingStore has a bool member
m_backingStoreSet, to remember if this link exists. It defaults to
false and is set to true, when setBackingStore() is called in the
constructor. It falsely remains true, when a platform window is
deleted, e.g. because a QWindow has been hidden. When the QWindow is
shown again, a new Android platform window is created. With
m_backingStoreSet still being true, this new platform window will
never be associated with a backing store. As a consequence, it will
never be displayed on the screen.

The 1:1 relationship of an Android platform window and an Android
backing store is neither ideal, nor in line with other QPA layers
(e.g. XCB). Changing the Android QPA implementation is complex and a
short term fix is  necessary.

This patch removes the member m_backingStoreSet. Instead of it,
QAndroidPlatformBackingStore::flush() directly checks, if the platform
window corresponding to the QWindow argument is associated to a backing
store. If that is not the case, setBackingStore() is called.

QTBUG-97482 has been fixed with another approach, which this patch
reverts.

The following commits are effectively reverted by this patch:
9a39ad8dfb4e6d1a179bd0fa38026886f8f7cb8e
f91588923b1e7b68f1bd79b38af44d024df85996
a4ca9e80658bca7dad1529f03c1b59173a6ecf62
dbb072eb2838a04e89e34dad686394a496d5de87
959a8b3967ac3b6315f5b458628ec5661dfc367e

Fixes: QTBUG-97482
Change-Id: Ic4344f8df2e954c057dd2705340f11dfd2d4c6fe
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 86fe84f5f7fd9a55e0f26a9572996caf443ff834)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-08-04 12:40:08 +00:00

72 lines
2.1 KiB
C++

// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef ANDROIDPLATFORMWINDOW_H
#define ANDROIDPLATFORMWINDOW_H
#include <qobject.h>
#include <qrect.h>
#include <qpa/qplatformwindow.h>
QT_BEGIN_NAMESPACE
class QAndroidPlatformScreen;
class QAndroidPlatformBackingStore;
class QAndroidPlatformWindow: public QPlatformWindow
{
public:
explicit QAndroidPlatformWindow(QWindow *window);
void lower() override;
void raise() override;
void setVisible(bool visible) override;
void setWindowState(Qt::WindowStates state) override;
void setWindowFlags(Qt::WindowFlags flags) override;
Qt::WindowFlags windowFlags() const;
void setParent(const QPlatformWindow *window) override;
WId winId() const override { return m_windowId; }
bool setMouseGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
bool setKeyboardGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
QAndroidPlatformScreen *platformScreen() const;
QMargins safeAreaMargins() const override;
void propagateSizeHints() override;
void requestActivateWindow() override;
void updateSystemUiVisibility();
inline bool isRaster() const {
if (isForeignWindow())
return false;
return window()->surfaceType() == QSurface::RasterSurface
|| window()->surfaceType() == QSurface::RasterGLSurface;
}
bool isExposed() const override;
virtual void applicationStateChanged(Qt::ApplicationState);
void setBackingStore(QAndroidPlatformBackingStore *store) { m_backingStore = store; }
QAndroidPlatformBackingStore *backingStore() const { return m_backingStore; }
virtual void repaint(const QRegion &) { }
protected:
void setGeometry(const QRect &rect) override;
protected:
Qt::WindowFlags m_windowFlags;
Qt::WindowStates m_windowState;
WId m_windowId;
QAndroidPlatformBackingStore *m_backingStore = nullptr;
};
QT_END_NAMESPACE
#endif // ANDROIDPLATFORMWINDOW_H