Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqnxscreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2011 - 2013 BlackBerry Limited. All rights reserved.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
5
6#include "qqnxglobal.h"
7
8#include "qqnxscreen.h"
9#include "qqnxwindow.h"
10#include "qqnxcursor.h"
11
12#include <QtCore/QThread>
13#include <QtCore/QDebug>
14#include <qpa/qwindowsysteminterface.h>
15
16#include <errno.h>
17
18#if defined(QQNX_PHYSICAL_SCREEN_WIDTH) && QQNX_PHYSICAL_SCREEN_WIDTH > 0 \
19 && defined(QQNX_PHYSICAL_SCREEN_HEIGHT) && QQNX_PHYSICAL_SCREEN_HEIGHT > 0
20#define QQNX_PHYSICAL_SCREEN_SIZE_DEFINED
21#elif defined(QQNX_PHYSICAL_SCREEN_WIDTH) || defined(QQNX_PHYSICAL_SCREEN_HEIGHT)
22#error Please define QQNX_PHYSICAL_SCREEN_WIDTH and QQNX_PHYSICAL_SCREEN_HEIGHT to values greater than zero
23#endif
24
25// The maximum z-order at which a foreign window will be considered
26// an underlay.
27static const int MAX_UNDERLAY_ZORDER = -1;
28
30
31Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen");
32
33static QSize determineScreenSize(screen_display_t display, bool primaryScreen) {
34 int val[2];
35
36 const int result = screen_get_display_property_iv(display, SCREEN_PROPERTY_PHYSICAL_SIZE, val);
37 Q_SCREEN_CHECKERROR(result, "Failed to query display physical size");
38 if (result != 0) {
39 return QSize(150, 90);
40 }
41
42 if (val[0] > 0 && val[1] > 0)
43 return QSize(val[0], val[1]);
44
45 qCDebug(lcQpaScreen, "QQnxScreen: screen_get_display_property_iv() reported an invalid "
46 "physical screen size (%dx%d). Falling back to QQNX_PHYSICAL_SCREEN_SIZE "
47 "environment variable.", val[0], val[1]);
48
49 const QString envPhySizeStr = qgetenv("QQNX_PHYSICAL_SCREEN_SIZE");
50 if (!envPhySizeStr.isEmpty()) {
51 const auto envPhySizeStrList = QStringView{envPhySizeStr}.split(u',');
52 const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
53 const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;
54
55 if (envWidth <= 0 || envHeight <= 0) {
56 qWarning("QQnxScreen: The value of QQNX_PHYSICAL_SCREEN_SIZE must be in the format "
57 "\"width,height\" in mm, with width, height > 0. Defaulting to 150x90. "
58 "Example: QQNX_PHYSICAL_SCREEN_SIZE=150,90");
59 return QSize(150, 90);
60 }
61
62 return QSize(envWidth, envHeight);
63 }
64
65#if defined(QQNX_PHYSICAL_SCREEN_SIZE_DEFINED)
66 const QSize defSize(QQNX_PHYSICAL_SCREEN_WIDTH, QQNX_PHYSICAL_SCREEN_HEIGHT);
67 qWarning("QQnxScreen: QQNX_PHYSICAL_SCREEN_SIZE variable not set. Falling back to defines "
68 "QQNX_PHYSICAL_SCREEN_WIDTH/QQNX_PHYSICAL_SCREEN_HEIGHT (%dx%d)",
69 defSize.width(), defSize.height());
70 return defSize;
71#else
72 if (primaryScreen)
73 qWarning("QQnxScreen: QQNX_PHYSICAL_SCREEN_SIZE variable not set. "
74 "Could not determine physical screen size. Defaulting to 150x90.");
75 return QSize(150, 90);
76#endif
77}
78
79QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, bool primaryScreen)
80 : m_screenContext(screenContext),
81 m_display(display),
82 m_rootWindow(0),
83 m_primaryScreen(primaryScreen),
84 m_keyboardHeight(0),
85 m_nativeOrientation(Qt::PrimaryOrientation),
86 m_coverWindow(0),
87 m_cursor(new QQnxCursor())
88{
89 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
90 // Cache initial orientation of this display
91 int result = screen_get_display_property_iv(m_display, SCREEN_PROPERTY_ROTATION,
92 &m_initialRotation);
93 Q_SCREEN_CHECKERROR(result, "Failed to query display rotation");
94
95 m_currentRotation = m_initialRotation;
96
97 // Cache size of this display in pixels
98 int val[2];
99 Q_SCREEN_CRITICALERROR(screen_get_display_property_iv(m_display, SCREEN_PROPERTY_SIZE, val),
100 "Failed to query display size");
101
102 m_currentGeometry = m_initialGeometry = QRect(0, 0, val[0], val[1]);
103
104 char name[100];
105 Q_SCREEN_CHECKERROR(screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, 100,
106 name), "Failed to query display name");
107 m_name = QString::fromUtf8(name);
108
109 // Cache size of this display in millimeters. We have to take care of the orientation.
110 // libscreen always reports the physical size dimensions as width and height in the
111 // native orientation. Contrary to this, QPlatformScreen::physicalSize() expects the
112 // returned dimensions to follow the current orientation.
113 const QSize screenSize = determineScreenSize(m_display, primaryScreen);
114
115 m_nativeOrientation = screenSize.width() >= screenSize.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
116
117 const int angle = screen()->angleBetween(m_nativeOrientation, orientation());
118 if (angle == 0 || angle == 180)
119 m_currentPhysicalSize = m_initialPhysicalSize = screenSize;
120 else
121 m_currentPhysicalSize = m_initialPhysicalSize = screenSize.transposed();
122}
123
125{
126 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
127 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
128 childWindow->setScreen(0);
129
130 if (m_coverWindow)
131 m_coverWindow->setScreen(0);
132
133 delete m_cursor;
134}
135
136QPixmap QQnxScreen::grabWindow(WId window, int x, int y, int width, int height) const
137{
138 QQnxWindow *qnxWin = findWindow(reinterpret_cast<screen_window_t>(window));
139 if (!qnxWin) {
140 qWarning("grabWindow: unknown window");
141 return QPixmap();
142 }
143
144 QRect bound = qnxWin->geometry();
145
146 if (width < 0)
147 width = bound.width();
148 if (height < 0)
149 height = bound.height();
150
151 bound &= QRect(x + bound.x(), y + bound.y(), width, height);
152
153 if (bound.width() <= 0 || bound.height() <= 0) {
154 qWarning("grabWindow: size is null");
155 return QPixmap();
156 }
157
158 // Create new context, only SCREEN_DISPLAY_MANAGER_CONTEXT can read from screen
159 screen_context_t context;
160 if (screen_create_context(&context, SCREEN_DISPLAY_MANAGER_CONTEXT)) {
161 if (errno == EPERM)
162 qWarning("grabWindow: root privileges required");
163 else
164 qWarning("grabWindow: cannot create context");
165 return QPixmap();
166 }
167
168 // Find corresponding display in SCREEN_DISPLAY_MANAGER_CONTEXT
169 int count = 0;
170 screen_display_t display = 0;
171 screen_get_context_property_iv(context, SCREEN_PROPERTY_DISPLAY_COUNT, &count);
172 if (count > 0) {
173 const size_t idLen = 30;
174 char matchId[idLen];
175 char id[idLen];
176 bool found = false;
177
178 screen_display_t *displays = static_cast<screen_display_t*>
179 (calloc(count, sizeof(screen_display_t)));
180 screen_get_context_property_pv(context, SCREEN_PROPERTY_DISPLAYS, (void **)displays);
181 screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, idLen, matchId);
182
183 while (count && !found) {
184 --count;
185 screen_get_display_property_cv(displays[count], SCREEN_PROPERTY_ID_STRING, idLen, id);
186 found = !strncmp(id, matchId, idLen);
187 }
188
189 if (found)
190 display = displays[count];
191
192 free(displays);
193 }
194
195 // Create screen and Qt pixmap
196 screen_pixmap_t pixmap;
198 if (display && !screen_create_pixmap(&pixmap, context)) {
199 screen_buffer_t buffer;
200 void *pointer;
201 int stride;
202 const int rect[4] = { bound.x(), bound.y(), bound.width(), bound.height() };
203
204 int val = SCREEN_USAGE_READ | SCREEN_USAGE_NATIVE;
205 screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_USAGE, &val);
206 val = SCREEN_FORMAT_RGBA8888;
207 screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_FORMAT, &val);
208
209 int err = screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);
210 err = err || screen_create_pixmap_buffer(pixmap);
211 err = err || screen_get_pixmap_property_pv(pixmap, SCREEN_PROPERTY_RENDER_BUFFERS,
212 reinterpret_cast<void**>(&buffer));
213 err = err || screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, &pointer);
214 err = err || screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);
215 err = err || screen_read_display(display, buffer, 1, rect, 0);
216
217 if (!err) {
218 const QImage img(static_cast<unsigned char*>(pointer),
219 bound.width(), bound.height(), stride, QImage::Format_ARGB32);
221 } else {
222 qWarning("grabWindow: capture error");
223 }
224 screen_destroy_pixmap(pixmap);
225 } else {
226 qWarning("grabWindow: display/pixmap error ");
227 }
228 screen_destroy_context(context);
229
230 return result;
231}
232
233static int defaultDepth()
234{
235 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
236 static int defaultDepth = 0;
237 if (defaultDepth == 0) {
238 // check if display depth was specified in environment variable;
239 // use default value if no valid value found
240 defaultDepth = qEnvironmentVariableIntValue("QQNX_DISPLAY_DEPTH");
241 if (defaultDepth != 16 && defaultDepth != 32)
242 defaultDepth = 32;
243 }
244 return defaultDepth;
245}
246
248{
249 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
250 // available geometry = total geometry - keyboard
251 return QRect(m_currentGeometry.x(), m_currentGeometry.y(),
252 m_currentGeometry.width(), m_currentGeometry.height() - m_keyboardHeight);
253}
254
256{
257 return defaultDepth();
258}
259
261{
262 screen_display_mode_t displayMode;
263 int result = screen_get_display_property_pv(m_display, SCREEN_PROPERTY_MODE, reinterpret_cast<void **>(&displayMode));
264 // Screen shouldn't really return 0 but it does so default to 60 or things break.
265 if (result != 0 || displayMode.refresh == 0) {
266 qWarning("QQnxScreen: Failed to query screen mode. Using default value of 60Hz");
267 return 60.0;
268 }
269 qCDebug(lcQpaScreen, "screen mode:\n"
270 " width = %u\n"
271 " height = %u\n"
272 " refresh = %u\n"
273 " interlaced = %u",
274 uint(displayMode.width), uint(displayMode.height), uint(displayMode.refresh), uint(displayMode.interlaced));
275 return static_cast<qreal>(displayMode.refresh);
276}
277
279{
280 return m_nativeOrientation;
281}
282
284{
286 if (m_nativeOrientation == Qt::LandscapeOrientation) {
287 // Landscape devices e.g. PlayBook
288 if (m_currentRotation == 0)
290 else if (m_currentRotation == 90)
292 else if (m_currentRotation == 180)
294 else
296 } else {
297 // Portrait devices e.g. Phones
298 // ###TODO Check these on an actual phone device
299 if (m_currentRotation == 0)
301 else if (m_currentRotation == 90)
303 else if (m_currentRotation == 180)
305 else
307 }
308 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "Orientation =" << orient;
309 return orient;
310}
311
313{
314 for (auto it = m_childWindows.rbegin(), end = m_childWindows.rend(); it != end; ++it) {
315 QWindow *win = (*it)->window();
316 if (win->geometry().contains(point))
317 return win;
318 }
319 return 0;
320}
321
325static bool isOrthogonal(int angle1, int angle2)
326{
327 return ((angle1 - angle2) % 180) != 0;
328}
329
330void QQnxScreen::setRotation(int rotation)
331{
332 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "orientation =" << rotation;
333 // Check if rotation changed
334 // We only want to rotate if we are the primary screen
335 if (m_currentRotation != rotation && isPrimaryScreen()) {
336 // Update rotation of root window
337 if (rootWindow())
339
340 const QRect previousScreenGeometry = geometry();
341
342 // Swap dimensions if we've rotated 90 or 270 from initial orientation
343 if (isOrthogonal(m_initialRotation, rotation)) {
344 m_currentGeometry = QRect(0, 0, m_initialGeometry.height(), m_initialGeometry.width());
345 m_currentPhysicalSize = QSize(m_initialPhysicalSize.height(), m_initialPhysicalSize.width());
346 } else {
347 m_currentGeometry = QRect(0, 0, m_initialGeometry.width(), m_initialGeometry.height());
348 m_currentPhysicalSize = m_initialPhysicalSize;
349 }
350
351 // Resize root window if we've rotated 90 or 270 from previous orientation
352 if (isOrthogonal(m_currentRotation, rotation)) {
353 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "resize, size =" << m_currentGeometry.size();
354 if (rootWindow())
355 rootWindow()->setGeometry(QRect(QPoint(0,0), m_currentGeometry.size()));
356
357 resizeWindows(previousScreenGeometry);
358 } else {
359 // TODO: Find one global place to flush display updates
360 // Force immediate display update if no geometry changes required
361 screen_flush_context(nativeContext(), 0);
362 }
363
364 // Save new rotation
365 m_currentRotation = rotation;
366
367 // TODO: check if other screens are supposed to rotate as well and/or whether this depends
368 // on if clone mode is being used.
369 // Rotating only the primary screen is what we had in the navigator event handler before refactoring
370 if (m_primaryScreen) {
373 }
374
375 // Flush everything, so that the windows rotations are applied properly.
376 // Needed for non-maximized windows
377 screen_flush_context( m_screenContext, 0 );
378 }
379}
380
384void QQnxScreen::resizeNativeWidgetWindow(QQnxWindow *w, const QRect &previousScreenGeometry) const
385{
386 const qreal relativeX = static_cast<qreal>(w->geometry().topLeft().x()) / previousScreenGeometry.width();
387 const qreal relativeY = static_cast<qreal>(w->geometry().topLeft().y()) / previousScreenGeometry.height();
388 const qreal relativeWidth = static_cast<qreal>(w->geometry().width()) / previousScreenGeometry.width();
389 const qreal relativeHeight = static_cast<qreal>(w->geometry().height()) / previousScreenGeometry.height();
390
391 const QRect windowGeometry(relativeX * geometry().width(), relativeY * geometry().height(),
392 relativeWidth * geometry().width(), relativeHeight * geometry().height());
393
394 w->setGeometry(windowGeometry);
395}
396
400void QQnxScreen::resizeTopLevelWindow(QQnxWindow *w, const QRect &previousScreenGeometry) const
401{
402 QRect windowGeometry = w->geometry();
403
404 const qreal relativeCenterX = static_cast<qreal>(w->geometry().center().x()) / previousScreenGeometry.width();
405 const qreal relativeCenterY = static_cast<qreal>(w->geometry().center().y()) / previousScreenGeometry.height();
406 const QPoint newCenter(relativeCenterX * geometry().width(), relativeCenterY * geometry().height());
407
408 windowGeometry.moveCenter(newCenter);
409
410 // adjust center position in case the window
411 // is clipped
412 if (!geometry().contains(windowGeometry)) {
413 const int x1 = windowGeometry.x();
414 const int y1 = windowGeometry.y();
415 const int x2 = x1 + windowGeometry.width();
416 const int y2 = y1 + windowGeometry.height();
417
418 if (x1 < 0) {
419 const int centerX = qMin(qAbs(x1) + windowGeometry.center().x(),
420 geometry().center().x());
421
422 windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
423 }
424
425 if (y1 < 0) {
426 const int centerY = qMin(qAbs(y1) + windowGeometry.center().y(),
427 geometry().center().y());
428
429 windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
430 }
431
432 if (x2 > geometry().width()) {
433 const int centerX = qMax(windowGeometry.center().x() - (x2 - geometry().width()),
434 geometry().center().x());
435
436 windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
437 }
438
439 if (y2 > geometry().height()) {
440 const int centerY = qMax(windowGeometry.center().y() - (y2 - geometry().height()),
441 geometry().center().y());
442
443 windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
444 }
445 }
446
447 // at this point, if the window is still clipped,
448 // it means that it's too big to fit on the screen,
449 // so we need to proportionally shrink it
450 if (!geometry().contains(windowGeometry)) {
451 QSize newSize = windowGeometry.size();
453 windowGeometry.setSize(newSize);
454
455 if (windowGeometry.x() < 0)
456 windowGeometry.moveCenter(QPoint(geometry().center().x(), windowGeometry.center().y()));
457
458 if (windowGeometry.y() < 0)
459 windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), geometry().center().y()));
460 }
461
462 w->setGeometry(windowGeometry);
463}
464
468void QQnxScreen::resizeWindows(const QRect &previousScreenGeometry)
469{
471
472 Q_FOREACH (QQnxWindow *w, m_childWindows) {
473
474 if (w->window()->windowState() & Qt::WindowFullScreen || w->window()->windowState() & Qt::WindowMaximized)
475 continue;
476
477 if (w->parent()) {
478 // This is a native (non-alien) widget window
479 resizeNativeWidgetWindow(w, previousScreenGeometry);
480 } else {
481 // This is a toplevel window
482 resizeTopLevelWindow(w, previousScreenGeometry);
483 }
484 }
485}
486
487QQnxWindow *QQnxScreen::findWindow(screen_window_t windowHandle) const
488{
489 Q_FOREACH (QQnxWindow *window, m_childWindows) {
490 QQnxWindow * const result = window->findWindow(windowHandle);
491 if (result)
492 return result;
493 }
494
495 return 0;
496}
497
499{
500 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "Window =" << window;
501
502 if (m_childWindows.contains(window))
503 return;
504
505 if (window->window()->type() != Qt::CoverWindow) {
506 // Ensure that the desktop window is at the bottom of the zorder.
507 // If we do not do this then we may end up activating the desktop
508 // when the navigator service gets an event that our window group
509 // has been activated (see QQnxScreen::activateWindowGroup()).
510 // Such a situation would strangely break focus handling due to the
511 // invisible desktop widget window being layered on top of normal
512 // windows
513 if (window->window()->type() == Qt::Desktop)
514 m_childWindows.push_front(window);
515 else
516 m_childWindows.push_back(window);
518 }
519}
520
522{
523 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "Window =" << window;
524
525 if (window != m_coverWindow) {
526 const int numWindowsRemoved = m_childWindows.removeAll(window);
527 if (window == m_rootWindow) //We just removed the root window
528 m_rootWindow = 0; //TODO we need a new root window ;)
529 if (numWindowsRemoved > 0)
531 } else {
532 m_coverWindow = 0;
533 }
534}
535
537{
538 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "Window =" << window;
539
540 if (window != m_coverWindow) {
542 m_childWindows.push_back(window);
543 }
544}
545
547{
548 qCDebug(lcQpaScreen) << Q_FUNC_INFO << "Window =" << window;
549
550 if (window != m_coverWindow) {
552 m_childWindows.push_front(window);
553 }
554}
555
557{
558 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
559
561 int result;
562 int topZorder = 0;
563
564 errno = 0;
565 if (rootWindow()) {
566 result = screen_get_window_property_iv(rootWindow()->nativeHandle(), SCREEN_PROPERTY_ZORDER, &topZorder);
567 if (result != 0) { //This can happen if we use winId in QWidgets
568 topZorder = 10;
569 qWarning("QQnxScreen: failed to query root window z-order, errno=%d", errno);
570 }
571 } else {
572 topZorder = 0; //We do not need z ordering on the secondary screen, because only one window
573 //is supported there
574 }
575
576 topZorder++; // root window has the lowest z-order in the windowgroup
577
578 int underlayZorder = -1;
579 // Underlays sit immediately above the root window in the z-ordering
580 Q_FOREACH (screen_window_t underlay, m_underlays) {
581 // Do nothing when this fails. This can happen if we have stale windows in m_underlays,
582 // which in turn can happen because a window was removed but we didn't get a notification
583 // yet.
584 screen_set_window_property_iv(underlay, SCREEN_PROPERTY_ZORDER, &underlayZorder);
585 underlayZorder--;
586 }
587
588 // Normal Qt windows come next above the root window z-ordering
589 for (it = m_childWindows.constBegin(); it != m_childWindows.constEnd(); ++it)
590 (*it)->updateZorder(topZorder);
591
592 // Finally overlays sit above all else in the z-ordering
593 Q_FOREACH (screen_window_t overlay, m_overlays) {
594 // No error handling, see underlay logic above
595 screen_set_window_property_iv(overlay, SCREEN_PROPERTY_ZORDER, &topZorder);
596 topZorder++;
597 }
598
599 // After a hierarchy update, we need to force a flush on all screens.
600 // Right now, all screens share a context.
601 screen_flush_context(m_screenContext, 0);
602}
603
605{
606 if (!m_primaryScreen)
607 return;
608
609 bool ok = false;
610 const int rotation = qEnvironmentVariableIntValue("ORIENTATION", &ok);
611
612 if (ok)
614}
615
617{
618 return m_cursor;
619}
620
621void QQnxScreen::keyboardHeightChanged(int height)
622{
623 if (height == m_keyboardHeight)
624 return;
625
626 m_keyboardHeight = height;
627
629}
630
631void QQnxScreen::addOverlayWindow(screen_window_t window)
632{
633 m_overlays.append(window);
635}
636
637void QQnxScreen::addUnderlayWindow(screen_window_t window)
638{
639 m_underlays.append(window);
641}
642
643void QQnxScreen::removeOverlayOrUnderlayWindow(screen_window_t window)
644{
645 const int numRemoved = m_overlays.removeAll(window) + m_underlays.removeAll(window);
646 if (numRemoved > 0) {
649 }
650}
651
653{
655 const screen_window_t windowHandle = reinterpret_cast<screen_window_t>(window);
656 screen_display_t display = 0;
657 if (screen_get_window_property_pv(windowHandle, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) {
658 qWarning("QQnx: Failed to get screen for window, errno=%d", errno);
659 return;
660 }
661
662 int zorder;
663 if (screen_get_window_property_iv(windowHandle, SCREEN_PROPERTY_ZORDER, &zorder) != 0) {
664 qWarning("QQnx: Failed to get z-order for window, errno=%d", errno);
665 zorder = 0;
666 }
667
668 char windowNameBuffer[256] = { 0 };
669 QByteArray windowName;
670
671 if (screen_get_window_property_cv(windowHandle, SCREEN_PROPERTY_ID_STRING,
672 sizeof(windowNameBuffer) - 1, windowNameBuffer) != 0) {
673 qWarning("QQnx: Failed to get id for window, errno=%d", errno);
674 }
675
676 windowName = QByteArray(windowNameBuffer);
677
678 if (display != nativeDisplay())
679 return;
680
681 // A window was created on this screen. If we don't know about this window yet, it means
682 // it was not created by Qt, but by some foreign library.
683 //
684 // Treat all foreign windows as overlays or underlays. A window will
685 // be treated as an underlay if its Z-order is less or equal than
686 // MAX_UNDERLAY_ZORDER. Otherwise, it will be treated as an overlay.
687 if (findWindow(windowHandle))
688 return;
689
690 if (zorder <= MAX_UNDERLAY_ZORDER)
691 addUnderlayWindow(windowHandle);
692 else
693 addOverlayWindow(windowHandle);
694
695 Q_EMIT foreignWindowCreated(windowHandle);
696}
697
699{
701 const screen_window_t windowHandle = reinterpret_cast<screen_window_t>(window);
702
703 removeOverlayOrUnderlayWindow(windowHandle);
704}
705
707{
708 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
709
710 if (!rootWindow() || id != rootWindow()->groupName())
711 return;
712
713 QWindow * const window = rootWindow()->window();
714
715 if (!window)
716 return;
717
719}
720
722{
723 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
724
725 if (!rootWindow() || id != rootWindow()->groupName())
726 return;
727
728 QWindow * const window = rootWindow()->window();
729
730 if (!window)
731 return;
732
733 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
734 childWindow->setExposed(true);
735
736 if (m_coverWindow)
737 m_coverWindow->setExposed(false);
738}
739
741{
742 qCDebug(lcQpaScreen) << Q_FUNC_INFO;
743
744 if (!rootWindow() || id != rootWindow()->groupName())
745 return;
746
747 if (m_coverWindow)
748 m_coverWindow->setExposed(true);
749
750 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
751 childWindow->setExposed(false);
752}
753
755{
756 return m_rootWindow;
757}
758
760{
761 // Optionally disable the screen power save
762 bool ok = false;
763 const int disablePowerSave = qEnvironmentVariableIntValue("QQNX_DISABLE_POWER_SAVE", &ok);
764 if (ok && disablePowerSave) {
765 const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
766 int result = screen_set_window_property_iv(window->nativeHandle(), SCREEN_PROPERTY_IDLE_MODE, &mode);
767 if (result != 0)
768 qWarning("QQnxRootWindow: failed to disable power saving mode");
769 }
770 m_rootWindow = window;
771}
772
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtGui
Definition qimage.h:37
@ Format_ARGB32
Definition qimage.h:47
void push_front(rvalue_ref t)
Definition qlist.h:677
void push_back(parameter_type t)
Definition qlist.h:675
const_iterator constBegin() const noexcept
Definition qlist.h:632
qsizetype removeAll(const AT &t)
Definition qlist.h:592
reverse_iterator rend()
Definition qlist.h:635
reverse_iterator rbegin()
Definition qlist.h:634
void append(parameter_type t)
Definition qlist.h:458
const_iterator constEnd() const noexcept
Definition qlist.h:633
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1437
The QPlatformCursor class provides information about pointer device events (movement,...
QScreen * screen() const
void resizeMaximizedWindows()
Convenience method to resize all the maximized and fullscreen windows of this platform screen.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
\inmodule QtCore\reentrant
Definition qpoint.h:25
void windowClosed(void *window)
QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen)
Qt::ScreenOrientation nativeOrientation() const override
Reimplement this function in subclass to return the native orientation of the screen,...
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
Definition qqnxscreen.h:48
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
QWindow * topLevelAt(const QPoint &point) const override
Return the given top level window for a given position.
void lowerWindow(QQnxWindow *window)
bool isPrimaryScreen() const
Definition qqnxscreen.h:61
void raiseWindow(QQnxWindow *window)
void activateWindowGroup(const QByteArray &id)
void foreignWindowClosed(void *window)
void removeWindow(QQnxWindow *child)
void addWindow(QQnxWindow *child)
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
screen_context_t nativeContext() const
Definition qqnxscreen.h:69
void deactivateWindowGroup(const QByteArray &id)
int rotation() const
Definition qqnxscreen.h:63
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override
This function is called when Qt needs to be able to grab the content of a window.
QQnxWindow * findWindow(screen_window_t windowHandle) const
void foreignWindowCreated(void *window)
void setRootWindow(QQnxWindow *)
int depth() const override
Reimplement in subclass to return current depth of the screen.
void adjustOrientation()
screen_display_t nativeDisplay() const
Definition qqnxscreen.h:68
void setRotation(int rotation)
QQnxWindow * rootWindow() const
void newWindowCreated(void *window)
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
void updateHierarchy()
void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state)
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
Definition qqnxwindow.h:31
void setExposed(bool exposed)
void setScreen(QQnxScreen *platformScreen)
void setRotation(int rotation)
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr void moveCenter(const QPoint &p) noexcept
Moves the rectangle, leaving the center point at the given position.
Definition qrect.h:328
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
Definition qrect.h:387
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:855
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:242
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:233
int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const
Convenience function to compute the angle of rotation to get from rotation a to rotation b.
Definition qscreen.cpp:519
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
void scale(int w, int h, Qt::AspectRatioMode mode) noexcept
Scales the size to a rectangle with the given width and height, according to the specified mode:
Definition qsize.h:145
constexpr QSize transposed() const noexcept
Definition qsize.h:142
\inmodule QtCore
Definition qstringview.h:78
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
Definition qstring.cpp:8249
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
static QThread * currentThread()
Definition qthread.cpp:1039
QWidget * window() const
Returns the window for this widget, i.e.
Definition qwidget.cpp:4313
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition qwidget.h:106
static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry)
static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation)
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState=-1)
\inmodule QtGui
Definition qwindow.h:63
QSet< QString >::iterator it
rect
[4]
else opt state
[0]
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
Definition qcompare.h:63
WindowState
Definition qnamespace.h:251
@ WindowFullScreen
Definition qnamespace.h:255
@ WindowMaximized
Definition qnamespace.h:254
@ KeepAspectRatio
ScreenOrientation
Definition qnamespace.h:271
@ InvertedLandscapeOrientation
Definition qnamespace.h:276
@ InvertedPortraitOrientation
Definition qnamespace.h:275
@ LandscapeOrientation
Definition qnamespace.h:274
@ PortraitOrientation
Definition qnamespace.h:273
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
@ Desktop
Definition qnamespace.h:215
@ CoverWindow
Definition qnamespace.h:218
static void * context
#define Q_FUNC_INFO
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
#define Q_FOREACH(variable, container)
Definition qforeach.h:66
#define qWarning
Definition qlogging.h:166
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint end
GLuint GLfloat GLfloat GLfloat x1
GLenum GLenum GLsizei count
const void GLsizei GLsizei stride
GLenum GLuint buffer
GLint GLsizei width
GLfloat angle
GLuint name
GLint y
GLuint GLfloat * val
GLfixed GLfixed GLfixed y2
GLint void * img
Definition qopenglext.h:233
GLfixed GLfixed x2
GLsizei const void * pointer
Definition qopenglext.h:384
GLuint64EXT * result
[6]
#define Q_SCREEN_CRITICALERROR(x, message)
Definition qqnxglobal.h:16
#define Q_SCREEN_CHECKERROR(x, message)
Definition qqnxglobal.h:13
static const int MAX_UNDERLAY_ZORDER
static bool isOrthogonal(int angle1, int angle2)
Check if the supplied angles are perpendicular to each other.
static int defaultDepth()
static QSize determineScreenSize(screen_display_t display, bool primaryScreen)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
#define Q_EMIT
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QWidget * win
Definition settings.cpp:6
widget render & pixmap
aWidget window() -> setWindowTitle("New Window Title")
[2]
bool contains(const AT &t) const noexcept
Definition qlist.h:45