Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QTestLiteStaticInfoPrivate Class Reference

Public Functions

Atom atom (QXlibStatic::X11Atom atom)
 
bool isSupportedByWM (Atom atom)
 
QImage qimageFromXImage (XImage *xi)
 
 QTestLiteStaticInfoPrivate ()
 
bool useXFixes () const
 
int xFixesEventBase () const
 
PtrXFixesSelectSelectionInput xFixesSelectSelectionInput () const
 

Private Functions

void initializeAllAtoms (QXlibScreen *screen)
 
void initializeSupportedAtoms (QXlibScreen *screen)
 
void resolveXFixes (QXlibScreen *screen)
 

Properties

Atom m_allAtoms [QXlibStatic::NAtoms]
 
Atom * m_supportedAtoms
 
PtrXFixesQueryExtension ptrXFixesQueryExtension
 
PtrXFixesQueryVersion ptrXFixesQueryVersion
 
PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput
 
PtrXFixesSetCursorName ptrXFixesSetCursorName
 
bool use_xfixes
 
int xfixes_errorbase
 
int xfixes_eventbase
 
int xfixes_major
 

Detailed Description

Definition at line 255 of file qxlibstatic.cpp.

Constructors and Destructors

◆ QTestLiteStaticInfoPrivate()

QTestLiteStaticInfoPrivate::QTestLiteStaticInfoPrivate ( )
inline

Definition at line 258 of file qxlibstatic.cpp.

259  : use_xfixes(false)
260  , xfixes_major(0)
261  , xfixes_eventbase(0)
262  , xfixes_errorbase(0)
263  {
264  QXlibScreen *screen = qobject_cast<QXlibScreen *> (QApplicationPrivate::platformIntegration()->screens().at(0));
265  Q_ASSERT(screen);
266 
267  initializeAllAtoms(screen);
268  initializeSupportedAtoms(screen);
269 
270  resolveXFixes(screen);
271  }
T qobject_cast(QObject *object)
Definition: qobject.h:375
void resolveXFixes(QXlibScreen *screen)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void initializeAllAtoms(QXlibScreen *screen)
void initializeSupportedAtoms(QXlibScreen *screen)

Functions

◆ atom()

Atom QTestLiteStaticInfoPrivate::atom ( QXlibStatic::X11Atom  atom)
inline

Definition at line 290 of file qxlibstatic.cpp.

Referenced by initializeSupportedAtoms().

291  {
292  return m_allAtoms[atom];
293  }
Atom m_allAtoms[QXlibStatic::NAtoms]
Atom atom(QXlibStatic::X11Atom atom)

◆ initializeAllAtoms()

void QTestLiteStaticInfoPrivate::initializeAllAtoms ( QXlibScreen screen)
inlineprivate

Definition at line 354 of file qxlibstatic.cpp.

Referenced by QTestLiteStaticInfoPrivate().

354  {
355  const char *names[QXlibStatic::NAtoms];
356  const char *ptr = x11_atomnames;
357 
358  int i = 0;
359  while (*ptr) {
360  names[i++] = ptr;
361  while (*ptr)
362  ++ptr;
363  ++ptr;
364  }
365 
367 
368  QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
369  settings_atom_name += XDisplayName(qPrintable(screen->display()->displayName()));
370  names[i++] = settings_atom_name;
371 
373  #if 0//defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6)
374  XInternAtoms(screen->display(), (char **)names, i, False, m_allAtoms);
375  #else
376  for (i = 0; i < QXlibStatic::NAtoms; ++i)
377  m_allAtoms[i] = XInternAtom(screen->display()->nativeDisplay(), (char *)names[i], False);
378  #endif
379  }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Display * nativeDisplay() const
QString displayName() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Atom m_allAtoms[QXlibStatic::NAtoms]
const T * ptr(const T &t)
static const char * x11_atomnames
Definition: qxlibstatic.cpp:54
QXlibDisplay * display() const
#define qPrintable(string)
Definition: qglobal.h:1750

◆ initializeSupportedAtoms()

void QTestLiteStaticInfoPrivate::initializeSupportedAtoms ( QXlibScreen screen)
inlineprivate

Definition at line 381 of file qxlibstatic.cpp.

Referenced by QTestLiteStaticInfoPrivate().

