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

#include <qbbrootwindow.h>

Public Functions

void flush () const
 
QByteArray groupName () const
 
screen_window_t nativeHandle () const
 
void post () const
 
 QBBRootWindow (QBBScreen *screen)
 
void resize (const QSize &size)
 
void setRotation (int rotation)
 
 ~QBBRootWindow ()
 

Private Functions

void createWindowGroup ()
 

Properties

QBBScreenm_screen
 
screen_window_t m_window
 
QByteArray m_windowGroupName
 

Detailed Description

Definition at line 54 of file qbbrootwindow.h.

Constructors and Destructors

◆ QBBRootWindow()

QBBRootWindow::QBBRootWindow ( QBBScreen screen)

Definition at line 57 of file qbbrootwindow.cpp.

58  : m_screen(screen),
59  m_window(0),
61 {
62 #if defined(QBBROOTWINDOW_DEBUG)
63  qDebug() << Q_FUNC_INFO;
64 #endif
65  // Create one top-level QNX window to act as a container for child windows
66  // since navigator only supports one application window
67  errno = 0;
68  int result = screen_create_window(&m_window, m_screen->nativeContext());
69  int val[2];
70  if (result != 0) {
71  qFatal("QBBRootWindow: failed to create window, errno=%d", errno);
72  }
73 
74  // Move window to proper display
75  errno = 0;
76  screen_display_t display = m_screen->nativeDisplay();
77  result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display);
78  if (result != 0) {
79  qFatal("QBBRootWindow: failed to set window display, errno=%d", errno);
80  }
81 
82  // Make sure window is above navigator but below keyboard if running as root
83  // since navigator won't automatically set our z-order in this case
84  if (getuid() == 0) {
85  errno = 0;
86  val[0] = MAGIC_ZORDER_FOR_NO_NAV;
87  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, val);
88  if (result != 0) {
89  qFatal("QBBRootWindow: failed to set window z-order, errno=%d", errno);
90  }
91  }
92 
93  // Window won't be visible unless it has some buffers so make one dummy buffer that is 1x1
94  errno = 0;
95  val[0] = SCREEN_USAGE_NATIVE;
96  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, val);
97  if (result != 0) {
98  qFatal("QBBRootWindow: failed to set window buffer usage, errno=%d", errno);
99  }
100 
101  errno = 0;
102  val[0] = m_screen->nativeFormat();
103  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val);
104  if (result != 0) {
105  qFatal("QBBRootWindow: failed to set window pixel format, errno=%d", errno);
106  }
107 
108  errno = 0;
109  val[0] = 1;
110  val[1] = 1;
111  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val);
112  if (result != 0) {
113  qFatal("QBBRootWindow: failed to set window buffer size, errno=%d", errno);
114  }
115 
116  errno = 0;
117  result = screen_create_window_buffers(m_window, 1);
118  if (result != 0) {
119  qFatal("QBB: failed to create window buffer, errno=%d", errno);
120  }
121 
122  // Window is always the size of the display
123  errno = 0;
124  QRect geometry = m_screen->geometry();
125  val[0] = geometry.width();
126  val[1] = geometry.height();
127  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val);
128  if (result != 0) {
129  qFatal("QBBRootWindow: failed to set window size, errno=%d", errno);
130  }
131 
132  // Fill the window with solid black
133  errno = 0;
134  val[0] = 0;
135  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_COLOR, val);
136  if (result != 0) {
137  qFatal("QBBRootWindow: failed to set window colour, errno=%d", errno);
138  }
139 
140  // Make the window opaque
141  errno = 0;
142  val[0] = SCREEN_TRANSPARENCY_NONE;
143  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val);
144  if (result != 0) {
145  qFatal("QBBRootWindow: failed to set window transparency, errno=%d", errno);
146  }
147 
148  // Set the swap interval to 1
149  errno = 0;
150  val[0] = 1;
151  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, val);
152  if (result != 0) {
153  qFatal("QBBRootWindow: failed to set window swap interval, errno=%d", errno);
154  }
155 
156  // Set viewport size equal to window size but move outside buffer so the fill colour is used exclusively
157  errno = 0;
158  val[0] = geometry.width();
159  val[1] = geometry.height();
160  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val);
161  if (result != 0) {
162  qFatal("QBBRootWindow: failed to set window source size, errno=%d", errno);
163  }
164 
165  errno = 0;
166  val[0] = 1;
167  val[1] = 0;
168  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_POSITION, val);
169  if (result != 0) {
170  qFatal("QBBRootWindow: failed to set window source position, errno=%d", errno);
171  }
172 
174  post();
175 }
int nativeFormat() const
Definition: qbbscreen.h:71
QByteArray m_windowGroupName
Definition: qbbrootwindow.h:76
screen_context_t nativeContext() const
Definition: qbbscreen.h:73
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
void post() const
Q_CORE_EXPORT void qDebug(const char *,...)
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
virtual QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
Definition: qbbscreen.h:63
screen_display_t nativeDisplay() const
Definition: qbbscreen.h:72
Q_CORE_EXPORT void qFatal(const char *,...)
QBBScreen * m_screen
Definition: qbbrootwindow.h:74
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
screen_window_t m_window
Definition: qbbrootwindow.h:75
void createWindowGroup()
static const int MAGIC_ZORDER_FOR_NO_NAV
int errno
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ ~QBBRootWindow()

QBBRootWindow::~QBBRootWindow ( )

Definition at line 177 of file qbbrootwindow.cpp.

