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

#include <qbbscreen.h>

Inheritance diagram for QBBScreen:
QPlatformScreen QObject

Public Slots

void activateWindowGroup (const QByteArray &id)
 
void deactivateWindowGroup (const QByteArray &id)
 
void newWindowCreated (screen_window_t window)
 
void setRotation (int rotation)
 
void windowClosed (screen_window_t window)
 
void windowGroupStateChanged (const QByteArray &id, Qt::WindowState state)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

void addWindow (QBBWindow *child)
 
void adjustOrientation ()
 
virtual QRect availableGeometry () const
 Reimplement in subclass to return the pixel geometry of the available space This normally is the desktop screen minus the task manager, global menubar etc. More...
 
QPlatformCursorcursor () const
 
virtual int depth () const
 Reimplement in subclass to return current depth of the screen. More...
 
void ensureDisplayCreated ()
 
QBBWindowfindWindow (screen_window_t windowHandle)
 
virtual QImage::Format format () const
 Reimplement in subclass to return the image format which corresponds to the screen format. More...
 
virtual QRect geometry () const
 Reimplement in subclass to return the pixel geometry of the screen. More...
 
void lowerWindow (QBBWindow *window)
 
screen_context_t nativeContext () const
 
screen_display_t nativeDisplay () const
 
int nativeFormat () const
 
void onWindowPost (QBBWindow *window)
 
virtual QSize physicalSize () const
 Reimplement this function in subclass to return the physical size of the screen. More...
 
 QBBScreen (screen_context_t context, screen_display_t display, int screenIndex)
 
void raiseWindow (QBBWindow *window)
 
void removeWindow (QBBWindow *child)
 
QSharedPointer< QBBRootWindowrootWindow () const
 
int rotation () const
 
void updateHierarchy ()
 
const char * windowGroupName () const
 
virtual ~QBBScreen ()
 
- Public Functions inherited from QPlatformScreen
virtual void setDirty (const QRect &)
 
virtual QWidgettopLevelAt (const QPoint &point) const
 Return the given top level widget for a given position. More...
 
virtual ~QPlatformScreen ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void keyboardHeightChanged (int height)
 

Private Functions

void addOverlayWindow (screen_window_t window)
 
bool isPrimaryDisplay ()
 
void removeOverlayWindow (screen_window_t window)
 
void resizeNativeWidgetWindow (QBBWindow *w, const QRect &previousScreenGeometry) const
 
void resizeTopLevelWindow (QBBWindow *w, const QRect &previousScreenGeometry) const
 Resize the given window to fit the screen geometry. More...
 
void resizeWindows (const QRect &previousScreenGeometry)
 Adjust windows to the new screen geometry. More...
 
QWidgettopMostChildWindow () const
 

Properties

QList< QBBWindow * > mChildren
 
screen_context_t mContext
 
QRect mCurrentGeometry
 
QSize mCurrentPhysicalSize
 
int mCurrentRotation
 
QPlatformCursormCursor
 
screen_display_t mDisplay
 
int mKeyboardHeight
 
QList< screen_window_t > mOverlays
 
bool mPosted
 
bool mPrimaryDisplay
 
QSharedPointer< QBBRootWindowmRootWindow
 
int mScreenIndex
 
QRect mStartGeometry
 
QSize mStartPhysicalSize
 
int mStartRotation
 
bool mUsingOpenGL
 

Additional Inherited Members

- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QPlatformScreen
static QPlatformScreenplatformScreenForWidget (const QWidget *widget)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 56 of file qbbscreen.h.

Constructors and Destructors

◆ QBBScreen()

QBBScreen::QBBScreen ( screen_context_t  context,
screen_display_t  display,
int  screenIndex 
)

Definition at line 108 of file qbbscreen.cpp.