382  {
383  Atom type;
384  int format;
385  long offset = 0;
386  unsigned long nitems, after;
387  unsigned char *data = 0;
388 
389  int e = XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
390  this->atom(QXlibStatic::_NET_SUPPORTED), 0, 0,
391  False, XA_ATOM, &type, &format, &nitems, &after, &data);
392  if (data)
393  XFree(data);
394 
395  if (e == Success && type == XA_ATOM && format == 32) {
396  QBuffer ts;
398 
399  while (after > 0) {
400  XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
401  this->atom(QXlibStatic::_NET_SUPPORTED), offset, 1024,
402  False, XA_ATOM, &type, &format, &nitems, &after, &data);
403 
404  if (type == XA_ATOM && format == 32) {
405  ts.write(reinterpret_cast<char *>(data), nitems * sizeof(long));
406  offset += nitems;
407  } else
408  after = 0;
409  if (data)
410  XFree(data);
411  }
412 
413  // compute nitems
414  QByteArray buffer(ts.buffer());
415  nitems = buffer.size() / sizeof(Atom);
416  m_supportedAtoms = new Atom[nitems + 1];
417  Atom *a = (Atom *) buffer.data();
418  uint i;
419  for (i = 0; i < nitems; i++)
420  m_supportedAtoms[i] = a[i];
421  m_supportedAtoms[nitems] = 0;
422 
423  }
424  }
int type
Definition: qmetatype.cpp:239
Window rootWindow()
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Display * nativeDisplay() const
long ASN1_INTEGER_get ASN1_INTEGER * a
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
QByteArray & buffer()
Returns a reference to the QBuffer&#39;s internal buffer.
Definition: qbuffer.cpp:271
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
Atom atom(QXlibStatic::X11Atom atom)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
QXlibDisplay * display() const

◆ isSupportedByWM()

bool QTestLiteStaticInfoPrivate::isSupportedByWM ( Atom  atom)
inline

Definition at line 273 of file qxlibstatic.cpp.

274  {
275  if (!m_supportedAtoms)
276  return false;
277 
278  bool supported = false;
279  int i = 0;
280  while (m_supportedAtoms[i] != 0) {
281  if (m_supportedAtoms[i++] == atom) {
282  supported = true;
283  break;
284  }
285  }
286 
287  return supported;
288  }
Atom atom(QXlibStatic::X11Atom atom)

◆ qimageFromXImage()

QImage QTestLiteStaticInfoPrivate::qimageFromXImage ( XImage *  xi)
inline

Definition at line 304 of file qxlibstatic.cpp.

305  {
307  if (xi->depth == 24)
308  format = QImage::Format_RGB32;
309  else if (xi->depth == 16)
310  format = QImage::Format_RGB16;
311 
312  QImage image = QImage((uchar *)xi->data, xi->width, xi->height, xi->bytes_per_line, format).copy();
313 
314  // we may have to swap the byte order
315  if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst)
316  || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst))
317  {
318  for (int i=0; i < image.height(); i++) {
319  if (xi->depth == 16) {
320  ushort *p = (ushort*)image.scanLine(i);
321  ushort *end = p + image.width();
322  while (p < end) {
323  *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);
324  p++;
325  }
326  } else {
327  uint *p = (uint*)image.scanLine(i);
328  uint *end = p + image.width();
329  while (p < end) {
330  *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
331  | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
332  p++;
333  }
334  }
335  }
336  }
337 
338  // fix-up alpha channel
339  if (format == QImage::Format_RGB32) {
340  QRgb *p = (QRgb *)image.bits();
341  for (int y = 0; y < xi->height; ++y) {
342  for (int x = 0; x < xi->width; ++x)
343  p[x] |= 0xff000000;
344  p += xi->bytes_per_line / 4;
345  }
346  }
347 
348  return image;
349  }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
unsigned int QRgb
Definition: qrgb.h:53
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
unsigned char uchar
Definition: qglobal.h:994
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
unsigned short ushort
Definition: qglobal.h:995
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
static const KeyPair *const end
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886

◆ resolveXFixes()

void QTestLiteStaticInfoPrivate::resolveXFixes ( QXlibScreen screen)
inlineprivate

Definition at line 426 of file qxlibstatic.cpp.

Referenced by QTestLiteStaticInfoPrivate().

