Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5#ifndef ANDROIDPLATFORMWINDOW_H
6#define ANDROIDPLATFORMWINDOW_H
7#include <qobject.h>
8#include <qrect.h>
9#include <qpa/qplatformwindow.h>
10#include <QtCore/qjnienvironment.h>
11#include <QtCore/qjniobject.h>
12#include <QtCore/qjnitypes.h>
13#include <QtCore/qloggingcategory.h>
14#include <QtCore/qmutex.h>
15#include <QtCore/qwaitcondition.h>
16#include <jni.h>
17
19
21Q_DECLARE_JNI_CLASS(QtWindow, "org/qtproject/qt/android/QtWindow")
22Q_DECLARE_JNI_CLASS(Surface, "android/view/Surface")
23
25
27{
28public:
29 enum class SurfaceContainer {
30 SurfaceView,
31 TextureView
32 };
33
36 void lower() override;
37 void raise() override;
38
39 void setVisible(bool visible) override;
40
41 void setWindowState(Qt::WindowStates state) override;
42 void setWindowFlags(Qt::WindowFlags flags) override;
43 Qt::WindowFlags windowFlags() const;
44 void setParent(const QPlatformWindow *window) override;
45
46 WId winId() const override;
47
48 bool setMouseGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
49 bool setKeyboardGrabEnabled(bool grab) override { Q_UNUSED(grab); return false; }
50
51 QAndroidPlatformScreen *platformScreen() const;
52
53 QMargins safeAreaMargins() const override;
54
55 void propagateSizeHints() override;
56 void requestActivateWindow() override;
57 void updateSystemUiVisibility();
58 inline bool isRaster() const { return m_isRaster; }
59 bool isExposed() const override;
60 QtJniTypes::QtWindow nativeWindow() const { return m_nativeQtWindow; }
61
62 virtual void applicationStateChanged(Qt::ApplicationState);
63 int nativeViewId() const { return m_nativeViewId; }
64
65 static bool registerNatives(QJniEnvironment &env);
66 void onSurfaceChanged(QtJniTypes::Surface surface);
67
68protected:
69 void setGeometry(const QRect &rect) override;
70 void lockSurface() { m_surfaceMutex.lock(); }
71 void unlockSurface() { m_surfaceMutex.unlock(); }
72 void createSurface();
73 void destroySurface();
74 void setNativeGeometry(const QRect &geometry);
75 void sendExpose() const;
76 bool blockedByModal() const;
77 bool isEmbeddingContainer() const;
78
79 Qt::WindowFlags m_windowFlags;
80 Qt::WindowStates m_windowState;
82
83 int m_nativeViewId = -1;
84 QtJniTypes::QtWindow m_nativeQtWindow;
85 SurfaceContainer m_surfaceContainerType = SurfaceContainer::SurfaceView;
86 QtJniTypes::QtWindow m_nativeParentQtWindow;
87 // The Android Surface, accessed from multiple threads, guarded by m_surfaceMutex
88 QtJniTypes::Surface m_androidSurfaceObject;
90 bool m_surfaceCreated = false;
92
93private:
94 static void setSurface(JNIEnv *env, jobject obj, jint windowId, QtJniTypes::Surface surface);
95 Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(setSurface)
96 static void windowFocusChanged(JNIEnv *env, jobject object, jboolean focus, jint windowId);
97 Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(windowFocusChanged)
98};
99
101#endif // ANDROIDPLATFORMWINDOW_H
QtJniTypes::QtWindow nativeWindow() const
bool setKeyboardGrabEnabled(bool grab) override
QtJniTypes::QtWindow m_nativeParentQtWindow
QtJniTypes::Surface m_androidSurfaceObject
QtJniTypes::QtWindow m_nativeQtWindow
bool setMouseGrabEnabled(bool grab) override
\inmodule QtCore
\inmodule QtCore
Definition qmargins.h:24
\inmodule QtCore
Definition qmutex.h:281
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qwindow.h:63
bool focus
[0]
rect
[4]
else opt state
[0]
static bool registerNatives()
Combined button and popup list for selecting options.
ApplicationState
Definition qnamespace.h:262
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLbitfield flags
GLhandleARB obj
[2]
QT_BEGIN_NAMESPACE Q_DECLARE_JNI_CLASS(Environment, "android/os/Environment")
#define Q_UNUSED(x)
w setWindowState(w->windowState() ^ Qt::WindowFullScreen)
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
file setParent(multiPart)
QQuickView * view
[0]