Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqnxwindow.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 "qqnxwindow.h"
7#include "qqnxintegration.h"
8#include "qqnxscreen.h"
9#include "qqnxlgmon.h"
10
11#include <QUuid>
12
13#include <QtGui/QWindow>
14#include <qpa/qwindowsysteminterface.h>
15
16#include "private/qguiapplication_p.h"
17
18#include <QtCore/QDebug>
19
20#include <errno.h>
21
22#if defined(QQNXWINDOW_DEBUG)
23#define qWindowDebug qDebug
24#else
25#define qWindowDebug QT_NO_QDEBUG_MACRO
26#endif
27
29
30#define DECLARE_DEBUG_VAR(variable) \
31 static bool debug_ ## variable() \
32 { static bool value = qgetenv("QNX_SCREEN_DEBUG").contains(QT_STRINGIFY(variable)); return value; }
36DECLARE_DEBUG_VAR(updates)
37DECLARE_DEBUG_VAR(cpu_time)
38DECLARE_DEBUG_VAR(gpu_time)
39DECLARE_DEBUG_VAR(statistics)
40#undef DECLARE_DEBUG_VAR
41
114QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootWindow)
116 m_screenContext(context),
117 m_window(0),
118 m_screen(0),
119 m_parentWindow(0),
120 m_visible(false),
121 m_exposed(true),
122 m_foreign(false),
123 m_windowState(Qt::WindowNoState),
124 m_firstActivateHandled(false)
125{
126 qWindowDebug() << "window =" << window << ", size =" << window->size();
127
128 QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window->screen()->handle());
129
130 // If a qnxInitialWindowGroup property is set on the window we'll take this as an
131 // indication that we want to create a child window and join that window group.
132 QVariant windowGroup = window->property("qnxInitialWindowGroup");
133 if (!windowGroup.isValid())
134 windowGroup = window->property("_q_platform_qnxParentGroup");
135
136 if (window->type() == Qt::CoverWindow) {
137 // Cover windows have to be top level to be accessible to window delegate (i.e. navigator)
138 // Desktop windows also need to be toplevel because they are not
139 // supposed to be part of the window hierarchy tree
140 m_isTopLevel = true;
141 } else if (parent() || windowGroup.isValid()) {
142 // If we have a parent we are a child window. Sometimes we have to be a child even if we
143 // don't have a parent e.g. our parent might be in a different process.
144 m_isTopLevel = false;
145 } else {
146 // We're parentless. If we're not using a root window, we'll always be a top-level window
147 // otherwise only the first window is.
148 m_isTopLevel = !needRootWindow || !platformScreen->rootWindow();
149 }
150
151 if (window->type() == Qt::Desktop) // A desktop widget does not need a libscreen window
152 return;
153
154 QVariant type = window->property("_q_platform_qnxWindowType");
155 if (type.isValid() && type.canConvert<int>()) {
157 screen_create_window_type(&m_window, m_screenContext, type.value<int>()),
158 "Could not create window");
159 } else if (m_isTopLevel) {
160 Q_SCREEN_CRITICALERROR(screen_create_window(&m_window, m_screenContext),
161 "Could not create top level window"); // Creates an application window
162 if (window->type() != Qt::CoverWindow) {
163 if (needRootWindow)
164 platformScreen->setRootWindow(this);
165 }
166 } else {
168 screen_create_window_type(&m_window, m_screenContext, SCREEN_CHILD_WINDOW),
169 "Could not create child window");
170 }
171
172 createWindowGroup();
173
174 // If the window has a qnxWindowId property, set this as the string id property. This generally
175 // needs to be done prior to joining any group as it might be used by the owner of the
176 // group to identify the window.
177 QVariant windowId = window->property("qnxWindowId");
178 if (!windowId.isValid())
179 windowId = window->property("_q_platform_qnxWindowId");
180 if (windowId.isValid() && windowId.canConvert<QByteArray>()) {
181 QByteArray id = windowId.toByteArray();
182 Q_SCREEN_CHECKERROR(screen_set_window_property_cv(m_window, SCREEN_PROPERTY_ID_STRING,
183 id.size(), id), "Failed to set id");
184 }
185
186 // If a window group has been provided join it now. If it's an empty string that's OK too,
187 // it'll cause us not to join a group (the app will presumably join at some future time).
188 if (windowGroup.isValid() && windowGroup.canConvert<QByteArray>())
189 joinWindowGroup(windowGroup.toByteArray());
190
191 QVariant pipelineValue = window->property("_q_platform_qnxPipeline");
192 if (pipelineValue.isValid()) {
193 bool ok = false;
194 int pipeline = pipelineValue.toInt(&ok);
195 if (ok) {
196 qWindowDebug() << "Set pipeline value to" << pipeline;
197
199 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_PIPELINE, &pipeline),
200 "Failed to set window pipeline");
201 } else {
202 qWindowDebug() << "Invalid pipeline value:" << pipelineValue;
203 }
204 }
205
206 int debug = 0;
207 if (Q_UNLIKELY(debug_fps())) {
208 debug |= SCREEN_DEBUG_GRAPH_FPS;
209 }
210 if (Q_UNLIKELY(debug_posts())) {
211 debug |= SCREEN_DEBUG_GRAPH_POSTS;
212 }
213 if (Q_UNLIKELY(debug_blits())) {
214 debug |= SCREEN_DEBUG_GRAPH_BLITS;
215 }
216 if (Q_UNLIKELY(debug_updates())) {
217 debug |= SCREEN_DEBUG_GRAPH_UPDATES;
218 }
219 if (Q_UNLIKELY(debug_cpu_time())) {
220 debug |= SCREEN_DEBUG_GRAPH_CPU_TIME;
221 }
222 if (Q_UNLIKELY(debug_gpu_time())) {
223 debug |= SCREEN_DEBUG_GRAPH_GPU_TIME;
224 }
225 if (Q_UNLIKELY(debug_statistics())) {
226 debug = SCREEN_DEBUG_STATISTICS;
227 }
228
229 if (debug > 0) {
230 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_DEBUG, &debug),
231 "Could not set SCREEN_PROPERTY_DEBUG");
232 qWindowDebug() << "window SCREEN_PROPERTY_DEBUG= " << debug;
233 }
234}
235
236QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, screen_window_t screenWindow)
238 , m_screenContext(context)
239 , m_window(screenWindow)
240 , m_screen(0)
241 , m_parentWindow(0)
242 , m_visible(false)
243 , m_exposed(true)
244 , m_foreign(true)
245 , m_windowState(Qt::WindowNoState)
246 , m_parentGroupName(256, 0)
247 , m_isTopLevel(false)
248{
249 qWindowDebug() << "window =" << window << ", size =" << window->size();
250
251 collectWindowGroup();
252
253 screen_get_window_property_cv(m_window,
254 SCREEN_PROPERTY_PARENT,
255 m_parentGroupName.size(),
256 m_parentGroupName.data());
257 m_parentGroupName.resize(strlen(m_parentGroupName.constData()));
258
259 // If a window group has been provided join it now. If it's an empty string that's OK too,
260 // it'll cause us not to join a group (the app will presumably join at some future time).
261 QVariant parentGroup = window->property("qnxInitialWindowGroup");
262 if (!parentGroup.isValid())
263 parentGroup = window->property("_q_platform_qnxParentGroup");
264 if (parentGroup.isValid() && parentGroup.canConvert<QByteArray>())
265 joinWindowGroup(parentGroup.toByteArray());
266}
267
269{
270 qWindowDebug() << "window =" << window();
271
272 // Qt should have already deleted the children before deleting the parent.
273 Q_ASSERT(m_childWindows.size() == 0);
274
275 // Remove from plugin's window mapper
276 QQnxIntegration::instance()->removeWindow(m_window);
277
278 // Remove from parent's Hierarchy.
279 removeFromParent();
280 if (m_screen)
281 m_screen->updateHierarchy();
282
283 // Cleanup QNX window and its buffers
284 // Foreign windows are cleaned up externally after the CLOSE event has been handled.
285 if (m_foreign)
286 removeContextPermission();
287 else
288 screen_destroy_window(m_window);
289}
290
292{
293 QRect newGeometry = rect;
295 newGeometry = screen()->geometry();
296
297 if (window()->type() != Qt::Desktop)
298 setGeometryHelper(newGeometry);
299
300 if (isExposed())
302}
303
304void QQnxWindow::setGeometryHelper(const QRect &rect)
305{
306 qWindowDebug() << "window =" << window()
307 << ", (" << rect.x() << "," << rect.y()
308 << "," << rect.width() << "," << rect.height() << ")";
309
310 // Call base class method
312
313 // Set window geometry equal to widget geometry
314 int val[2];
315 val[0] = rect.x();
316 val[1] = rect.y();
317 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, val),
318 "Failed to set window position");
319
320 val[0] = rect.width();
321 val[1] = rect.height();
322 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val),
323 "Failed to set window size");
324
325 // Set viewport size equal to window size
326 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val),
327 "Failed to set window source size");
328
329 screen_flush_context(m_screenContext, 0);
330
332}
333
334void QQnxWindow::setVisible(bool visible)
335{
336 qWindowDebug() << "window =" << window() << "visible =" << visible;
337
338 if (m_visible == visible || window()->type() == Qt::Desktop)
339 return;
340
341 // The first time through we join a window group if appropriate.
342 if (m_parentGroupName.isNull() && !m_isTopLevel) {
343 joinWindowGroup(parent() ? static_cast<QQnxWindow*>(parent())->groupName()
344 : QByteArray(m_screen->windowGroupName()));
345 }
346
347 m_visible = visible;
348
349 QQnxWindow *root = this;
350 while (root->m_parentWindow)
351 root = root->m_parentWindow;
352
353 root->updateVisibility(root->m_visible);
354
356
357 if (visible) {
358 applyWindowState();
359 } else {
360 if (showWithoutActivating() && focusable() && m_firstActivateHandled) {
361 m_firstActivateHandled = false;
362 int val = SCREEN_SENSITIVITY_NO_FOCUS;
364 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
365 "Failed to set window sensitivity");
366 }
367
368 // Flush the context, otherwise it won't disappear immediately
369 screen_flush_context(m_screenContext, 0);
370 }
371}
372
373void QQnxWindow::updateVisibility(bool parentVisible)
374{
375 qWindowDebug() << "parentVisible =" << parentVisible << "window =" << window();
376 // Set window visibility
377 int val = (m_visible && parentVisible) ? 1 : 0;
378 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &val),
379 "Failed to set window visibility");
380
381 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
382 childWindow->updateVisibility(m_visible && parentVisible);
383}
384
386{
387 qWindowDebug() << "window =" << window() << "opacity =" << level;
388 // Set window global alpha
389 int val = (int)(level * 255);
390 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_GLOBAL_ALPHA, &val),
391 "Failed to set global alpha");
392
393 screen_flush_context(m_screenContext, 0);
394}
395
396void QQnxWindow::setExposed(bool exposed)
397{
398 qWindowDebug() << "window =" << window() << "expose =" << exposed;
399
400 if (m_exposed != exposed) {
401 m_exposed = exposed;
403 }
404}
405
407{
408 return m_visible && m_exposed;
409}
410
412{
413 qWindowDebug() << "window =" << window() << "size =" << size;
414
415 // libscreen fails when creating empty buffers
416 const QSize nonEmptySize = size.isEmpty() ? QSize(1, 1) : size;
417 int format = pixelFormat();
418
419 if (nonEmptySize == m_bufferSize || format == -1)
420 return;
421
423 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &format),
424 "Failed to set window format");
425
426 if (m_bufferSize.isValid()) {
427 // destroy buffers first, if resized
428 Q_SCREEN_CRITICALERROR(screen_destroy_window_buffers(m_window),
429 "Failed to destroy window buffers");
430 }
431
432 int val[2] = { nonEmptySize.width(), nonEmptySize.height() };
433 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val),
434 "Failed to set window buffer size");
435
436 Q_SCREEN_CRITICALERROR(screen_create_window_buffers(m_window, MAX_BUFFER_COUNT),
437 "Failed to create window buffers");
438
439 // check if there are any buffers available
440 int bufferCount = 0;
442 screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount),
443 "Failed to query render buffer count");
444
445 if (Q_UNLIKELY(bufferCount != MAX_BUFFER_COUNT)) {
446 qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d.",
447 MAX_BUFFER_COUNT, bufferCount);
448 }
449
450 // Set the transparency. According to QNX technical support, setting the window
451 // transparency property should always be done *after* creating the window
452 // buffers in order to guarantee the property is paid attention to.
453 if (size.isEmpty()) {
454 // We can't create 0x0 buffers and instead make them 1x1. But to allow these windows to
455 // still be 'visible' (thus allowing their children to be visible), we need to allow
456 // them to be posted but still not show up.
457 val[0] = SCREEN_TRANSPARENCY_DISCARD;
458 } else if (window()->requestedFormat().alphaBufferSize() == 0) {
459 // To avoid overhead in the composition manager, disable blending
460 // when the underlying window buffer doesn't have an alpha channel.
461 val[0] = SCREEN_TRANSPARENCY_NONE;
462 } else {
463 // Normal alpha blending. This doesn't commit us to translucency; the
464 // normal backfill during the painting will contain a fully opaque
465 // alpha channel unless the user explicitly intervenes to make something
466 // transparent.
467 val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER;
468 }
469
470 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val),
471 "Failed to set window transparency");
472
473 // Cache new buffer size
474 m_bufferSize = nonEmptySize;
475 resetBuffers();
476}
477
479{
480 qWindowDebug() << "window =" << window() << "platformScreen =" << platformScreen;
481
482 if (platformScreen == 0) { // The screen has been destroyed
483 m_screen = 0;
484 Q_FOREACH (QQnxWindow *childWindow, m_childWindows) {
485 childWindow->setScreen(0);
486 }
487 return;
488 }
489
490 if (m_screen == platformScreen)
491 return;
492
493 if (m_screen) {
494 qWindowDebug("Moving window to different screen");
495 m_screen->removeWindow(this);
496
498 screen_leave_window_group(m_window);
499 }
500 }
501
502 m_screen = platformScreen;
503 if (!m_parentWindow) {
504 platformScreen->addWindow(this);
505 }
506 if (m_isTopLevel) {
507 // Move window to proper screen/display
508 screen_display_t display = platformScreen->nativeDisplay();
510 screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display),
511 "Failed to set window display");
512 } else {
513 Q_FOREACH (QQnxWindow *childWindow, m_childWindows) {
514 // Only subwindows and tooltips need necessarily be moved to another display with the window.
515 if (window()->type() == Qt::SubWindow || window()->type() == Qt::ToolTip)
516 childWindow->setScreen(platformScreen);
517 }
518 }
519
520 m_screen->updateHierarchy();
521}
522
523void QQnxWindow::removeFromParent()
524{
525 qWindowDebug() << "window =" << window();
526 // Remove from old Hierarchy position
527 if (m_parentWindow) {
528 if (Q_UNLIKELY(!m_parentWindow->m_childWindows.removeAll(this)))
529 qFatal("QQnxWindow: Window Hierarchy broken; window has parent, but parent hasn't got child.");
530 else
531 m_parentWindow = nullptr;
532 } else if (m_screen) {
533 m_screen->removeWindow(this);
534 }
535}
536
538{
539 qWindowDebug() << "window =" << this->window() << "platformWindow =" << window;
540 // Cast away the const, we need to modify the hierarchy.
541 QQnxWindow* const newParent = static_cast<QQnxWindow*>(const_cast<QPlatformWindow*>(window));
542
543 if (newParent == m_parentWindow)
544 return;
545
546 if (static_cast<QQnxScreen *>(screen())->rootWindow() == this) {
547 qWarning("Application window cannot be reparented");
548 return;
549 }
550
551 removeFromParent();
552 m_parentWindow = newParent;
553
554 // Add to new hierarchy position.
555 if (m_parentWindow) {
556 if (m_parentWindow->m_screen != m_screen)
557 setScreen(m_parentWindow->m_screen);
558
559 m_parentWindow->m_childWindows.push_back(this);
560 joinWindowGroup(m_parentWindow->groupName());
561 } else {
562 m_screen->addWindow(this);
564 }
565
566 m_screen->updateHierarchy();
567}
568
570{
571 qWindowDebug() << "window =" << window();
572
573 if (m_parentWindow) {
574 m_parentWindow->m_childWindows.removeAll(this);
575 m_parentWindow->m_childWindows.push_back(this);
576 } else {
577 m_screen->raiseWindow(this);
578 }
579
580 m_screen->updateHierarchy();
581}
582
584{
585 qWindowDebug() << "window =" << window();
586
587 if (m_parentWindow) {
588 m_parentWindow->m_childWindows.removeAll(this);
589 m_parentWindow->m_childWindows.push_front(this);
590 } else {
591 m_screen->lowerWindow(this);
592 }
593
594 m_screen->updateHierarchy();
595}
596
598{
599 QQnxWindow *focusWindow = nullptr;
601 focusWindow = static_cast<QQnxWindow*>(QGuiApplication::focusWindow()->handle());
602
603 if (focusWindow == this)
604 return;
605
606 if (static_cast<QQnxScreen *>(screen())->rootWindow() == this ||
607 (focusWindow && findWindow(focusWindow->nativeHandle()))) {
608 // If the focus window is a child, we can just set the focus of our own window
609 // group to our window handle
610 setFocus(nativeHandle());
611 } else {
612 // In order to receive focus the parent's window group has to give focus to the
613 // child. If we have several hierarchy layers, we have to do that several times
614 QQnxWindow *currentWindow = this;
615 QList<QQnxWindow*> windowList;
616 while (currentWindow) {
617 auto platformScreen = static_cast<QQnxScreen *>(screen());
618 windowList.prepend(currentWindow);
619 // If we find the focus window, we don't have to go further
620 if (currentWindow == focusWindow)
621 break;
622
623 if (currentWindow->parent()){
624 currentWindow = static_cast<QQnxWindow*>(currentWindow->parent());
625 } else if (platformScreen->rootWindow() &&
626 platformScreen->rootWindow()->m_windowGroupName == currentWindow->m_parentGroupName) {
627 currentWindow = platformScreen->rootWindow();
628 } else {
629 currentWindow = nullptr;
630 }
631 }
632
633 // We have to apply the focus from parent to child windows
634 for (int i = 1; i < windowList.size(); ++i)
635 windowList.at(i-1)->setFocus(windowList.at(i)->nativeHandle());
636
637 windowList.last()->setFocus(windowList.constLast()->nativeHandle());
638 }
639
640 screen_flush_context(m_screenContext, 0);
641}
642
643void QQnxWindow::setFocus(screen_window_t newFocusWindow)
644{
645 screen_window_t temporaryFocusWindow = nullptr;
646
647 screen_group_t screenGroup = 0;
648 Q_SCREEN_CHECKERROR(screen_get_window_property_pv(nativeHandle(), SCREEN_PROPERTY_GROUP,
649 reinterpret_cast<void **>(&screenGroup)),
650 "Failed to retrieve window group");
651
652 if (showWithoutActivating() && focusable() && !m_firstActivateHandled) {
653 m_firstActivateHandled = true;
654 int val = SCREEN_SENSITIVITY_TEST;
656 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
657 "Failed to set window sensitivity");
658
659#if _SCREEN_VERSION < _SCREEN_MAKE_VERSION(1, 0, 0)
660 // For older versions of screen, the window may still have group
661 // focus even though it was marked NO_FOCUS when it was hidden.
662 // In that situation, focus has to be given to another window
663 // so that this window can take focus back from it.
664 screen_window_t oldFocusWindow = nullptr;
666 screen_get_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
667 reinterpret_cast<void **>(&oldFocusWindow)),
668 "Failed to retrieve group focus");
669 if (newFocusWindow == oldFocusWindow) {
670 char groupName[256];
671 memset(groupName, 0, sizeof(groupName));
672 Q_SCREEN_CHECKERROR(screen_get_group_property_cv(screenGroup, SCREEN_PROPERTY_NAME,
673 sizeof(groupName) - 1, groupName),
674 "Failed to retrieve group name");
675
676 Q_SCREEN_CHECKERROR(screen_create_window_type(&temporaryFocusWindow,
677 m_screenContext, SCREEN_CHILD_WINDOW),
678 "Failed to create temporary focus window");
679 Q_SCREEN_CHECKERROR(screen_join_window_group(temporaryFocusWindow, groupName),
680 "Temporary focus window failed to join window group");
682 screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
683 reinterpret_cast<void **>(&temporaryFocusWindow)),
684 "Temporary focus window failed to take focus");
685 screen_flush_context(m_screenContext, 0);
686 }
687#endif
688 }
689
690 Q_SCREEN_CHECKERROR(screen_set_group_property_pv(screenGroup, SCREEN_PROPERTY_FOCUS,
691 reinterpret_cast<void **>(&newFocusWindow)),
692 "Failed to set group focus");
693
694 screen_destroy_window(temporaryFocusWindow);
695}
696
697void QQnxWindow::setWindowState(Qt::WindowStates state)
698{
699 qWindowDebug() << "state =" << state;
700
701 // Prevent two calls with Qt::WindowFullScreen from changing m_unmaximizedGeometry
702 if (m_windowState == state)
703 return;
704
705 m_windowState = state;
706
707 if (m_visible)
708 applyWindowState();
709}
710
712{
713 // nothing to do; silence base class warning
714 qWindowDebug("ignored");
715}
716
718{
719 return m_screen;
720}
721
722QQnxWindow *QQnxWindow::findWindow(screen_window_t windowHandle)
723{
724 if (m_window == windowHandle)
725 return this;
726
727 Q_FOREACH (QQnxWindow *window, m_childWindows) {
728 QQnxWindow * const result = window->findWindow(windowHandle);
729 if (result)
730 return result;
731 }
732
733 return 0;
734}
735
737{
738 qWarning("Qt::WindowMinimized is not supported by this OS version");
739}
740
741void QQnxWindow::setRotation(int rotation)
742{
743 qWindowDebug() << "angle =" << rotation;
745 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation),
746 "Failed to set window rotation");
747}
748
750{
751 if (window()->type() == Qt::Desktop)
752 return;
753
754 // Alpha channel is always pre-multiplied if present
755 int val = SCREEN_PRE_MULTIPLIED_ALPHA;
756 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ALPHA_MODE, &val),
757 "Failed to set alpha mode");
758
759 // Set the window swap interval
760 val = 1;
762 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &val),
763 "Failed to set swap interval");
764
765 if (showWithoutActivating() || !focusable()) {
766 // NO_FOCUS is temporary for showWithoutActivating (and pop-up) windows.
767 // Using NO_FOCUS ensures that screen doesn't activate the window because
768 // it was just created. Sensitivity will be changed to TEST when the
769 // window is clicked or touched.
770 val = SCREEN_SENSITIVITY_NO_FOCUS;
772 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val),
773 "Failed to set window sensitivity");
774 }
775
776 QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window()->screen()->handle());
777 setScreen(platformScreen);
778
779 if (window()->type() == Qt::CoverWindow)
780 m_exposed = false;
781
782 // Add window to plugin's window mapper
783 QQnxIntegration::instance()->addWindow(m_window, window());
784
785 // Qt never calls these setters after creating the window, so we need to do that ourselves here
786 setWindowState(window()->windowState());
787 setOpacity(window()->opacity());
788
789 if (window()->parent() && window()->parent()->handle())
790 setParent(window()->parent()->handle());
791
792 setGeometryHelper(shouldMakeFullScreen() ? screen()->geometry() : window()->geometry());
793}
794
795void QQnxWindow::collectWindowGroup()
796{
797 QByteArray groupName(256, 0);
798 Q_SCREEN_CHECKERROR(screen_get_window_property_cv(m_window,
799 SCREEN_PROPERTY_GROUP,
800 groupName.size(),
801 groupName.data()),
802 "Failed to retrieve window group");
804 m_windowGroupName = groupName;
805}
806
807void QQnxWindow::createWindowGroup()
808{
809 Q_SCREEN_CHECKERROR(screen_create_window_group(m_window, nullptr),
810 "Failed to create window group");
811
812 collectWindowGroup();
813}
814
816{
817 bool changed = false;
818
819 qWindowDebug() << "group:" << groupName;
820
821 // screen has this annoying habit of generating a CLOSE/CREATE when the owner context of
822 // the parent group moves a foreign window to another group that it also owns. The
823 // CLOSE/CREATE changes the identity of the foreign window. Usually, this is undesirable.
824 // To prevent this CLOSE/CREATE when changing the parent group, we temporarily add a
825 // context permission for the Qt context. screen won't send a CLOSE/CREATE when the
826 // context has some permission other than the PARENT permission. If there isn't a new
827 // group (the window has no parent), this context permission is left in place.
828
829 if (m_foreign && !m_parentGroupName.isEmpty())\
830 addContextPermission();
831
832 if (!groupName.isEmpty()) {
833 if (groupName != m_parentGroupName) {
834 screen_join_window_group(m_window, groupName);
835 m_parentGroupName = groupName;
836 changed = true;
837 }
838 } else {
839 if (!m_parentGroupName.isEmpty()) {
840 screen_leave_window_group(m_window);
841 changed = true;
842 }
843 // By setting to an empty string we'll stop setVisible from trying to
844 // change our group, we want that to happen only if joinWindowGroup has
845 // never been called. This allows windows to be created that are not initially
846 // part of any group.
847 m_parentGroupName = "";
848 }
849
850 if (m_foreign && !groupName.isEmpty())
851 removeContextPermission();
852
853 if (changed)
854 screen_flush_context(m_screenContext, 0);
855}
856
857void QQnxWindow::updateZorder(int &topZorder)
858{
859 updateZorder(m_window, topZorder);
860
861 Q_FOREACH (QQnxWindow *childWindow, m_childWindows)
862 childWindow->updateZorder(topZorder);
863}
864
865void QQnxWindow::updateZorder(screen_window_t window, int &topZorder)
866{
867 Q_SCREEN_CHECKERROR(screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &topZorder),
868 "Failed to set window z-order");
869 topZorder++;
870}
871
872void QQnxWindow::applyWindowState()
873{
874 if (m_windowState & Qt::WindowMinimized) {
875 minimize();
876
877 if (m_unmaximizedGeometry.isValid())
878 setGeometry(m_unmaximizedGeometry);
879 else
880 setGeometry(m_screen->geometry());
881 } else if (m_windowState & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
882 m_unmaximizedGeometry = geometry();
883 setGeometry(m_windowState & Qt::WindowFullScreen ? m_screen->geometry()
884 : m_screen->availableGeometry());
885 } else if (m_unmaximizedGeometry.isValid()) {
886 setGeometry(m_unmaximizedGeometry);
887 }
888}
889
891{
892 if (m_cover) {
893 m_cover->updateCover();
894 qqnxLgmonFramePosted(true); // for performance measurements
895 } else {
896 qqnxLgmonFramePosted(false); // for performance measurements
897 }
898}
899
901{
902 return ((static_cast<QQnxScreen *>(screen())->rootWindow() == this)
904}
905
906
908{
909 if (showWithoutActivating() && focusable() && !m_firstActivateHandled)
911}
912
913bool QQnxWindow::showWithoutActivating() const
914{
915 return (window()->flags() & Qt::Popup) == Qt::Popup
916 || window()->property("_q_showWithoutActivating").toBool();
917}
918
919bool QQnxWindow::focusable() const
920{
922}
923
924void QQnxWindow::addContextPermission()
925{
926 QByteArray grantString("context:");
927 grantString.append(QQnxIntegration::instance()->screenContextId());
928 grantString.append(":rw-");
929 screen_set_window_property_cv(m_window,
930 SCREEN_PROPERTY_PERMISSIONS,
931 grantString.length(),
932 grantString.data());
933}
934
935void QQnxWindow::removeContextPermission()
936{
937 QByteArray revokeString("context:");
938 revokeString.append(QQnxIntegration::instance()->screenContextId());
939 revokeString.append(":---");
940 screen_set_window_property_cv(m_window,
941 SCREEN_PROPERTY_PERMISSIONS,
942 revokeString.length(),
943 revokeString.data());
944}
945
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:534
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:474
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:106
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
void push_front(rvalue_ref t)
Definition qlist.h:674
T & last()
Definition qlist.h:631
const T & constLast() const noexcept
Definition qlist.h:633
void push_back(parameter_type t)
Definition qlist.h:672
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
qsizetype removeAll(const AT &t)
Definition qlist.h:575
void prepend(rvalue_ref t)
Definition qlist.h:456
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4187
The QPlatformScreen class provides an abstraction for visual displays.
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
The QPlatformWindow class provides an abstraction for top-level windows.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
QPlatformWindow * parent() const
Returns the parent platform window (or \nullptr if orphan).
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or resized using the QWindow API.
virtual QRect geometry() const
Returns the current geometry of a window.
\inmodule QtCore\reentrant
Definition qpoint.h:23
virtual void updateCover()=0
static QQnxIntegration * instance()
const char * windowGroupName() const
Definition qqnxscreen.h:66
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
Definition qqnxscreen.h:44
void lowerWindow(QQnxWindow *window)
void raiseWindow(QQnxWindow *window)
void removeWindow(QQnxWindow *child)
void addWindow(QQnxWindow *child)
void setRootWindow(QQnxWindow *)
screen_display_t nativeDisplay() const
Definition qqnxscreen.h:64
QQnxWindow * rootWindow() const
void updateHierarchy()
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
Definition qqnxwindow.h:28
void windowPosted()
screen_context_t m_screenContext
Definition qqnxwindow.h:81
void setExposed(bool exposed)
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
virtual int pixelFormat() const =0
QQnxWindow * findWindow(screen_window_t windowHandle)
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
bool shouldMakeFullScreen() const
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
virtual void resetBuffers()=0
bool isExposed() const override
Returns if this window is exposed in the windowing system.
void initWindow()
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
QQnxWindow(QWindow *window, screen_context_t context, bool needRootWindow)
void joinWindowGroup(const QByteArray &groupName)
void minimize()
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
QByteArray groupName() const
Definition qqnxwindow.h:67
screen_window_t nativeHandle() const
Definition qqnxwindow.h:42
void setScreen(QQnxScreen *platformScreen)
void setBufferSize(const QSize &size)
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
QPlatformScreen * screen() const override
Returns the platform screen handle corresponding to this platform window, or null if the window is no...
void setRotation(int rotation)
void handleActivationEvent()
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
void setOpacity(qreal level) override
Reimplement to be able to let Qt set the opacity level of a window.
virtual ~QQnxWindow()
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
Definition qrect.h:169
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:241
QPlatformScreen * handle() const
Get the platform screen handle.
Definition qscreen.cpp:83
\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
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Definition qsize.h:123
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
Definition qsize.h:126
\inmodule QtCore
Definition qvariant.h:64
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:707
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
bool canConvert(QMetaType targetType) const
Definition qvariant.h:342
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
static void handleGeometryChange(QWindow *window, const QRect &newRect)
static bool handleExposeEvent(QWindow *window, const QRegion &region)
\inmodule QtGui
Definition qwindow.h:63
QSize size() const override
Returns the size of the window excluding any window frame.
Definition qwindow.h:210
rect
[4]
else opt state
[0]
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
@ WindowFullScreen
Definition qnamespace.h:254
@ WindowMinimized
Definition qnamespace.h:252
@ WindowMaximized
Definition qnamespace.h:253
@ Desktop
Definition qnamespace.h:214
@ WindowDoesNotAcceptFocus
Definition qnamespace.h:235
@ ToolTip
Definition qnamespace.h:212
@ Popup
Definition qnamespace.h:210
@ CoverWindow
Definition qnamespace.h:217
@ SubWindow
Definition qnamespace.h:215
static void * context
#define Q_UNLIKELY(x)
#define Q_FOREACH(variable, container)
Definition qforeach.h:66
#define qWarning
Definition qlogging.h:162
#define qFatal
Definition qlogging.h:164
GLuint64 GLenum void * handle
GLenum GLuint GLint level
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum type
GLbitfield flags
GLint GLsizei GLsizei GLenum format
GLuint GLfloat * val
GLuint64EXT * result
[6]
#define Q_SCREEN_CRITICALERROR(x, message)
Definition qqnxglobal.h:16
#define Q_SCREEN_CHECKERROR(x, message)
Definition qqnxglobal.h:13
void qqnxLgmonFramePosted(bool)
Definition qqnxlgmon.h:35
const int SCREEN_PROPERTY_FOCUS
Definition qqnxscreen.h:25
#define DECLARE_DEBUG_VAR(variable)
#define qWindowDebug
#define MAX_BUFFER_COUNT
Definition qqnxwindow.h:21
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
double qreal
Definition qtypes.h:92
aWidget window() -> setWindowTitle("New Window Title")
[2]