427  {
428 #ifndef QT_NO_XFIXES
429  // See if Xfixes is supported on the connected display
430  if (XQueryExtension(screen->display()->nativeDisplay(), "XFIXES", &xfixes_major,
432  ptrXFixesQueryExtension = XFIXES_LOAD_V1(XFixesQueryExtension);
433  ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
434  ptrXFixesSetCursorName = XFIXES_LOAD_V2(XFixesSetCursorName);
435  ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
436 
439  &xfixes_errorbase)) {
440  // Xfixes is supported.
441  // Note: the XFixes protocol version is negotiated using QueryVersion.
442  // We supply the highest version we support, the X server replies with
443  // the highest version it supports, but no higher than the version we
444  // asked for. The version sent back is the protocol version the X server
445  // will use to talk us. If this call is removed, the behavior of the
446  // X server when it receives an XFixes request is undefined.
447  int major = 3;
448  int minor = 0;
449  ptrXFixesQueryVersion(screen->display()->nativeDisplay(), &major, &minor);
450  use_xfixes = (major >= 1);
451  xfixes_major = major;
452  }
453  }
454 #endif // QT_NO_XFIXES
455 
456  }
Display * nativeDisplay() const
PtrXFixesQueryVersion ptrXFixesQueryVersion
PtrXFixesQueryExtension ptrXFixesQueryExtension
#define XFIXES_LOAD_V2(symbol)
PtrXFixesSetCursorName ptrXFixesSetCursorName
QXlibDisplay * display() const
PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput
#define XFIXES_LOAD_V1(symbol)

◆ useXFixes()

bool QTestLiteStaticInfoPrivate::useXFixes ( ) const
inline

Definition at line 295 of file qxlibstatic.cpp.

Referenced by QXlibStatic::xFixesSelectSelectionInput().

295 { return use_xfixes; }

◆ xFixesEventBase()

int QTestLiteStaticInfoPrivate::xFixesEventBase ( ) const
inline

Definition at line 297 of file qxlibstatic.cpp.

◆ xFixesSelectSelectionInput()

PtrXFixesSelectSelectionInput QTestLiteStaticInfoPrivate::xFixesSelectSelectionInput ( ) const
inline

Definition at line 299 of file qxlibstatic.cpp.

300  {
302  }
PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput

Properties

◆ m_allAtoms

Atom QTestLiteStaticInfoPrivate::m_allAtoms[QXlibStatic::NAtoms]
private

Definition at line 459 of file qxlibstatic.cpp.

Referenced by atom(), and initializeAllAtoms().

◆ m_supportedAtoms

Atom* QTestLiteStaticInfoPrivate::m_supportedAtoms
private

Definition at line 458 of file qxlibstatic.cpp.

Referenced by initializeSupportedAtoms(), and isSupportedByWM().

◆ ptrXFixesQueryExtension

PtrXFixesQueryExtension QTestLiteStaticInfoPrivate::ptrXFixesQueryExtension
private

Definition at line 462 of file qxlibstatic.cpp.

Referenced by resolveXFixes().

◆ ptrXFixesQueryVersion

PtrXFixesQueryVersion QTestLiteStaticInfoPrivate::ptrXFixesQueryVersion
private

Definition at line 463 of file qxlibstatic.cpp.

Referenced by resolveXFixes().

◆ ptrXFixesSelectSelectionInput

PtrXFixesSelectSelectionInput QTestLiteStaticInfoPrivate::ptrXFixesSelectSelectionInput
private

Definition at line 465 of file qxlibstatic.cpp.

Referenced by resolveXFixes(), and xFixesSelectSelectionInput().

◆ ptrXFixesSetCursorName

PtrXFixesSetCursorName QTestLiteStaticInfoPrivate::ptrXFixesSetCursorName
private

Definition at line 464 of file qxlibstatic.cpp.

Referenced by resolveXFixes().

◆ use_xfixes

bool QTestLiteStaticInfoPrivate::use_xfixes
private

Definition at line 468 of file qxlibstatic.cpp.

Referenced by resolveXFixes(), and useXFixes().

◆ xfixes_errorbase

int QTestLiteStaticInfoPrivate::xfixes_errorbase
private

Definition at line 471 of file qxlibstatic.cpp.

Referenced by resolveXFixes().

◆ xfixes_eventbase

int QTestLiteStaticInfoPrivate::xfixes_eventbase
private

Definition at line 470 of file qxlibstatic.cpp.

Referenced by resolveXFixes(), and xFixesEventBase().

◆ xfixes_major

int QTestLiteStaticInfoPrivate::xfixes_major
private

Definition at line 469 of file qxlibstatic.cpp.

Referenced by resolveXFixes().


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