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