109  : mContext(context),
110  mDisplay(display),
111  mPosted(false),
112  mUsingOpenGL(false),
113  mPrimaryDisplay(screenIndex == 0),
114  mKeyboardHeight(0),
115  mScreenIndex(screenIndex),
116  mCursor(new QBBCursor(this))
117 {
118 #if defined(QBBSCREEN_DEBUG)
119  qDebug() << "QBBScreen::QBBScreen";
120 #endif
121 
122  // cache initial orientation of this display
123  // TODO: use ORIENTATION environment variable?
124  errno = 0;
125  int result = screen_get_display_property_iv(mDisplay, SCREEN_PROPERTY_ROTATION, &mStartRotation);
126  if (result != 0) {
127  qFatal("QBBScreen: failed to query display rotation, errno=%d", errno);
128  }
129 
131 
132  // cache size of this display in pixels
133  // TODO: use WIDTH and HEIGHT environment variables?
134  errno = 0;
135  int val[2];
136  result = screen_get_display_property_iv(mDisplay, SCREEN_PROPERTY_SIZE, val);
137  if (result != 0) {
138  qFatal("QBBScreen: failed to query display size, errno=%d", errno);
139  }
140 
141  mCurrentGeometry = mStartGeometry = QRect(0, 0, val[0], val[1]);
142 
143  // Cache size of this display in millimeters
145 
146  // swap physical dimensions when rotated orthogonally
147  if (mStartRotation == 90 || mStartRotation == 270)
149 
151 
152  // We only create the root window if we are not the primary display.
153  if (mPrimaryDisplay)
155 }
QSharedPointer< QBBRootWindow > mRootWindow
Definition: qbbscreen.h:115
QSize mStartPhysicalSize
Definition: qbbscreen.h:123
int mStartRotation
Definition: qbbscreen.h:120
bool mPosted
Definition: qbbscreen.h:116
screen_context_t mContext
Definition: qbbscreen.h:113
int mScreenIndex
Definition: qbbscreen.h:130
bool mPrimaryDisplay
Definition: qbbscreen.h:118
int mCurrentRotation
Definition: qbbscreen.h:121
Q_CORE_EXPORT void qDebug(const char *,...)
bool mUsingOpenGL
Definition: qbbscreen.h:117
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
QRect mCurrentGeometry
Definition: qbbscreen.h:126
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
static QSize determineScreenSize(screen_display_t display, bool primaryScreen)
Definition: qbbscreen.cpp:67
screen_display_t mDisplay
Definition: qbbscreen.h:114
QRect mStartGeometry
Definition: qbbscreen.h:125
int mKeyboardHeight
Definition: qbbscreen.h:122
Q_CORE_EXPORT void qFatal(const char *,...)
QSize mCurrentPhysicalSize
Definition: qbbscreen.h:124
QPlatformCursor * mCursor
Definition: qbbscreen.h:132
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int errno

◆ ~QBBScreen()

QBBScreen::~QBBScreen ( )
virtual

Definition at line 157 of file qbbscreen.cpp.

158 {
159 #if defined(QBBSCREEN_DEBUG)
160  qDebug() << "QBBScreen::~QBBScreen";
161 #endif
162 }
Q_CORE_EXPORT void qDebug(const char *,...)

Functions

◆ activateWindowGroup

void QBBScreen::activateWindowGroup ( const QByteArray id)
slot

Definition at line 553 of file qbbscreen.cpp.

Referenced by rootWindow().

554 {
555 #if defined(QBBSCREEN_DEBUG)
556  qDebug() << Q_FUNC_INFO;
557 #endif
558 
559  if (!rootWindow() || id != rootWindow()->groupName())
560  return;
561 
562  QWidget * const window = topMostChildWindow();
563 
564  if (!window)
565  return;
566 
568 }
QWidget * topMostChildWindow() const
Definition: qbbscreen.cpp:582
QSharedPointer< QBBRootWindow > rootWindow() const
Definition: qbbscreen.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
static void handleWindowActivated(QWidget *w)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ addOverlayWindow()

void QBBScreen::addOverlayWindow ( screen_window_t  window)
private

Definition at line 523 of file qbbscreen.cpp.

Referenced by newWindowCreated(), and rootWindow().

524 {
526  updateHierarchy();
527 }
NSWindow * window
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void updateHierarchy()
Definition: qbbscreen.cpp:456
QList< screen_window_t > mOverlays
Definition: qbbscreen.h:129

◆ addWindow()

void QBBScreen::addWindow ( QBBWindow child)

Definition at line 400 of file qbbscreen.cpp.

Referenced by QBBWindow::setParent(), QBBWindow::setScreen(), and windowGroupName().

