Qt 4.8
Public Types | Public Functions | Static Private Functions | List of all members
QXcbNativeInterface Class Reference

#include <qxcbnativeinterface.h>

Inheritance diagram for QXcbNativeInterface:
QPlatformNativeInterface

Public Types

enum  ResourceType {
  Display, EglDisplay, Connection, Screen,
  GraphicsDevice, EglContext
}
 

Public Functions

void * connectionForWidget (QWidget *widget)
 
void * displayForWidget (QWidget *widget)
 
void * eglContextForWidget (QWidget *widget)
 
void * eglDisplayForWidget (QWidget *widget)
 
void * graphicsDeviceForWidget (QWidget *widget)
 
void * nativeResourceForWidget (const QByteArray &resourceString, QWidget *widget)
 
void * screenForWidget (QWidget *widget)
 

Static Private Functions

static QXcbScreenqPlatformScreenForWidget (QWidget *widget)
 

Detailed Description

Definition at line 50 of file qxcbnativeinterface.h.

Enumerations

◆ ResourceType

Functions

◆ connectionForWidget()

void * QXcbNativeInterface::connectionForWidget ( QWidget widget)

Definition at line 137 of file qxcbnativeinterface.cpp.

138 {
139  QXcbScreen *screen = qPlatformScreenForWidget(widget);
140  return screen->xcb_connection();
141 }
static QXcbScreen * qPlatformScreenForWidget(QWidget *widget)
xcb_connection_t * xcb_connection() const
Definition: qxcbobject.h:56

◆ displayForWidget()

void * QXcbNativeInterface::displayForWidget ( QWidget widget)

Definition at line 115 of file qxcbnativeinterface.cpp.

116 {
117 #if defined(XCB_USE_XLIB)
118  QXcbScreen *screen = qPlatformScreenForWidget(widget);
119  return screen->connection()->xlib_display();
120 #else
121  Q_UNUSED(widget);
122  return 0;
123 #endif
124 }
static QXcbScreen * qPlatformScreenForWidget(QWidget *widget)
QXcbConnection * connection() const
Definition: qxcbobject.h:53
#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

◆ eglContextForWidget()

void * QXcbNativeInterface::eglContextForWidget ( QWidget widget)

Definition at line 162 of file qxcbnativeinterface.cpp.

163 {
164  Q_ASSERT(widget);
165  if (!widget->platformWindow()) {
166  qDebug() << "QPlatformWindow does not exist for widget" << widget
167  << "cannot return EGLContext";
168  return 0;
169  }
170  QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
171  if (!platformContext) {
172  qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
173  << "cannot return EGLContext";
174  return 0;
175  }
176 #if defined(XCB_USE_EGL)
177  QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(platformContext);
178  return eglPlatformContext->eglContext();
179 #elif defined (XCB_USE_DRI2)
180  QDri2Context *dri2Context = static_cast<QDri2Context *>(platformContext);
181  return dri2Context->eglContext();
182 #else
183  return 0;
184 #endif
185 }
EGLContext eglContext() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qDebug(const char *,...)
void * eglContext() const
The QPlatformGLContext class provides an abstraction for native GL contexts.

◆ eglDisplayForWidget()

void * QXcbNativeInterface::eglDisplayForWidget ( QWidget widget)

Definition at line 126 of file qxcbnativeinterface.cpp.

127 {
128 #if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
129  QXcbScreen *screen = qPlatformScreenForWidget(widget);
130  return screen->connection()->egl_display();
131 #else
132  Q_UNUSED(widget)
133  return 0;
134 #endif
135 }
static QXcbScreen * qPlatformScreenForWidget(QWidget *widget)
QXcbConnection * connection() const
Definition: qxcbobject.h:53
#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

◆ graphicsDeviceForWidget()

void * QXcbNativeInterface::graphicsDeviceForWidget ( QWidget widget)

Definition at line 149 of file qxcbnativeinterface.cpp.

150 {
151 #if defined(XCB_USE_DRI2)
152  QXcbScreen *screen = qPlatformScreenForWidget(widget);
153  QByteArray deviceName = screen->connection()->dri2DeviceName();
154  return deviceName.data();
155 #else
156  Q_UNUSED(widget);
157  return 0;
158 #endif
159 
160 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static QXcbScreen * qPlatformScreenForWidget(QWidget *widget)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QXcbConnection * connection() const
Definition: qxcbobject.h:53
#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

◆ nativeResourceForWidget()

void * QXcbNativeInterface::nativeResourceForWidget ( const QByteArray resourceString,
QWidget widget 
)
virtual

Reimplemented from QPlatformNativeInterface.

Definition at line 74 of file qxcbnativeinterface.cpp.

75 {
76  QByteArray lowerCaseResource = resourceString.toLower();
77  ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
78  void *result = 0;
79  switch(resource) {
80  case Display:
81  result = displayForWidget(widget);
82  break;
83  case EglDisplay:
84  result = eglDisplayForWidget(widget);
85  break;
86  case Connection:
87  result = connectionForWidget(widget);
88  break;
89  case Screen:
90  result = qPlatformScreenForWidget(widget);
91  break;
92  case GraphicsDevice:
93  result = graphicsDeviceForWidget(widget);
94  break;
95  case EglContext:
96  result = eglContextForWidget(widget);
97  break;
98  default:
99  result = 0;
100  }
101  return result;
102 }
static QXcbScreen * qPlatformScreenForWidget(QWidget *widget)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray toLower() const
Returns a lowercase copy of the byte array.
void * connectionForWidget(QWidget *widget)
void * eglContextForWidget(QWidget *widget)
void * graphicsDeviceForWidget(QWidget *widget)
void * displayForWidget(QWidget *widget)
void * eglDisplayForWidget(QWidget *widget)

◆ qPlatformScreenForWidget()

QXcbScreen * QXcbNativeInterface::qPlatformScreenForWidget ( QWidget widget)
staticprivate

Definition at line 104 of file qxcbnativeinterface.cpp.

105 {
106  QXcbScreen *screen;
107  if (widget) {
108  screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
109  }else {
110  screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
111  }
112  return screen;
113 }
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)

◆ screenForWidget()

void * QXcbNativeInterface::screenForWidget ( QWidget widget)

Definition at line 143 of file qxcbnativeinterface.cpp.

144 {
145  QXcbScreen *screen = qPlatformScreenForWidget(widget);
146  return screen->screen();
147 }
static QXcbScreen * qPlatformScreenForWidget(QWidget *widget)
xcb_screen_t * screen() const
Definition: qxcbscreen.h:67

The documentation for this class was generated from the following files: