15#include <QtGui/QWindow>
16#include <qpa/qwindowsysteminterface.h>
18#include "private/qguiapplication_p.h"
20#include <QtCore/QDebug>
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; }
38#undef DECLARE_DEBUG_VAR
121 m_windowState(
Qt::WindowNoState),
122 m_firstActivateHandled(
false)
131 if (!windowGroup.isValid())
139 }
else if (
parent() || windowGroup.isValid()) {
142 m_isTopLevel =
false;
146 m_isTopLevel = !needRootWindow || !platformScreen->
rootWindow();
153 if (
type.isValid() &&
type.canConvert<
int>()) {
156 "Could not create window");
157 }
else if (m_isTopLevel) {
159 "Could not create top level window");
166 screen_create_window_type(&m_window,
m_screenContext, SCREEN_CHILD_WINDOW),
167 "Could not create child window");
176 if (!windowId.isValid())
178 if (windowId.isValid() && windowId.canConvert<
QByteArray>()) {
181 id.
size(),
id),
"Failed to set id");
186 if (windowGroup.isValid() && windowGroup.canConvert<
QByteArray>())
190 if (pipelineValue.isValid()) {
192 int pipeline = pipelineValue.
toInt(&
ok);
194 qCDebug(lcQpaWindow) <<
"Set pipeline value to" << pipeline;
197 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_PIPELINE, &pipeline),
198 "Failed to set window pipeline");
200 qCDebug(lcQpaWindow) <<
"Invalid pipeline value:" << pipelineValue;
206 debug |= SCREEN_DEBUG_GRAPH_FPS;
209 debug |= SCREEN_DEBUG_GRAPH_POSTS;
212 debug |= SCREEN_DEBUG_GRAPH_BLITS;
215 debug |= SCREEN_DEBUG_GRAPH_UPDATES;
218 debug |= SCREEN_DEBUG_GRAPH_CPU_TIME;
221 debug |= SCREEN_DEBUG_GRAPH_GPU_TIME;
224 debug = SCREEN_DEBUG_STATISTICS;
229 "Could not set SCREEN_PROPERTY_DEBUG");
230 qCDebug(lcQpaWindow) <<
"window SCREEN_PROPERTY_DEBUG= " <<
debug;
237 , m_window(screenWindow)
243 , m_windowState(
Qt::WindowNoState)
244 , m_parentGroupName(256, 0)
245 , m_isTopLevel(
false)
249 collectWindowGroup();
251 screen_get_window_property_cv(m_window,
252 SCREEN_PROPERTY_PARENT,
253 m_parentGroupName.
size(),
254 m_parentGroupName.
data());
260 if (!parentGroup.isValid())
262 if (parentGroup.isValid() && parentGroup.canConvert<
QByteArray>())
284 removeContextPermission();
286 screen_destroy_window(m_window);
296 setGeometryHelper(newGeometry);
302void QQnxWindow::setGeometryHelper(
const QRect &
rect)
306 <<
"," <<
rect.width() <<
"," <<
rect.height() <<
")";
316 "Failed to set window position");
321 "Failed to set window size");
325 "Failed to set window source size");
334 qCDebug(lcQpaWindow) <<
"window =" <<
window() <<
"visible =" << visible;
340 if (m_parentGroupName.
isNull() && !m_isTopLevel) {
348 while (root->m_parentWindow)
349 root = root->m_parentWindow;
351 root->updateVisibility(root->m_visible);
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");
371void QQnxWindow::updateVisibility(
bool parentVisible)
373 qCDebug(lcQpaWindow) <<
"parentVisible =" << parentVisible <<
"window =" <<
window();
375 int val = (m_visible && parentVisible) ? 1 : 0;
377 "Failed to set window visibility");
380 childWindow->updateVisibility(m_visible && parentVisible);
389 "Failed to set global alpha");
396 qCDebug(lcQpaWindow) <<
"window =" <<
window() <<
"expose =" << exposed;
398 if (m_exposed != exposed) {
406 return m_visible && m_exposed;
417 if (nonEmptySize == m_bufferSize ||
format == -1)
421 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &
format),
422 "Failed to set window format");
427 "Failed to destroy window buffers");
430 int val[2] = { nonEmptySize.width(), nonEmptySize.height() };
432 "Failed to set window buffer size");
435 "Failed to create window buffers");
440 screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount),
441 "Failed to query render buffer count");
444 qFatal(
"QQnxWindow: invalid buffer count. Expected = %d, got = %d.",
451 if (
size.isEmpty()) {
455 val[0] = SCREEN_TRANSPARENCY_DISCARD;
456 }
else if (
window()->requestedFormat().alphaBufferSize() == 0) {
459 val[0] = SCREEN_TRANSPARENCY_NONE;
465 val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER;
469 "Failed to set window transparency");
472 m_bufferSize = nonEmptySize;
478 qCDebug(lcQpaWindow) <<
"window =" <<
window() <<
"platformScreen =" << platformScreen;
480 if (platformScreen == 0) {
483 childWindow->setScreen(0);
488 if (m_screen == platformScreen)
492 qCDebug(lcQpaWindow) <<
"Moving window to different screen";
496 screen_leave_window_group(m_window);
500 m_screen = platformScreen;
501 if (!m_parentWindow) {
508 screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (
void **)&
display),
509 "Failed to set window display");
514 childWindow->setScreen(platformScreen);
521void QQnxWindow::removeFromParent()
525 if (m_parentWindow) {
527 qFatal(
"QQnxWindow: Window Hierarchy broken; window has parent, but parent hasn't got child.");
529 m_parentWindow =
nullptr;
530 }
else if (m_screen) {
541 if (newParent == m_parentWindow)
545 qWarning(
"Application window cannot be reparented");
550 m_parentWindow = newParent;
553 if (m_parentWindow) {
554 if (m_parentWindow->m_screen != m_screen)
557 m_parentWindow->m_childWindows.
push_back(
this);
571 if (m_parentWindow) {
572 m_parentWindow->m_childWindows.
removeAll(
this);
573 m_parentWindow->m_childWindows.
push_back(
this);
585 if (m_parentWindow) {
586 m_parentWindow->m_childWindows.
removeAll(
this);
587 m_parentWindow->m_childWindows.
push_front(
this);
601 if (focusWindow ==
this)
613 QList<QQnxWindow*> windowList;
614 while (currentWindow) {
616 windowList.prepend(currentWindow);
618 if (currentWindow == focusWindow)
621 if (currentWindow->
parent()){
623 }
else if (platformScreen->rootWindow() &&
624 platformScreen->rootWindow()->m_windowGroupName == currentWindow->m_parentGroupName) {
625 currentWindow = platformScreen->rootWindow();
627 currentWindow =
nullptr;
632 for (
int i = 1;
i < windowList.size(); ++
i)
633 windowList.at(
i-1)->setFocus(windowList.at(
i)->nativeHandle());
635 windowList.last()->setFocus(windowList.constLast()->nativeHandle());
641void QQnxWindow::setFocus(screen_window_t newFocusWindow)
643 screen_window_t temporaryFocusWindow =
nullptr;
645 screen_group_t screenGroup = 0;
647 reinterpret_cast<void **
>(&screenGroup)),
648 "Failed to retrieve window group");
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");
657#if _SCREEN_VERSION < _SCREEN_MAKE_VERSION(1, 0, 0)
662 screen_window_t oldFocusWindow =
nullptr;
665 reinterpret_cast<void **
>(&oldFocusWindow)),
666 "Failed to retrieve group focus");
667 if (newFocusWindow == oldFocusWindow) {
672 "Failed to retrieve group name");
676 "Failed to create temporary focus window");
678 "Temporary focus window failed to join window group");
681 reinterpret_cast<void **
>(&temporaryFocusWindow)),
682 "Temporary focus window failed to take focus");
689 reinterpret_cast<void **
>(&newFocusWindow)),
690 "Failed to set group focus");
692 screen_destroy_window(temporaryFocusWindow);
700 if (m_windowState ==
state)
703 m_windowState =
state;
722 if (m_window == windowHandle)
736 qWarning(
"Qt::WindowMinimized is not supported by this OS version");
743 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation),
744 "Failed to set window rotation");
753 int val = SCREEN_PRE_MULTIPLIED_ALPHA;
755 "Failed to set alpha mode");
760 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &
val),
761 "Failed to set swap interval");
763 if (showWithoutActivating() || !focusable()) {
768 val = SCREEN_SENSITIVITY_NO_FOCUS;
770 screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &
val),
771 "Failed to set window sensitivity");
793void QQnxWindow::collectWindowGroup()
797 SCREEN_PROPERTY_GROUP,
800 "Failed to retrieve window group");
805void QQnxWindow::createWindowGroup()
808 "Failed to create window group");
810 collectWindowGroup();
815 bool changed =
false;
827 if (m_foreign && !m_parentGroupName.
isEmpty())\
828 addContextPermission();
832 screen_join_window_group(m_window,
groupName);
837 if (!m_parentGroupName.
isEmpty()) {
838 screen_leave_window_group(m_window);
845 m_parentGroupName =
"";
849 removeContextPermission();
855void QQnxWindow::updateZorder(
int &topZorder)
857 updateZorder(m_window, topZorder);
860 childWindow->updateZorder(topZorder);
863void QQnxWindow::updateZorder(screen_window_t
window,
int &topZorder)
866 "Failed to set window z-order");
870void QQnxWindow::applyWindowState()
875 if (m_unmaximizedGeometry.
isValid())
882 : m_screen->availableGeometry());
883 }
else if (m_unmaximizedGeometry.
isValid()) {
907 if (showWithoutActivating() && focusable() && !m_firstActivateHandled)
911bool QQnxWindow::showWithoutActivating()
const
917bool QQnxWindow::focusable()
const
922void QQnxWindow::addContextPermission()
926 grantString.append(
":rw-");
927 screen_set_window_property_cv(m_window,
928 SCREEN_PROPERTY_PERMISSIONS,
929 grantString.length(),
933void QQnxWindow::removeContextPermission()
937 revokeString.append(
":---");
938 screen_set_window_property_cv(m_window,
939 SCREEN_PROPERTY_PERMISSIONS,
940 revokeString.length(),
941 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)
void push_back(parameter_type t)
qsizetype removeAll(const AT &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 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.
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 ®ion)
int x
the x position of the window's geometry
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
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
#define Q_FOREACH(variable, container)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
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)