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
qandroidplatformintegration.h
Go to the documentation of this file.
1// Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QANDROIDPLATFORMINTERATION_H
5#define QANDROIDPLATFORMINTERATION_H
6
9
10#include <QtGui/qtguiglobal.h>
11#include <qpa/qplatformintegration.h>
12#include <qpa/qplatformmenu.h>
13#include <qpa/qplatformnativeinterface.h>
14#include <qpa/qplatformopenglcontext.h>
15#include <qpa/qplatformoffscreensurface.h>
16#include <qpa/qplatformtheme.h>
17#include <private/qflatmap_p.h>
18#include <QtCore/qvarlengtharray.h>
19
20#include <EGL/egl.h>
21#include <memory>
22
24
27class QPlatformAccessibility;
28
29struct AndroidStyle;
31{
32public:
33 void *nativeResourceForIntegration(const QByteArray &resource) override;
34 void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
35 void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override;
36 std::shared_ptr<AndroidStyle> m_androidStyle;
37
38protected:
39 void customEvent(QEvent *event) override;
40};
41
43 , QNativeInterface::Private::QEGLIntegration
44 , QNativeInterface::Private::QAndroidOffScreenIntegration
45{
47
48public:
51
52 void initialize() override;
53
55
57 QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override;
60 QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const override;
62 QAndroidPlatformScreen *screen() { return m_primaryScreen; }
64 QOffscreenSurface *createOffscreenSurface(ANativeWindow *nativeSurface) const override;
65
66 void setAvailableGeometry(const QRect &availableGeometry);
67 void setPhysicalSize(int width, int height);
68 void setScreenSize(int width, int height);
69 // The 3 methods above were replaced by a new one, so that we could have
70 // a better control over "geometry changed" event handling. Technically
71 // they are no longer used and can be removed. Not doing it now, because
72 // I'm not sure if it might be helpful to have them or not.
73 void setScreenSizeParameters(const QSize &physicalSize, const QSize &screenSize,
74 const QRect &availableGeometry);
75 void setRefreshRate(qreal refreshRate);
76 bool isVirtualDesktop() { return true; }
77
78 QPlatformFontDatabase *fontDatabase() const override;
79
80 void handleScreenAdded(int displayId);
81 void handleScreenChanged(int displayId);
82 void handleScreenRemoved(int displayId);
83
84#ifndef QT_NO_CLIPBOARD
85 QPlatformClipboard *clipboard() const override;
86#endif
87
88 QPlatformInputContext *inputContext() const override;
90 QPlatformServices *services() const override;
91
92#if QT_CONFIG(accessibility)
93 virtual QPlatformAccessibility *accessibility() const override;
94#endif
95
96 QVariant styleHint(StyleHint hint) const override;
97 Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override;
98
99 QStringList themeNames() const override;
100 QPlatformTheme *createPlatformTheme(const QString &name) const override;
101
102 static void setDefaultDisplayMetrics(int availableLeft, int availableTop, int availableWidth,
103 int availableHeight, int physicalWidth, int physicalHeight,
104 int screenWidth, int screenHeight);
105 static void setScreenOrientation(Qt::ScreenOrientation currentOrientation,
106 Qt::ScreenOrientation nativeOrientation);
107
108 QPointingDevice *touchDevice() const { return m_touchDevice; }
110
111 void flushPendingUpdates();
112
114 static Qt::ColorScheme colorScheme() { return m_colorScheme; }
115#if QT_CONFIG(vulkan)
116 QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
117#endif
118
119private:
120 EGLDisplay m_eglDisplay;
121 QPointingDevice *m_touchDevice;
122
123 QAndroidPlatformScreen *m_primaryScreen;
124
125 QThread *m_mainThread;
126
127 static Qt::ColorScheme m_colorScheme;
128
129 static QRect m_defaultAvailableGeometry;
130 static QSize m_defaultPhysicalSize;
131 static QSize m_defaultScreenSize;
132
133 static Qt::ScreenOrientation m_orientation;
134 static Qt::ScreenOrientation m_nativeOrientation;
135 static bool m_showPasswordEnabled;
136
137 QPlatformFontDatabase *m_androidFDB;
138 QAndroidPlatformNativeInterface *m_androidPlatformNativeInterface;
139 QAndroidPlatformServices *m_androidPlatformServices;
140
141 // Handling the multiple screens connected. Every display is identified
142 // with an unique (autoincremented) displayID. The values of this ID will
143 // not repeat during the OS runtime. We use this value as the key in the
144 // storage of screens.
145 QFlatMap<int, QAndroidPlatformScreen *, std::less<int>
146 , QVarLengthArray<int, 10>
147 , QVarLengthArray<QAndroidPlatformScreen *, 10> > m_screens;
148 // ID of the primary display, in documentation it is said to be always 0,
149 // but nevertheless it is retrieved
150 int m_primaryDisplayId = 0;
151
152#ifndef QT_NO_CLIPBOARD
153 QPlatformClipboard *m_androidPlatformClipboard;
154#endif
155
156 QAndroidSystemLocale *m_androidSystemLocale;
157#if QT_CONFIG(accessibility)
158 mutable QPlatformAccessibility *m_accessibility;
159#endif
160
161 QScopedPointer<QPlatformInputContext> m_inputContext;
162};
163
165
166#endif
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QPlatformWindow * createForeignWindow(QWindow *window, WId nativeHandle) const override
static void setDefaultDisplayMetrics(int availableLeft, int availableTop, int availableWidth, int availableHeight, int physicalWidth, int physicalHeight, int screenWidth, int screenHeight)
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
QStringList themeNames() const override
QPlatformNativeInterface * nativeInterface() const override
QPlatformTheme * createPlatformTheme(const QString &name) const override
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
void setAvailableGeometry(const QRect &availableGeometry)
QOffscreenSurface * createOffscreenSurface(ANativeWindow *nativeSurface) const override
void setScreenSize(int width, int height)
QPlatformOffscreenSurface * createPlatformOffscreenSurface(QOffscreenSurface *surface) const override
Factory function for QOffscreenSurface.
QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const override
Factory function for QPlatformOpenGLContext.
void setPhysicalSize(int width, int height)
bool hasCapability(QPlatformIntegration::Capability cap) const override
void setScreenSizeParameters(const QSize &physicalSize, const QSize &screenSize, const QRect &availableGeometry)
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
void setTouchDevice(QPointingDevice *touchDevice)
QPlatformClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
static void updateColorScheme(Qt::ColorScheme colorScheme)
QOpenGLContext * createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const override
Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override
QAndroidPlatformIntegration(const QStringList &paramList)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QVariant styleHint(StyleHint hint) const override
static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, Qt::ScreenOrientation nativeOrientation)
QPlatformServices * services() const override
void customEvent(QEvent *event) override
This event handler can be reimplemented in a subclass to receive custom events.
void * nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override
void * nativeResourceForWindow(const QByteArray &resource, QWindow *window) override
void * nativeResourceForIntegration(const QByteArray &resource) override
std::shared_ptr< AndroidStyle > m_androidStyle
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtGui
\inmodule QtGui
The QPlatformBackingStore class provides the drawing area for top-level windows.
The QPlatformClipboard class provides an abstraction for the system clipboard.
The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they ...
The QPlatformInputContext class abstracts the input method dependent data and composing state.
The QPlatformIntegration class is the entry for WindowSystem specific functionality.
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformNativeInterface class provides an abstraction for retrieving native resource handles.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
The QPlatformServices provides the backend for desktop-related functionality.
The QPlatformTheme class allows customizing the UI based on themes.
The QPlatformVulkanInstance class provides an abstraction for Vulkan instances.
The QPlatformWindow class provides an abstraction for top-level windows.
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
\inmodule QtGui
Definition qwindow.h:63
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
WindowState
Definition qnamespace.h:251
ColorScheme
Definition qnamespace.h:50
ScreenOrientation
Definition qnamespace.h:271
static void * context
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
GLint GLsizei GLsizei height
GLint GLsizei width
GLbitfield flags
GLuint name
struct _cl_event * event
GLenum cap
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
double qreal
Definition qtypes.h:187
aWidget window() -> setWindowTitle("New Window Title")
[2]