1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qplatformintegration_qpa.h"
44 #include <QtGui/QPlatformFontDatabase>
45 #include <QtGui/QPlatformClipboard>
46 #include <QtGui/QPlatformPrinterSupport>
47 #include <QtGui/private/qguiapplication_p.h>
48 #include <QtGui/private/qpixmap_raster_p.h>
49 #include <private/qdnd_p.h>
54 Accessor for the platform integrations fontdatabase.
56 Default implementation returns a default QPlatformFontDatabase.
58 \sa QPlatformFontDatabase
60 QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
62 static QPlatformFontDatabase *db = 0;
64 db = new QPlatformFontDatabase;
70 Accessor for the platform integrations clipboard.
72 Default implementation returns a default QPlatformClipboard.
74 \sa QPlatformClipboard
78 #ifndef QT_NO_CLIPBOARD
80 QPlatformClipboard *QPlatformIntegration::clipboard() const
82 static QPlatformClipboard *clipboard = 0;
84 clipboard = new QPlatformClipboard;
91 #ifndef QT_NO_DRAGANDDROP
93 Accessor for the platform integrations drag object.
95 Default implementation returns 0, implying no drag and drop support.
98 QPlatformDrag *QPlatformIntegration::drag() const
104 QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
110 \class QPlatformIntegration
115 \brief The QPlatformIntegration class is the entry for WindowSystem specific functionality.
117 QPlatformIntegration is the single entry point for windowsystem specific functionality when
118 using the QPA platform. It has factory functions for creating platform specific pixmaps and
119 windows. The class also controls the font subsystem.
121 QPlatformIntegration is a singelton class which gets instansiated in the QApplication
122 constructor. The QPlatformIntegration instance do not have ownership of objects it creates in
123 functions where the name starts with create. However, functions which don't have a name
124 starting with create acts as assessors to member variables.
126 It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefor
127 the recommended approach for making new platform plugin is to copy an existing plugin inside
128 the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.
130 The minimal platform integration is the smallest platform integration it is possible to make,
131 which makes it an ideal starting point for new plugins. For a slightly more advanced plugin,
132 consider reviewing the directfb plugin, or the testlite plugin.
136 \fn QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
138 Factory function for QPlatformPixmap. PixelType can be either PixmapType or BitmapType.
143 \fn QPlatformWindow *QPlatformIntegration::createPlatformWindow(QWindow *window, WId winId = 0) const
145 Factory function for QPlatformWindow. The widget parameter is a pointer to the top level
146 widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually
147 never used, but there for future reference. Its purpose is if it is going to be possible to
148 create QPlatformWindows on existing WId.
150 All tlw has to have a QPlatformWindow, and it will be created when the QPlatformWindow is set
151 to be visible for the first time. If the tlw's window flags are changed, or if the tlw's
152 QPlatformWindowFormat is changed, then the tlw's QPlatformWindow is deleted and a new one is
155 \sa QPlatformWindow, QPlatformWindowFormat
156 \sa createPlatformBackingStore(QWindow *window) const
160 \fn QPlatformBackingStore *QPlatformIntegration::createPlatformBackingStore(QWindow *window) const
162 Factory function for QPlatformBackingStore. The QWindow parameter is a pointer to the
163 top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
164 before the QPlatformBackingStore for tlw where the widget also requires a backing store.
167 \sa createPlatformWindow(QWindow *window, WId winId = 0) const
172 \fn void QPlatformIntegration::moveToScreen(QWindow *window, int screen)
174 This function is called when a QWindow is displayed on screen, or the QWindow is to be
175 displayed on a new screen. The QWindow parameter is a pointer to the top level widget and
176 the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.
178 Default implementation does nothing.
184 \fn QList<QPlatformScreen *> QPlatformIntegration::screens() const
186 Accessor function to a list of all the screens on the current system. The screen with the
187 index == 0 is the default/main screen.
191 \fn bool QPlatformIntegration::isVirtualDesktop()
193 Returns if the current windowing system configuration defines all the screens to be one
194 desktop(virtual desktop), or if each screen is a desktop of its own.
196 Default implementation returns false.
200 \fn QAbstractEventDispatcher *createEventDispatcher() const
202 Factory function for the event dispatcher. The platform plugin
203 must create and and return a QAbstractEventDispatcher subclass when
204 this function is called.
207 bool QPlatformIntegration::hasCapability(Capability cap) const
213 QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
215 return new QRasterPlatformPixmap(type);
218 QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(QGuiGLContext *context) const
220 qWarning("This plugin does not support createPlatformGLContext!");
226 Returns the platform's printing support.
231 QPlatformPrinterSupport *QPlatformIntegration::printerSupport() const
233 static QPlatformPrinterSupport *ps = 0;
234 #ifndef QT_NO_PRINTER
236 ps = new QPlatformPrinterSupport;
242 Returns the platforms input context.
244 The default implementation returns 0, implying no input method support.
246 QPlatformInputContext *QPlatformIntegration::inputContext() const
252 Should be called by the implementation whenever a new screen is added.
254 The first screen added will be the primary screen, used for default-created
255 windows, GL contexts, and other resources unless otherwise specified.
257 This adds the screen to QGuiApplication::screens(), and emits the
258 QGuiApplication::screenAdded() signal.
260 The screen is automatically removed when the QPlatformScreen is destroyed.
262 void QPlatformIntegration::screenAdded(QPlatformScreen *ps)
264 QScreen *screen = ps ? ps->screen() : 0;
265 if (screen && !QGuiApplicationPrivate::screen_list.contains(screen)) {
266 QGuiApplicationPrivate::screen_list << screen;
267 emit qGuiApp->screenAdded(screen);