401 {
402 #if defined(QBBSCREEN_DEBUG)
403  qDebug() << "QBBScreen::addWindow=" << window;
404 #endif
405 
407  return;
408 
409  // Ensure that the desktop window is at the bottom of the zorder.
410  // If we do not do this then we may end up activating the desktop
411  // when the navigator service gets an event that our window group
412  // has been activated (see QBBScreen::activateWindowGroup()).
413  // Such a situation would strangely break focus handling due to the
414  // invisible desktop widget window being layered on top of normal
415  // windows
416  if (window->widget()->windowType() == Qt::Desktop)
418  else
420  updateHierarchy();
421 }
void push_front(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:297
void push_back(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:296
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
void updateHierarchy()
Definition: qbbscreen.cpp:456
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128

◆ adjustOrientation()

void QBBScreen::adjustOrientation ( )

Definition at line 496 of file qbbscreen.cpp.

Referenced by QBBIntegration::createDisplay(), and windowGroupName().

497 {
498  if (!mPrimaryDisplay)
499  return;
500 
501  bool ok = false;
502  const int rotation = qgetenv("ORIENTATION").toInt(&ok);
503 
504  if (ok)
505  setRotation(rotation);
506 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
void setRotation(int rotation)
Definition: qbbscreen.cpp:229
bool mPrimaryDisplay
Definition: qbbscreen.h:118
int rotation() const
Definition: qbbscreen.h:69
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...

◆ availableGeometry()

QRect QBBScreen::availableGeometry ( ) const
virtual

Reimplement in subclass to return the pixel geometry of the available space This normally is the desktop screen minus the task manager, global menubar etc.

Reimplemented from QPlatformScreen.

Definition at line 209 of file qbbscreen.cpp.

Referenced by geometry().

210 {
211  // available geometry = total geometry - keyboard
214 }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QRect mCurrentGeometry
Definition: qbbscreen.h:126
int mKeyboardHeight
Definition: qbbscreen.h:122
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ cursor()

QPlatformCursor * QBBScreen::cursor ( ) const

Definition at line 508 of file qbbscreen.cpp.

Referenced by rootWindow().

509 {
510  return mCursor;
511 }
QPlatformCursor * mCursor
Definition: qbbscreen.h:132

◆ deactivateWindowGroup

void QBBScreen::deactivateWindowGroup ( const QByteArray id)
slot

Definition at line 570 of file qbbscreen.cpp.

Referenced by rootWindow().

571 {
572 #if defined(QBBSCREEN_DEBUG)
573  qDebug() << Q_FUNC_INFO;
574 #endif
575 
576  if (!rootWindow() || id != rootWindow()->groupName())
577  return;
578 
580 }
QSharedPointer< QBBRootWindow > rootWindow() const
Definition: qbbscreen.h:89
Q_CORE_EXPORT void qDebug(const char *,...)
static void handleWindowActivated(QWidget *w)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ depth()

int QBBScreen::depth ( ) const
virtual

Reimplement in subclass to return current depth of the screen.

Implements QPlatformScreen.

Definition at line 216 of file qbbscreen.cpp.

Referenced by format(), geometry(), nativeFormat(), and QBBGLContext::QBBGLContext().

217 {
218  return defaultDepth();
219 }
static int defaultDepth()
Definition: qbbscreen.cpp:164

◆ ensureDisplayCreated()

void QBBScreen::ensureDisplayCreated ( )

Definition at line 178 of file qbbscreen.cpp.

Referenced by QBBWindow::setScreen(), and windowGroupName().

179 {
180  if (!mRootWindow)
182 }
QSharedPointer< QBBRootWindow > mRootWindow
Definition: qbbscreen.h:115

◆ findWindow()

QBBWindow * QBBScreen::findWindow ( screen_window_t  windowHandle)

Definition at line 389 of file qbbscreen.cpp.

Referenced by newWindowCreated(), and windowGroupName().

390 {
392  QBBWindow * const result = window->findWindow(windowHandle);
393  if (result)
394  return result;
395  }
396 
397  return 0;
398 }
NSWindow * window
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
Definition: qglobal.h:2435
QBBWindow * findWindow(screen_window_t windowHandle)
Definition: qbbwindow.cpp:617

◆ format()

virtual QImage::Format QBBScreen::format ( ) const
inlinevirtual

Reimplement in subclass to return the image format which corresponds to the screen format.

Implements QPlatformScreen.

Definition at line 66 of file qbbscreen.h.

66 { return (depth() == 32) ? QImage::Format_RGB32 : QImage::Format_RGB16; }
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: qbbscreen.cpp:216

◆ geometry()

virtual QRect QBBScreen::geometry ( ) const
inlinevirtual

Reimplement in subclass to return the pixel geometry of the screen.

Implements QPlatformScreen.

Definition at line 63 of file qbbscreen.h.

Referenced by QBBRootWindow::QBBRootWindow(), resizeNativeWidgetWindow(), resizeTopLevelWindow(), and setRotation().

63 { return mCurrentGeometry; }
QRect mCurrentGeometry
Definition: qbbscreen.h:126

◆ isPrimaryDisplay()

bool QBBScreen::isPrimaryDisplay ( )
inlineprivate

Definition at line 134 of file qbbscreen.h.

134 { return mPrimaryDisplay; }
bool mPrimaryDisplay
Definition: qbbscreen.h:118

◆ keyboardHeightChanged

void QBBScreen::keyboardHeightChanged ( int  height)
privateslot

Definition at line 513 of file qbbscreen.cpp.

Referenced by rootWindow().

514 {
515  if (height == mKeyboardHeight)
516  return;
517 
518  mKeyboardHeight = height;
519 
521 }
static void handleScreenAvailableGeometryChange(int screenIndex)
int mScreenIndex
Definition: qbbscreen.h:130
int mKeyboardHeight
Definition: qbbscreen.h:122

◆ lowerWindow()

void QBBScreen::lowerWindow ( QBBWindow window)

Definition at line 445 of file qbbscreen.cpp.

Referenced by QBBWindow::lower(), and windowGroupName().

446 {
447 #if defined(QBBSCREEN_DEBUG)
448  qDebug() << "QBBScreen::lower window=" << window;
449 #endif
450 
451  removeWindow(window);
452  mChildren.push_front(window);
453  updateHierarchy();
454 }
void push_front(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:297
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
void updateHierarchy()
Definition: qbbscreen.cpp:456
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
void removeWindow(QBBWindow *child)
Definition: qbbscreen.cpp:423

◆ nativeContext()

screen_context_t QBBScreen::nativeContext ( ) const
inline

◆ nativeDisplay()

screen_display_t QBBScreen::nativeDisplay ( ) const
inline

◆ nativeFormat()

int QBBScreen::nativeFormat ( ) const
inline

Definition at line 71 of file qbbscreen.h.

Referenced by QBBRootWindow::QBBRootWindow(), and QBBWindow::setBufferSize().

71 { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; }
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
Definition: qbbscreen.cpp:216

◆ newWindowCreated

void QBBScreen::newWindowCreated ( screen_window_t  window)
slot

Definition at line 184 of file qbbscreen.cpp.

Referenced by rootWindow().

185 {
187  screen_display_t display = 0;
188  if (screen_get_window_property_pv(window, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) {
189  qWarning("QBBScreen: Failed to get screen for window, errno=%d", errno);
190  return;
191  }
192 
193  if (display == nativeDisplay()) {
194  // A window was created on this screen. If we don't know about this window yet, it means
195  // it was not created by Qt, but by some foreign library like the multimedia renderer, which
196  // creates an overlay window when playing a video.
197  // Treat all foreign windows as overlays here.
198  if (!findWindow(window))
200  }
201 }
void addOverlayWindow(screen_window_t window)
Definition: qbbscreen.cpp:523
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
NSWindow * window
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
Q_CORE_EXPORT void qWarning(const char *,...)
screen_display_t nativeDisplay() const
Definition: qbbscreen.h:72
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
QBBWindow * findWindow(screen_window_t windowHandle)
Definition: qbbscreen.cpp:389
int errno

◆ onWindowPost()

void QBBScreen::onWindowPost ( QBBWindow window)

Definition at line 483 of file qbbscreen.cpp.

Referenced by QBBWindow::post(), and windowGroupName().

484 {
485  Q_UNUSED(window)
486 
487  // post app window (so navigator will show it) after first child window
488  // has posted; this only needs to happen once as the app window's content
489  // never changes
490  if (!mPosted && mRootWindow) {
491  mRootWindow->post();
492  mPosted = true;
493  }
494 }
QSharedPointer< QBBRootWindow > mRootWindow
Definition: qbbscreen.h:115
bool mPosted
Definition: qbbscreen.h:116
void post() const
#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

◆ physicalSize()

virtual QSize QBBScreen::physicalSize ( ) const
inlinevirtual

Reimplement this function in subclass to return the physical size of the screen.

This function is used by QFont to convert point sizes to pixel sizes.

The default implementation takes the pixel size of the screen, considers a resolution of 100 dots per inch, and returns the calculated physical size. A device with a screen that has different resolutions will need to be supported by a suitable reimplementation of this function.

Reimplemented from QPlatformScreen.

Definition at line 67 of file qbbscreen.h.

67 { return mCurrentPhysicalSize; }
QSize mCurrentPhysicalSize
Definition: qbbscreen.h:124

◆ raiseWindow()

void QBBScreen::raiseWindow ( QBBWindow window)

Definition at line 434 of file qbbscreen.cpp.

Referenced by QBBWindow::raise(), and windowGroupName().

435 {
436 #if defined(QBBSCREEN_DEBUG)
437  qDebug() << "QBBScreen::raise window=" << window;
438 #endif
439 
440  removeWindow(window);
441  mChildren.push_back(window);
442  updateHierarchy();
443 }
void push_back(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:296
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
void updateHierarchy()
Definition: qbbscreen.cpp:456
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
void removeWindow(QBBWindow *child)
Definition: qbbscreen.cpp:423

◆ removeOverlayWindow()

void QBBScreen::removeOverlayWindow ( screen_window_t  window)
private

Definition at line 529 of file qbbscreen.cpp.

Referenced by rootWindow(), and windowClosed().

530 {
531  const int numOverlaysRemoved = mOverlays.removeAll(window);
532  if (numOverlaysRemoved > 0)
533  updateHierarchy();
534 }
NSWindow * window
void updateHierarchy()
Definition: qbbscreen.cpp:456
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
QList< screen_window_t > mOverlays
Definition: qbbscreen.h:129

◆ removeWindow()

void QBBScreen::removeWindow ( QBBWindow child)

Definition at line 423 of file qbbscreen.cpp.

Referenced by lowerWindow(), raiseWindow(), QBBWindow::removeFromParent(), QBBWindow::setScreen(), and windowGroupName().

424 {
425 #if defined(QBBSCREEN_DEBUG)
426  qDebug() << "QBBScreen::removeWindow=" << window;
427 #endif
428 
429  const int numWindowsRemoved = mChildren.removeAll(window);
430  if (numWindowsRemoved > 0)
431  updateHierarchy();
432 }
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
void updateHierarchy()
Definition: qbbscreen.cpp:456
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ resizeNativeWidgetWindow()

void QBBScreen::resizeNativeWidgetWindow ( QBBWindow w,
const QRect previousScreenGeometry 
) const
private

Definition at line 288 of file qbbscreen.cpp.

Referenced by resizeWindows(), and rootWindow().

289 {
290  const qreal relativeX = static_cast<qreal>(w->geometry().topLeft().x()) / previousScreenGeometry.width();
291  const qreal relativeY = static_cast<qreal>(w->geometry().topLeft().y()) / previousScreenGeometry.height();
292  const qreal relativeWidth = static_cast<qreal>(w->geometry().width()) / previousScreenGeometry.width();
293  const qreal relativeHeight = static_cast<qreal>(w->geometry().height()) / previousScreenGeometry.height();
294 
295  const QRect windowGeometry(relativeX * geometry().width(), relativeY * geometry().height(),
296  relativeWidth * geometry().width(), relativeHeight * geometry().height());
297 
298  w->widget()->setGeometry(windowGeometry);
299 }
double qreal
Definition: qglobal.h:1193
virtual QRect geometry() const
Returnes the current geometry of a window.
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
virtual QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
Definition: qbbscreen.h:63
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ resizeTopLevelWindow()

void QBBScreen::resizeTopLevelWindow ( QBBWindow w,
const QRect previousScreenGeometry 
) const
private

Resize the given window to fit the screen geometry.

Definition at line 304 of file qbbscreen.cpp.

Referenced by resizeWindows(), and rootWindow().

305 {
306  QRect windowGeometry = w->geometry();
307 
308  const qreal relativeCenterX = static_cast<qreal>(w->geometry().center().x()) / previousScreenGeometry.width();
309  const qreal relativeCenterY = static_cast<qreal>(w->geometry().center().y()) / previousScreenGeometry.height();
310  const QPoint newCenter(relativeCenterX * geometry().width(), relativeCenterY * geometry().height());
311 
312  windowGeometry.moveCenter(newCenter);
313 
314  // adjust center position in case the window
315  // is clipped
316  if (!geometry().contains(windowGeometry)) {
317  const int x1 = windowGeometry.x();
318  const int y1 = windowGeometry.y();
319  const int x2 = x1 + windowGeometry.width();
320  const int y2 = y1 + windowGeometry.height();
321 
322  if (x1 < 0) {
323  const int centerX = qMin(qAbs(x1) + windowGeometry.center().x(),
324  geometry().center().x());
325 
326  windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
327  }
328 
329  if (y1 < 0) {
330  const int centerY = qMin(qAbs(y1) + windowGeometry.center().y(),
331  geometry().center().y());
332 
333  windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
334  }
335 
336  if (x2 > geometry().width()) {
337  const int centerX = qMax(windowGeometry.center().x() - (x2 - geometry().width()),
338  geometry().center().x());
339 
340  windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
341  }
342 
343  if (y2 > geometry().height()) {
344  const int centerY = qMax(windowGeometry.center().y() - (y2 - geometry().height()),
345  geometry().center().y());
346 
347  windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
348  }
349  }
350 
351  // at this point, if the window is still clipped,
352  // it means that it's too big to fit on the screen,
353  // so we need to proportionally shrink it
354  if (!geometry().contains(windowGeometry)) {
355  QSize newSize = windowGeometry.size();
356  newSize.scale(geometry().size(), Qt::KeepAspectRatio);
357  windowGeometry.setSize(newSize);
358 
359  if (windowGeometry.x() < 0)
360  windowGeometry.moveCenter(QPoint(geometry().center().x(), windowGeometry.center().y()));
361 
362  if (windowGeometry.y() < 0)
363  windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), geometry().center().y()));
364  }
365 
366  w->widget()->setGeometry(windowGeometry);
367 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
virtual QRect geometry() const
Returnes the current geometry of a window.
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
virtual QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
Definition: qbbscreen.h:63
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void scale(int w, int h, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified mode: ...
Definition: qsize.h:138
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ resizeWindows()

void QBBScreen::resizeWindows ( const QRect previousScreenGeometry)
private

Adjust windows to the new screen geometry.

Definition at line 372 of file qbbscreen.cpp.

Referenced by rootWindow(), and setRotation().

373 {
375 
377  continue;
378 
379  if (w->widget()->parent()) {
380  // This is a native (non-alien) widget window
381  resizeNativeWidgetWindow(w, previousScreenGeometry);
382  } else {
383  // This is a toplevel window
384  resizeTopLevelWindow(w, previousScreenGeometry);
385  }
386  }
387 }
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void resizeNativeWidgetWindow(QBBWindow *w, const QRect &previousScreenGeometry) const
Definition: qbbscreen.cpp:288
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
Definition: qglobal.h:2435
void resizeTopLevelWindow(QBBWindow *w, const QRect &previousScreenGeometry) const
Resize the given window to fit the screen geometry.
Definition: qbbscreen.cpp:304
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ rootWindow()

QSharedPointer<QBBRootWindow> QBBScreen::rootWindow ( ) const
inline

Definition at line 89 of file qbbscreen.h.

Referenced by activateWindowGroup(), deactivateWindowGroup(), QBBNativeInterface::nativeResourceForWidget(), and windowGroupStateChanged().

89 { return mRootWindow; }
QSharedPointer< QBBRootWindow > mRootWindow
Definition: qbbscreen.h:115

◆ rotation()

int QBBScreen::rotation ( ) const
inline

Definition at line 69 of file qbbscreen.h.

Referenced by adjustOrientation(), rootWindow(), and setRotation().

69 { return mCurrentRotation; }
int mCurrentRotation
Definition: qbbscreen.h:121

◆ setRotation

void QBBScreen::setRotation ( int  rotation)
slot

Definition at line 229 of file qbbscreen.cpp.

Referenced by adjustOrientation(), and rootWindow().

230 {
231 #if defined(QBBSCREEN_DEBUG)
232  qDebug() << "QBBScreen::setRotation, o=" << rotation;
233 #endif
234 
235  // check if rotation changed
236  if (mCurrentRotation != rotation) {
237  // update rotation of root window
238  if (mRootWindow)
240 
241  const QRect previousScreenGeometry = geometry();
242 
243  // swap dimensions if we've rotated 90 or 270 from initial orientation
247  } else {
249  mCurrentPhysicalSize = mStartPhysicalSize;
250  }
251 
252  // resize app window if we've rotated 90 or 270 from previous orientation
254 
255 #if defined(QBBSCREEN_DEBUG)
256  qDebug() << "QBBScreen::setRotation - resize, s=" << mCurrentGeometry.size();
257 #endif
258  if (mRootWindow)
260 
261  if (mPrimaryDisplay)
262  resizeWindows(previousScreenGeometry);
263  } else {
264  // TODO: find one global place to flush display updates
265 #if defined(QBBSCREEN_DEBUG)
266  qDebug() << "QBBScreen::setRotation - flush";
267 #endif
268  // force immediate display update if no geometry changes required
269  if (mRootWindow)
270  mRootWindow->flush();
271  }
272 
273  // save new rotation
275 
276  // TODO: check if other screens are supposed to rotate as well and/or whether this depends
277  // on if clone mode is being used.
278  // Rotating only the primary screen is what we had in the navigator event handler before refactoring
279  if (mPrimaryDisplay)
281 
282  // Flush everything, so that the windows rotations are applied properly.
283  // Needed for non-maximized windows
284  screen_flush_context(mContext, 0);
285  }
286 }
QSharedPointer< QBBRootWindow > mRootWindow
Definition: qbbscreen.h:115
QSize mStartPhysicalSize
Definition: qbbscreen.h:123
int mStartRotation
Definition: qbbscreen.h:120
screen_context_t mContext
Definition: qbbscreen.h:113
static void handleScreenGeometryChange(int screenIndex)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void resizeWindows(const QRect &previousScreenGeometry)
Adjust windows to the new screen geometry.
Definition: qbbscreen.cpp:372
int mScreenIndex
Definition: qbbscreen.h:130
bool mPrimaryDisplay
Definition: qbbscreen.h:118
void flush() const
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int mCurrentRotation
Definition: qbbscreen.h:121
void resize(const QSize &size)
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
Definition: qsize.h:126
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QRect mCurrentGeometry
Definition: qbbscreen.h:126
int rotation() const
Definition: qbbscreen.h:69
virtual QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
Definition: qbbscreen.h:63
static bool isOrthogonal(int angle1, int angle2)
Check if the supplied angles are perpendicular to each other.
Definition: qbbscreen.cpp:224
QRect mStartGeometry
Definition: qbbscreen.h:125
QSize mCurrentPhysicalSize
Definition: qbbscreen.h:124
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setRotation(int rotation)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ topMostChildWindow()

QWidget * QBBScreen::topMostChildWindow ( ) const
private

Definition at line 582 of file qbbscreen.cpp.

Referenced by activateWindowGroup(), rootWindow(), and windowGroupStateChanged().

583 {
584  if (!mChildren.isEmpty()) {
585 
586  // We're picking up the last window of the list here
587  // because this list is ordered by stacking order.
588  // Last window is effectively the one on top.
589  return mChildren.last()->widget();
590  }
591 
592  return 0;
593 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ updateHierarchy()

void QBBScreen::updateHierarchy ( )

Definition at line 456 of file qbbscreen.cpp.

Referenced by addOverlayWindow(), addWindow(), QBBWindow::lower(), lowerWindow(), QBBWindow::raise(), raiseWindow(), removeOverlayWindow(), removeWindow(), QBBWindow::setParent(), QBBWindow::setScreen(), windowGroupName(), and QBBWindow::~QBBWindow().

457 {
458 #if defined(QBBSCREEN_DEBUG)
459  qDebug() << "QBBScreen::updateHierarchy";
460 #endif
461 
463  int topZorder = 1; // root window is z-order 0, all "top" level windows are "above" it
464 
465  for (it = mChildren.constBegin(); it != mChildren.constEnd(); ++it) {
466  (*it)->updateZorder(topZorder);
467  }
468 
469  topZorder++;
470  Q_FOREACH (screen_window_t overlay, mOverlays) {
471  // Do nothing when this fails. This can happen if we have stale windows in mOverlays,
472  // which in turn can happen because a window was removed but we didn't get a notification
473  // yet.
474  screen_set_window_property_iv(overlay, SCREEN_PROPERTY_ZORDER, &topZorder);
475  topZorder++;
476  }
477 
478  // After a hierarchy update, we need to force a flush on all screens.
479  // Right now, all screens share a context.
480  screen_flush_context( mContext, 0 );
481 }
#define it(className, varName)
screen_context_t mContext
Definition: qbbscreen.h:113
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
Q_CORE_EXPORT void qDebug(const char *,...)
QList< QBBWindow * > mChildren
Definition: qbbscreen.h:128
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
Definition: qglobal.h:2435
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
QList< screen_window_t > mOverlays
Definition: qbbscreen.h:129

◆ windowClosed

void QBBScreen::windowClosed ( screen_window_t  window)
slot

Definition at line 203 of file qbbscreen.cpp.

Referenced by rootWindow().

204 {
207 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
NSWindow * window
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
void removeOverlayWindow(screen_window_t window)
Definition: qbbscreen.cpp:529
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419

◆ windowGroupName()

const char* QBBScreen::windowGroupName ( ) const
inline

Definition at line 74 of file qbbscreen.h.

Referenced by QBBWindow::setScreen().

74 { return mRootWindow->groupName().constData(); }
QSharedPointer< QBBRootWindow > mRootWindow
Definition: qbbscreen.h:115
QByteArray groupName() const
Definition: qbbrootwindow.h:69
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433

◆ windowGroupStateChanged

void QBBScreen::windowGroupStateChanged ( const QByteArray id,
Qt::WindowState  state 
)
slot

Definition at line 536 of file qbbscreen.cpp.

Referenced by rootWindow().

537 {
538 #if defined(QBBSCREEN_DEBUG)
539  qDebug() << Q_FUNC_INFO;
540 #endif
541 
542  if (!rootWindow() || id != rootWindow()->groupName())
543  return;
544 
545  QWidget * const window = topMostChildWindow();
546 
547  if (!window)
548  return;
549 
551 }
QWidget * topMostChildWindow() const
Definition: qbbscreen.cpp:582
QSharedPointer< QBBRootWindow > rootWindow() const
Definition: qbbscreen.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
static void handleWindowStateChanged(QWidget *w, Qt::WindowState newState)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Properties

◆ mChildren

QList<QBBWindow*> QBBScreen::mChildren
private

◆ mContext

screen_context_t QBBScreen::mContext
private

Definition at line 113 of file qbbscreen.h.

Referenced by nativeContext(), setRotation(), and updateHierarchy().

◆ mCurrentGeometry

QRect QBBScreen::mCurrentGeometry
private

Definition at line 126 of file qbbscreen.h.

Referenced by availableGeometry(), geometry(), QBBScreen(), and setRotation().

◆ mCurrentPhysicalSize

QSize QBBScreen::mCurrentPhysicalSize
private

Definition at line 124 of file qbbscreen.h.

Referenced by physicalSize(), QBBScreen(), and setRotation().

◆ mCurrentRotation

int QBBScreen::mCurrentRotation
private

Definition at line 121 of file qbbscreen.h.

Referenced by QBBScreen(), rotation(), and setRotation().

◆ mCursor

QPlatformCursor* QBBScreen::mCursor
private

Definition at line 132 of file qbbscreen.h.

Referenced by cursor().

◆ mDisplay

screen_display_t QBBScreen::mDisplay
private

Definition at line 114 of file qbbscreen.h.

Referenced by nativeDisplay(), and QBBScreen().

◆ mKeyboardHeight

int QBBScreen::mKeyboardHeight
private

Definition at line 122 of file qbbscreen.h.

Referenced by availableGeometry(), and keyboardHeightChanged().

◆ mOverlays

QList<screen_window_t> QBBScreen::mOverlays
private

Definition at line 129 of file qbbscreen.h.

Referenced by addOverlayWindow(), removeOverlayWindow(), and updateHierarchy().

◆ mPosted

bool QBBScreen::mPosted
private

Definition at line 116 of file qbbscreen.h.

Referenced by onWindowPost().

◆ mPrimaryDisplay

bool QBBScreen::mPrimaryDisplay
private

Definition at line 118 of file qbbscreen.h.

Referenced by adjustOrientation(), isPrimaryDisplay(), QBBScreen(), and setRotation().

◆ mRootWindow

QSharedPointer<QBBRootWindow> QBBScreen::mRootWindow
private

◆ mScreenIndex

int QBBScreen::mScreenIndex
private

Definition at line 130 of file qbbscreen.h.

Referenced by keyboardHeightChanged(), and setRotation().

◆ mStartGeometry

QRect QBBScreen::mStartGeometry
private

Definition at line 125 of file qbbscreen.h.

Referenced by QBBScreen(), and setRotation().

◆ mStartPhysicalSize

QSize QBBScreen::mStartPhysicalSize
private

Definition at line 123 of file qbbscreen.h.

Referenced by QBBScreen(), and setRotation().

◆ mStartRotation

int QBBScreen::mStartRotation
private

Definition at line 120 of file qbbscreen.h.

Referenced by QBBScreen(), and setRotation().

◆ mUsingOpenGL

bool QBBScreen::mUsingOpenGL
private

Definition at line 117 of file qbbscreen.h.


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