Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qandroidplatformwindow.h
Go to the documentation of this file.
1// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6#ifndef ANDROIDPLATFORMWINDOW_H
7#define ANDROIDPLATFORMWINDOW_H
8#include <qobject.h>
9#include <qrect.h>
10#include <qpa/qplatformwindow.h>
11#include <QtCore/qjnienvironment.h>
12#include <QtCore/qjniobject.h>
13#include <QtCore/qjnitypes.h>
14#include <QtCore/qloggingcategory.h>
15#include <QtCore/qmutex.h>
16#include <QtCore/qwaitcondition.h>
17#include <jni.h>
18
20
21Q_DECLARE_LOGGING_CATEGORY(lcQpaWindow)
22Q_DECLARE_JNI_CLASS(QtWindow, "org/qtproject/qt/android/QtWindow")
23Q_DECLARE_JNI_CLASS(Surface, "android/view/Surface")
24Q_DECLARE_JNI_CLASS(Insets, "android/graphics/Insets")
25
26class QAndroidPlatformScreen;
27
29{
30public:
35
36 explicit QAndroidPlatformWindow(QWindow *window);
37 void initialize() override;
38
40 void lower() override;
41 void raise() override;
42
43 void setVisible(bool visible) override;
44
45 void setWindowState(Qt::WindowStates state) override;
46 void setWindowFlags(Qt::WindowFlags flags) override;
47 void setParent(const QPlatformWindow *window) override;
48
49 WId winId() const override;
50
51 bool setMouseGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
52 bool setKeyboardGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
53
55
56 QMargins safeAreaMargins() const override;
57 void setSafeAreaMargins(const QMargins safeMargins);
58
61 void updateSystemUiVisibility(Qt::WindowStates states, Qt::WindowFlags flags);
63 inline bool isRaster() const { return m_isRaster; }
64 bool isExposed() const override;
65 QtJniTypes::QtWindow nativeWindow() const { return m_nativeQtWindow; }
66
68 int nativeViewId() const { return m_nativeViewId; }
69
70 static bool registerNatives(QJniEnvironment &env);
71 void onSurfaceChanged(QtJniTypes::Surface surface);
72
73 void lockSurface() { m_surfaceMutex.lock(); }
74 void unlockSurface() { m_surfaceMutex.unlock(); }
75
76 static int surfacesCount();
77
78protected:
79 void setGeometry(const QRect &rect) override;
80 void createSurface();
81 void destroySurface();
82 void sendExpose() const;
83 bool blockedByModal() const;
84 bool isEmbeddingContainer() const;
85 virtual void clearSurface() {}
86 static void incrementSurfacesCount();
87 static void decrementSurfacesCount();
88
90
95 // The Android Surface, accessed from multiple threads, guarded by m_surfaceMutex.
96 // If the window is using QtSurface, which is a SurfaceView subclass, this Surface will be
97 // automatically created by Android when QtSurface is in a layout and visible. If the
98 // QtSurface is detached or hidden (app goes to background), Android will automatically
99 // destroy the Surface.
105
107
108private:
109 static void setSurface(JNIEnv *env, jobject obj, jint windowId, QtJniTypes::Surface surface);
112 Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(windowFocusChanged)
114 Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(safeAreaMarginsChanged)
115
117};
118
119QT_END_NAMESPACE
120#endif // ANDROIDPLATFORMWINDOW_H
static const char m_qtTag[]
#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE)
#define CHECK_AND_INIT_STATIC_FIELD(TYPE, VAR, CLASS, FIELD_NAME)
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
virtual void applicationStateChanged(Qt::ApplicationState)
QAndroidPlatformWindow(QWindow *window)
void setSafeAreaMargins(const QMargins safeMargins)
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
QtJniTypes::QtWindow nativeWindow() const
void onSurfaceChanged(QtJniTypes::Surface surface)
bool isExposed() const override
Returns if this window is exposed in the windowing system.
SurfaceContainer m_surfaceContainerType
QAndroidPlatformScreen * platformScreen() const
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
bool setKeyboardGrabEnabled(bool grab) override
static bool registerNatives(QJniEnvironment &env)
QtJniTypes::QtWindow m_nativeParentQtWindow
QtJniTypes::Surface m_androidSurfaceObject
void updateSystemUiVisibility(Qt::WindowStates states, Qt::WindowFlags flags)
QtJniTypes::QtWindow m_nativeQtWindow
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
bool setMouseGrabEnabled(bool grab) override
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QMargins safeAreaMargins() const override
The safe area margins of a window represent the area that is safe to place content within,...
\inmodule QtCore\reentrant
Definition qpoint.h:30
Combined button and popup list for selecting options.
void notifyDescriptionOrNameChanged(uint accessibilityObjectId)
void notifyObjectShow(uint accessibilityObjectId)
static bool clickAction_helper(int objectId)
static const JNINativeMethod methods[]
void notifyLocationChange(uint accessibilityObjectId)
void runInObjectContext(QObject *context, Func &&func, Ret *retVal)
static jboolean scrollForward(JNIEnv *, jobject, jint objectId)
void notifyObjectFocus(uint accessibilityObjectId)
static jboolean scrollBackward(JNIEnv *, jobject, jint objectId)
static QString descriptionForInterface(QAccessibleInterface *iface)
static int hitTest_helper(float x, float y)
static jstring descriptionForAccessibleObject(JNIEnv *env, jobject, jint objectId)
static bool scroll_helper(int objectId, const QString &actionName)
static QString classNameForRole(QAccessible::Role role, QAccessible::State state)
static jmethodID m_setContentDescriptionMethodID
static QString textFromValue(QAccessibleInterface *iface)
void createAccessibilityContextObject(QObject *parent)
static QVarLengthArray< int, 8 > childIdListForAccessibleObject_helper(int objectId)
static NodeInfo populateNode_helper(int objectId)
void notifyObjectHide(uint accessibilityObjectId)
static jboolean focusAction(JNIEnv *, jobject, jint objectId)
static jmethodID m_setVisibleToUserMethodID
static jint hitTest(JNIEnv *, jobject, jfloat x, jfloat y)
static bool focusAction_helper(int objectId)
static jboolean clickAction(JNIEnv *, jobject, jint objectId)
static jstring jvalueForAccessibleObject(int objectId)
static void setActive(JNIEnv *, jobject, jboolean active)
static void invokeActionOnInterfaceInMainThread(QAccessibleActionInterface *actionInterface, const QString &action)
static jmethodID m_setTextSelectionMethodID
bool registerNatives(QJniEnvironment &env)
QAccessibleInterface * interfaceFromId(jint objectId)
void notifyValueChanged(uint accessibilityObjectId)
void notifyAnnouncementEvent(uint accessibilityObjectId, const QString &message)
static int parentId_helper(int objectId)
static QRect screenRect_helper(int objectId, bool clip=true)
static QString descriptionForAccessibleObject_helper(int objectId)
static jint parentId(JNIEnv *, jobject, jint objectId)
static jobject screenRect(JNIEnv *env, jobject, jint objectId)
static jintArray childIdListForAccessibleObject(JNIEnv *env, jobject, jint objectId)
static jboolean populateNode(JNIEnv *env, jobject, jint objectId, jobject node)
void notifyScrolledEvent(uint accessiblityObjectId)
QBasicMutex * platformInterfaceMutex()
QAndroidPlatformIntegration * androidPlatformIntegration()
#define qApp