178 {
179  // Cleanup top-level QNX window
180  screen_destroy_window(m_window);
181 }
screen_window_t m_window
Definition: qbbrootwindow.h:75

Functions

◆ createWindowGroup()

void QBBRootWindow::createWindowGroup ( )
private

Definition at line 246 of file qbbrootwindow.cpp.

Referenced by groupName(), and QBBRootWindow().

247 {
248  // Generate a random window group name
250 
251  // Create window group so child windows can be parented by container window
252  errno = 0;
253  int result = screen_create_window_group(m_window, m_windowGroupName.constData());
254  if (result != 0) {
255  qFatal("QBBRootWindow: failed to create app window group, errno=%d", errno);
256  }
257 }
QByteArray m_windowGroupName
Definition: qbbrootwindow.h:76
static QUuid createUuid()
On any platform other than Windows, this function returns a new UUID with variant QUuid::DCE and vers...
Definition: quuid.cpp:897
QString toString() const
Returns the string representation of this QUuid.
Definition: quuid.cpp:512
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
Q_CORE_EXPORT void qFatal(const char *,...)
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
screen_window_t m_window
Definition: qbbrootwindow.h:75
int errno

◆ flush()

void QBBRootWindow::flush ( ) const

Definition at line 203 of file qbbrootwindow.cpp.

Referenced by nativeHandle(), and QBBScreen::setRotation().

204 {
205 #if defined(QBBROOTWINDOW_DEBUG)
206  qDebug() << Q_FUNC_INFO;
207 #endif
208  // Force immediate display update
209  errno = 0;
210  int result = screen_flush_context(m_screen->nativeContext(), 0);
211  if (result != 0) {
212  qFatal("QBBRootWindow: failed to flush context, errno=%d", errno);
213  }
214 }
screen_context_t nativeContext() const
Definition: qbbscreen.h:73
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qFatal(const char *,...)
QBBScreen * m_screen
Definition: qbbrootwindow.h:74
int errno
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ groupName()

QByteArray QBBRootWindow::groupName ( ) const
inline

Definition at line 69 of file qbbrootwindow.h.

Referenced by QBBNativeInterface::nativeResourceForWidget(), and QBBScreen::windowGroupName().

69 { return m_windowGroupName; }
QByteArray m_windowGroupName
Definition: qbbrootwindow.h:76

◆ nativeHandle()

screen_window_t QBBRootWindow::nativeHandle ( ) const
inline

Definition at line 60 of file qbbrootwindow.h.

60 { return m_window; }
screen_window_t m_window
Definition: qbbrootwindow.h:75

◆ post()

void QBBRootWindow::post ( ) const

Definition at line 183 of file qbbrootwindow.cpp.

Referenced by nativeHandle(), QBBScreen::onWindowPost(), and QBBRootWindow().

184 {
185 #if defined(QBBROOTWINDOW_DEBUG)
186  qDebug() << Q_FUNC_INFO;
187 #endif
188  errno = 0;
189  screen_buffer_t buffer;
190  int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&buffer);
191  if (result != 0) {
192  qFatal("QBBRootWindow: failed to query window buffer, errno=%d", errno);
193  }
194 
195  errno = 0;
196  int dirtyRect[] = {0, 0, 1, 1};
197  result = screen_post_window(m_window, buffer, 1, dirtyRect, 0);
198  if (result != 0) {
199  qFatal("QBB: failed to post window buffer, errno=%d", errno);
200  }
201 }
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qFatal(const char *,...)
screen_window_t m_window
Definition: qbbrootwindow.h:75
int errno
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ resize()

void QBBRootWindow::resize ( const QSize size)

Definition at line 228 of file qbbrootwindow.cpp.

Referenced by nativeHandle(), and QBBScreen::setRotation().

229 {
230  errno = 0;
231  int val[] = {size.width(), size.height()};
232  int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val);
233  if (result != 0) {
234  qFatal("QBBRootWindow: failed to set window size, errno=%d", errno);
235  }
236 
237  errno = 0;
238  result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val);
239  if (result != 0) {
240  qFatal("QBBRootWindow: failed to set window source size, errno=%d", errno);
241  }
242 
243  // NOTE: display will update when child windows relayout and repaint
244 }
int width() const
Returns the width.
Definition: qsize.h:126
Q_CORE_EXPORT void qFatal(const char *,...)
int height() const
Returns the height.
Definition: qsize.h:129
screen_window_t m_window
Definition: qbbrootwindow.h:75
int errno

◆ setRotation()

void QBBRootWindow::setRotation ( int  rotation)

Definition at line 216 of file qbbrootwindow.cpp.

Referenced by nativeHandle(), and QBBScreen::setRotation().

217 {
218 #if defined(QBBROOTWINDOW_DEBUG)
219  qDebug() << Q_FUNC_INFO << "angle =" << rotation;
220 #endif
221  errno = 0;
222  int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation);
223  if (result != 0) {
224  qFatal("QBBRootWindow: failed to set window rotation, errno=%d", errno);
225  }
226 }
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qFatal(const char *,...)
screen_window_t m_window
Definition: qbbrootwindow.h:75
int errno
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Properties

◆ m_screen

QBBScreen* QBBRootWindow::m_screen
private

Definition at line 74 of file qbbrootwindow.h.

Referenced by flush(), and QBBRootWindow().

◆ m_window

screen_window_t QBBRootWindow::m_window
private

◆ m_windowGroupName

QByteArray QBBRootWindow::m_windowGroupName
private

Definition at line 76 of file qbbrootwindow.h.

Referenced by createWindowGroup(), and groupName().


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