1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the config.tests of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qwaylandintegration.h"
44 #include "qwaylanddisplay.h"
45 #include "qwaylandshmbackingstore.h"
46 #include "qwaylandshmwindow.h"
47 #include "qwaylandnativeinterface.h"
48 #include "qwaylandclipboard.h"
49 #include "qwaylanddnd.h"
51 #include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h"
52 #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
54 #include <QtGui/private/qguiapplication_p.h>
56 #include <QtGui/QWindowSystemInterface>
57 #include <qpa/qplatformcursor.h>
58 #include <QtGui/QSurfaceFormat>
59 #include <QtGui/QOpenGLContext>
61 #include <qpa/qplatforminputcontextfactory_p.h>
62 #include <qpa/qplatformaccessibility.h>
63 #include <qpa/qplatforminputcontext.h>
65 #ifdef QT_WAYLAND_GL_SUPPORT
66 #include "gl_integration/qwaylandglintegration.h"
69 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
70 #include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
73 QWaylandIntegration::QWaylandIntegration()
74 : mFontDb(new QGenericUnixFontDatabase())
75 , mEventDispatcher(createUnixEventDispatcher())
76 , mNativeInterface(new QWaylandNativeInterface(this))
77 , mAccessibility(new QPlatformAccessibility())
79 QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher);
80 mDisplay = new QWaylandDisplay();
81 mClipboard = new QWaylandClipboard(mDisplay);
82 mDrag = new QWaylandDrag(mDisplay);
84 foreach (QPlatformScreen *screen, mDisplay->screens())
87 mInputContext = QPlatformInputContextFactory::create();
90 QWaylandIntegration::~QWaylandIntegration()
94 delete mAccessibility;
95 delete mNativeInterface;
99 QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const
101 return mNativeInterface;
104 bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) const
107 case ThreadedPixmaps: return true;
109 #ifdef QT_WAYLAND_GL_SUPPORT
115 #ifdef QT_WAYLAND_GL_SUPPORT
116 return mDisplay->eglIntegration()->supportsThreadedOpenGL();
120 case BufferQueueingOpenGL:
122 default: return QPlatformIntegration::hasCapability(cap);
126 QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
128 #ifdef QT_WAYLAND_GL_SUPPORT
129 if (window->surfaceType() == QWindow::OpenGLSurface)
130 return mDisplay->eglIntegration()->createEglWindow(window);
132 return new QWaylandShmWindow(window);
135 QPlatformOpenGLContext *QWaylandIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
137 #ifdef QT_WAYLAND_GL_SUPPORT
138 return mDisplay->eglIntegration()->createPlatformOpenGLContext(context->format(), context->shareHandle());
145 QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *window) const
147 return new QWaylandShmBackingStore(window);
150 QAbstractEventDispatcher *QWaylandIntegration::guiThreadEventDispatcher() const
152 return mEventDispatcher;
155 QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
160 QPlatformClipboard *QWaylandIntegration::clipboard() const
165 QPlatformDrag *QWaylandIntegration::drag() const
170 QPlatformInputContext *QWaylandIntegration::inputContext() const
172 return mInputContext;
175 QVariant QWaylandIntegration::styleHint(StyleHint hint) const
177 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
178 if (hint == ShowIsFullScreen && mDisplay->windowManagerIntegration())
179 return mDisplay->windowManagerIntegration()->showIsFullScreen();
181 return QPlatformIntegration::styleHint(hint);
184 QPlatformAccessibility *QWaylandIntegration::accessibility() const
186 return mAccessibility;
189 QPlatformServices *QWaylandIntegration::services() const
191 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
192 return mDisplay->windowManagerIntegration();
194 return QWaylandIntegration::services();
198 QWaylandDisplay *QWaylandIntegration::display() const