13#include <QtGui/QWindow>
14#include <qpa/qwindowsysteminterface.h>
16#include "private/qguiapplication_p.h"
18#include <QtCore/QDebug>
22#if defined(QQNXWINDOW_DEBUG)
23#define qWindowDebug qDebug
25#define qWindowDebug QT_NO_QDEBUG_MACRO
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; }
40#undef DECLARE_DEBUG_VAR
123 m_windowState(
Qt::WindowNoState),
124 m_firstActivateHandled(
false)
144 m_isTopLevel =
false;
148 m_isTopLevel = !needRootWindow || !platformScreen->
rootWindow();
155 if (
type.isValid() &&
type.canConvert<
int>()) {
158 "Could not create window");
159 }
else if (m_isTopLevel) {
161 "Could not create top level window");
168 screen_create_window_type(&m_window,
m_screenContext, SCREEN_CHILD_WINDOW),
169 "Could not create child window");
183 id.
size(),
id),
"Failed to set id");
194 int pipeline = pipelineValue.
toInt(&
ok);
199 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_PIPELINE, &pipeline),
200 "Failed to set window pipeline");
202 qWindowDebug() <<
"Invalid pipeline value:" << pipelineValue;
208 debug |= SCREEN_DEBUG_GRAPH_FPS;
211 debug |= SCREEN_DEBUG_GRAPH_POSTS;
214 debug |= SCREEN_DEBUG_GRAPH_BLITS;
217 debug |= SCREEN_DEBUG_GRAPH_UPDATES;
220 debug |= SCREEN_DEBUG_GRAPH_CPU_TIME;
223 debug |= SCREEN_DEBUG_GRAPH_GPU_TIME;
226 debug = SCREEN_DEBUG_STATISTICS;
231 "Could not set SCREEN_PROPERTY_DEBUG");
239 , m_window(screenWindow)
245 , m_windowState(
Qt::WindowNoState)
246 , m_parentGroupName(256, 0)
247 , m_isTopLevel(
false)
251 collectWindowGroup();
253 screen_get_window_property_cv(m_window,
254 SCREEN_PROPERTY_PARENT,
255 m_parentGroupName.
size(),
256 m_parentGroupName.
data());
286 removeContextPermission();
288 screen_destroy_window(m_window);
298 setGeometryHelper(newGeometry);
304void QQnxWindow::setGeometryHelper(
const QRect &
rect)
307 <<
", (" <<
rect.x() <<
"," <<
rect.y()
308 <<
"," <<
rect.width() <<
"," <<
rect.height() <<
")";
318 "Failed to set window position");
323 "Failed to set window size");
327 "Failed to set window source size");
342 if (m_parentGroupName.
isNull() && !m_isTopLevel) {
350 while (root->m_parentWindow)
351 root = root->m_parentWindow;
353 root->updateVisibility(root->m_visible);
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");
373void QQnxWindow::updateVisibility(
bool parentVisible)
377 int val = (m_visible && parentVisible) ? 1 : 0;
379 "Failed to set window visibility");
382 childWindow->updateVisibility(m_visible && parentVisible);
391 "Failed to set global alpha");
400 if (m_exposed != exposed) {
408 return m_visible && m_exposed;
419 if (nonEmptySize == m_bufferSize ||
format == -1)
423 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &
format),
424 "Failed to set window format");
429 "Failed to destroy window buffers");
434 "Failed to set window buffer size");
437 "Failed to create window buffers");
442 screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount),
443 "Failed to query render buffer count");
446 qFatal(
"QQnxWindow: invalid buffer count. Expected = %d, got = %d.",
453 if (
size.isEmpty()) {
457 val[0] = SCREEN_TRANSPARENCY_DISCARD;
458 }
else if (
window()->requestedFormat().alphaBufferSize() == 0) {
461 val[0] = SCREEN_TRANSPARENCY_NONE;
467 val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER;
471 "Failed to set window transparency");
474 m_bufferSize = nonEmptySize;
482 if (platformScreen == 0) {
490 if (m_screen == platformScreen)
498 screen_leave_window_group(m_window);
502 m_screen = platformScreen;
503 if (!m_parentWindow) {
510 screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (
void **)&
display),
511 "Failed to set window display");
523void QQnxWindow::removeFromParent()
527 if (m_parentWindow) {
529 qFatal(
"QQnxWindow: Window Hierarchy broken; window has parent, but parent hasn't got child.");
531 m_parentWindow =
nullptr;
532 }
else if (m_screen) {
543 if (newParent == m_parentWindow)
547 qWarning(
"Application window cannot be reparented");
552 m_parentWindow = newParent;
555 if (m_parentWindow) {
556 if (m_parentWindow->m_screen != m_screen)
559 m_parentWindow->m_childWindows.
push_back(
this);
573 if (m_parentWindow) {
574 m_parentWindow->m_childWindows.
removeAll(
this);
575 m_parentWindow->m_childWindows.
push_back(
this);
587 if (m_parentWindow) {
588 m_parentWindow->m_childWindows.
removeAll(
this);
589 m_parentWindow->m_childWindows.
push_front(
this);
603 if (focusWindow ==
this)
616 while (currentWindow) {
618 windowList.
prepend(currentWindow);
620 if (currentWindow == focusWindow)
623 if (currentWindow->
parent()){
625 }
else if (platformScreen->rootWindow() &&
626 platformScreen->rootWindow()->m_windowGroupName == currentWindow->m_parentGroupName) {
627 currentWindow = platformScreen->rootWindow();
629 currentWindow =
nullptr;
634 for (
int i = 1;
i < windowList.
size(); ++
i)
635 windowList.
at(
i-1)->setFocus(windowList.
at(
i)->nativeHandle());
637 windowList.
last()->setFocus(windowList.
constLast()->nativeHandle());
643void QQnxWindow::setFocus(screen_window_t newFocusWindow)
645 screen_window_t temporaryFocusWindow =
nullptr;
647 screen_group_t screenGroup = 0;
649 reinterpret_cast<void **
>(&screenGroup)),
650 "Failed to retrieve window group");
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");
659#if _SCREEN_VERSION < _SCREEN_MAKE_VERSION(1, 0, 0)
664 screen_window_t oldFocusWindow =
nullptr;
667 reinterpret_cast<void **
>(&oldFocusWindow)),
668 "Failed to retrieve group focus");
669 if (newFocusWindow == oldFocusWindow) {
674 "Failed to retrieve group name");
678 "Failed to create temporary focus window");
680 "Temporary focus window failed to join window group");
683 reinterpret_cast<void **
>(&temporaryFocusWindow)),
684 "Temporary focus window failed to take focus");
691 reinterpret_cast<void **
>(&newFocusWindow)),
692 "Failed to set group focus");
694 screen_destroy_window(temporaryFocusWindow);
702 if (m_windowState ==
state)
705 m_windowState =
state;
724 if (m_window == windowHandle)
738 qWarning(
"Qt::WindowMinimized is not supported by this OS version");
745 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation),
746 "Failed to set window rotation");
755 int val = SCREEN_PRE_MULTIPLIED_ALPHA;
757 "Failed to set alpha mode");
762 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &
val),
763 "Failed to set swap interval");
765 if (showWithoutActivating() || !focusable()) {
770 val = SCREEN_SENSITIVITY_NO_FOCUS;
772 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &
val),
773 "Failed to set window sensitivity");
795void QQnxWindow::collectWindowGroup()
799 SCREEN_PROPERTY_GROUP,
802 "Failed to retrieve window group");
807void QQnxWindow::createWindowGroup()
810 "Failed to create window group");
812 collectWindowGroup();
817 bool changed =
false;
829 if (m_foreign && !m_parentGroupName.
isEmpty())\
830 addContextPermission();
834 screen_join_window_group(m_window,
groupName);
839 if (!m_parentGroupName.
isEmpty()) {
840 screen_leave_window_group(m_window);
847 m_parentGroupName =
"";
851 removeContextPermission();
857void QQnxWindow::updateZorder(
int &topZorder)
859 updateZorder(m_window, topZorder);
862 childWindow->updateZorder(topZorder);
865void QQnxWindow::updateZorder(screen_window_t
window,
int &topZorder)
868 "Failed to set window z-order");
872void QQnxWindow::applyWindowState()
877 if (m_unmaximizedGeometry.
isValid())
884 : m_screen->availableGeometry());
885 }
else if (m_unmaximizedGeometry.
isValid()) {
909 if (showWithoutActivating() && focusable() && !m_firstActivateHandled)
913bool QQnxWindow::showWithoutActivating()
const
919bool QQnxWindow::focusable()
const
924void QQnxWindow::addContextPermission()
928 grantString.append(
":rw-");
929 screen_set_window_property_cv(m_window,
930 SCREEN_PROPERTY_PERMISSIONS,
931 grantString.length(),
935void QQnxWindow::removeContextPermission()
939 revokeString.append(
":---");
940 screen_set_window_property_cv(m_window,
941 SCREEN_PROPERTY_PERMISSIONS,
942 revokeString.length(),
943 revokeString.data());
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
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
void push_front(rvalue_ref t)
const T & constLast() const noexcept
void push_back(parameter_type t)
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void prepend(rvalue_ref t)
QVariant property(const char *name) const
Returns the value of the object's name property.
\inmodule QtCore\reentrant
virtual void updateCover()=0
static QQnxIntegration * instance()
const char * windowGroupName() const
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
void lowerWindow(QQnxWindow *window)
void raiseWindow(QQnxWindow *window)
void removeWindow(QQnxWindow *child)
void addWindow(QQnxWindow *child)
void setRootWindow(QQnxWindow *)
screen_display_t nativeDisplay() const
QQnxWindow * rootWindow() const
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
screen_context_t m_screenContext
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 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 propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
QByteArray groupName() const
screen_window_t nativeHandle() const
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.
\inmodule QtCore\reentrant
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
QPlatformScreen * handle() const
Get the platform screen handle.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
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
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 ®ion)
QSize size() const override
Returns the size of the window excluding any window frame.
struct wl_display * display
Combined button and popup list for selecting options.
@ WindowDoesNotAcceptFocus
#define Q_FOREACH(variable, container)
GLuint64 GLenum void * handle
GLenum GLuint GLint level
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
#define Q_SCREEN_CRITICALERROR(x, message)
#define Q_SCREEN_CHECKERROR(x, message)
void qqnxLgmonFramePosted(bool)
const int SCREEN_PROPERTY_FOCUS
#define DECLARE_DEBUG_VAR(variable)