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 <QtGui/QPlatformCursor>
58 #include <QtGui/QSurfaceFormat>
59 #include <QtGui/QOpenGLContext>
61 #include <private/qplatforminputcontextfactory_qpa_p.h>
62 #include <qplatformaccessibility_qpa.h>
63 #include <qplatforminputcontext_qpa.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 QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const
92 return mNativeInterface;
95 bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) const
98 case ThreadedPixmaps: return true;
100 #ifdef QT_WAYLAND_GL_SUPPORT
106 return hasCapability(OpenGL);
107 case BufferQueueingOpenGL:
109 default: return QPlatformIntegration::hasCapability(cap);
113 QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
115 #ifdef QT_WAYLAND_GL_SUPPORT
116 if (window->surfaceType() == QWindow::OpenGLSurface)
117 return mDisplay->eglIntegration()->createEglWindow(window);
119 return new QWaylandShmWindow(window);
122 QPlatformOpenGLContext *QWaylandIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
124 #ifdef QT_WAYLAND_GL_SUPPORT
125 return mDisplay->eglIntegration()->createPlatformOpenGLContext(context->format(), context->shareHandle());
132 QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *window) const
134 return new QWaylandShmBackingStore(window);
137 QAbstractEventDispatcher *QWaylandIntegration::guiThreadEventDispatcher() const
139 return mEventDispatcher;
142 QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
147 QPlatformClipboard *QWaylandIntegration::clipboard() const
152 QPlatformDrag *QWaylandIntegration::drag() const
157 QPlatformInputContext *QWaylandIntegration::inputContext() const
159 return mInputContext;
162 QVariant QWaylandIntegration::styleHint(StyleHint hint) const
164 #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
165 if (hint == ShowIsFullScreen && mDisplay->windowManagerIntegration())
166 return mDisplay->windowManagerIntegration()->showIsFullScreen();
168 return QPlatformIntegration::styleHint(hint);
171 QPlatformAccessibility *QWaylandIntegration::accessibility() const
173 return mAccessibility;
176 QWaylandDisplay *QWaylandIntegration::display() const