Qt 4.8
Functions
qbbscreen.cpp File Reference
#include "qbbscreen.h"
#include "qbbrootwindow.h"
#include "qbbwindow.h"
#include "qbbcursor.h"
#include <QDebug>
#include <QtCore/QThread>
#include <QtGui/QWindowSystemInterface>
#include <errno.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static int defaultDepth ()
 
static QSize determineScreenSize (screen_display_t display, bool primaryScreen)
 
static bool isOrthogonal (int angle1, int angle2)
 Check if the supplied angles are perpendicular to each other. More...
 

Function Documentation

◆ defaultDepth()

static int defaultDepth ( )
static

Definition at line 164 of file qbbscreen.cpp.

Referenced by QBBScreen::depth(), and QPixmap::swap().

165 {
166  static int defaultDepth = 0;
167  if (defaultDepth == 0) {
168  // check if display depth was specified in environment variable;
169  // use default value if no valid value found
170  defaultDepth = qgetenv("QBB_DISPLAY_DEPTH").toInt();
171  if (defaultDepth != 16 && defaultDepth != 32) {
172  defaultDepth = 32;
173  }
174  }
175  return defaultDepth;
176 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static int defaultDepth()
Definition: qbbscreen.cpp:164
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...

◆ determineScreenSize()

static QSize determineScreenSize ( screen_display_t  display,
bool  primaryScreen 
)
static

Definition at line 67 of file qbbscreen.cpp.

Referenced by QBBScreen::QBBScreen().

68 {
69  int val[2];
70 
71  errno = 0;
72  const int result = screen_get_display_property_iv(display, SCREEN_PROPERTY_PHYSICAL_SIZE, val);
73  if (result != 0) {
74  qFatal("QBBScreen: failed to query display physical size, errno=%d", errno);
75  return QSize(150, 90);
76  }
77 
78  if (val[0] > 0 && val[1] > 0)
79  return QSize(val[0], val[1]);
80 
81  qWarning("QBBScreen: screen_get_display_property_iv() reported an invalid physical screen size (%dx%d). Falling back to QBB_PHYSICAL_SCREEN_SIZE environment variable.", val[0], val[1]);
82 
83  const QString envPhySizeStr = qgetenv("QBB_PHYSICAL_SCREEN_SIZE");
84  if (!envPhySizeStr.isEmpty()) {
85  const QStringList envPhySizeStrList = envPhySizeStr.split(QLatin1Char(','));
86  const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
87  const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;
88 
89  if (envWidth <= 0 || envHeight <= 0) {
90  qFatal("QBBScreen: The value of QBB_PHYSICAL_SCREEN_SIZE must be in the format \"width,height\" in mm, with width, height > 0. Example: QBB_PHYSICAL_SCREEN_SIZE=150,90");
91  return QSize(150, 90);
92  }
93 
94  return QSize(envWidth, envHeight);
95  }
96 
97 #if defined(QBB_PHYSICAL_SCREEN_SIZE_DEFINED)
98  const QSize defSize(QBB_PHYSICAL_SCREEN_WIDTH, QBB_PHYSICAL_SCREEN_HEIGHT);
99  qWarning("QBBScreen: QBB_PHYSICAL_SCREEN_SIZE variable not set. Falling back to defines QBB_PHYSICAL_SCREEN_WIDTH/QBB_PHYSICAL_SCREEN_HEIGHT (%dx%d)", defSize.width(), defSize.height());
100  return defSize;
101 #else
102  if (primaryScreen)
103  qFatal("QBBScreen: QBB_PHYSICAL_SCREEN_SIZE variable not set. Could not determine physical screen size.");
104  return QSize(150, 90);
105 #endif
106 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
Q_CORE_EXPORT void qFatal(const char *,...)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
int errno

◆ isOrthogonal()

static bool isOrthogonal ( int  angle1,
int  angle2 
)
static

Check if the supplied angles are perpendicular to each other.

Definition at line 224 of file qbbscreen.cpp.

Referenced by QBBScreen::setRotation().

225 {
226  return ((angle1 - angle2) % 180) != 0;
227 }