1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qminimaleglintegration.h"
5
6#include "qminimaleglwindow.h"
7#ifndef QT_NO_OPENGL
8# include "qminimaleglbackingstore.h"
9#endif
10#include <QtGui/private/qgenericunixfontdatabase_p.h>
11
12#if defined(Q_OS_UNIX)
13# include <QtGui/private/qgenericunixeventdispatcher_p.h>
14#elif defined(Q_OS_WIN)
15# include <QtGui/private/qwindowsguieventdispatcher_p.h>
16#endif
17
18#include <qpa/qplatformwindow.h>
19#include <QtGui/QSurfaceFormat>
20#include <QtGui/QOpenGLContext>
21#include <QtGui/QScreen>
22#include <qpa/qwindowsysteminterface.h>
23
24// this is where EGL headers are pulled in, make sure it is last
25#include "qminimaleglscreen.h"
26
27QT_BEGIN_NAMESPACE
28
29QMinimalEglIntegration::QMinimalEglIntegration()
30 : mFontDb(new QGenericUnixFontDatabase()), mScreen(new QMinimalEglScreen(EGL_DEFAULT_DISPLAY))
31{
32 QWindowSystemInterface::handleScreenAdded(screen: mScreen);
33
34#ifdef QEGL_EXTRA_DEBUG
35 qWarning("QMinimalEglIntegration\n");
36#endif
37}
38
39QMinimalEglIntegration::~QMinimalEglIntegration()
40{
41 QWindowSystemInterface::handleScreenRemoved(screen: mScreen);
42 delete mFontDb;
43}
44
45bool QMinimalEglIntegration::hasCapability(QPlatformIntegration::Capability cap) const
46{
47 switch (cap) {
48 case ThreadedPixmaps: return true;
49 case OpenGL: return true;
50 case ThreadedOpenGL: return true;
51 default: return QPlatformIntegration::hasCapability(cap);
52 }
53}
54
55QPlatformWindow *QMinimalEglIntegration::createPlatformWindow(QWindow *window) const
56{
57#ifdef QEGL_EXTRA_DEBUG
58 qWarning("QMinimalEglIntegration::createPlatformWindow %p\n",window);
59#endif
60 QPlatformWindow *w = new QMinimalEglWindow(window);
61 w->requestActivateWindow();
62 return w;
63}
64
65
66QPlatformBackingStore *QMinimalEglIntegration::createPlatformBackingStore(QWindow *window) const
67{
68#ifdef QEGL_EXTRA_DEBUG
69 qWarning("QMinimalEglIntegration::createWindowSurface %p\n", window);
70#endif
71#ifndef QT_NO_OPENGL
72 return new QMinimalEglBackingStore(window);
73#else
74 Q_UNUSED(window);
75 return nullptr;
76#endif
77}
78#ifndef QT_NO_OPENGL
79QPlatformOpenGLContext *QMinimalEglIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
80{
81 return static_cast<QMinimalEglScreen *>(context->screen()->handle())->platformContext();
82}
83#endif
84
85QPlatformFontDatabase *QMinimalEglIntegration::fontDatabase() const
86{
87 return mFontDb;
88}
89
90QAbstractEventDispatcher *QMinimalEglIntegration::createEventDispatcher() const
91{
92#if defined(Q_OS_UNIX)
93 return createUnixEventDispatcher();
94#elif defined(Q_OS_WIN)
95 return new QWindowsGuiEventDispatcher;
96#else
97 return nullptr;
98#endif
99}
100
101QVariant QMinimalEglIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
102{
103 if (hint == QPlatformIntegration::ShowIsFullScreen)
104 return true;
105
106 return QPlatformIntegration::styleHint(hint);
107}
108
109QT_END_NAMESPACE
110

source code of qtbase/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp