Qt 6.x
The Qt SDK
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#include "qqnxglobal.h"
5
6#include "qqnxscreen.h"
7#include "qqnxwindow.h"
8#include "qqnxcursor.h"
9
10#include <QtCore/QThread>
11#include <QtCore/QDebug>
12#include <qpa/qwindowsysteminterface.h>
13
14#include <errno.h>
15
16#if defined(QQNXSCREEN_DEBUG)
17#define qScreenDebug qDebug
18#else
19#define qScreenDebug QT_NO_QDEBUG_MACRO
20#endif
21
22#if defined(QQNX_PHYSICAL_SCREEN_WIDTH) && QQNX_PHYSICAL_SCREEN_WIDTH > 0 \
23 && defined(QQNX_PHYSICAL_SCREEN_HEIGHT) && QQNX_PHYSICAL_SCREEN_HEIGHT > 0
24#define QQNX_PHYSICAL_SCREEN_SIZE_DEFINED
25#elif defined(QQNX_PHYSICAL_SCREEN_WIDTH) || defined(QQNX_PHYSICAL_SCREEN_HEIGHT)
26#error Please define QQNX_PHYSICAL_SCREEN_WIDTH and QQNX_PHYSICAL_SCREEN_HEIGHT to values greater than zero
27#endif
28
29// The maximum z-order at which a foreign window will be considered
30// an underlay.
31static const int MAX_UNDERLAY_ZORDER = -1;
32
34
35static QSize determineScreenSize(screen_display_t display, bool primaryScreen) {
36 int val[2];
37
38 const int result = screen_get_display_property_iv(display, SCREEN_PROPERTY_PHYSICAL_SIZE, val);
39 Q_SCREEN_CHECKERROR(result, "Failed to query display physical size");
40 if (result != 0) {
41 return QSize(150, 90);
42 }
43
44 if (val[0] > 0 && val[1] > 0)
45 return QSize(val[0], val[1]);
46
47 qScreenDebug("QQnxScreen: screen_get_display_property_iv() reported an invalid "
48 "physical screen size (%dx%d). Falling back to QQNX_PHYSICAL_SCREEN_SIZE "
49 "environment variable.", val[0], val[1]);
50
51 const QString envPhySizeStr = qgetenv("QQNX_PHYSICAL_SCREEN_SIZE");
52 if (!envPhySizeStr.isEmpty()) {
53 const auto envPhySizeStrList = QStringView{envPhySizeStr}.split(u',');
54 const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
55 const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;
56
57 if (envWidth <= 0 || envHeight <= 0) {
58 qWarning("QQnxScreen: The value of QQNX_PHYSICAL_SCREEN_SIZE must be in the format "
59 "\"width,height\" in mm, with width, height > 0. Defaulting to 150x90. "
60 "Example: QQNX_PHYSICAL_SCREEN_SIZE=150,90");
61 return QSize(150, 90);
62 }
63
64 return QSize(envWidth, envHeight);
65 }
66
67#if defined(QQNX_PHYSICAL_SCREEN_SIZE_DEFINED)
68 const QSize defSize(QQNX_PHYSICAL_SCREEN_WIDTH, QQNX_PHYSICAL_SCREEN_HEIGHT);
69 qWarning("QQnxScreen: QQNX_PHYSICAL_SCREEN_SIZE variable not set. Falling back to defines "
70 "QQNX_PHYSICAL_SCREEN_WIDTH/QQNX_PHYSICAL_SCREEN_HEIGHT (%dx%d)",
71 defSize.width(), defSize.height());
72 return defSize;
73#else
74 if (primaryScreen)
75 qWarning("QQnxScreen: QQNX_PHYSICAL_SCREEN_SIZE variable not set. "
76 "Could not determine physical screen size. Defaulting to 150x90.");
77 return QSize(150, 90);
78#endif
79}
80
81QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, bool primaryScreen)
82 : m_screenContext(screenContext),
83 m_display(display),
84 m_rootWindow(0),
85 m_primaryScreen(primaryScreen),
86 m_keyboardHeight(0),
87 m_nativeOrientation(Qt::PrimaryOrientation),
88 m_coverWindow(0),
89 m_cursor(new QQnxCursor())
90{
92 // Cache initial orientation of this display
93 int result = screen_get_display_property_iv(m_display, SCREEN_PROPERTY_ROTATION,
94 &m_initialRotation);
95 Q_SCREEN_CHECKERROR(result, "Failed to query display rotation");
96
97 m_currentRotation = m_initialRotation;
98
99 // Cache size of this display in pixels
100 int val[2];
101 Q_SCREEN_CRITICALERROR(screen_get_display_property_iv(m_display, SCREEN_PROPERTY_SIZE, val),
102 "Failed to query display size");
103
104 m_currentGeometry = m_initialGeometry = QRect(0, 0, val[0], val[1]);
105
106 char name[100];
107 Q_SCREEN_CHECKERROR(screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, 100,
108 name), "Failed to query display name");
109 m_name = QString::fromUtf8(name);
110
111 // Cache size of this display in millimeters. We have to take care of the orientation.
112 // libscreen always reports the physical size dimensions as width and height in the
113 // native orientation. Contrary to this, QPlatformScreen::physicalSize() expects the
114 // returned dimensions to follow the current orientation.
115 const QSize screenSize = determineScreenSize(m_display, primaryScreen);
116
117 m_nativeOrientation = screenSize.width() >= screenSize.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
118
119 const int angle = screen()->angleBetween(m_nativeOrientation, orientation());
120 if (angle == 0 || angle == 180)
121 m_currentPhysicalSize = m_initialPhysicalSize = screenSize;
122 else
123 m_currentPhysicalSize = m_initialPhysicalSize = screenSize.transposed();
124}
125
127{
128 qScreenDebug();
129 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
130 childWindow->setScreen(0);
131
132 if (m_coverWindow)
133 m_coverWindow->setScreen(0);
134
135 delete m_cursor;
136}
137
138QPixmap QQnxScreen::grabWindow(WId window, int x, int y, int width, int height) const
139{
140 QQnxWindow *qnxWin = findWindow(reinterpret_cast<screen_window_t>(window));
141 if (!qnxWin) {
142 qWarning("grabWindow: unknown window");
143 return QPixmap();
144 }
145
146 QRect bound = qnxWin->geometry();
147
148 if (width < 0)
149 width = bound.width();
150 if (height < 0)
151 height = bound.height();
152
153 bound &= QRect(x + bound.x(), y + bound.y(), width, height);
154
155 if (bound.width() <= 0 || bound.height() <= 0) {
156 qWarning("grabWindow: size is null");
157 return QPixmap();
158 }
159
160 // Create new context, only SCREEN_DISPLAY_MANAGER_CONTEXT can read from screen
161 screen_context_t context;
162 if (screen_create_context(&context, SCREEN_DISPLAY_MANAGER_CONTEXT)) {
163 if (errno == EPERM)
164 qWarning("grabWindow: root privileges required");
165 else
166 qWarning("grabWindow: cannot create context");
167 return QPixmap();
168 }
169
170 // Find corresponding display in SCREEN_DISPLAY_MANAGER_CONTEXT
171 int count = 0;
172 screen_display_t display = 0;
173 screen_get_context_property_iv(context, SCREEN_PROPERTY_DISPLAY_COUNT, &count);
174 if (count > 0) {
175 const size_t idLen = 30;
176 char matchId[idLen];
177 char id[idLen];
178 bool found = false;
179
180 screen_display_t *displays = static_cast<screen_display_t*>
181 (calloc(count, sizeof(screen_display_t)));
182 screen_get_context_property_pv(context, SCREEN_PROPERTY_DISPLAYS, (void **)displays);
183 screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, idLen, matchId);
184
185 while (count && !found) {
186 --count;
187 screen_get_display_property_cv(displays[count], SCREEN_PROPERTY_ID_STRING, idLen, id);
188 found = !strncmp(id, matchId, idLen);
189 }
190
191 if (found)
192 display = displays[count];
193
194 free(displays);
195 }
196
197 // Create screen and Qt pixmap
198 screen_pixmap_t pixmap;
200 if (display && !screen_create_pixmap(&pixmap, context)) {
201 screen_buffer_t buffer;
202 void *pointer;
203 int stride;
204 const int rect[4] = { bound.x(), bound.y(), bound.width(), bound.height() };
205
206 int val = SCREEN_USAGE_READ | SCREEN_USAGE_NATIVE;
207 screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_USAGE, &val);
208 val = SCREEN_FORMAT_RGBA8888;
209 screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_FORMAT, &val);
210
211 int err = screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);
212 err = err || screen_create_pixmap_buffer(pixmap);
213 err = err || screen_get_pixmap_property_pv(pixmap, SCREEN_PROPERTY_RENDER_BUFFERS,
214 reinterpret_cast<void**>(&buffer));
215 err = err || screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, &pointer);
216 err = err || screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);
217 err = err || screen_read_display(display, buffer, 1, rect, 0);
218
219 if (!err) {
220 const QImage img(static_cast<unsigned char*>(pointer),
221 bound.width(), bound.height(), stride, QImage::Format_ARGB32);
223 } else {
224 qWarning("grabWindow: capture error");
225 }
226 screen_destroy_pixmap(pixmap);
227 } else {
228 qWarning("grabWindow: display/pixmap error ");
229 }
230 screen_destroy_context(context);
231
232 return result;
233}
234
235static int defaultDepth()
236{
237 qScreenDebug();
238 static int defaultDepth = 0;
239 if (defaultDepth == 0) {
240 // check if display depth was specified in environment variable;
241 // use default value if no valid value found
242 defaultDepth = qEnvironmentVariableIntValue("QQNX_DISPLAY_DEPTH");
243 if (defaultDepth != 16 && defaultDepth != 32)
244 defaultDepth = 32;
245 }
246 return defaultDepth;
247}
248
250{
251 qScreenDebug();
252 // available geometry = total geometry - keyboard
253 return QRect(m_currentGeometry.x(), m_currentGeometry.y(),
254 m_currentGeometry.width(), m_currentGeometry.height() - m_keyboardHeight);
255}
256
258{
259 return defaultDepth();
260}
261
263{
264 screen_display_mode_t displayMode;
265 int result = screen_get_display_property_pv(m_display, SCREEN_PROPERTY_MODE, reinterpret_cast<void **>(&displayMode));
266 // Screen shouldn't really return 0 but it does so default to 60 or things break.
267 if (result != 0 || displayMode.refresh == 0) {
268 qWarning("QQnxScreen: Failed to query screen mode. Using default value of 60Hz");
269 return 60.0;
270 }
271 qScreenDebug("screen mode:\n"
272 " width = %u\n"
273 " height = %u\n"
274 " refresh = %u\n"
275 " interlaced = %u",
276 uint(displayMode.width), uint(displayMode.height), uint(displayMode.refresh), uint(displayMode.interlaced));
277 return static_cast<qreal>(displayMode.refresh);
278}
279
281{
282 return m_nativeOrientation;
283}
284
286{
288 if (m_nativeOrientation == Qt::LandscapeOrientation) {
289 // Landscape devices e.g. PlayBook
290 if (m_currentRotation == 0)
292 else if (m_currentRotation == 90)
294 else if (m_currentRotation == 180)
296 else
298 } else {
299 // Portrait devices e.g. Phones
300 // ###TODO Check these on an actual phone device
301 if (m_currentRotation == 0)
303 else if (m_currentRotation == 90)
305 else if (m_currentRotation == 180)
307 else
309 }
310 qScreenDebug() << "orientation =" << orient;
311 return orient;
312}
313
315{
316 for (auto it = m_childWindows.rbegin(), end = m_childWindows.rend(); it != end; ++it) {
317 QWindow *win = (*it)->window();
318 if (win->geometry().contains(point))
319 return win;
320 }
321 return 0;
322}
323
327static bool isOrthogonal(int angle1, int angle2)
328{
329 return ((angle1 - angle2) % 180) != 0;
330}
331
332void QQnxScreen::setRotation(int rotation)
333{
334 qScreenDebug("orientation = %d", rotation);
335 // Check if rotation changed
336 // We only want to rotate if we are the primary screen
337 if (m_currentRotation != rotation && isPrimaryScreen()) {
338 // Update rotation of root window
339 if (rootWindow())
341
342 const QRect previousScreenGeometry = geometry();
343
344 // Swap dimensions if we've rotated 90 or 270 from initial orientation
345 if (isOrthogonal(m_initialRotation, rotation)) {
346 m_currentGeometry = QRect(0, 0, m_initialGeometry.height(), m_initialGeometry.width());
347 m_currentPhysicalSize = QSize(m_initialPhysicalSize.height(), m_initialPhysicalSize.width());
348 } else {
349 m_currentGeometry = QRect(0, 0, m_initialGeometry.width(), m_initialGeometry.height());
350 m_currentPhysicalSize = m_initialPhysicalSize;
351 }
352
353 // Resize root window if we've rotated 90 or 270 from previous orientation
354 if (isOrthogonal(m_currentRotation, rotation)) {
355 qScreenDebug() << "resize, size =" << m_currentGeometry.size();
356 if (rootWindow())
357 rootWindow()->setGeometry(QRect(QPoint(0,0), m_currentGeometry.size()));
358
359 resizeWindows(previousScreenGeometry);
360 } else {
361 // TODO: Find one global place to flush display updates
362 // Force immediate display update if no geometry changes required
363 screen_flush_context(nativeContext(), 0);
364 }
365
366 // Save new rotation
367 m_currentRotation = rotation;
368
369 // TODO: check if other screens are supposed to rotate as well and/or whether this depends
370 // on if clone mode is being used.
371 // Rotating only the primary screen is what we had in the navigator event handler before refactoring
372 if (m_primaryScreen) {
375 }
376
377 // Flush everything, so that the windows rotations are applied properly.
378 // Needed for non-maximized windows
379 screen_flush_context( m_screenContext, 0 );
380 }
381}
382
386void QQnxScreen::resizeNativeWidgetWindow(QQnxWindow *w, const QRect &previousScreenGeometry) const
387{
388 const qreal relativeX = static_cast<qreal>(w->geometry().topLeft().x()) / previousScreenGeometry.width();
389 const qreal relativeY = static_cast<qreal>(w->geometry().topLeft().y()) / previousScreenGeometry.height();
390 const qreal relativeWidth = static_cast<qreal>(w->geometry().width()) / previousScreenGeometry.width();
391 const qreal relativeHeight = static_cast<qreal>(w->geometry().height()) / previousScreenGeometry.height();
392
393 const QRect windowGeometry(relativeX * geometry().width(), relativeY * geometry().height(),
394 relativeWidth * geometry().width(), relativeHeight * geometry().height());
395
396 w->setGeometry(windowGeometry);
397}
398
402void QQnxScreen::resizeTopLevelWindow(QQnxWindow *w, const QRect &previousScreenGeometry) const
403{
404 QRect windowGeometry = w->geometry();
405
406 const qreal relativeCenterX = static_cast<qreal>(w->geometry().center().x()) / previousScreenGeometry.width();
407 const qreal relativeCenterY = static_cast<qreal>(w->geometry().center().y()) / previousScreenGeometry.height();
408 const QPoint newCenter(relativeCenterX * geometry().width(), relativeCenterY * geometry().height());
409
410 windowGeometry.moveCenter(newCenter);
411
412 // adjust center position in case the window
413 // is clipped
414 if (!geometry().contains(windowGeometry)) {
415 const int x1 = windowGeometry.x();
416 const int y1 = windowGeometry.y();
417 const int x2 = x1 + windowGeometry.width();
418 const int y2 = y1 + windowGeometry.height();
419
420 if (x1 < 0) {
421 const int centerX = qMin(qAbs(x1) + windowGeometry.center().x(),
422 geometry().center().x());
423
424 windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
425 }
426
427 if (y1 < 0) {
428 const int centerY = qMin(qAbs(y1) + windowGeometry.center().y(),
429 geometry().center().y());
430
431 windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
432 }
433
434 if (x2 > geometry().width()) {
435 const int centerX = qMax(windowGeometry.center().x() - (x2 - geometry().width()),
436 geometry().center().x());
437
438 windowGeometry.moveCenter(QPoint(centerX, windowGeometry.center().y()));
439 }
440
441 if (y2 > geometry().height()) {
442 const int centerY = qMax(windowGeometry.center().y() - (y2 - geometry().height()),
443 geometry().center().y());
444
445 windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), centerY));
446 }
447 }
448
449 // at this point, if the window is still clipped,
450 // it means that it's too big to fit on the screen,
451 // so we need to proportionally shrink it
452 if (!geometry().contains(windowGeometry)) {
453 QSize newSize = windowGeometry.size();
455 windowGeometry.setSize(newSize);
456
457 if (windowGeometry.x() < 0)
458 windowGeometry.moveCenter(QPoint(geometry().center().x(), windowGeometry.center().y()));
459
460 if (windowGeometry.y() < 0)
461 windowGeometry.moveCenter(QPoint(windowGeometry.center().x(), geometry().center().y()));
462 }
463
464 w->setGeometry(windowGeometry);
465}
466
470void QQnxScreen::resizeWindows(const QRect &previousScreenGeometry)
471{
473
474 Q_FOREACH (QQnxWindow *w, m_childWindows) {
475
476 if (w->window()->windowState() & Qt::WindowFullScreen || w->window()->windowState() & Qt::WindowMaximized)
477 continue;
478
479 if (w->parent()) {
480 // This is a native (non-alien) widget window
481 resizeNativeWidgetWindow(w, previousScreenGeometry);
482 } else {
483 // This is a toplevel window
484 resizeTopLevelWindow(w, previousScreenGeometry);
485 }
486 }
487}
488
489QQnxWindow *QQnxScreen::findWindow(screen_window_t windowHandle) const
490{
491 Q_FOREACH (QQnxWindow *window, m_childWindows) {
492 QQnxWindow * const result = window->findWindow(windowHandle);
493 if (result)
494 return result;
495 }
496
497 return 0;
498}
499
501{
502 qScreenDebug() << "window =" << window;
503
504 if (m_childWindows.contains(window))
505 return;
506
507 if (window->window()->type() != Qt::CoverWindow) {
508 // Ensure that the desktop window is at the bottom of the zorder.
509 // If we do not do this then we may end up activating the desktop
510 // when the navigator service gets an event that our window group
511 // has been activated (see QQnxScreen::activateWindowGroup()).
512 // Such a situation would strangely break focus handling due to the
513 // invisible desktop widget window being layered on top of normal
514 // windows
515 if (window->window()->type() == Qt::Desktop)
516 m_childWindows.push_front(window);
517 else
518 m_childWindows.push_back(window);
520 }
521}
522
524{
525 qScreenDebug() << "window =" << window;
526
527 if (window != m_coverWindow) {
528 const int numWindowsRemoved = m_childWindows.removeAll(window);
529 if (window == m_rootWindow) //We just removed the root window
530 m_rootWindow = 0; //TODO we need a new root window ;)
531 if (numWindowsRemoved > 0)
533 } else {
534 m_coverWindow = 0;
535 }
536}
537
539{
540 qScreenDebug() << "window =" << window;
541
542 if (window != m_coverWindow) {
544 m_childWindows.push_back(window);
545 }
546}
547
549{
550 qScreenDebug() << "window =" << window;
551
552 if (window != m_coverWindow) {
554 m_childWindows.push_front(window);
555 }
556}
557
559{
560 qScreenDebug();
561
563 int result;
564 int topZorder = 0;
565
566 errno = 0;
567 if (rootWindow()) {
568 result = screen_get_window_property_iv(rootWindow()->nativeHandle(), SCREEN_PROPERTY_ZORDER, &topZorder);
569 if (result != 0) { //This can happen if we use winId in QWidgets
570 topZorder = 10;
571 qWarning("QQnxScreen: failed to query root window z-order, errno=%d", errno);
572 }
573 } else {
574 topZorder = 0; //We do not need z ordering on the secondary screen, because only one window
575 //is supported there
576 }
577
578 topZorder++; // root window has the lowest z-order in the windowgroup
579
580 int underlayZorder = -1;
581 // Underlays sit immediately above the root window in the z-ordering
582 Q_FOREACH (screen_window_t underlay, m_underlays) {
583 // Do nothing when this fails. This can happen if we have stale windows in m_underlays,
584 // which in turn can happen because a window was removed but we didn't get a notification
585 // yet.
586 screen_set_window_property_iv(underlay, SCREEN_PROPERTY_ZORDER, &underlayZorder);
587 underlayZorder--;
588 }
589
590 // Normal Qt windows come next above the root window z-ordering
591 for (it = m_childWindows.constBegin(); it != m_childWindows.constEnd(); ++it)
592 (*it)->updateZorder(topZorder);
593
594 // Finally overlays sit above all else in the z-ordering
595 Q_FOREACH (screen_window_t overlay, m_overlays) {
596 // No error handling, see underlay logic above
597 screen_set_window_property_iv(overlay, SCREEN_PROPERTY_ZORDER, &topZorder);
598 topZorder++;
599 }
600
601 // After a hierarchy update, we need to force a flush on all screens.
602 // Right now, all screens share a context.
603 screen_flush_context(m_screenContext, 0);
604}
605
607{
608 if (!m_primaryScreen)
609 return;
610
611 bool ok = false;
612 const int rotation = qEnvironmentVariableIntValue("ORIENTATION", &ok);
613
614 if (ok)
616}
617
619{
620 return m_cursor;
621}
622
623void QQnxScreen::keyboardHeightChanged(int height)
624{
625 if (height == m_keyboardHeight)
626 return;
627
628 m_keyboardHeight = height;
629
631}
632
633void QQnxScreen::addOverlayWindow(screen_window_t window)
634{
635 m_overlays.append(window);
637}
638
639void QQnxScreen::addUnderlayWindow(screen_window_t window)
640{
641 m_underlays.append(window);
643}
644
645void QQnxScreen::removeOverlayOrUnderlayWindow(screen_window_t window)
646{
647 const int numRemoved = m_overlays.removeAll(window) + m_underlays.removeAll(window);
648 if (numRemoved > 0) {
651 }
652}
653
655{
657 const screen_window_t windowHandle = reinterpret_cast<screen_window_t>(window);
658 screen_display_t display = 0;
659 if (screen_get_window_property_pv(windowHandle, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) {
660 qWarning("QQnx: Failed to get screen for window, errno=%d", errno);
661 return;
662 }
663
664 int zorder;
665 if (screen_get_window_property_iv(windowHandle, SCREEN_PROPERTY_ZORDER, &zorder) != 0) {
666 qWarning("QQnx: Failed to get z-order for window, errno=%d", errno);
667 zorder = 0;
668 }
669
670 char windowNameBuffer[256] = { 0 };
671 QByteArray windowName;
672
673 if (screen_get_window_property_cv(windowHandle, SCREEN_PROPERTY_ID_STRING,
674 sizeof(windowNameBuffer) - 1, windowNameBuffer) != 0) {
675 qWarning("QQnx: Failed to get id for window, errno=%d", errno);
676 }
677
678 windowName = QByteArray(windowNameBuffer);
679
680 if (display != nativeDisplay())
681 return;
682
683 // A window was created on this screen. If we don't know about this window yet, it means
684 // it was not created by Qt, but by some foreign library.
685 //
686 // Treat all foreign windows as overlays or underlays. A window will
687 // be treated as an underlay if its Z-order is less or equal than
688 // MAX_UNDERLAY_ZORDER. Otherwise, it will be treated as an overlay.
689 if (findWindow(windowHandle))
690 return;
691
692 if (zorder <= MAX_UNDERLAY_ZORDER)
693 addUnderlayWindow(windowHandle);
694 else
695 addOverlayWindow(windowHandle);
696
697 Q_EMIT foreignWindowCreated(windowHandle);
698}
699
701{
703 const screen_window_t windowHandle = reinterpret_cast<screen_window_t>(window);
704
705 removeOverlayOrUnderlayWindow(windowHandle);
706}
707
709{
710 qScreenDebug();
711
712 if (!rootWindow() || id != rootWindow()->groupName())
713 return;
714
715 QWindow * const window = rootWindow()->window();
716
717 if (!window)
718 return;
719
721}
722
724{
725 qScreenDebug();
726
727 if (!rootWindow() || id != rootWindow()->groupName())
728 return;
729
730 QWindow * const window = rootWindow()->window();
731
732 if (!window)
733 return;
734
735 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
736 childWindow->setExposed(true);
737
738 if (m_coverWindow)
739 m_coverWindow->setExposed(false);
740}
741
743{
744 qScreenDebug();
745
746 if (!rootWindow() || id != rootWindow()->groupName())
747 return;
748
749 if (m_coverWindow)
750 m_coverWindow->setExposed(true);
751
752 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
753 childWindow->setExposed(false);
754}
755
757{
758 return m_rootWindow;
759}
760
762{
763 // Optionally disable the screen power save
764 bool ok = false;
765 const int disablePowerSave = qEnvironmentVariableIntValue("QQNX_DISABLE_POWER_SAVE", &ok);
766 if (ok && disablePowerSave) {
767 const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
768 int result = screen_set_window_property_iv(window->nativeHandle(), SCREEN_PROPERTY_IDLE_MODE, &mode);
769 if (result != 0)
770 qWarning("QQnxRootWindow: failed to disable power saving mode");
771 }
772 m_rootWindow = window;
773}
774
\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:674
void push_back(parameter_type t)
Definition qlist.h:672
const_iterator constBegin() const noexcept
Definition qlist.h:615
qsizetype removeAll(const AT &t)
Definition qlist.h:575
reverse_iterator rend()
Definition qlist.h:618
reverse_iterator rbegin()
Definition qlist.h:617
void append(parameter_type t)
Definition qlist.h:441
const_iterator constEnd() const noexcept
Definition qlist.h:616
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1561
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:1445
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.
virtual QRect geometry() const
Returns the current geometry of a window.
\inmodule QtCore\reentrant
Definition qpoint.h:23
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:127
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:132
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:44
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:57
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:65
void deactivateWindowGroup(const QByteArray &id)
int rotation() const
Definition qqnxscreen.h:59
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:64
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:28
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:327
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
Definition qrect.h:386
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:851
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:184
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:241
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:235
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:187
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:232
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:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
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:144
constexpr QSize transposed() const noexcept
Definition qsize.h:141
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
Definition qstring.cpp:7956
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
static QThread * currentThread()
Definition qthread.cpp:966
QWidget * window() const
Returns the window for this widget, i.e.
Definition qwidget.cpp:4320
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.
WindowState
Definition qnamespace.h:250
@ WindowFullScreen
Definition qnamespace.h:254
@ WindowMaximized
Definition qnamespace.h:253
@ KeepAspectRatio
ScreenOrientation
Definition qnamespace.h:270
@ InvertedLandscapeOrientation
Definition qnamespace.h:275
@ InvertedPortraitOrientation
Definition qnamespace.h:274
@ LandscapeOrientation
Definition qnamespace.h:273
@ PortraitOrientation
Definition qnamespace.h:272
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
@ Desktop
Definition qnamespace.h:214
@ CoverWindow
Definition qnamespace.h:217
static void * context
#define Q_FOREACH(variable, container)
Definition qforeach.h:66
#define qWarning
Definition qlogging.h:162
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 QT_BEGIN_NAMESPACE 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.
static int defaultDepth()
#define qScreenDebug
#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:29
double qreal
Definition qtypes.h:92
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:44