Qt 4.8
qxlibnativeinterface.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qxlibnativeinterface.h"
43 
44 #include "qxlibdisplay.h"
45 #include <QtGui/private/qapplication_p.h>
46 
47 class QXlibResourceMap : public QMap<QByteArray, QXlibNativeInterface::ResourceType>
48 {
49 public:
51  :QMap<QByteArray, QXlibNativeInterface::ResourceType>()
52  {
59  }
60 };
61 
62 Q_GLOBAL_STATIC(QXlibResourceMap, qXlibResourceMap)
63 
64 
65 void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
66 {
67  QByteArray lowerCaseResource = resourceString.toLower();
68  ResourceType resource = qXlibResourceMap()->value(lowerCaseResource);
69  void *result = 0;
70  switch(resource) {
71  case Display:
72  result = displayForWidget(widget);
73  break;
74  case EglDisplay:
75  result = eglDisplayForWidget(widget);
76  break;
77  case Connection:
78  result = connectionForWidget(widget);
79  break;
80  case Screen:
81  result = reinterpret_cast<void *>(qPlatformScreenForWidget(widget)->xScreenNumber());
82  break;
83  case GraphicsDevice:
84  result = graphicsDeviceForWidget(widget);
85  break;
86  case EglContext:
87  result = eglContextForWidget(widget);
88  break;
89  default:
90  result = 0;
91  }
92  return result;
93 }
94 
96 {
97  return qPlatformScreenForWidget(widget)->display()->nativeDisplay();
98 }
99 
101 {
102  Q_UNUSED(widget);
103  return 0;
104 }
105 
107 {
108  Q_UNUSED(widget);
109  return 0;
110 }
111 
113 {
114  Q_UNUSED(widget);
115  return 0;
116 }
117 
119 {
120  Q_UNUSED(widget);
121  return 0;
122 }
123 
125 {
126  QXlibScreen *screen;
127  if (widget) {
128  screen = static_cast<QXlibScreen *>(QPlatformScreen::platformScreenForWidget(widget));
129  }else {
130  screen = static_cast<QXlibScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
131  }
132  return screen;
133 }
static QXlibScreen * qPlatformScreenForWidget(QWidget *widget)
QPointer< QWidget > widget
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QByteArray toLower() const
Returns a lowercase copy of the byte array.
void * screenForWidget(QWidget *widget)
void * eglDisplayForWidget(QWidget *widget)
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)
void * displayForWidget(QWidget *widget)
struct _XDisplay Display
Definition: qwindowdefs.h:115
iterator insert(const QByteArray &key, const QXlibNativeInterface::ResourceType &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
void * eglContextForWidget(QWidget *widget)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
void * graphicsDeviceForWidget(QWidget *widget)